Commit f0c110f7 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Cache the swap control setting, even on Mesa.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%404002
parent f9ef094b
...@@ -283,15 +283,16 @@ int X11_GL_CreateContext(_THIS) ...@@ -283,15 +283,16 @@ int X11_GL_CreateContext(_THIS)
} }
if ( !glXExtensionSupported(this, "GLX_MESA_swap_control") ) { if ( !glXExtensionSupported(this, "GLX_MESA_swap_control") ) {
this->gl_data->glXSwapIntervalMESA = NULL; this->gl_data->glXSwapIntervalMESA = NULL;
this->gl_data->glXGetSwapIntervalMESA = NULL;
} }
if ( this->gl_config.swap_control >= 0 ) { if ( this->gl_config.swap_control >= 0 ) {
int rc = -1;
if ( this->gl_data->glXSwapIntervalMESA ) { if ( this->gl_data->glXSwapIntervalMESA ) {
this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control); rc = this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control);
} else if ( this->gl_data->glXSwapIntervalSGI ) { } else if ( this->gl_data->glXSwapIntervalSGI ) {
if (this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control) == 0) { rc = this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control);
this->gl_data->sgi_swap_interval = this->gl_config.swap_control;
} }
if (rc == 0) {
this->gl_data->swap_interval = this->gl_config.swap_control;
} }
} }
#else #else
...@@ -412,11 +413,9 @@ int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) ...@@ -412,11 +413,9 @@ int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
} }
break; break;
case SDL_GL_SWAP_CONTROL: case SDL_GL_SWAP_CONTROL:
if ( this->gl_data->glXGetSwapIntervalMESA ) { if ( ( this->gl_data->glXSwapIntervalMESA ) ||
*value = this->gl_data->glXGetSwapIntervalMESA(); ( this->gl_data->glXSwapIntervalSGI ) ) {
return 0; *value = this->gl_data->swap_interval;
} else if ( this->gl_data->glXSwapIntervalSGI ) {
*value = this->gl_data->sgi_swap_interval;
return 0; return 0;
} else { } else {
unsupported = 1; unsupported = 1;
...@@ -469,7 +468,6 @@ void X11_GL_UnloadLibrary(_THIS) ...@@ -469,7 +468,6 @@ void X11_GL_UnloadLibrary(_THIS)
this->gl_data->glXSwapBuffers = NULL; this->gl_data->glXSwapBuffers = NULL;
this->gl_data->glXSwapIntervalSGI = NULL; this->gl_data->glXSwapIntervalSGI = NULL;
this->gl_data->glXSwapIntervalMESA = NULL; this->gl_data->glXSwapIntervalMESA = NULL;
this->gl_data->glXGetSwapIntervalMESA = NULL;
this->gl_config.dll_handle = NULL; this->gl_config.dll_handle = NULL;
this->gl_config.driver_loaded = 0; this->gl_config.driver_loaded = 0;
...@@ -530,8 +528,6 @@ int X11_GL_LoadLibrary(_THIS, const char* path) ...@@ -530,8 +528,6 @@ int X11_GL_LoadLibrary(_THIS, const char* path)
(int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI"); (int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI");
this->gl_data->glXSwapIntervalMESA = this->gl_data->glXSwapIntervalMESA =
(GLint (*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA"); (GLint (*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA");
this->gl_data->glXGetSwapIntervalMESA =
(GLint (*)(void)) GL_LoadFunction(handle, "glXGetSwapIntervalMESA");
if ( (this->gl_data->glXChooseVisual == NULL) || if ( (this->gl_data->glXChooseVisual == NULL) ||
(this->gl_data->glXCreateContext == NULL) || (this->gl_data->glXCreateContext == NULL) ||
......
...@@ -73,9 +73,7 @@ struct SDL_PrivateGLData { ...@@ -73,9 +73,7 @@ struct SDL_PrivateGLData {
int (*glXSwapIntervalSGI) ( int interval ); int (*glXSwapIntervalSGI) ( int interval );
GLint (*glXSwapIntervalMESA) ( unsigned interval ); GLint (*glXSwapIntervalMESA) ( unsigned interval );
GLint (*glXGetSwapIntervalMESA) ( void ); int swap_interval;
int sgi_swap_interval;
#endif /* SDL_VIDEO_OPENGL_GLX */ #endif /* SDL_VIDEO_OPENGL_GLX */
}; };
......
...@@ -122,7 +122,7 @@ static SDL_VideoDevice *X11_CreateDevice(int devindex) ...@@ -122,7 +122,7 @@ static SDL_VideoDevice *X11_CreateDevice(int devindex)
SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); SDL_memset(device->gl_data, 0, (sizeof *device->gl_data));
#if SDL_VIDEO_OPENGL_GLX #if SDL_VIDEO_OPENGL_GLX
device->gl_data->sgi_swap_interval = -1; device->gl_data->swap_interval = -1;
#endif #endif
/* Set the driver flags */ /* Set the driver flags */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment