Sebastian Lackner : opengl32: Add wrappers for glDebugMessageCallback to handle calling convention differences.
Alexandre Julliard
julliard at winehq.org
Tue Oct 9 16:22:47 CDT 2018
Module: wine
Branch: master
Commit: e07230ed4e8302efce99ce1924389c229d90adfd
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e07230ed4e8302efce99ce1924389c229d90adfd
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Fri Oct 5 04:20:30 2018 +0000
opengl32: Add wrappers for glDebugMessageCallback to handle calling convention differences.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38402
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/opengl32/make_opengl | 3 +++
dlls/opengl32/opengl_ext.c | 24 +++----------------
dlls/opengl32/tests/opengl.c | 44 ++++++++++++++++++++++++++++++++++
dlls/opengl32/wgl.c | 57 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 107 insertions(+), 21 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl
index f2c93ef..f91796e 100755
--- a/dlls/opengl32/make_opengl
+++ b/dlls/opengl32/make_opengl
@@ -416,6 +416,9 @@ sub needs_wrapper($$)
my %funcs =
(
"glDebugEntry" => 1,
+ "glDebugMessageCallback" => 1,
+ "glDebugMessageCallbackAMD" => 1,
+ "glDebugMessageCallbackARB" => 1,
"glGetIntegerv" => 1,
"glGetString" => 1,
"glGetStringi" => 1,
diff --git a/dlls/opengl32/opengl_ext.c b/dlls/opengl32/opengl_ext.c
index 0f4c130..c27af43 100644
--- a/dlls/opengl32/opengl_ext.c
+++ b/dlls/opengl32/opengl_ext.c
@@ -2327,27 +2327,6 @@ static void WINAPI glCurrentPaletteMatrixARB( GLint index )
funcs->ext.p_glCurrentPaletteMatrixARB( index );
}
-static void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam )
-{
- const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
- TRACE( "(%p, %p)\n", callback, userParam );
- funcs->ext.p_glDebugMessageCallback( callback, userParam );
-}
-
-static void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam )
-{
- const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
- TRACE( "(%p, %p)\n", callback, userParam );
- funcs->ext.p_glDebugMessageCallbackAMD( callback, userParam );
-}
-
-static void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam )
-{
- const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
- TRACE( "(%p, %p)\n", callback, userParam );
- funcs->ext.p_glDebugMessageCallbackARB( callback, userParam );
-}
-
static void WINAPI glDebugMessageControl( GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled )
{
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
@@ -18686,6 +18665,9 @@ static BOOL WINAPI wglSwapIntervalEXT( int interval )
return funcs->ext.p_wglSwapIntervalEXT( interval );
}
+extern void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) DECLSPEC_HIDDEN;
+extern void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam ) DECLSPEC_HIDDEN;
+extern void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam ) DECLSPEC_HIDDEN;
extern const GLubyte * WINAPI glGetStringi( GLenum name, GLuint index ) DECLSPEC_HIDDEN;
extern BOOL WINAPI wglBindTexImageARB( HPBUFFERARB hPbuffer, int iBuffer ) DECLSPEC_HIDDEN;
extern HGLRC WINAPI wglCreateContextAttribsARB( HDC hDC, HGLRC hShareContext, const int *attribList ) DECLSPEC_HIDDEN;
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index 8105201..65a5914 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -48,6 +48,11 @@ static HDC (WINAPI *pwglGetPbufferDCARB)(HPBUFFERARB);
static BOOL (WINAPI *pwglSwapIntervalEXT)(int interval);
static int (WINAPI *pwglGetSwapIntervalEXT)(void);
+/* GL_ARB_debug_output */
+static void (WINAPI *pglDebugMessageCallbackARB)(void *, void *);
+static void (WINAPI *pglDebugMessageControlARB)(GLenum, GLenum, GLenum, GLsizei, const GLuint *, GLboolean);
+static void (WINAPI *pglDebugMessageInsertARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const char *);
+
static const char* wgl_extensions = NULL;
static void init_functions(void)
@@ -80,6 +85,11 @@ static void init_functions(void)
GET_PROC(wglSwapIntervalEXT)
GET_PROC(wglGetSwapIntervalEXT)
+ /* GL_ARB_debug_output */
+ GET_PROC(glDebugMessageCallbackARB)
+ GET_PROC(glDebugMessageControlARB)
+ GET_PROC(glDebugMessageInsertARB)
+
#undef GET_PROC
}
@@ -305,6 +315,39 @@ static void test_choosepixelformat(void)
pfd.cAuxBuffers = 0;
}
+static void WINAPI gl_debug_message_callback(GLenum source, GLenum type, GLuint id, GLenum severity,
+ GLsizei length, const GLchar *message, const void *userParam)
+{
+ DWORD *count = (DWORD *)userParam;
+ (*count)++;
+}
+
+static void test_debug_message_callback(void)
+{
+ static const char testmsg[] = "Hello World";
+ DWORD count;
+
+ if (!pglDebugMessageCallbackARB)
+ {
+ skip("glDebugMessageCallbackARB not supported\n");
+ return;
+ }
+
+ glEnable(GL_DEBUG_OUTPUT);
+ glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
+
+ pglDebugMessageCallbackARB(gl_debug_message_callback, &count);
+ pglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
+
+ count = 0;
+ pglDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 0x42424242,
+ GL_DEBUG_SEVERITY_LOW, sizeof(testmsg), testmsg);
+ ok(count == 1, "expected count == 1, got %u\n", count);
+
+ glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
+ glDisable(GL_DEBUG_OUTPUT);
+}
+
static void test_setpixelformat(HDC winhdc)
{
int res = 0;
@@ -1786,6 +1829,7 @@ START_TEST(opengl)
}
test_choosepixelformat();
+ test_debug_message_callback();
test_setpixelformat(hdc);
test_destroy(hdc);
test_sharelists(hdc);
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 04ace8e..9241005 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -58,6 +58,9 @@ struct opengl_context
DWORD tid; /* thread that the context is current in */
HDC draw_dc; /* current drawing DC */
HDC read_dc; /* current reading DC */
+ void (CALLBACK *debug_callback)(GLenum, GLenum, GLuint, GLenum,
+ GLsizei, const GLchar *, const void *); /* debug callback */
+ const void *debug_user; /* debug user parameter */
GLubyte *extensions; /* extension string */
GLuint *disabled_exts; /* indices of disabled extensions */
struct wgl_context *drv_ctx; /* driver context */
@@ -1746,6 +1749,60 @@ const GLubyte * WINAPI glGetString( GLenum name )
return ret;
}
+/* wrapper for glDebugMessageCallback* functions */
+static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GLenum severity,
+ GLsizei length, const GLchar *message,const void *userParam )
+{
+ struct wgl_handle *ptr = (struct wgl_handle *)userParam;
+ if (!ptr->u.context->debug_callback) return;
+ ptr->u.context->debug_callback( source, type, id, severity, length, message, ptr->u.context->debug_user );
+}
+
+/***********************************************************************
+ * glDebugMessageCallback
+ */
+void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam )
+{
+ struct wgl_handle *ptr = get_current_context_ptr();
+ const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
+
+ TRACE( "(%p, %p)\n", callback, userParam );
+
+ ptr->u.context->debug_callback = callback;
+ ptr->u.context->debug_user = userParam;
+ funcs->ext.p_glDebugMessageCallback( gl_debug_message_callback, ptr );
+}
+
+/***********************************************************************
+ * glDebugMessageCallbackAMD
+ */
+void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam )
+{
+ struct wgl_handle *ptr = get_current_context_ptr();
+ const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
+
+ TRACE( "(%p, %p)\n", callback, userParam );
+
+ ptr->u.context->debug_callback = callback;
+ ptr->u.context->debug_user = userParam;
+ funcs->ext.p_glDebugMessageCallbackAMD( gl_debug_message_callback, ptr );
+}
+
+/***********************************************************************
+ * glDebugMessageCallbackARB
+ */
+void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam )
+{
+ struct wgl_handle *ptr = get_current_context_ptr();
+ const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
+
+ TRACE( "(%p, %p)\n", callback, userParam );
+
+ ptr->u.context->debug_callback = callback;
+ ptr->u.context->debug_user = userParam;
+ funcs->ext.p_glDebugMessageCallbackARB( gl_debug_message_callback, ptr );
+}
+
/***********************************************************************
* OpenGL initialisation routine
*/
More information about the wine-cvs
mailing list