From 163641baaf8d47a8a460bf3fac6a6639fcf4a9f9 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Tue, 10 Dec 2002 21:17:04 +0000 Subject: [PATCH] Removed continuity_break code, added tiny DCQ switch The continuity_break code is rendered superfluous by the FlushGraphics and RenderingCond pair now, and it was breaking the situation where you try to push onto a full queue. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@403 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/BUGS | 4 --- sc2/ChangeLog | 4 +++ sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c | 1 - sc2/src/sc2code/libs/graphics/sdl/dcqueue.c | 9 +++++-- .../sc2code/libs/graphics/sdl/sdl_common.c | 25 +++++-------------- .../sc2code/libs/graphics/sdl/sdl_common.h | 1 - 6 files changed, 17 insertions(+), 27 deletions(-) diff --git a/sc2/BUGS b/sc2/BUGS index d9a02de92..4b314df4e 100644 --- a/sc2/BUGS +++ b/sc2/BUGS @@ -101,7 +101,3 @@ The bugs reported but not yet verified: - In starmap, when any zone of influence is moving, the starmap cursor behaves badly (erases what it passes over). Leaving and returning to the starmap fixes it - -- Under FreeBSD, waiting on condition variables doesn't seem to - actually wait or hand control to the renderer, thus spinlocking and - crashing. diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 89b0400f0..9416028cc 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,8 @@ 0.2: +- Defining DCQ_OF_DOOM lowers the DrawCommandQueue size to 512, to aid in + simulating severe overload stresses on the machine +- Removed TFB_FlushGraphics' dependency on GraphicsSem, which the new + condition variable code both breaks and makes unnecessary - Scan tint is now cleared right after the scan, from PhracturedBlue - Recoded the DCQ to not sit on the heap, added debugging info - Fixed Outfit Starship and Shipyard graphics, from TDuck diff --git a/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c b/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c index 00fdbaf31..b8f20a4d1 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c +++ b/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c @@ -77,7 +77,6 @@ FlushGraphics (void) { TFB_DrawCommand DrawCommand; TFB_BatchReset (); - continuity_break = 1; DrawCommand.Type = TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS; DrawCommand.image = 0; TFB_EnqueueDrawCommand(&DrawCommand); diff --git a/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c b/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c index 4bc9b0e59..c78bb71d4 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c +++ b/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c @@ -32,7 +32,11 @@ static Uint32 DCQ_locking_thread = 0; // become tolerable before initiating livelock deterrence and game // slowdown. Other constants for controlling the frameskip/slowdown // balance may be found in sdl_common.c near TFB_FlushGraphics. +#ifdef DCQ_OF_DOOM +#define DCQ_MAX 512 +#else #define DCQ_MAX 16384 +#endif TFB_DrawCommand DCQ[DCQ_MAX]; TFB_DrawCommandQueue DrawCommandQueue; @@ -151,16 +155,17 @@ TFB_DrawCommandQueue_Push (TFB_DrawCommand* Command) while (DrawCommandQueue.FullSize >= DCQ_MAX - 1) { int old_depth, i; - fprintf (stderr, "DCQ overload (Size = %d). Sleeping until renderer is done.\n", DrawCommandQueue.Size); + fprintf (stderr, "DCQ overload (Size = %d, FullSize = %d). Sleeping until renderer is done.\n", DrawCommandQueue.Size, DrawCommandQueue.FullSize); // Restore the DCQ locking level. I *think* this is // always 1, but... + TFB_BatchReset (); old_depth = DCQ_locking_depth; for (i = 0; i < old_depth; i++) Unlock_DCQ (); WaitCondVar (RenderingCond); for (i = 0; i < old_depth; i++) Lock_DCQ (); - fprintf (stderr, "DCQ clear (Size = %d). Continuing.\n", DrawCommandQueue.Size); + fprintf (stderr, "DCQ clear (Size = %d, FullSize = %d). Continuing.\n", DrawCommandQueue.Size, DrawCommandQueue.FullSize); } DCQ[DrawCommandQueue.InsertionPoint] = *Command; DrawCommandQueue.InsertionPoint = (DrawCommandQueue.InsertionPoint + 1) % DCQ_MAX; diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index b9059a7cb..bfd3b3e18 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -37,8 +37,6 @@ volatile int TransitionAmount = 255; SDL_Rect TransitionClipRect; int GfxFlags = 0; -volatile int continuity_break; - int TFB_InitGraphics (int driver, int flags, int width, int height, int bpp) @@ -511,9 +509,15 @@ TFB_ComputeFPS () // on slower machines. Even there, it's seems nonexistent outside of // communications screens. --Michael +#ifdef DCQ_OF_DOOM +#define DCQ_FORCE_SLOWDOWN_SIZE 128 +#define DCQ_FORCE_BREAK_SIZE 512 +#define DCQ_LIVELOCK_MAX 256 +#else #define DCQ_FORCE_SLOWDOWN_SIZE 1024 #define DCQ_FORCE_BREAK_SIZE 4096 #define DCQ_LIVELOCK_MAX 2048 +#endif void TFB_FlushGraphics () // Only call from main thread!! @@ -548,23 +552,6 @@ TFB_FlushGraphics () // Only call from main thread!! return; } - if (!continuity_break) { - // TODO: a more optimal way of getting the lock on GraphicsSem.. - // cannot currently use SDL_SemWait because it would break - // the usage of continuity_break - // Michael asks: Why are we locking, then releasing, the GraphicsSem? - - semval = TimeoutSetSemaphore (GraphicsSem, ONE_SECOND / 10); - if (semval != 0) - { - BroadcastCondVar (RenderingCond); - return; - } - else - SDL_SemPost (GraphicsSem); - } - continuity_break = 0; - if (GfxFlags & TFB_GFXFLAGS_SHOWFPS) TFB_ComputeFPS (); diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.h b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.h index 8d52010fc..f64da7097 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.h +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.h @@ -36,7 +36,6 @@ extern SDL_Surface *TransitionScreen; extern volatile int TransitionAmount; extern SDL_Rect TransitionClipRect; -extern volatile int continuity_break; extern int GfxFlags; void ScreenOrigin (FRAME Display, COORD sx, COORD sy);