From: Jacek Caban jacek@codeweavers.com
--- dlls/opengl32/make_opengl | 1 - dlls/opengl32/unix_thunks.c | 18 ++++++++++++- dlls/opengl32/unix_thunks.h | 2 -- dlls/opengl32/unix_wgl.c | 54 ++++++++++++------------------------- 4 files changed, 34 insertions(+), 41 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index ec302a51c90..bd8bbb120d4 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -248,7 +248,6 @@ my %manual_wow64_thunks = "wglGetProcAddress" => 1, "wglGetProcAddress" => 1, "wglMakeContextCurrentARB" => 1, - "wglMakeCurrent" => 1, "wglQueryCurrentRendererStringWINE" => 1, "wglQueryRendererStringWINE" => 1, ); diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index d8dab1a7874..19aa9084a7a 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -68,7 +68,7 @@ NTSTATUS wgl_wglGetProcAddress( void *args ) return STATUS_SUCCESS; }
-NTSTATUS wgl_wglMakeCurrent( void *args ) +static NTSTATUS wgl_wglMakeCurrent( void *args ) { struct wglMakeCurrent_params *params = args; pthread_mutex_lock( &wgl_lock ); @@ -29941,6 +29941,22 @@ 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 ); + pthread_mutex_lock( &wgl_lock ); + params->ret = wrap_wglMakeCurrent( teb, ULongToPtr(params->hDc), ULongToPtr(params->newContext) ); + pthread_mutex_unlock( &wgl_lock ); + return STATUS_SUCCESS; +} + static NTSTATUS wow64_wgl_wglSetPixelFormat( void *args ) { struct diff --git a/dlls/opengl32/unix_thunks.h b/dlls/opengl32/unix_thunks.h index 93573510057..4171b0ca8e3 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -38,8 +38,6 @@ extern NTSTATUS wgl_wglDeleteContext( void *args ); extern NTSTATUS wow64_wgl_wglDeleteContext( void *args ); extern NTSTATUS wgl_wglGetProcAddress( void *args ); extern NTSTATUS wow64_wgl_wglGetProcAddress( void *args ); -extern NTSTATUS wgl_wglMakeCurrent( void *args ); -extern NTSTATUS wow64_wgl_wglMakeCurrent( void *args ); extern NTSTATUS gl_glGetString( void *args ); extern NTSTATUS wow64_gl_glGetString( void *args ); extern NTSTATUS ext_glClientWaitSync( void *args ); diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 410178ac090..61643a9e0ac 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -365,6 +365,20 @@ static void free_handle_ptr( struct wgl_handle *ptr ) next_free = ptr; }
+static void update_teb32_context( TEB *teb ) +{ +#ifdef _WIN64 + TEB32 *teb32; + + if (!teb->WowTebOffset) return; + teb32 = (TEB32 *)((char *)teb + teb->WowTebOffset); + + teb32->glCurrentRC = (UINT_PTR)teb->glCurrentRC; + teb32->glReserved1[0] = (UINT_PTR)teb->glReserved1[0]; + teb32->glReserved1[1] = (UINT_PTR)teb->glReserved1[1]; +#endif +} + static int *memdup_attribs( const int *attribs ) { const int *attr; @@ -1020,21 +1034,20 @@ BOOL wrap_wglMakeCurrent( TEB *teb, HDC hdc, HGLRC hglrc ) teb->glReserved1[1] = hdc; teb->glCurrentRC = hglrc; teb->glTable = (void *)funcs; - return TRUE; } - if (prev) + else if (prev) { if (!funcs->p_wglMakeCurrent( 0, NULL )) return FALSE; prev->tid = 0; teb->glCurrentRC = 0; teb->glTable = &null_opengl_funcs; - return TRUE; } - if (!hdc) + else if (!hdc) { RtlSetLastWin32Error( ERROR_INVALID_HANDLE ); return FALSE; } + update_teb32_context( teb ); return TRUE; }
@@ -1427,18 +1440,6 @@ static PTR32 find_wow64_string( const char *str, PTR32 wow64_str ) return wow64_str; }
-static inline void update_teb32_context( TEB *teb ) -{ - void *teb32; - - if (!teb->WowTebOffset) return; - teb32 = (char *)teb + teb->WowTebOffset; - - ((TEB32 *)teb32)->glCurrentRC = (UINT_PTR)teb->glCurrentRC; - ((TEB32 *)teb32)->glReserved1[0] = (UINT_PTR)teb->glReserved1[0]; - ((TEB32 *)teb32)->glReserved1[1] = (UINT_PTR)teb->glReserved1[1]; -} - NTSTATUS wow64_wgl_wglCreateContext( void *args ) { struct @@ -1527,27 +1528,6 @@ NTSTATUS wow64_wgl_wglDeleteContext( void *args ) return status; }
-NTSTATUS wow64_wgl_wglMakeCurrent( void *args ) -{ - struct - { - PTR32 teb; - PTR32 hDc; - PTR32 newContext; - BOOL ret; - } *params32 = args; - struct wglMakeCurrent_params params = - { - .teb = get_teb64(params32->teb), - .hDc = ULongToPtr(params32->hDc), - .newContext = ULongToPtr(params32->newContext), - }; - NTSTATUS status; - if (!(status = wgl_wglMakeCurrent( ¶ms ))) update_teb32_context( params.teb ); - params32->ret = params.ret; - return status; -} - NTSTATUS wow64_ext_wglMakeContextCurrentARB( void *args ) { struct