GTK+: OpenGL: Add fences as glFinish alternative.

This commit is contained in:
Brandon Wright 2018-12-03 17:28:22 -06:00
parent 536c6708c3
commit dc4de5b7c7
3 changed files with 18 additions and 2 deletions

View File

@ -584,6 +584,9 @@ int S9xOpenGLDisplayDriver::create_context ()
else
core = false;
if (version >= 31 || epoxy_has_gl_extension ("GL_ARB_sync"))
fences = true;
return 1;
}
@ -639,11 +642,21 @@ void S9xOpenGLDisplayDriver::swap_buffers ()
context->swap_buffers ();
if (config->sync_every_frame)
{
if (fences)
{
GLsync fence = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
usleep (0);
glClientWaitSync (fence, GL_SYNC_FLUSH_COMMANDS_BIT, 100000000);
glDeleteSync (fence);
}
else
{
usleep (0);
glFinish ();
}
}
}
void S9xOpenGLDisplayDriver::deinit ()
{

View File

@ -63,6 +63,7 @@ class S9xOpenGLDisplayDriver : public S9xDisplayDriver
bool npot;
bool using_pbos;
bool initialized;
bool fences;
bool using_glsl_shaders;
GLSLShader *glsl_shader;

View File

@ -156,6 +156,8 @@ void GTKGLXContext::swap_interval (int frames)
glXSwapIntervalEXT (display, xid, frames);
else if (epoxy_has_glx_extension (display, screen, "GLX_SGI_swap_control"))
glXSwapIntervalSGI (frames);
else if (epoxy_has_glx_extension (display, screen, "GLX_MESA_swap_control"))
glXSwapIntervalMESA (frames);
}