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 else
core = false; core = false;
if (version >= 31 || epoxy_has_gl_extension ("GL_ARB_sync"))
fences = true;
return 1; return 1;
} }
@ -640,8 +643,18 @@ void S9xOpenGLDisplayDriver::swap_buffers ()
if (config->sync_every_frame) if (config->sync_every_frame)
{ {
usleep (0); if (fences)
glFinish (); {
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 ();
}
} }
} }

View File

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

View File

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