From: Derek Lesho dlesho@codeweavers.com
Signed-off-by: Derek Lesho dlesho@codeweavers.com --- dlls/opengl32/make_opengl | 2 +- dlls/opengl32/unix_thunks.c | 5 ++--- dlls/opengl32/unix_thunks.h | 2 +- dlls/opengl32/unix_wgl.c | 35 ++++++++++++----------------------- include/wine/opengl_driver.h | 10 ++++++++++ 5 files changed, 26 insertions(+), 28 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 61eafbec33e..87bff92c310 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -200,6 +200,7 @@ my %manual_unix_thunks = "glFramebufferReadBufferEXT" => 1, "glGetBooleanv" => 1, "glGetDoublev" => 1, + "glGetError" => 1, "glGetFloatv" => 1, "glGetFramebufferParameterivEXT" => 1, "glGetInteger64v" => 1, @@ -288,7 +289,6 @@ my %manual_wow64_wrappers = "glFlushMappedNamedBufferRangeEXT" => 0, "glGetBufferPointerv" => 0, "glGetBufferPointervARB" => 0, - "glGetError" => 0, "glGetNamedBufferPointerv" => 0, "glGetNamedBufferPointervEXT" => 0, "glGetSynciv" => 0, diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 7d4c00edbe9..835e7636d54 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -1019,8 +1019,7 @@ static NTSTATUS gl_glGetDoublev( void *args ) static NTSTATUS gl_glGetError( void *args ) { struct glGetError_params *params = args; - const struct opengl_funcs *funcs = params->teb->glTable; - params->ret = funcs->p_glGetError(); + params->ret = wrap_glGetError( params->teb ); return STATUS_SUCCESS; }
@@ -32252,7 +32251,7 @@ static NTSTATUS wow64_gl_glGetError( void *args ) GLenum ret; } *params = args; TEB *teb = get_teb64( params->teb ); - params->ret = wow64_glGetError( teb ); + params->ret = wrap_glGetError( teb ); return STATUS_SUCCESS; }
diff --git a/dlls/opengl32/unix_thunks.h b/dlls/opengl32/unix_thunks.h index 4bf2d13c476..3f00ad63832 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -16,6 +16,7 @@ extern void wrap_glFinish( TEB *teb ); extern void wrap_glFlush( TEB *teb ); extern void wrap_glGetBooleanv( TEB *teb, GLenum pname, GLboolean *data ); extern void wrap_glGetDoublev( TEB *teb, GLenum pname, GLdouble *data ); +extern GLenum wrap_glGetError( TEB *teb ); extern void wrap_glGetFloatv( TEB *teb, GLenum pname, GLfloat *data ); extern void wrap_glGetIntegerv( TEB *teb, GLenum pname, GLint *data ); extern const GLubyte *wrap_glGetString( TEB *teb, GLenum name ); @@ -47,7 +48,6 @@ extern BOOL wrap_wglReleaseTexImageARB( TEB *teb, HPBUFFERARB hPbuffer, int iBuf extern BOOL wrap_wglSetPbufferAttribARB( TEB *teb, HPBUFFERARB hPbuffer, const int *piAttribList );
#ifdef _WIN64 -extern GLenum wow64_glGetError( TEB *teb ); extern void wow64_glBufferStorage( TEB *teb, GLenum target, GLsizeiptr size, const void *data, GLbitfield flags ); extern GLenum wow64_glClientWaitSync( TEB *teb, GLsync sync, GLbitfield flags, GLuint64 timeout ); extern void wow64_glDeleteBuffers( TEB *teb, GLsizei n, const GLuint *buffers ); diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 8878aae8a54..242bb9bdaf7 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -143,7 +143,6 @@ struct context GLubyte *extensions; /* extension string */ char *wow64_version; /* wow64 GL version override */ struct buffers *buffers; /* wow64 buffers map */ - GLenum gl_error; /* wrapped GL error */ const char **extension_array; /* array of supported extensions */ size_t extension_count; /* size of supported extensions */ BOOL use_pinned_memory; /* use GL_AMD_pinned_memory to emulate persistent maps */ @@ -2064,6 +2063,18 @@ void wrap_glGetFramebufferParameterivEXT( TEB *teb, GLuint fbo, GLenum pname, GL funcs->p_glGetFramebufferParameterivEXT( fbo, pname, params ); }
+GLenum wrap_glGetError( TEB *teb ) +{ + struct wgl_context *ctx = &get_current_context( teb, NULL, NULL )->base; + const struct opengl_funcs *funcs = teb->glTable; + GLenum gl_err, prev_err; + + gl_err = funcs->p_glGetError(); + prev_err = ctx->gl_error; + ctx->gl_error = GL_NO_ERROR; + return prev_err ? prev_err : gl_err; +} + NTSTATUS process_attach( void *args ) { struct process_attach_params *params = args; @@ -2161,28 +2172,6 @@ NTSTATUS return_wow64_string( const void *str, PTR32 *wow64_str ) return STATUS_BUFFER_TOO_SMALL; }
-GLenum wow64_glGetError( TEB *teb ) -{ - const struct opengl_funcs *funcs = teb->glTable; - GLenum gl_err, prev_err; - struct context *ctx; - - if (!(ctx = get_current_context( teb, NULL, NULL ))) return GL_INVALID_OPERATION; - gl_err = funcs->p_glGetError(); - prev_err = ctx->gl_error; - ctx->gl_error = GL_NO_ERROR; - return prev_err ? prev_err : gl_err; -} - -static void set_gl_error( TEB *teb, GLenum gl_error ) -{ - const struct opengl_funcs *funcs = teb->glTable; - struct context *ctx; - - if (!(ctx = get_current_context( teb, NULL, NULL )) || ctx->gl_error) return; - if (!(ctx->gl_error = funcs->p_glGetError())) ctx->gl_error = gl_error; -} - static struct wgl_handle *get_sync_ptr( TEB *teb, GLsync sync ) { struct wgl_handle *handle = get_handle_ptr( sync ); diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 77d1c818438..1ee22365429 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -77,6 +77,7 @@ 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 gl_error; /* wrapped GL error */ };
/* interface between opengl32 and win32u */ @@ -129,6 +130,15 @@ struct opengl_funcs void *egl_handle; };
+static inline void set_gl_error( TEB *teb, GLenum gl_error ) +{ + const struct opengl_funcs *funcs = teb->glTable; + struct wgl_context *ctx = teb->glContext; + + if (!ctx || ctx->gl_error) return; + if (!(ctx->gl_error = funcs->p_glGetError())) ctx->gl_error = gl_error; +} + struct egl_platform { struct list entry;