From d58da58aeef3833d79910933acb32c2d2744f811 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 29 Sep 2016 12:20:32 -0400 Subject: [PATCH] - fixed: Prevents too many drawer thread commands from queueing up. Previously, drawing too many columns (which was accumulated by amassing a huge number of sprites) would crash the game. --- src/r_draw_rgba.cpp | 2 ++ src/r_draw_rgba.h | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 0d86ead47..91044d1dd 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -55,6 +55,8 @@ extern int wallshade; // Use multiple threads when drawing CVAR(Bool, r_multithreaded, true, 0); +// [SP] Set Max Threads to a sane amount +CVAR(Int, r_multithreadedmax, 1024, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // Use linear filtering when scaling up CVAR(Bool, r_magfilter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index df3d0f233..e5fa88ed0 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -196,6 +196,7 @@ public: EXTERN_CVAR(Bool, r_multithreaded) EXTERN_CVAR(Bool, r_mipmap) +EXTERN_CVAR(Int, r_multithreadedmax) // Manages queueing up commands and executing them on worker threads class DrawerCommandQueue @@ -248,6 +249,14 @@ public: } else { + // [SP] Note: I've put in a hack here to throttle the speed of the rendering if + // the thread queue gets to big. This is one way to prevent too many commands + // going into the thread queue, which is causing crashes when there are too + // many threads (of which, there can be only as many as there are columns on + // the screen - guess what happens when you're too full of sprites!) + if (queue->commands.size() > r_multithreadedmax) + R_EndDrawerCommands(); + void *ptr = AllocMemory(sizeof(T)); if (!ptr) // Out of memory - render what we got {