From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/make_opengl | 2 +- dlls/opengl32/tests/opengl.c | 10 ++++----- dlls/opengl32/unix_thunks.c | 29 ------------------------- dlls/opengl32/unix_thunks.h | 1 - dlls/opengl32/unix_wgl.c | 41 +++--------------------------------- dlls/opengl32/unixlib.h | 9 -------- dlls/opengl32/wgl.c | 21 ++++++------------ dlls/win32u/opengl.c | 7 +----- 8 files changed, 16 insertions(+), 104 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 0991d968516..195fa2972c7 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -143,6 +143,7 @@ my %manual_win_functions = "wglGetExtensionsStringEXT" => 1, "wglGetLayerPaletteEntries" => 1, "wglGetProcAddress" => 1, + "wglMakeCurrent" => 1, "wglRealizeLayerPalette" => 1, "wglSetLayerPaletteEntries" => 1, "wglSwapLayerBuffers" => 1, @@ -174,7 +175,6 @@ my %manual_win_thunks = "wglGetPixelFormatAttribfvARB" => 1, "wglGetPixelFormatAttribivARB" => 1, "wglMakeContextCurrentARB" => 1, - "wglMakeCurrent" => 1, "wglQueryCurrentRendererStringWINE" => 1, "wglQueryRendererStringWINE" => 1, "wglSwapBuffers" => 1, diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 64434c5143b..aa12a776d46 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -1446,9 +1446,8 @@ static void test_makecurrent(HDC winhdc) SetLastError( 0xdeadbeef ); ret = wglMakeCurrent( NULL, NULL ); - ok( !ret || broken(ret) /* nt4 */, "wglMakeCurrent succeeded\n" ); - if (!ret) ok( GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got error=%lx\n", GetLastError() ); + ok( !ret, "wglMakeCurrent succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got error=%lx\n", GetLastError() ); ret = wglMakeCurrent( winhdc, NULL ); ok( ret, "wglMakeCurrent failed\n" ); @@ -1463,9 +1462,8 @@ static void test_makecurrent(HDC winhdc) SetLastError( 0xdeadbeef ); ret = wglMakeCurrent( NULL, NULL ); - ok( !ret || broken(ret) /* nt4 */, "wglMakeCurrent succeeded\n" ); - if (!ret) ok( GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got error=%lx\n", GetLastError() ); + ok( !ret, "wglMakeCurrent succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got error=%lx\n", GetLastError() ); ret = wglMakeCurrent( winhdc, hglrc ); ok( ret, "wglMakeCurrent failed\n" ); diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index d9874a9803c..35c7831fb1d 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -58,13 +58,6 @@ static NTSTATUS wgl_wglGetPixelFormat( void *args ) return STATUS_SUCCESS; } -static NTSTATUS wgl_wglMakeCurrent( void *args ) -{ - struct wglMakeCurrent_params *params = args; - params->ret = wrap_wglMakeCurrent( params->teb, params->hDc, params->newContext ); - return STATUS_SUCCESS; -} - static NTSTATUS wgl_wglSetPixelFormat( void *args ) { struct wglSetPixelFormat_params *params = args; @@ -30580,7 +30573,6 @@ const unixlib_entry_t __wine_unix_call_funcs[] = wgl_wglCreateContext, wgl_wglDeleteContext, wgl_wglGetPixelFormat, - wgl_wglMakeCurrent, wgl_wglSetPixelFormat, wgl_wglShareLists, wgl_wglSwapBuffers, @@ -33746,20 +33738,6 @@ static NTSTATUS wow64_wgl_wglGetPixelFormat( void *args ) return STATUS_SUCCESS; } -static NTSTATUS wow64_wgl_wglMakeCurrent( void *args ) -{ - struct - { - PTR32 teb; - PTR32 hDc; - PTR32 newContext; - BOOL ret; - } *params = args; - TEB *teb = get_teb64( params->teb ); - params->ret = wrap_wglMakeCurrent( teb, ULongToPtr(params->hDc), ULongToPtr(params->newContext) ); - return STATUS_SUCCESS; -} - static NTSTATUS wow64_wgl_wglSetPixelFormat( void *args ) { struct @@ -87004,7 +86982,6 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] = wow64_wgl_wglCreateContext, wow64_wgl_wglDeleteContext, wow64_wgl_wglGetPixelFormat, - wow64_wgl_wglMakeCurrent, wow64_wgl_wglSetPixelFormat, wow64_wgl_wglShareLists, wow64_wgl_wglSwapBuffers, @@ -90126,11 +90103,6 @@ static int null_wglGetPixelFormat( HDC hdc ) RtlSetLastWin32Error( ERROR_INVALID_PIXEL_FORMAT ); return 0; } -static BOOL null_wglMakeCurrent( HDC hDc, HGLRC newContext ) -{ - WARN( "unsupported\n" ); - return 0; -} static BOOL null_wglSetPixelFormat( HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR *ppfd ) { WARN( "unsupported\n" ); @@ -91505,7 +91477,6 @@ struct opengl_funcs null_opengl_funcs = .p_wglCreateContext = null_wglCreateContext, .p_wglDeleteContext = null_wglDeleteContext, .p_wglGetPixelFormat = null_wglGetPixelFormat, - .p_wglMakeCurrent = null_wglMakeCurrent, .p_wglSetPixelFormat = null_wglSetPixelFormat, .p_wglShareLists = null_wglShareLists, .p_wglSwapBuffers = null_wglSwapBuffers, diff --git a/dlls/opengl32/unix_thunks.h b/dlls/opengl32/unix_thunks.h index 02cf89eedbf..700f857fa29 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -5,7 +5,6 @@ typedef ULONG PTR32; extern BOOL wrap_wglCopyContext( TEB *teb, HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ); extern HGLRC wrap_wglCreateContext( TEB *teb, HDC hDc, HGLRC handle ); extern BOOL wrap_wglDeleteContext( TEB *teb, HGLRC oldContext ); -extern BOOL wrap_wglMakeCurrent( TEB *teb, HDC hDc, HGLRC newContext ); extern BOOL wrap_wglShareLists( TEB *teb, HGLRC hrcSrvShare, HGLRC hrcSrvSource ); extern BOOL wrap_wglSwapBuffers( TEB *teb, HDC hdc ); extern void wrap_glClear( TEB *teb, GLbitfield mask, PFN_glClear func ); diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index e5386290538..6db14e54418 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -316,7 +316,7 @@ static BOOL copy_context_attributes( TEB *teb, HGLRC client_dst, struct context return FALSE; } - funcs->p_wglMakeCurrent( hdc, client_dst ); + funcs->p_wglMakeContextCurrentARB( hdc, hdc, client_dst ); if (mask & GL_COLOR_BUFFER_BIT) { @@ -369,8 +369,7 @@ static BOOL copy_context_attributes( TEB *teb, HGLRC client_dst, struct context } dst->used |= (src->used & mask); - if (!old_ctx) funcs->p_wglMakeCurrent( NULL, NULL ); - else if (!old_funcs->p_wglMakeContextCurrentARB) old_funcs->p_wglMakeCurrent( draw_hdc, old_ctx->client ); + if (!old_ctx) funcs->p_wglMakeContextCurrentARB( NULL, NULL, NULL ); else old_funcs->p_wglMakeContextCurrentARB( draw_hdc, read_hdc, old_ctx->client ); NtUserReleaseDC( hwnd, hdc ); @@ -1143,40 +1142,6 @@ static void make_context_current( TEB *teb, const struct opengl_funcs *funcs, HD if (TRACE_ON(opengl)) for (i = 0; i < count; i++) TRACE( "++ %s\n", all_extensions[client->extension_array[i]].name ); } -BOOL wrap_wglMakeCurrent( TEB *teb, HDC hdc, HGLRC client_context ) -{ - DWORD tid = HandleToULong(teb->ClientId.UniqueThread); - struct context *ctx, *prev = get_current_context( teb, NULL, NULL ); - - if (client_context) - { - const struct opengl_funcs *funcs = get_context_funcs( client_context ); - if (!(ctx = get_updated_context( teb, client_context ))) return FALSE; - if (ctx->tid && ctx->tid != tid) - { - RtlSetLastWin32Error( ERROR_BUSY ); - return FALSE; - } - - if (!funcs->p_wglMakeCurrent( hdc, client_context )) return FALSE; - if (prev) prev->tid = 0; - make_context_current( teb, funcs, hdc, hdc, client_context, ctx ); - } - else if (prev) - { - const struct opengl_funcs *funcs = teb->glTable; - if (!funcs->p_wglMakeCurrent( 0, NULL )) return FALSE; - prev->tid = 0; - teb->glTable = &null_opengl_funcs; - } - else if (!hdc) - { - RtlSetLastWin32Error( ERROR_INVALID_HANDLE ); - return FALSE; - } - return TRUE; -} - static void free_context( struct context *ctx ) { free( ctx->wow64_version ); @@ -1428,7 +1393,7 @@ BOOL wrap_wglMakeContextCurrentARB( TEB *teb, HDC draw_hdc, HDC read_hdc, HGLRC else if (prev) { const struct opengl_funcs *funcs = teb->glTable; - if (!funcs->p_wglMakeCurrent( 0, NULL )) return FALSE; + if (!funcs->p_wglMakeContextCurrentARB( NULL, NULL, NULL )) return FALSE; prev->tid = 0; teb->glTable = &null_opengl_funcs; } diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index 226caf331d5..b52bafa9e04 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -51,14 +51,6 @@ struct wglGetPixelFormat_params int ret; }; -struct wglMakeCurrent_params -{ - TEB *teb; - HDC hDc; - HGLRC newContext; - BOOL ret; -}; - struct wglSetPixelFormat_params { TEB *teb; @@ -25874,7 +25866,6 @@ enum unix_funcs unix_wglCreateContext, unix_wglDeleteContext, unix_wglGetPixelFormat, - unix_wglMakeCurrent, unix_wglSetPixelFormat, unix_wglShareLists, unix_wglSwapBuffers, diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 6c3383d72da..7fd3db66fd5 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -407,20 +407,13 @@ BOOL WINAPI wglDeleteContext( HGLRC handle ) BOOL WINAPI wglMakeCurrent( HDC hdc, HGLRC handle ) { - TEB *teb = NtCurrentTeb(); - struct wglMakeCurrent_params args = { .teb = teb, .hDc = hdc }; - NTSTATUS status; - - TRACE( "hdc %p, newContext %p\n", hdc, handle ); - - if (!get_context_from_handle( handle, &args.newContext )) return FALSE; - if ((status = UNIX_CALL( wglMakeCurrent, &args ))) WARN( "wglMakeCurrent returned %#lx\n", status ); - if (status || !args.ret) return FALSE; - - teb->glCurrentRC = handle; - teb->glReserved1[0] = hdc; - teb->glReserved1[1] = hdc; - return TRUE; + TRACE( "hdc %p, handle %p\n", hdc, handle ); + if (!hdc && !handle && !NtCurrentTeb()->glCurrentRC) + { + RtlSetLastWin32Error( ERROR_INVALID_HANDLE ); + return FALSE; + } + return wglMakeContextCurrentARB( hdc, hdc, handle ); } BOOL WINAPI wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC handle ) diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 0815f4378e8..4ad0cbb4e4a 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1929,11 +1929,6 @@ static BOOL win32u_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC c return TRUE; } -static BOOL win32u_wglMakeCurrent( HDC hdc, HGLRC client_context ) -{ - return win32u_wglMakeContextCurrentARB( hdc, hdc, client_context ); -} - static void opengl_client_pbuffer_init( HPBUFFERARB client_pbuffer, struct pbuffer *pbuffer, const struct opengl_funcs *funcs ) { struct opengl_client_pbuffer *client = opengl_client_pbuffer_from_client( client_pbuffer ); @@ -2702,7 +2697,7 @@ static void display_funcs_init(void) display_funcs.p_wglDeleteContext = (void *)1; /* never called */ display_funcs.p_wglCopyContext = (void *)1; /* never called */ display_funcs.p_wglShareLists = (void *)1; /* never called */ - display_funcs.p_wglMakeCurrent = win32u_wglMakeCurrent; + display_funcs.p_wglMakeCurrent = (void *)1; /* never called */ display_funcs.p_wglSwapBuffers = win32u_wglSwapBuffers; display_funcs.p_context_flush = win32u_context_flush; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10763