From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/unix_wgl.c | 17 +++++++++++------ dlls/win32u/opengl.c | 9 +++++---- include/wine/opengl_driver.h | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 17994a2c324..c061450b140 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -745,10 +745,12 @@ static BOOL is_any_extension_supported( struct context *ctx, const char *extensi static void set_gl_error( TEB *teb, GLenum error ) { const struct opengl_funcs *funcs = teb->glTable; + struct opengl_client_context *client; struct context *ctx; - if (!(ctx = get_current_context( teb, NULL, NULL )) || ctx->base.error) return; - if (!(ctx->base.error = funcs->p_glGetError())) ctx->base.error = error; + if (!(ctx = get_current_context( teb, NULL, NULL ))) return; + if (!(client = opengl_client_context_from_client( ctx->base.client_context ))) return; + if (!client->last_error && !(client->last_error = funcs->p_glGetError())) client->last_error = error; } static BOOL get_default_fbo_integer( struct context *ctx, struct opengl_drawable *draw, struct opengl_drawable *read, @@ -1961,13 +1963,16 @@ void wrap_glGetFramebufferParameterivEXT( TEB *teb, GLuint fbo, GLenum pname, GL GLenum wrap_glGetError( TEB *teb ) { const struct opengl_funcs *funcs = teb->glTable; - struct wgl_context *ctx; + struct opengl_client_context *client; GLenum error, wrapped; + struct context *ctx; + + if (!(ctx = get_current_context( teb, NULL, NULL ))) return GL_INVALID_OPERATION; + if (!(client = opengl_client_context_from_client( ctx->base.client_context ))) return GL_INVALID_OPERATION; - if (!(ctx = &get_current_context( teb, NULL, NULL )->base)) return GL_INVALID_OPERATION; error = funcs->p_glGetError(); - wrapped = ctx->error; - ctx->error = GL_NO_ERROR; + wrapped = client->last_error; + client->last_error = GL_NO_ERROR; return wrapped ? wrapped : error; } diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index c41d36f808e..8e5b708a500 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -2409,12 +2409,13 @@ static int win32u_wglGetSwapIntervalEXT(void) static void set_gl_error( GLenum error ) { - struct wgl_context *ctx = NtCurrentTeb()->glContext; const struct opengl_funcs *funcs = &display_funcs; + struct opengl_client_context *client; + struct wgl_context *ctx; - if (!ctx || ctx->error) return; - if ((ctx->error = funcs->p_glGetError())) return; - ctx->error = error; + if (!(ctx = NtCurrentTeb()->glContext)) return; + if (!(client = opengl_client_context_from_client( ctx->client_context ))) return; + if (!client->last_error && !(client->last_error = funcs->p_glGetError())) client->last_error = error; } static struct egl_platform *egl_platform_from_index( GLint index ) diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 47c5195091f..366f600e002 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -64,6 +64,7 @@ struct opengl_client_context struct HGLRC__ obj; /* client object header */ UINT64 unix_handle; UINT64 unix_funcs; + GLenum last_error; }; static inline struct opengl_client_context *opengl_client_context_from_client( HGLRC client_context ) @@ -100,7 +101,6 @@ struct wgl_context int format; /* pixel format of the context */ struct opengl_drawable *draw; /* currently bound draw surface */ struct opengl_drawable *read; /* currently bound read surface */ - GLenum error; /* wrapped GL error */ }; static inline struct wgl_context *opengl_context_from_handle( HGLRC client_context ) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9953