From: Jacek Caban jacek@codeweavers.com
--- dlls/opengl32/make_opengl | 4 ++-- dlls/opengl32/unix_thunks.c | 36 ++++++++++++++++++++++++++++++-- dlls/opengl32/unix_thunks.h | 6 ++---- dlls/opengl32/unix_wgl.c | 41 ++++++++++++++----------------------- dlls/opengl32/unixlib.h | 6 ++++++ dlls/opengl32/wgl.c | 12 +++++------ 6 files changed, 65 insertions(+), 40 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 38af409f050..4109fa1102f 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -218,8 +218,6 @@ my %manual_wow64_thunks = "glGetBufferPointervARB" => 1, "glGetNamedBufferPointerv" => 1, "glGetNamedBufferPointervEXT" => 1, - "glMapNamedBuffer" => 1, - "glMapNamedBufferEXT" => 1, "glMapNamedBufferRange" => 1, "glMapNamedBufferRangeEXT" => 1, "glPathGlyphIndexRangeNV" => 1, @@ -238,6 +236,8 @@ my %manual_wow64_wrappers = "glMapBuffer" => 1, "glMapBufferARB" => 1, "glMapBufferRange" => 1, + "glMapNamedBuffer" => 1, + "glMapNamedBufferEXT" => 1, "glUnmapBuffer" => 1, "glUnmapBufferARB" => 1, "glUnmapNamedBuffer" => 1, diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 74c98e9984d..69fa7add2af 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -13105,7 +13105,7 @@ static NTSTATUS ext_glMapGrid2xOES( void *args ) return STATUS_SUCCESS; }
-NTSTATUS ext_glMapNamedBuffer( void *args ) +static NTSTATUS ext_glMapNamedBuffer( void *args ) { struct glMapNamedBuffer_params *params = args; const struct opengl_funcs *funcs = params->teb->glTable; @@ -13114,7 +13114,7 @@ NTSTATUS ext_glMapNamedBuffer( void *args ) return STATUS_SUCCESS; }
-NTSTATUS ext_glMapNamedBufferEXT( void *args ) +static NTSTATUS ext_glMapNamedBufferEXT( void *args ) { struct glMapNamedBufferEXT_params *params = args; const struct opengl_funcs *funcs = params->teb->glTable; @@ -53796,6 +53796,38 @@ static NTSTATUS wow64_ext_glMapGrid2xOES( void *args ) return STATUS_SUCCESS; }
+static NTSTATUS wow64_ext_glMapNamedBuffer( void *args ) +{ + struct + { + PTR32 teb; + GLuint buffer; + GLenum access; + PTR32 ret; + PTR32 client_ptr; + } *params = args; + TEB *teb = get_teb64( params->teb ); + params->ret = wow64_glMapNamedBuffer( teb, params->buffer, params->access, ¶ms->client_ptr ); + set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + return STATUS_SUCCESS; +} + +static NTSTATUS wow64_ext_glMapNamedBufferEXT( void *args ) +{ + struct + { + PTR32 teb; + GLuint buffer; + GLenum access; + PTR32 ret; + PTR32 client_ptr; + } *params = args; + TEB *teb = get_teb64( params->teb ); + params->ret = wow64_glMapNamedBufferEXT( teb, params->buffer, params->access, ¶ms->client_ptr ); + set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + return STATUS_SUCCESS; +} + static NTSTATUS wow64_ext_glMapObjectBufferATI( void *args ) { struct diff --git a/dlls/opengl32/unix_thunks.h b/dlls/opengl32/unix_thunks.h index f81d7cf3853..f3d6d37bd33 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -40,6 +40,8 @@ extern GLboolean wow64_glIsSync( TEB *teb, GLsync sync ); extern PTR32 wow64_glMapBuffer( TEB *teb, GLenum target, GLenum access, PTR32 *client_ptr ); extern PTR32 wow64_glMapBufferARB( TEB *teb, GLenum target, GLenum access, PTR32 *client_ptr ); extern PTR32 wow64_glMapBufferRange( TEB *teb, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, PTR32 *client_ptr ); +extern PTR32 wow64_glMapNamedBuffer( TEB *teb, GLuint buffer, GLenum access, PTR32 *client_ptr ); +extern PTR32 wow64_glMapNamedBufferEXT( TEB *teb, GLuint buffer, GLenum access, PTR32 *client_ptr ); extern GLboolean wow64_glUnmapBuffer( TEB *teb, GLenum target, PTR32 *client_ptr ); extern GLboolean wow64_glUnmapBufferARB( TEB *teb, GLenum target, PTR32 *client_ptr ); extern GLboolean wow64_glUnmapNamedBuffer( TEB *teb, GLuint buffer, PTR32 *client_ptr ); @@ -57,10 +59,6 @@ extern NTSTATUS ext_glGetNamedBufferPointerv( void *args ); extern NTSTATUS wow64_ext_glGetNamedBufferPointerv( void *args ); extern NTSTATUS ext_glGetNamedBufferPointervEXT( void *args ); extern NTSTATUS wow64_ext_glGetNamedBufferPointervEXT( void *args ); -extern NTSTATUS ext_glMapNamedBuffer( void *args ); -extern NTSTATUS wow64_ext_glMapNamedBuffer( void *args ); -extern NTSTATUS ext_glMapNamedBufferEXT( void *args ); -extern NTSTATUS wow64_ext_glMapNamedBufferEXT( void *args ); extern NTSTATUS ext_glMapNamedBufferRange( void *args ); extern NTSTATUS wow64_ext_glMapNamedBufferRange( void *args ); extern NTSTATUS ext_glMapNamedBufferRangeEXT( void *args ); diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index abc0592a2fa..50b21568a3e 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1841,43 +1841,32 @@ PTR32 wow64_glMapBufferRange( TEB *teb, GLenum target, GLintptr offset, GLsizeip return 0; }
-static NTSTATUS wow64_gl_map_named_buffer( void *args, NTSTATUS (*gl_map_named_buffer64)(void *) ) +static PTR32 wow64_gl_map_named_buffer( TEB *teb, GLuint buffer, GLenum access, PTR32 *client_ptr, + PFN_glMapNamedBuffer gl_map_named_buffer64 ) { - struct - { - PTR32 teb; - GLuint buffer; - GLenum access; - PTR32 ret; - } *params32 = args; - struct glMapNamedBuffer_params params = - { - .teb = get_teb64(params32->teb), - .buffer = params32->buffer, - .access = params32->access, - }; NTSTATUS status; + void *ptr;
/* already mapped, we're being called again with a wow64 pointer */ - if (params32->ret) params.ret = get_named_buffer_pointer( params.teb, params.buffer ); - else if ((status = gl_map_named_buffer64( ¶ms ))) return status; + if (*client_ptr) ptr = get_named_buffer_pointer( teb, buffer ); + else ptr = gl_map_named_buffer64( buffer, access );
- status = wow64_map_buffer( params.teb, params.buffer, 0, params.ret, 0, - map_range_flags_from_map_flags( params.access ), ¶ms32->ret ); - if (!status || status == STATUS_INVALID_ADDRESS) return status; - - unmap_named_buffer( params.teb, params.buffer ); - return status; + status = wow64_map_buffer( teb, buffer, 0, ptr, 0, map_range_flags_from_map_flags( access ), client_ptr ); + if (!status) return *client_ptr; + if (status != STATUS_INVALID_ADDRESS) unmap_named_buffer( teb, buffer ); + return 0; }
-NTSTATUS wow64_ext_glMapNamedBuffer( void *args ) +PTR32 wow64_glMapNamedBuffer( TEB *teb, GLuint buffer, GLenum access, PTR32 *client_ptr ) { - return wow64_gl_map_named_buffer( args, ext_glMapNamedBuffer ); + const struct opengl_funcs *funcs = teb->glTable; + return wow64_gl_map_named_buffer( teb, buffer, access, client_ptr, funcs->p_glMapNamedBuffer ); }
-NTSTATUS wow64_ext_glMapNamedBufferEXT( void *args ) +PTR32 wow64_glMapNamedBufferEXT( TEB *teb, GLuint buffer, GLenum access, PTR32 *client_ptr ) { - return wow64_gl_map_named_buffer( args, ext_glMapNamedBufferEXT ); + const struct opengl_funcs *funcs = teb->glTable; + return wow64_gl_map_named_buffer( teb, buffer, access, client_ptr, funcs->p_glMapNamedBufferEXT ); }
static NTSTATUS wow64_gl_map_named_buffer_range( void *args, NTSTATUS (*gl_map_named_buffer_range64)(void *) ) diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index e673b7b8e7d..3322812f43e 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -12446,6 +12446,9 @@ struct glMapNamedBuffer_params GLuint buffer; GLenum access; void *ret; +#ifndef _WIN64 + void *client_ptr; +#endif };
struct glMapNamedBufferEXT_params @@ -12454,6 +12457,9 @@ struct glMapNamedBufferEXT_params GLuint buffer; GLenum access; void *ret; +#ifndef _WIN64 + void *client_ptr; +#endif };
struct glMapNamedBufferRange_params diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index d438966f898..7aa375d8aa8 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1753,17 +1753,17 @@ static void *gl_map_named_buffer( enum unix_funcs code, GLuint buffer, GLenum ac
TRACE( "(%d, %d)\n", buffer, access );
- if (!(status = WINE_UNIX_CALL( code, &args ))) return args.ret; + status = WINE_UNIX_CALL( code, &args ); #ifndef _WIN64 - if (status == STATUS_INVALID_ADDRESS) + if (args.client_ptr) { TRACE( "Unable to map wow64 buffer directly, using copy buffer!\n" ); - if (!(args.ret = _aligned_malloc( (size_t)args.ret, 16 ))) status = STATUS_NO_MEMORY; - else if (!(status = WINE_UNIX_CALL( code, &args ))) return args.ret; - _aligned_free( args.ret ); + if (!(args.client_ptr = _aligned_malloc( (size_t)args.client_ptr, 16 ))) return NULL;; + status = WINE_UNIX_CALL( code, &args ); + if (args.ret != args.client_ptr) _aligned_free( args.client_ptr ); } #endif - WARN( "glMapNamedBuffer returned %#lx\n", status ); + if (status) WARN( "glMapNamedBuffer returned %#lx\n", status ); return args.ret; }