Module: wine Branch: master Commit: 6153ced0f9d86f1a55020f352b43bdf0b32e7286 URL: https://gitlab.winehq.org/wine/wine/-/commit/6153ced0f9d86f1a55020f352b43bdf...
Author: Matteo Bruni mbruni@codeweavers.com Date: Thu Nov 9 21:30:04 2023 +0100
opengl32: Skip filter_extensions_index() on GL contexts < 3.0.
glGetStringi() is not available before 3.0. We can't trust its function pointer being NULL since the GL implementation is allowed to return anything in this case (*cough* macOS's GL on Metal *cough*).
This probably regressed when fd92954df8cf12c61e08c7ef7acf172efb7c44ad removed the "if (!disabled[0]) return FALSE;" exit from filter_extensions(), although that simply exposed an existing issue.
---
dlls/opengl32/unix_wgl.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 5da69196548..e03bbc0a9c0 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -198,13 +198,32 @@ static GLubyte *filter_extensions_list( const char *extensions, const char *disa return (GLubyte *)str; }
+static const char *parse_gl_version( const char *gl_version, int *major, int *minor ) +{ + const char *ptr = gl_version; + + *major = atoi( ptr ); + if (*major <= 0) + ERR( "Invalid OpenGL major version %d.\n", *major ); + + while (isdigit( *ptr )) ++ptr; + if (*ptr++ != '.') + ERR( "Invalid OpenGL version string %s.\n", debugstr_a(gl_version) ); + + *minor = atoi( ptr ); + + while (isdigit( *ptr )) ++ptr; + return ptr; +} + static GLuint *filter_extensions_index( TEB *teb, const char *disabled ) { const struct opengl_funcs *funcs = teb->glTable; + const char *ext, *version; GLuint *disabled_index; GLint extensions_count; unsigned int i = 0, j; - const char *ext; + int major, minor;
if (!funcs->ext.p_glGetStringi) { @@ -213,6 +232,11 @@ static GLuint *filter_extensions_index( TEB *teb, const char *disabled ) if (!funcs->ext.p_glGetStringi) return NULL; }
+ version = (const char *)funcs->gl.p_glGetString( GL_VERSION ); + parse_gl_version( version, &major, &minor ); + if (major < 3) + return NULL; + funcs->gl.p_glGetIntegerv( GL_NUM_EXTENSIONS, &extensions_count ); disabled_index = malloc( extensions_count * sizeof(*disabled_index) ); if (!disabled_index) return NULL; @@ -413,24 +437,6 @@ static BOOL check_extension_support( TEB *teb, const char *extension, const char return FALSE; }
-static const char *parse_gl_version( const char *gl_version, int *major, int *minor ) -{ - const char *ptr = gl_version; - - *major = atoi( ptr ); - if (*major <= 0) - ERR( "Invalid OpenGL major version %d.\n", *major ); - - while (isdigit( *ptr )) ++ptr; - if (*ptr++ != '.') - ERR( "Invalid OpenGL version string %s.\n", debugstr_a(gl_version) ); - - *minor = atoi( ptr ); - - while (isdigit( *ptr )) ++ptr; - return ptr; -} - static void wrap_glGetIntegerv( TEB *teb, GLenum pname, GLint *data ) { const struct opengl_funcs *funcs = teb->glTable;