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.
This commit is contained in:
parent
69ef2f9c16
commit
adc581d2ab
2 changed files with 48 additions and 0 deletions
|
@ -52,6 +52,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue