mirror of https://github.com/snes9xgit/snes9x.git
GTK+: OpenGL: Use fence to allow GTK+ to run during wait.
This commit is contained in:
parent
dc4de5b7c7
commit
8106c284d5
|
@ -1897,3 +1897,10 @@ S9xInitDisplay (int argc, char **argv)
|
|||
S9xCustomDisplayString = S9xGTKDisplayString;
|
||||
}
|
||||
|
||||
bool
|
||||
S9xDisplayDriverIsReady ()
|
||||
{
|
||||
if (!driver)
|
||||
return false;
|
||||
return driver->is_ready ();
|
||||
}
|
||||
|
|
|
@ -132,5 +132,6 @@ void S9xDisplayReconfigure ();
|
|||
void S9xQueryDrivers ();
|
||||
|
||||
S9xDisplayDriver *S9xDisplayGetDriver ();
|
||||
bool S9xDisplayDriverIsReady ();
|
||||
|
||||
#endif /* __GTK_DISPLAY_H */
|
||||
|
|
|
@ -23,6 +23,7 @@ class S9xDisplayDriver
|
|||
virtual void push_buffer (uint16 *src) = 0;
|
||||
virtual void *get_parameters () = 0;
|
||||
virtual void save (const char *filename) = 0;
|
||||
virtual bool is_ready () = 0;
|
||||
|
||||
/* Namespaced sizing constants */
|
||||
static const int image_width = 1024;
|
||||
|
|
|
@ -24,6 +24,7 @@ class S9xGTKDisplayDriver : public S9xDisplayDriver
|
|||
void push_buffer (uint16 *src);
|
||||
void *get_parameters () { return NULL; }
|
||||
void save (const char *filename) { }
|
||||
bool is_ready () { return true; }
|
||||
|
||||
private:
|
||||
void clear ();
|
||||
|
|
|
@ -88,6 +88,7 @@ S9xOpenGLDisplayDriver::S9xOpenGLDisplayDriver (Snes9xWindow *window,
|
|||
this->window = window;
|
||||
this->config = config;
|
||||
this->drawing_area = GTK_WIDGET (window->drawing_area);
|
||||
fence = NULL;
|
||||
}
|
||||
|
||||
void S9xOpenGLDisplayDriver::update (int width, int height, int yoffset)
|
||||
|
@ -645,10 +646,9 @@ void S9xOpenGLDisplayDriver::swap_buffers ()
|
|||
{
|
||||
if (fences)
|
||||
{
|
||||
GLsync fence = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
usleep (0);
|
||||
glClientWaitSync (fence, GL_SYNC_FLUSH_COMMANDS_BIT, 100000000);
|
||||
glDeleteSync (fence);
|
||||
if (fence)
|
||||
glDeleteSync (fence);
|
||||
fence = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -716,3 +716,16 @@ int S9xOpenGLDisplayDriver::query_availability ()
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool S9xOpenGLDisplayDriver::is_ready ()
|
||||
{
|
||||
if (!fence)
|
||||
return true;
|
||||
|
||||
if (glClientWaitSync (fence, GL_SYNC_FLUSH_COMMANDS_BIT, 0) == GL_TIMEOUT_EXPIRED)
|
||||
return false;
|
||||
|
||||
glDeleteSync (fence);
|
||||
fence = NULL;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ class S9xOpenGLDisplayDriver : public S9xDisplayDriver
|
|||
void *get_parameters ();
|
||||
void save (const char *filename);
|
||||
static int query_availability ();
|
||||
bool is_ready ();
|
||||
|
||||
private:
|
||||
int opengl_defaults ();
|
||||
|
@ -74,6 +75,8 @@ class S9xOpenGLDisplayDriver : public S9xDisplayDriver
|
|||
|
||||
OpenGLContext *context;
|
||||
|
||||
GLsync fence;
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GTKGLXContext glx;
|
||||
#endif
|
||||
|
|
|
@ -32,6 +32,7 @@ class S9xXVDisplayDriver : public S9xDisplayDriver
|
|||
void *get_parameters () { return NULL; }
|
||||
void save (const char *filename) { }
|
||||
static int query_availability ();
|
||||
bool is_ready () { return true; }
|
||||
|
||||
private:
|
||||
void clear ();
|
||||
|
|
|
@ -308,9 +308,13 @@ gboolean S9xIdleFunc (gpointer data)
|
|||
}
|
||||
|
||||
S9xCheckPointerTimer ();
|
||||
S9xThrottle ();
|
||||
S9xProcessEvents (TRUE);
|
||||
|
||||
if (!S9xDisplayDriverIsReady ())
|
||||
return TRUE;
|
||||
|
||||
S9xThrottle ();
|
||||
|
||||
if (!S9xNetplayPush ())
|
||||
{
|
||||
if(Settings.Rewinding)
|
||||
|
|
Loading…
Reference in New Issue