GLES: Only use GPU sync if necessary and available.

If there are complaints of reduced performance, or visual artefacts compared to 4.6.1, it may be worth increasing HW_MAX_PIPELINE_BUFFERS to 4 again.
This commit is contained in:
Emile Belanger 2021-09-21 17:32:15 +01:00 committed by Christoph Oelckers
parent 24aa497e4f
commit 4de6b769d3

View file

@ -235,28 +235,34 @@ void GLBuffer::Resize(size_t newsize)
void GLBuffer::GPUDropSync()
{
#if !(USE_GLES2) // Only applicable when running on desktop for now
if (mGLSync != NULL)
if (gles.useMappedBuffers && glFenceSync && glClientWaitSync)
{
glDeleteSync(mGLSync);
}
if (mGLSync != NULL)
{
glDeleteSync(mGLSync);
}
mGLSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
mGLSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
#endif
}
void GLBuffer::GPUWaitSync()
{
#if !(USE_GLES2) // Only applicable when running on desktop for now
GLenum status = glClientWaitSync(mGLSync, GL_SYNC_FLUSH_COMMANDS_BIT, 1000 * 1000 * 50); // Wait for a max of 50ms...
if (status != GL_ALREADY_SIGNALED && status != GL_CONDITION_SATISFIED)
if (gles.useMappedBuffers && glFenceSync && glClientWaitSync)
{
//Printf("Error on glClientWaitSync: %d\n", status);
GLenum status = glClientWaitSync(mGLSync, GL_SYNC_FLUSH_COMMANDS_BIT, 1000 * 1000 * 50); // Wait for a max of 50ms...
if (status != GL_ALREADY_SIGNALED && status != GL_CONDITION_SATISFIED)
{
//Printf("Error on glClientWaitSync: %d\n", status);
}
glDeleteSync(mGLSync);
mGLSync = NULL;
}
glDeleteSync(mGLSync);
mGLSync = NULL;
#endif
}