From: Jacek Caban jacek@codeweavers.com
--- dlls/opengl32/make_opengl | 11 ++++++---- dlls/opengl32/unix_thunks.c | 36 +++++++++++++++++++++++++++++-- dlls/opengl32/unix_thunks.h | 6 ++---- dlls/opengl32/unix_wgl.c | 42 +++++++++++++------------------------ dlls/opengl32/unixlib.h | 6 ++++++ dlls/opengl32/wgl.c | 12 +++++------ 6 files changed, 70 insertions(+), 43 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index ddd1eea2652..a839ec4a70f 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, - "glMapBuffer" => 1, - "glMapBufferARB" => 1, "glMapBufferRange" => 1, "glMapNamedBuffer" => 1, "glMapNamedBufferEXT" => 1, @@ -238,6 +236,8 @@ my %manual_wow64_wrappers = "glFenceSync" => 0, "glGetSynciv" => 0, "glIsSync" => 0, + "glMapBuffer" => 1, + "glMapBufferARB" => 1, "glUnmapBuffer" => 1, "glUnmapBufferARB" => 1, "glUnmapNamedBuffer" => 1, @@ -451,7 +451,7 @@ sub generate_unix_thunk($$$$) } elsif ($ptype eq "PTR32") { - $ret_expr .= "(UINT_PTR)"; + $ret_expr .= "(UINT_PTR)" unless $ret_type =~ /*/; $need_manual_thunk = 1 if $ret_type =~ /(GLsync|PROC|GLintptr|*)/; } } @@ -543,8 +543,11 @@ sub generate_unix_thunk($$$$) sub generate_wrapper_declaration($$$) { my ($name, $func, $is_wow64) = @_; - my $ret = "extern " . get_func_ret( $func, 0 ); my $decl_args = get_func_args( $func, 0 ); + my $ret_type = get_func_ret( $func, 0 ); + my $ret = "extern "; + $ret_type = "PTR32" if $is_wow64 && $ret_type =~ /*/; + $ret .= $ret_type; $ret .= $is_wow64 ? " wow64_" : " wrap_"; $ret .= "$name( TEB *teb,"; foreach my $arg (@{$func->[1]}) diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index f670e8905da..3e75d59e856 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -13051,7 +13051,7 @@ static NTSTATUS ext_glMap2xOES( void *args ) return STATUS_SUCCESS; }
-NTSTATUS ext_glMapBuffer( void *args ) +static NTSTATUS ext_glMapBuffer( void *args ) { struct glMapBuffer_params *params = args; const struct opengl_funcs *funcs = params->teb->glTable; @@ -13060,7 +13060,7 @@ NTSTATUS ext_glMapBuffer( void *args ) return STATUS_SUCCESS; }
-NTSTATUS ext_glMapBufferARB( void *args ) +static NTSTATUS ext_glMapBufferARB( void *args ) { struct glMapBufferARB_params *params = args; const struct opengl_funcs *funcs = params->teb->glTable; @@ -53690,6 +53690,38 @@ static NTSTATUS wow64_ext_glMap2xOES( void *args ) return STATUS_SUCCESS; }
+static NTSTATUS wow64_ext_glMapBuffer( void *args ) +{ + struct + { + PTR32 teb; + GLenum target; + GLenum access; + PTR32 ret; + PTR32 client_ptr; + } *params = args; + TEB *teb = get_teb64( params->teb ); + params->ret = wow64_glMapBuffer( teb, params->target, params->access, ¶ms->client_ptr ); + set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + return STATUS_SUCCESS; +} + +static NTSTATUS wow64_ext_glMapBufferARB( void *args ) +{ + struct + { + PTR32 teb; + GLenum target; + GLenum access; + PTR32 ret; + PTR32 client_ptr; + } *params = args; + TEB *teb = get_teb64( params->teb ); + params->ret = wow64_glMapBufferARB( teb, params->target, params->access, ¶ms->client_ptr ); + set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + return STATUS_SUCCESS; +} + static NTSTATUS wow64_ext_glMapControlPointsNV( void *args ) { struct diff --git a/dlls/opengl32/unix_thunks.h b/dlls/opengl32/unix_thunks.h index 8305ffaaae3..c587d0dd52e 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -37,6 +37,8 @@ extern void wow64_glDeleteSync( TEB *teb, GLsync sync ); extern GLsync wow64_glFenceSync( TEB *teb, GLenum condition, GLbitfield flags ); extern void wow64_glGetSynciv( TEB *teb, GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values ); 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 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 ); @@ -54,10 +56,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_glMapBuffer( void *args ); -extern NTSTATUS wow64_ext_glMapBuffer( void *args ); -extern NTSTATUS ext_glMapBufferARB( void *args ); -extern NTSTATUS wow64_ext_glMapBufferARB( void *args ); extern NTSTATUS ext_glMapBufferRange( void *args ); extern NTSTATUS wow64_ext_glMapBufferRange( void *args ); extern NTSTATUS ext_glMapNamedBuffer( void *args ); diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index c1cc0081460..7bd90498450 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1798,43 +1798,31 @@ NTSTATUS wow64_ext_glGetNamedBufferPointervEXT( void *args ) return wow64_gl_get_named_buffer_pointer_v( args, ext_glGetNamedBufferPointervEXT ); }
-static NTSTATUS wow64_gl_map_buffer( void *args, NTSTATUS (*gl_map_buffer64)(void *) ) +static PTR32 wow64_gl_map_buffer( TEB *teb, GLenum target, GLenum access, PTR32 *client_ptr, + PFN_glMapBuffer gl_map_buffer64 ) { - struct - { - PTR32 teb; - GLenum target; - GLenum access; - PTR32 ret; - } *params32 = args; - struct glMapBuffer_params params = - { - .teb = get_teb64(params32->teb), - .target = params32->target, - .access = params32->access, - }; NTSTATUS status; + void *ptr;
- /* already mapped, we're being called again with a wow64 pointer */ - if (params32->ret) params.ret = get_buffer_pointer( params.teb, params.target ); - else if ((status = gl_map_buffer64( ¶ms ))) return status; - - status = wow64_map_buffer( params.teb, 0, params.target, params.ret, 0, - map_range_flags_from_map_flags( params.access ), ¶ms32->ret ); - if (!status || status == STATUS_INVALID_ADDRESS) return status; + /* if *ret, we're being called again with a wow64 pointer */ + ptr = *client_ptr ? get_buffer_pointer( teb, target ) : gl_map_buffer64( target, access );
- unmap_buffer( params.teb, params.target ); - return status; + status = wow64_map_buffer( teb, 0, target, ptr, 0, map_range_flags_from_map_flags( access ), client_ptr ); + if (!status) return *client_ptr; + if (status != STATUS_INVALID_ADDRESS) unmap_buffer( teb, target ); + return 0; }
-NTSTATUS wow64_ext_glMapBuffer( void *args ) +PTR32 wow64_glMapBuffer( TEB *teb, GLenum target, GLenum access, PTR32 *client_ptr ) { - return wow64_gl_map_buffer( args, ext_glMapBuffer ); + const struct opengl_funcs *funcs = teb->glTable; + return wow64_gl_map_buffer( teb, target, access, client_ptr, funcs->p_glMapBuffer ); }
-NTSTATUS wow64_ext_glMapBufferARB( void *args ) +PTR32 wow64_glMapBufferARB( TEB *teb, GLenum target, GLenum access, PTR32 *client_ptr ) { - return wow64_gl_map_buffer( args, ext_glMapBufferARB ); + const struct opengl_funcs *funcs = teb->glTable; + return wow64_gl_map_buffer( teb, target, access, client_ptr, funcs->p_glMapBufferARB ); }
NTSTATUS wow64_ext_glMapBufferRange( void *args ) diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index 86ed177fded..948364b787f 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -12379,6 +12379,9 @@ struct glMapBuffer_params GLenum target; GLenum access; void *ret; +#ifndef _WIN64 + void *client_ptr; +#endif };
struct glMapBufferARB_params @@ -12387,6 +12390,9 @@ struct glMapBufferARB_params GLenum target; GLenum access; void *ret; +#ifndef _WIN64 + void *client_ptr; +#endif };
struct glMapBufferRange_params diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 3d8e7e4e024..ca61caf1cc5 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1689,17 +1689,17 @@ static void *gl_map_buffer( enum unix_funcs code, GLenum target, GLenum access )
TRACE( "target %d, access %d\n", target, 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( "glMapBuffer returned %#lx\n", status ); + if (status) WARN( "glMapBuffer returned %#lx\n", status ); return args.ret; }