From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/make_opengl | 18 ++++++++---------- dlls/opengl32/unix_wgl.c | 31 ++++++++++++++++--------------- dlls/opengl32/unixlib.h | 18 ++++++++---------- dlls/opengl32/wgl.c | 12 ++++++++---- 4 files changed, 40 insertions(+), 39 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 54873150da3..7d906ae43dd 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -1079,18 +1079,16 @@ foreach (sort keys %ext_functions) } print OUT "};\n\n";
-print OUT "typedef void (WINAPI *gl_debug_cb)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *);\n"; print OUT "struct wine_gl_debug_message_params\n"; print OUT "{\n"; -print OUT " gl_debug_cb user_callback;\n"; -print OUT " const void *user_data;\n"; -print OUT "\n"; -print OUT " GLenum source;\n"; -print OUT " GLenum type;\n"; -print OUT " GLuint id;\n"; -print OUT " GLenum severity;\n"; -print OUT " GLsizei length;\n"; -print OUT " const GLchar *message;\n"; +print OUT " UINT64 debug_callback; /* client pointer */\n"; +print OUT " UINT64 debug_user; /* client pointer */\n"; +print OUT " UINT32 source;\n"; +print OUT " UINT32 type;\n"; +print OUT " UINT32 id;\n"; +print OUT " UINT32 severity;\n"; +print OUT " UINT32 length;\n"; +print OUT " const char *message;\n"; print OUT "};\n\n";
print OUT "#define UNIX_CALL( func, params ) WINE_UNIX_CALL( unix_ ## func, params )\n\n"; diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 093dab4efb8..c7d380d894b 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -66,8 +66,8 @@ enum wgl_handle_type struct opengl_context { DWORD tid; /* thread that the context is current in */ - void (CALLBACK *debug_callback)( GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void * ); /* debug callback */ - const void *debug_user; /* debug user parameter */ + UINT64 debug_callback; /* client pointer */ + UINT64 debug_user; /* client pointer */ GLubyte *extensions; /* extension string */ GLuint *disabled_exts; /* indices of disabled extensions */ struct wgl_context *drv_ctx; /* driver context */ @@ -896,7 +896,7 @@ static BOOL wrap_wglSetPbufferAttribARB( HPBUFFERARB handle, const int *attribs }
static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GLenum severity, - GLsizei length, const GLchar *message, const void *userParam ) + GLsizei length, const GLchar *message, const void *user ) { struct wine_gl_debug_message_params params = { @@ -909,8 +909,9 @@ static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GL }; void *ret_ptr; ULONG ret_len; - struct wgl_handle *ptr = (struct wgl_handle *)userParam; + struct wgl_handle *ptr = (struct wgl_handle *)user;
+ if (!ptr->u.context->debug_callback) return; if (!NtCurrentTeb()) { fprintf( stderr, "msg:gl_debug_message_callback called from native thread, severity %#x, message "%.*s".\n", @@ -918,46 +919,46 @@ static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GL return; }
- if (!(params.user_callback = ptr->u.context->debug_callback)) return; - params.user_data = ptr->u.context->debug_user; + params.debug_callback = ptr->u.context->debug_callback; + params.debug_user = ptr->u.context->debug_user;
KeUserModeCallback( NtUserCallOpenGLDebugMessageCallback, ¶ms, sizeof(params), &ret_ptr, &ret_len ); }
-static void wrap_glDebugMessageCallback( TEB *teb, GLDEBUGPROC callback, const void *userParam ) +static void wrap_glDebugMessageCallback( TEB *teb, GLDEBUGPROC callback, const void *user ) { struct wgl_handle *ptr = get_current_context_ptr( teb ); const struct opengl_funcs *funcs = teb->glTable;
if (!funcs->ext.p_glDebugMessageCallback) return;
- ptr->u.context->debug_callback = callback; - ptr->u.context->debug_user = userParam; + ptr->u.context->debug_callback = (UINT_PTR)callback; + ptr->u.context->debug_user = (UINT_PTR)user; funcs->ext.p_glDebugMessageCallback( gl_debug_message_callback, ptr ); }
-static void wrap_glDebugMessageCallbackAMD( TEB *teb, GLDEBUGPROCAMD callback, void *userParam ) +static void wrap_glDebugMessageCallbackAMD( TEB *teb, GLDEBUGPROCAMD callback, void *user ) { struct wgl_handle *ptr = get_current_context_ptr( teb ); const struct opengl_funcs *funcs = teb->glTable;
if (!funcs->ext.p_glDebugMessageCallbackAMD) return;
- ptr->u.context->debug_callback = callback; - ptr->u.context->debug_user = userParam; + ptr->u.context->debug_callback = (UINT_PTR)callback; + ptr->u.context->debug_user = (UINT_PTR)user; funcs->ext.p_glDebugMessageCallbackAMD( gl_debug_message_callback, ptr ); }
-static void wrap_glDebugMessageCallbackARB( TEB *teb, GLDEBUGPROCARB callback, const void *userParam ) +static void wrap_glDebugMessageCallbackARB( TEB *teb, GLDEBUGPROCARB callback, const void *user ) { struct wgl_handle *ptr = get_current_context_ptr( teb ); const struct opengl_funcs *funcs = teb->glTable;
if (!funcs->ext.p_glDebugMessageCallbackARB) return;
- ptr->u.context->debug_callback = callback; - ptr->u.context->debug_user = userParam; + ptr->u.context->debug_callback = (UINT_PTR)callback; + ptr->u.context->debug_user = (UINT_PTR)user; funcs->ext.p_glDebugMessageCallbackARB( gl_debug_message_callback, ptr ); }
diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index 301038ca102..900932ff8ce 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -28377,18 +28377,16 @@ enum unix_funcs unix_wglSwapIntervalEXT, };
-typedef void (WINAPI *gl_debug_cb)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *); struct wine_gl_debug_message_params { - gl_debug_cb user_callback; - const void *user_data; - - GLenum source; - GLenum type; - GLuint id; - GLenum severity; - GLsizei length; - const GLchar *message; + UINT64 debug_callback; /* client pointer */ + UINT64 debug_user; /* client pointer */ + UINT32 source; + UINT32 type; + UINT32 id; + UINT32 severity; + UINT32 length; + const char *message; };
#define UNIX_CALL( func, params ) WINE_UNIX_CALL( unix_ ## func, params ) diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 19d989e44fc..b4daa642348 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1875,11 +1875,15 @@ GLboolean WINAPI glUnmapNamedBufferEXT( GLuint buffer ) return gl_unmap_named_buffer( unix_glUnmapNamedBufferEXT, buffer ); }
-static NTSTATUS WINAPI call_opengl_debug_message_callback( void *args, ULONG size ) +typedef void (WINAPI *gl_debug_message)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *); + +static NTSTATUS WINAPI call_gl_debug_message_callback( void *args, ULONG size ) { struct wine_gl_debug_message_params *params = args; - params->user_callback( params->source, params->type, params->id, params->severity, - params->length, params->message, params->user_data ); + gl_debug_message callback = (void *)(UINT_PTR)params->debug_callback; + const void *user = (void *)(UINT_PTR)params->debug_user; + callback( params->source, params->type, params->id, params->severity, + params->length, params->message, user ); return STATUS_SUCCESS; }
@@ -1901,7 +1905,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) }
kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - kernel_callback_table[NtUserCallOpenGLDebugMessageCallback] = call_opengl_debug_message_callback; + kernel_callback_table[NtUserCallOpenGLDebugMessageCallback] = call_gl_debug_message_callback; /* fallthrough */ case DLL_THREAD_ATTACH: if ((status = UNIX_CALL( thread_attach, NtCurrentTeb() )))
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/make_opengl | 2 +- dlls/opengl32/unix_wgl.c | 28 +++++++++++++++------------- dlls/opengl32/unixlib.h | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 7d906ae43dd..4c2b2f77167 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -1088,7 +1088,7 @@ print OUT " UINT32 type;\n"; print OUT " UINT32 id;\n"; print OUT " UINT32 severity;\n"; print OUT " UINT32 length;\n"; -print OUT " const char *message;\n"; +print OUT " char message[1];\n"; print OUT "};\n\n";
print OUT "#define UNIX_CALL( func, params ) WINE_UNIX_CALL( unix_ ## func, params )\n\n"; diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index c7d380d894b..c5c584fc848 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -898,18 +898,11 @@ static BOOL wrap_wglSetPbufferAttribARB( HPBUFFERARB handle, const int *attribs static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *user ) { - struct wine_gl_debug_message_params params = - { - .source = source, - .type = type, - .id = id, - .severity = severity, - .length = length, - .message = message, - }; + struct wine_gl_debug_message_params *params; void *ret_ptr; ULONG ret_len; struct wgl_handle *ptr = (struct wgl_handle *)user; + UINT len = strlen( message ) + 1, size;
if (!ptr->u.context->debug_callback) return; if (!NtCurrentTeb()) @@ -919,11 +912,20 @@ static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GL return; }
- params.debug_callback = ptr->u.context->debug_callback; - params.debug_user = ptr->u.context->debug_user; - - KeUserModeCallback( NtUserCallOpenGLDebugMessageCallback, ¶ms, sizeof(params), + size = offsetof(struct wine_gl_debug_message_params, message[len] ); + if (!(params = malloc( size ))) return; + params->debug_callback = ptr->u.context->debug_callback; + params->debug_user = ptr->u.context->debug_user; + params->source = source; + params->type = type; + params->id = id; + params->severity = severity; + params->length = length; + memcpy( params->message, message, len ); + + KeUserModeCallback( NtUserCallOpenGLDebugMessageCallback, params, size, &ret_ptr, &ret_len ); + free( params ); }
static void wrap_glDebugMessageCallback( TEB *teb, GLDEBUGPROC callback, const void *user ) diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index 900932ff8ce..46b081e0b18 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -28386,7 +28386,7 @@ struct wine_gl_debug_message_params UINT32 id; UINT32 severity; UINT32 length; - const char *message; + char message[1]; };
#define UNIX_CALL( func, params ) WINE_UNIX_CALL( unix_ ## func, params )