mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-06-02 18:21:02 +00:00
- Found out that just omitting the glFinish call is not working glitch-free. I reorganized the code so that the
glFinish/SwapBuffers call is delayed until the latest possible moment which is after scene processing for the next frame is complete and right before actual rendering starts. This does not show any obvious problems but it still gives almost the same performance gains as omitting glFinish. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@591 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
4025c3fe8e
commit
b8133792c0
5 changed files with 44 additions and 16 deletions
|
@ -89,7 +89,7 @@ public:
|
|||
void SetViewArea();
|
||||
void ResetViewport();
|
||||
void SetViewport(GL_IRECT *bounds);
|
||||
sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview);
|
||||
sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
||||
void RenderView(player_t *player);
|
||||
void SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle);
|
||||
void SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror);
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
void CreateScene();
|
||||
void RenderScene(int recursion);
|
||||
void RenderTranslucent();
|
||||
void DrawScene();
|
||||
void DrawScene(bool toscreen = false);
|
||||
void DrawBlend(sector_t * viewsector);
|
||||
|
||||
void DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, int cm_index, bool hudModelStep);
|
||||
|
@ -131,7 +131,7 @@ public:
|
|||
|
||||
void SetProjection(float fov, float ratio, float fovratio);
|
||||
void SetViewMatrix(bool mirror, bool planemirror);
|
||||
void ProcessScene();
|
||||
void ProcessScene(bool toscreen = false);
|
||||
|
||||
bool StartOffscreen();
|
||||
void EndOffscreen();
|
||||
|
|
|
@ -546,12 +546,22 @@ void FGLRenderer::RenderTranslucent()
|
|||
// stencil, z-buffer and the projection matrix intact!
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
EXTERN_CVAR(Bool, gl_draw_synchronized)
|
||||
|
||||
void FGLRenderer::DrawScene()
|
||||
void FGLRenderer::DrawScene(bool toscreen)
|
||||
{
|
||||
static int recursion=0;
|
||||
|
||||
CreateScene();
|
||||
|
||||
// Up to this point in the main draw call no rendering is performed so we can wait
|
||||
// with swapping the render buffer until now.
|
||||
if (!gl_draw_synchronized && toscreen)
|
||||
{
|
||||
All.Unclock();
|
||||
static_cast<OpenGLFrameBuffer*>(screen)->Swap();
|
||||
All.Clock();
|
||||
}
|
||||
RenderScene(recursion);
|
||||
|
||||
// Handle all portals after rendering the opaque objects but before
|
||||
|
@ -809,13 +819,13 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FGLRenderer::ProcessScene()
|
||||
void FGLRenderer::ProcessScene(bool toscreen)
|
||||
{
|
||||
FDrawInfo::StartDrawInfo();
|
||||
iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0;
|
||||
GLPortal::BeginScene();
|
||||
|
||||
DrawScene();
|
||||
DrawScene(toscreen);
|
||||
FDrawInfo::EndDrawInfo();
|
||||
|
||||
}
|
||||
|
@ -869,7 +879,7 @@ void FGLRenderer::SetFixedColormap (player_t *player)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview)
|
||||
sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
|
||||
{
|
||||
sector_t * retval;
|
||||
R_SetupFrame (camera);
|
||||
|
@ -904,7 +914,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
|
|||
angle_t a1 = GLRenderer->FrustumAngle();
|
||||
clipper.SafeAddClipRange(viewangle+a1, viewangle-a1);
|
||||
|
||||
ProcessScene();
|
||||
ProcessScene(toscreen);
|
||||
|
||||
gl_frameCount++; // This counter must be increased right before the interpolations are restored.
|
||||
interpolator.RestoreInterpolations ();
|
||||
|
@ -968,7 +978,7 @@ void FGLRenderer::RenderView (player_t* player)
|
|||
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
||||
GLRenderer->mLightCount = ((it.Next()) != NULL);
|
||||
|
||||
sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView * 360.0f / FINEANGLES, ratio, fovratio, true);
|
||||
sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView * 360.0f / FINEANGLES, ratio, fovratio, true, true);
|
||||
EndDrawScene(viewsector);
|
||||
|
||||
All.Unclock();
|
||||
|
@ -996,7 +1006,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei
|
|||
GLRenderer->mLightCount = ((it.Next()) != NULL);
|
||||
|
||||
sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds,
|
||||
FieldOfView * 360.0f / FINEANGLES, 1.6f, 1.6f, true);
|
||||
FieldOfView * 360.0f / FINEANGLES, 1.6f, 1.6f, true, false);
|
||||
gl.Disable(GL_STENCIL_TEST);
|
||||
screen->Begin2D(false);
|
||||
DrawBlend(viewsector);
|
||||
|
|
|
@ -88,6 +88,7 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(int width, int height, int bits, int refres
|
|||
gl_GenerateGlobalBrightmapFromColormap();
|
||||
DoSetGamma();
|
||||
needsetgamma = true;
|
||||
swapped = false;
|
||||
}
|
||||
|
||||
OpenGLFrameBuffer::~OpenGLFrameBuffer()
|
||||
|
@ -168,7 +169,7 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
// Updates the screen
|
||||
//
|
||||
//==========================================================================
|
||||
CVAR(Bool, gl_draw_synchronized, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, gl_draw_sync, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
|
||||
void OpenGLFrameBuffer::Update()
|
||||
{
|
||||
|
@ -190,10 +191,26 @@ void OpenGLFrameBuffer::Update()
|
|||
|
||||
Begin2D(false);
|
||||
}
|
||||
if (gl_draw_sync || !swapped)
|
||||
{
|
||||
Swap();
|
||||
}
|
||||
swapped = false;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Swap the buffers
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void OpenGLFrameBuffer::Swap()
|
||||
{
|
||||
Finish.Reset();
|
||||
Finish.Clock();
|
||||
if (gl_draw_synchronized) gl.Finish();
|
||||
else gl.Flush();
|
||||
gl.Finish();
|
||||
if (needsetgamma)
|
||||
{
|
||||
DoSetGamma();
|
||||
|
@ -201,8 +218,7 @@ void OpenGLFrameBuffer::Update()
|
|||
}
|
||||
gl.SwapBuffers();
|
||||
Finish.Unclock();
|
||||
|
||||
Unlock();
|
||||
swapped = true;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
void WipeEndScreen();
|
||||
bool WipeDo(int ticks);
|
||||
void WipeCleanup();
|
||||
void Swap();
|
||||
|
||||
|
||||
private:
|
||||
|
@ -96,6 +97,7 @@ private:
|
|||
int translation;
|
||||
bool iscomplex;
|
||||
bool needsetgamma;
|
||||
bool swapped;
|
||||
|
||||
PalEntry SourcePalette[256];
|
||||
BYTE *ScreenshotBuffer;
|
||||
|
|
|
@ -84,7 +84,7 @@ void FCanvasTexture::RenderGLView (AActor *Viewpoint, int FOV)
|
|||
bounds.width=FHardwareTexture::GetTexDimension(gltex->GetWidth(GLUSE_TEXTURE));
|
||||
bounds.height=FHardwareTexture::GetTexDimension(gltex->GetHeight(GLUSE_TEXTURE));
|
||||
|
||||
GLRenderer->RenderViewpoint(Viewpoint, &bounds, FOV, (float)width/height, (float)width/height, false);
|
||||
GLRenderer->RenderViewpoint(Viewpoint, &bounds, FOV, (float)width/height, (float)width/height, false, false);
|
||||
|
||||
if (!usefb)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue