Clear and InvalidateFramebuffer optimization

This commit is contained in:
Magnus Norddahl 2016-08-17 17:37:13 +02:00
parent fa2bcebd51
commit 5eeac830eb
3 changed files with 12 additions and 8 deletions

View File

@ -174,19 +174,19 @@ void FGLRenderer::Set3DViewport(bool mainview)
mBuffers->BindSceneFB();
}
// Always clear all buffers with scissor test disabled.
// This is faster on newer hardware because it allows the GPU to skip
// reading from slower memory where the full buffers are stored.
glDisable(GL_SCISSOR_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
const auto &bounds = mSceneViewport;
glViewport(bounds.left, bounds.top, bounds.width, bounds.height);
glScissor(bounds.left, bounds.top, bounds.width, bounds.height);
glEnable(GL_SCISSOR_TEST);
#ifdef _DEBUG
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
#else
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
#endif
glEnable(GL_MULTISAMPLE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST);

View File

@ -244,6 +244,8 @@ void gl_LoadExtensions()
gl.buffermethod = BM_PERSISTENT;
}
if (gl.version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER;
const char *lm = Args->CheckValue("-lightmethod");
if (lm != NULL)
{

View File

@ -23,7 +23,9 @@ enum RenderFlags
RFL_NO_RGBA16F = 32,
RFL_NO_DEPTHSTENCIL = 64,
RFL_NO_CLIP_PLANES = 128
RFL_NO_CLIP_PLANES = 128,
RFL_INVALIDATE_BUFFER = 256
};
enum TexMode