Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Workaround for NVIDIA bug in glXSwapIntervalEXT.
Browse files Browse the repository at this point in the history
       This works around a bug in NVIDIA's implementation of
       glXSwapIntervalEXT, where it ignores updates to what it *thinks* is the
       current value, even though glXQueryDrawable returns a different value.

       Bug reported to NVIDIA and will hopefully be a part of 319.xx.

       Also a fix for invalidly treating glXSwapIntervalEXT as having an int
       return value (it's void).
  • Loading branch information
slouken committed Feb 12, 2013
1 parent 016410d commit 28c6fa1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Empty file modified build-scripts/ltmain.sh 100644 → 100755
Empty file.
24 changes: 17 additions & 7 deletions src/video/x11/SDL_x11opengl.c
Expand Up @@ -332,7 +332,7 @@ X11_GL_InitExtensions(_THIS)
_this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_FALSE;
if (HasExtension("GLX_EXT_swap_control", extensions)) {
_this->gl_data->glXSwapIntervalEXT =
(int (*)(Display*,GLXDrawable,int))
(void (*)(Display*,GLXDrawable,int))
X11_GL_GetProcAddress(_this, "glXSwapIntervalEXT");
if (HasExtension("GLX_EXT_swap_control_tear", extensions)) {
_this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_TRUE;
Expand Down Expand Up @@ -667,13 +667,23 @@ X11_GL_SetSwapInterval(_THIS, int interval)
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
const SDL_WindowData *windowdata = (SDL_WindowData *)
_this->current_glwin->driverdata;

Window drawable = windowdata->xwindow;
status = _this->gl_data->glXSwapIntervalEXT(display,drawable,interval);
if (status != 0) {
SDL_SetError("glxSwapIntervalEXT failed");
} else {
swapinterval = interval;
}

/*
* This is a workaround for a bug in NVIDIA drivers. Bug has been reported
* and will be fixed in a future release (probably 319.xx).
*
* There's a bug where glXSetSwapIntervalEXT ignores updates because
* it has the wrong value cached. To work around it, we just run a no-op
* update to the current value.
*/
int currentInterval = _this, X11_GL_GetSwapInterval(_this);
_this->gl_data->glXSwapIntervalEXT(display, drawable, currentInterval);
_this->gl_data->glXSwapIntervalEXT(display, drawable, interval);

status = 0;
swapinterval = interval;
} else if (_this->gl_data->glXSwapIntervalMESA) {
status = _this->gl_data->glXSwapIntervalMESA(interval);
if (status != 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/video/x11/SDL_x11opengl.h
Expand Up @@ -40,7 +40,7 @@ struct SDL_GLDriverData
Bool(*glXMakeCurrent) (Display*,GLXDrawable,GLXContext);
void (*glXSwapBuffers) (Display*, GLXDrawable);
void (*glXQueryDrawable) (Display*,GLXDrawable,int,unsigned int*);
int (*glXSwapIntervalEXT) (Display*,GLXDrawable,int);
void (*glXSwapIntervalEXT) (Display*,GLXDrawable,int);
int (*glXSwapIntervalSGI) (int);
int (*glXSwapIntervalMESA) (int);
int (*glXGetSwapIntervalMESA) (void);
Expand Down

0 comments on commit 28c6fa1

Please sign in to comment.