Skip to content

Commit

Permalink
engine: client: skip drawing 2D during changelevel before the client …
Browse files Browse the repository at this point in the history
…was active

* Prevents screen garbage on GPUs with tile-based renderers like Adreno and ImgTec
  • Loading branch information
a1batross committed Jul 11, 2024
1 parent b77a4ed commit 56ba232
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions engine/client/cl_scrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,19 @@ void SCR_MakeScreenShot( void )
SCR_DrawPlaque
================
*/
static void SCR_DrawPlaque( void )
static qboolean SCR_DrawPlaque( void )
{
if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background )
{
int levelshot = ref.dllFuncs.GL_LoadTexture( cl_levelshot_name.string, NULL, 0, TF_IMAGE );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
if( !cl.background ) CL_DrawHUD( CL_LOADING );

return true;
}

return false;
}

/*
Expand Down Expand Up @@ -500,7 +504,7 @@ void SCR_TileClear( void )
int i, top, bottom, left, right;
dirty_t clear;

if( scr_viewsize.value >= 120 )
if( likely( scr_viewsize.value >= 120 ))
return; // full screen rendering

// erase rect will be the union of the past three frames
Expand Down Expand Up @@ -578,6 +582,8 @@ text to the screen.
*/
void SCR_UpdateScreen( void )
{
qboolean screen_redraw = true; // assume screen has been redrawn

if( !V_PreRender( )) return;

switch( cls.state )
Expand All @@ -588,7 +594,7 @@ void SCR_UpdateScreen( void )
case ca_connecting:
case ca_connected:
case ca_validate:
SCR_DrawPlaque();
screen_redraw = SCR_DrawPlaque();
break;
case ca_active:
Con_RunConsole ();
Expand All @@ -602,7 +608,11 @@ void SCR_UpdateScreen( void )
break;
}

V_PostRender();
// during changelevel we might have a few frames when we have nothing to draw
// (assuming levelshots are off) and drawing 2d on top of nothing or cleared screen
// is ugly, specifically with Adreno and ImgTec GPUs
if( screen_redraw || !cls.changelevel || !cls.changedemo )
V_PostRender();
}

/*
Expand Down

0 comments on commit 56ba232

Please sign in to comment.