From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/make_opengl | 15 +++++++++- dlls/opengl32/unix_thunks.c | 28 ++----------------- dlls/opengl32/unix_wgl.c | 53 ++++++++++++++++++++++++++++++++++++ dlls/win32u/opengl.c | 50 ++++------------------------------ include/wine/opengl_driver.h | 1 + 5 files changed, 76 insertions(+), 71 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index fa4983384a5..5fa0f449e27 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -195,6 +195,19 @@ my %manual_win_thunks = "wglQueryRendererStringWINE" => 1, "wglSwapBuffers" => 1, ); +my %manual_unix_thunks = + ( + "glDebugMessageCallback" => 1, + "glDebugMessageCallbackAMD" => 1, + "glDebugMessageCallbackARB" => 1, + "glFinish" => 1, + "glFlush" => 1, + "glGetIntegerv" => 1, + "glGetString" => 1, + "glGetStringi" => 1, + "wglGetProcAddress" => 1, + "wglSwapBuffers" => 1, + ); my %manual_wow64_thunks = ( "glClientWaitSync" => 1, @@ -742,7 +755,7 @@ sub needs_wrapper($$) { my ($name, $func) = @_;
- return 1 if $name =~ /^glDebugMessageCallback|^glGetString|^glGetIntegerv|^wglGetProcAddress/; + return 1 if defined $manual_unix_thunks{$name};
# check if return value needs special handling (my $type = $func->[0]->textContent()) =~ s/ $//; diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 26f89bfc1eb..d79709e57e0 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -29,6 +29,9 @@ extern NTSTATUS wgl_wglDeleteContext( void *args ); extern NTSTATUS wgl_wglGetProcAddress( void *args ); extern NTSTATUS wgl_wglMakeCurrent( void *args ); extern NTSTATUS wgl_wglShareLists( void *args ); +extern NTSTATUS wgl_wglSwapBuffers( void *args ); +extern NTSTATUS gl_glFinish( void *args ); +extern NTSTATUS gl_glFlush( void *args ); extern NTSTATUS gl_glGetIntegerv( void *args ); extern NTSTATUS gl_glGetString( void *args ); extern NTSTATUS ext_glDebugMessageCallback( void *args ); @@ -64,15 +67,6 @@ static NTSTATUS wgl_wglSetPixelFormat( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS wgl_wglSwapBuffers( void *args ) -{ - struct wglSwapBuffers_params *params = args; - const struct opengl_funcs *funcs = get_dc_funcs( params->hdc ); - if (!funcs || !funcs->p_wglSwapBuffers) return STATUS_NOT_IMPLEMENTED; - params->ret = funcs->p_wglSwapBuffers( params->hdc ); - return STATUS_SUCCESS; -} - static NTSTATUS gl_glAccum( void *args ) { struct glAccum_params *params = args; @@ -785,22 +779,6 @@ static NTSTATUS gl_glFeedbackBuffer( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS gl_glFinish( void *args ) -{ - struct glFinish_params *params = args; - const struct opengl_funcs *funcs = params->teb->glTable; - funcs->p_glFinish(); - return STATUS_SUCCESS; -} - -static NTSTATUS gl_glFlush( void *args ) -{ - struct glFlush_params *params = args; - const struct opengl_funcs *funcs = params->teb->glTable; - funcs->p_glFlush(); - return STATUS_SUCCESS; -} - static NTSTATUS gl_glFogf( void *args ) { struct glFogf_params *params = args; diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index f143eb3cd07..3792e9cb11f 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -767,6 +767,59 @@ static BOOL wrap_wglDeleteContext( TEB *teb, HGLRC hglrc ) return TRUE; }
+static void flush_context( TEB *teb, struct opengl_context *context, BOOL finish ) +{ + const struct opengl_funcs *funcs = teb->glTable; + HDC hdc = teb->glReserved1[0]; + + if (!funcs->p_wgl_context_flush( hdc, context->drv_ctx, finish )) + { + /* default implementation: call the functions directly */ + if (finish) funcs->p_glFinish(); + else funcs->p_glFlush(); + } +} + +NTSTATUS gl_glFinish( void *args ) +{ + struct glFinish_params *params = args; + const struct opengl_funcs *funcs = params->teb->glTable; + struct opengl_context *ctx = get_current_context( params->teb ); + + if (ctx) flush_context( params->teb, ctx, TRUE ); + else funcs->p_glFinish(); + + return STATUS_SUCCESS; +} + +NTSTATUS gl_glFlush( void *args ) +{ + struct glFlush_params *params = args; + const struct opengl_funcs *funcs = params->teb->glTable; + struct opengl_context *ctx = get_current_context( params->teb ); + + if (ctx) flush_context( params->teb, ctx, FALSE ); + else funcs->p_glFlush(); + + return STATUS_SUCCESS; +} + +NTSTATUS wgl_wglSwapBuffers( void *args ) +{ + struct wglSwapBuffers_params *params = args; + const struct opengl_funcs *funcs = get_dc_funcs( params->hdc ); + if (!funcs || !funcs->p_wglSwapBuffers) return STATUS_NOT_IMPLEMENTED; + + if (!(params->ret = funcs->p_wglSwapBuffers( params->hdc ))) + { + struct opengl_context *ctx = get_current_context( params->teb ); + /* default implementation: implicitly flush the context */ + if (ctx) flush_context( params->teb, ctx, FALSE ); + } + + return STATUS_SUCCESS; +} + static BOOL wrap_wglShareLists( HGLRC hglrcSrc, HGLRC hglrcDst ) { const struct opengl_funcs *src_funcs, *dst_funcs; diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index e29fe97f4a7..c7d185cf130 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -45,10 +45,6 @@ struct wgl_context const struct opengl_funcs *funcs; void *driver_private; int pixel_format; - - /* hooked host function pointers */ - PFN_glFinish p_glFinish; - PFN_glFlush p_glFlush; };
struct wgl_pbuffer @@ -74,9 +70,6 @@ static struct egl_platform display_egl; static struct opengl_funcs display_funcs; static struct opengl_funcs memory_funcs;
-static PFN_glFinish p_memory_glFinish, p_display_glFinish; -static PFN_glFlush p_memory_glFlush, p_display_glFlush; - static const struct opengl_funcs *get_dc_funcs( HDC hdc, const struct opengl_funcs *null_funcs );
static const struct @@ -1084,8 +1077,6 @@ static struct wgl_context *context_create( HDC hdc, struct wgl_context *shared, context->driver_funcs = driver_funcs; context->funcs = funcs; context->pixel_format = format; - context->p_glFinish = funcs == &display_funcs ? p_display_glFinish : p_memory_glFinish; - context->p_glFlush = funcs == &display_funcs ? p_display_glFlush : p_memory_glFlush;
if (!driver_funcs->p_context_create( hdc, format, shared_private, attribs, &context->driver_private )) { @@ -1612,9 +1603,8 @@ static int get_window_swap_interval( HWND hwnd ) return interval; }
-static void wgl_context_flush( struct wgl_context *context, BOOL finish ) +static BOOL win32u_wgl_context_flush( HDC hdc, struct wgl_context *context, BOOL finish ) { - HDC hdc = NtCurrentTeb()->glReserved1[0]; int interval; HWND hwnd;
@@ -1623,12 +1613,7 @@ static void wgl_context_flush( struct wgl_context *context, BOOL finish )
TRACE( "context %p, hwnd %p, hdc %p, interval %d, finish %u\n", context, hwnd, hdc, interval, finish );
- if (!context->driver_funcs->p_context_flush( context->driver_private, hwnd, hdc, interval, finish )) - { - /* default implementation: call the hooked functions */ - if (finish) context->p_glFinish(); - else context->p_glFlush(); - } + return context->driver_funcs->p_context_flush( context->driver_private, hwnd, hdc, interval, finish ); }
static BOOL win32u_wglSwapBuffers( HDC hdc ) @@ -1649,14 +1634,7 @@ static BOOL win32u_wglSwapBuffers( HDC hdc ) if (!(hwnd = NtUserWindowFromDC( hdc ))) interval = 0; else interval = get_window_swap_interval( hwnd );
- if (!driver_funcs->p_swap_buffers( context ? context->driver_private : NULL, hwnd, hdc, interval )) - { - /* default implementation: implicitly flush the context */ - if (context) wgl_context_flush( context, FALSE ); - return FALSE; - } - - return TRUE; + return driver_funcs->p_swap_buffers( context ? context->driver_private : NULL, hwnd, hdc, interval ); }
static BOOL win32u_wglSwapIntervalEXT( int interval ) @@ -1705,18 +1683,6 @@ static int win32u_wglGetSwapIntervalEXT(void) return interval; }
-static void win32u_glFlush(void) -{ - struct wgl_context *context = NtCurrentTeb()->glContext; - if (context) wgl_context_flush( context, FALSE ); -} - -static void win32u_glFinish(void) -{ - struct wgl_context *context = NtCurrentTeb()->glContext; - if (context) wgl_context_flush( context, TRUE ); -} - static void init_opengl_funcs( struct opengl_funcs *funcs, const struct opengl_driver_funcs *driver_funcs ) { #define USE_GL_FUNC(func) \ @@ -1749,10 +1715,7 @@ static void memory_funcs_init(void) memory_funcs.p_wglMakeCurrent = win32u_wglMakeCurrent;
memory_funcs.p_wglSwapBuffers = win32u_wglSwapBuffers; - p_memory_glFinish = memory_funcs.p_glFinish; - memory_funcs.p_glFinish = win32u_glFinish; - p_memory_glFlush = memory_funcs.p_glFlush; - memory_funcs.p_glFlush = win32u_glFlush; + memory_funcs.p_wgl_context_flush = win32u_wgl_context_flush; }
static void display_funcs_init(void) @@ -1782,10 +1745,7 @@ static void display_funcs_init(void) display_funcs.p_wglMakeCurrent = win32u_wglMakeCurrent;
display_funcs.p_wglSwapBuffers = win32u_wglSwapBuffers; - p_display_glFinish = display_funcs.p_glFinish; - display_funcs.p_glFinish = win32u_glFinish; - p_display_glFlush = display_funcs.p_glFlush; - display_funcs.p_glFlush = win32u_glFlush; + display_funcs.p_wgl_context_flush = win32u_wgl_context_flush;
if (display_egl.has_EGL_EXT_pixel_format_float) { diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 2de585d8ce5..697b08fc99d 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -78,6 +78,7 @@ struct opengl_funcs BOOL (*p_wglSetPixelFormat)( HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR *ppfd ); BOOL (*p_wglShareLists)( struct wgl_context * hrcSrvShare, struct wgl_context * hrcSrvSource ); BOOL (*p_wglSwapBuffers)( HDC hdc ); + BOOL (*p_wgl_context_flush)( HDC hdc, struct wgl_context *context, BOOL finish ); void (*p_get_pixel_formats)( struct wgl_pixel_format *formats, UINT max_formats, UINT *num_formats, UINT *num_onscreen_formats ); void * (*p_wglAllocateMemoryNV)( GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority ); BOOL (*p_wglBindTexImageARB)( struct wgl_pbuffer * hPbuffer, int iBuffer );