From adc581d2ab5484505280628b340f67c044396305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Sun, 19 May 2013 16:14:47 +0200 Subject: [PATCH] kwin: Resolve functions for GL_ARB_robustness Only the subset of functions available in core contexts is resolved, except for glGetnTexImageARB() and glGetnUniformivARB(), which are not used by kwin. Instead of setting the function pointers to NULL when the extension isn't supported, kwin provides its own implementations that call the non-robust versions of the functions. This is so callers don't have to check if the extension is supported before calling the functions. --- libkwineffects/kwinglutils_funcs.cpp | 39 ++++++++++++++++++++++++++++ libkwineffects/kwinglutils_funcs.h | 9 +++++++ 2 files changed, 48 insertions(+) diff --git a/libkwineffects/kwinglutils_funcs.cpp b/libkwineffects/kwinglutils_funcs.cpp index 65585b1709..234c62c4d6 100644 --- a/libkwineffects/kwinglutils_funcs.cpp +++ b/libkwineffects/kwinglutils_funcs.cpp @@ -52,6 +52,11 @@ along with this program. If not, see . namespace KWin { +static GLenum GetGraphicsResetStatus(); +static void ReadnPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, + GLenum type, GLsizei bufSize, GLvoid *data); +static void GetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + #ifndef KWIN_HAVE_OPENGLES // Function pointers glXGetProcAddress_func glXGetProcAddress; @@ -188,6 +193,11 @@ glUniform1uiv_func glUniform1uiv; glUniform2uiv_func glUniform2uiv; glUniform3uiv_func glUniform3uiv; +// GL_ARB_robustness +glGetGraphicsResetStatus_func glGetGraphicsResetStatus; +glReadnPixels_func glReadnPixels; +glGetnUniformfv_func glGetnUniformfv; + static glXFuncPtr getProcAddress(const char* name) { @@ -667,6 +677,17 @@ void glResolveFunctions(OpenGLPlatformInterface platformInterface) glFlushMappedBufferRange = NULL; } + if (hasGLExtension("GL_ARB_robustness")) { + // See http://www.opengl.org/registry/specs/ARB/robustness.txt + GL_RESOLVE_WITH_EXT(glGetGraphicsResetStatus, glGetGraphicsResetStatusARB); + GL_RESOLVE_WITH_EXT(glReadnPixels, glReadnPixelsARB); + GL_RESOLVE_WITH_EXT(glGetnUniformfv, glGetnUniformfvARB); + } else { + glGetGraphicsResetStatus = KWin::GetGraphicsResetStatus; + glReadnPixels = KWin::ReadnPixels; + glGetnUniformfv = KWin::GetnUniformfv; + } + #else if (hasGLExtension("GL_OES_mapbuffer")) { @@ -702,4 +723,22 @@ void glResolveFunctions(OpenGLPlatformInterface platformInterface) #endif } +static GLenum GetGraphicsResetStatus() +{ + return GL_NO_ERROR; +} + +static void ReadnPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, + GLenum type, GLsizei bufSize, GLvoid *data) +{ + Q_UNUSED(bufSize) + glReadPixels(x, y, width, height, format, type, data); +} + +static void GetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params) +{ + Q_UNUSED(bufSize) + glGetUniformfv(program, location, params); +} + } // namespace diff --git a/libkwineffects/kwinglutils_funcs.h b/libkwineffects/kwinglutils_funcs.h index 5b306be64c..9e68a5eb0a 100644 --- a/libkwineffects/kwinglutils_funcs.h +++ b/libkwineffects/kwinglutils_funcs.h @@ -444,6 +444,15 @@ typedef void (*glFlushMappedBufferRange_func)(GLenum target, GLintptr offset, GL extern KWIN_EXPORT glMapBufferRange_func glMapBufferRange; extern KWIN_EXPORT glFlushMappedBufferRange_func glFlushMappedBufferRange; +// GL_ARB_robustness +typedef GLenum (*glGetGraphicsResetStatus_func)(); +typedef void (*glReadnPixels_func)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (*glGetnUniformfv_func)(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + +extern KWIN_EXPORT glGetGraphicsResetStatus_func glGetGraphicsResetStatus; +extern KWIN_EXPORT glReadnPixels_func glReadnPixels; +extern KWIN_EXPORT glGetnUniformfv_func glGetnUniformfv; + } // namespace #endif // not KWIN_HAVE_OPENGLES