From: Jacek Caban jacek@codeweavers.com
--- dlls/opengl32/make_opengl | 2 +- dlls/opengl32/unix_thunks.c | 20 +++++++++++++++++++- dlls/opengl32/unix_thunks.h | 3 +-- dlls/opengl32/unix_wgl.c | 34 +++++++++------------------------- dlls/opengl32/unixlib.h | 3 +++ dlls/opengl32/wgl.c | 12 ++++++------ 6 files changed, 39 insertions(+), 35 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index a839ec4a70f..38af409f050 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -218,7 +218,6 @@ my %manual_wow64_thunks = "glGetBufferPointervARB" => 1, "glGetNamedBufferPointerv" => 1, "glGetNamedBufferPointervEXT" => 1, - "glMapBufferRange" => 1, "glMapNamedBuffer" => 1, "glMapNamedBufferEXT" => 1, "glMapNamedBufferRange" => 1, @@ -238,6 +237,7 @@ my %manual_wow64_wrappers = "glIsSync" => 0, "glMapBuffer" => 1, "glMapBufferARB" => 1, + "glMapBufferRange" => 1, "glUnmapBuffer" => 1, "glUnmapBufferARB" => 1, "glUnmapNamedBuffer" => 1, diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 3e75d59e856..74c98e9984d 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -13069,7 +13069,7 @@ static NTSTATUS ext_glMapBufferARB( void *args ) return STATUS_SUCCESS; }
-NTSTATUS ext_glMapBufferRange( void *args ) +static NTSTATUS ext_glMapBufferRange( void *args ) { struct glMapBufferRange_params *params = args; const struct opengl_funcs *funcs = params->teb->glTable; @@ -53722,6 +53722,24 @@ static NTSTATUS wow64_ext_glMapBufferARB( void *args ) return STATUS_SUCCESS; }
+static NTSTATUS wow64_ext_glMapBufferRange( void *args ) +{ + struct + { + PTR32 teb; + GLenum target; + PTR32 offset; + PTR32 length; + GLbitfield access; + PTR32 ret; + PTR32 client_ptr; + } *params = args; + TEB *teb = get_teb64( params->teb ); + params->ret = wow64_glMapBufferRange( teb, params->target, (GLintptr)ULongToPtr(params->offset), (GLsizeiptr)ULongToPtr(params->length), 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 c587d0dd52e..f81d7cf3853 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -39,6 +39,7 @@ extern void wow64_glGetSynciv( TEB *teb, GLsync sync, GLenum pname, GLsizei coun 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 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 ); @@ -56,8 +57,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_glMapBufferRange( void *args ); -extern NTSTATUS wow64_ext_glMapBufferRange( void *args ); extern NTSTATUS ext_glMapNamedBuffer( void *args ); extern NTSTATUS wow64_ext_glMapNamedBuffer( void *args ); extern NTSTATUS ext_glMapNamedBufferEXT( void *args ); diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 7bd90498450..abc0592a2fa 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1825,36 +1825,20 @@ PTR32 wow64_glMapBufferARB( TEB *teb, GLenum target, GLenum access, PTR32 *clien return wow64_gl_map_buffer( teb, target, access, client_ptr, funcs->p_glMapBufferARB ); }
-NTSTATUS wow64_ext_glMapBufferRange( void *args ) +PTR32 wow64_glMapBufferRange( TEB *teb, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, PTR32 *client_ptr ) { - struct - { - PTR32 teb; - GLenum target; - PTR32 offset; - PTR32 length; - GLbitfield access; - PTR32 ret; - } *params32 = args; - struct glMapBufferRange_params params = - { - .teb = get_teb64(params32->teb), - .target = params32->target, - .offset = (GLintptr)ULongToPtr(params32->offset), - .length = (GLsizeiptr)ULongToPtr(params32->length), - .access = params32->access, - }; + const struct opengl_funcs *funcs = teb->glTable; NTSTATUS status; + void *ptr;
/* already mapped, we're being called again with a wow64 pointer */ - if (params32->ret) params.ret = (char *)get_buffer_pointer( params.teb, params.target ); - else if ((status = ext_glMapBufferRange( ¶ms ))) return status; + if (*client_ptr) ptr = (char *)get_buffer_pointer( teb, target ); + else ptr = funcs->p_glMapBufferRange( target, offset, length, access );
- status = wow64_map_buffer( params.teb, 0, params.target, params.ret, params.length, params.access, ¶ms32->ret ); - if (!status || status == STATUS_INVALID_ADDRESS) return status; - - unmap_buffer( params.teb, params.target ); - return status; + status = wow64_map_buffer( teb, 0, target, ptr, length, access, client_ptr ); + if (!status) return *client_ptr; + if (status != STATUS_INVALID_ADDRESS) unmap_buffer( teb, target ); + return 0; }
static NTSTATUS wow64_gl_map_named_buffer( void *args, NTSTATUS (*gl_map_named_buffer64)(void *) ) diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index 948364b787f..e673b7b8e7d 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -12403,6 +12403,9 @@ struct glMapBufferRange_params GLsizeiptr length; GLbitfield access; void *ret; +#ifndef _WIN64 + void *client_ptr; +#endif };
struct glMapControlPointsNV_params diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index ca61caf1cc5..d438966f898 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1727,17 +1727,17 @@ void * WINAPI glMapBufferRange( GLenum target, GLintptr offset, GLsizeiptr lengt
TRACE( "target %d, offset %Id, length %Id, access %d\n", target, offset, length, access );
- if (!(status = UNIX_CALL( glMapBufferRange, &args ))) return args.ret; + status = UNIX_CALL( glMapBufferRange, &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( length, 16 ))) status = STATUS_NO_MEMORY; - else if (!(status = UNIX_CALL( glMapBufferRange, &args ))) return args.ret; - _aligned_free( args.ret ); + if (!(args.client_ptr = _aligned_malloc( length, 16 ))) return NULL; + status = UNIX_CALL( glMapBufferRange, &args ); + if (args.ret != args.client_ptr) _aligned_free( args.client_ptr ); } #endif - WARN( "glMapBufferRange returned %#lx\n", status ); + if (status) WARN( "glMapBufferRange returned %#lx\n", status ); return args.ret; }