FlushGraphics now blocks until the requested graphics are drawn
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@387 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -52,6 +52,7 @@ The bugs reported but not yet verified:
|
|||||||
|
|
||||||
- "another difference or bug vs. pc version, the sun
|
- "another difference or bug vs. pc version, the sun
|
||||||
in all the large stars e.g. alpha centauri is too small"
|
in all the large stars e.g. alpha centauri is too small"
|
||||||
|
- The colors are wrong too, according to reports
|
||||||
|
|
||||||
- "For some odd reason, the new graphical menus are constantly freezing on
|
- "For some odd reason, the new graphical menus are constantly freezing on
|
||||||
me. I've played 15 times so far. 10 times it froze while I was trying to
|
me. I've played 15 times so far. 10 times it froze while I was trying to
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
0.2:
|
0.2:
|
||||||
|
- Rendering thread now broadcasts to a condition variable, stopping most
|
||||||
|
of the problems we were having where a fast thread spams the DCQ with
|
||||||
|
too many requests to handle in a timely manner
|
||||||
- Fixed an unsafe memory freeing from sfx.c
|
- Fixed an unsafe memory freeing from sfx.c
|
||||||
- Thread library now includes condition variables
|
- Thread library now includes condition variables
|
||||||
- Shofixti dialogue fixed to subtitles, by BlckKnght
|
- Shofixti dialogue fixed to subtitles, by BlckKnght
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ ConfirmExit (void)
|
|||||||
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
|
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
|
|
||||||
|
ClearSemaphore (GraphicsSem);
|
||||||
FlushGraphics ();
|
FlushGraphics ();
|
||||||
|
SetSemaphore (GraphicsSem);
|
||||||
|
|
||||||
{
|
{
|
||||||
INPUT_STATE PressState;
|
INPUT_STATE PressState;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ FlushGraphics (void)
|
|||||||
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS;
|
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS;
|
||||||
DrawCommand.image = 0;
|
DrawCommand.image = 0;
|
||||||
TFB_EnqueueDrawCommand(&DrawCommand);
|
TFB_EnqueueDrawCommand(&DrawCommand);
|
||||||
|
WaitCondVar (RenderingCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -155,18 +155,23 @@ TFB_DrawCommandQueue_Push (TFB_DrawCommandQueue* myQueue,
|
|||||||
TFB_DrawCommand* Command)
|
TFB_DrawCommand* Command)
|
||||||
{
|
{
|
||||||
Lock_DCQ ();
|
Lock_DCQ ();
|
||||||
if (myQueue->FullSize < DCQ_MAX - 1)
|
while (myQueue->FullSize >= DCQ_MAX - 1)
|
||||||
{
|
{
|
||||||
|
int old_depth, i;
|
||||||
|
fprintf (stderr, "DCQ overload. Sleeping until renderer is done.\n");
|
||||||
|
// Restore the DCQ locking level. I *think* this is
|
||||||
|
// always 1, but...
|
||||||
|
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 ();
|
||||||
|
}
|
||||||
DCQ[myQueue->InsertionPoint] = *Command;
|
DCQ[myQueue->InsertionPoint] = *Command;
|
||||||
myQueue->InsertionPoint = (myQueue->InsertionPoint + 1) % DCQ_MAX;
|
myQueue->InsertionPoint = (myQueue->InsertionPoint + 1) % DCQ_MAX;
|
||||||
myQueue->FullSize++;
|
myQueue->FullSize++;
|
||||||
Synchronize_DCQ ();
|
Synchronize_DCQ ();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf (stderr, "DCQ overload. Adjust your livelock deterrence constants!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
Unlock_DCQ ();
|
Unlock_DCQ ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
|
|
||||||
last_fade = current_fade;
|
last_fade = current_fade;
|
||||||
last_transition = current_transition;
|
last_transition = current_transition;
|
||||||
|
BroadcastCondVar (RenderingCond);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +556,10 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
|
|
||||||
semval = TimeoutSetSemaphore (GraphicsSem, ONE_SECOND / 10);
|
semval = TimeoutSetSemaphore (GraphicsSem, ONE_SECOND / 10);
|
||||||
if (semval != 0)
|
if (semval != 0)
|
||||||
|
{
|
||||||
|
BroadcastCondVar (RenderingCond);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
SDL_SemPost (GraphicsSem);
|
SDL_SemPost (GraphicsSem);
|
||||||
}
|
}
|
||||||
@@ -776,6 +779,7 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
}
|
}
|
||||||
|
|
||||||
TFB_SwapBuffers();
|
TFB_SwapBuffers();
|
||||||
|
BroadcastCondVar (RenderingCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ QUEUE race_q[NUM_PLAYERS];
|
|||||||
SOUND MenuSounds, GameSounds;
|
SOUND MenuSounds, GameSounds;
|
||||||
FRAME ActivityFrame, status, flagship_status, misc_data;
|
FRAME ActivityFrame, status, flagship_status, misc_data;
|
||||||
Semaphore GraphicsSem;
|
Semaphore GraphicsSem;
|
||||||
|
CondVar RenderingCond;
|
||||||
STRING GameStrings;
|
STRING GameStrings;
|
||||||
|
|
||||||
static MEM_HANDLE
|
static MEM_HANDLE
|
||||||
|
|||||||
@@ -1004,15 +1004,10 @@ int flash_rect_func(void *data)
|
|||||||
SetGraphicStrength (4, 4);
|
SetGraphicStrength (4, 4);
|
||||||
|
|
||||||
UnbatchGraphics ();
|
UnbatchGraphics ();
|
||||||
FlushGraphics ();
|
|
||||||
/* ACK, cheap hack, oh well, blame Michael Martin until he fixes it */
|
|
||||||
if (flash_rect.extent.width > 250)
|
|
||||||
{
|
|
||||||
SkipGraphics ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SetContext (OldContext);
|
SetContext (OldContext);
|
||||||
ClearSemaphore (GraphicsSem);
|
ClearSemaphore (GraphicsSem);
|
||||||
|
FlushGraphics ();
|
||||||
SleepThreadUntil (TimeIn + WaitTime);
|
SleepThreadUntil (TimeIn + WaitTime);
|
||||||
TimeIn = GetTimeCounter ();
|
TimeIn = GetTimeCounter ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ extern FRAME ActivityFrame;
|
|||||||
extern SOUND MenuSounds, GameSounds;
|
extern SOUND MenuSounds, GameSounds;
|
||||||
extern QUEUE race_q[NUM_PLAYERS];
|
extern QUEUE race_q[NUM_PLAYERS];
|
||||||
extern Semaphore GraphicsSem;
|
extern Semaphore GraphicsSem;
|
||||||
|
extern CondVar RenderingCond;
|
||||||
extern STRING GameStrings;
|
extern STRING GameStrings;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|||||||
@@ -174,7 +174,9 @@ PauseGame (void)
|
|||||||
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
|
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
|
|
||||||
|
ClearSemaphore (GraphicsSem);
|
||||||
FlushGraphics ();
|
FlushGraphics ();
|
||||||
|
SetSemaphore (GraphicsSem);
|
||||||
|
|
||||||
{
|
{
|
||||||
BYTE scan;
|
BYTE scan;
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
mem_init ();
|
mem_init ();
|
||||||
GraphicsSem = CreateSemaphore (1);
|
GraphicsSem = CreateSemaphore (1);
|
||||||
|
RenderingCond = CreateCondVar ();
|
||||||
init_xform_control ();
|
init_xform_control ();
|
||||||
|
|
||||||
TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp);
|
TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp);
|
||||||
|
|||||||
Reference in New Issue
Block a user