From: Jacek Caban jacek@codeweavers.com
--- dlls/opengl32/make_opengl | 4 ++-- dlls/opengl32/unix_thunks.c | 40 +++++++++++++++++++++++++++++++-- dlls/opengl32/unix_thunks.h | 6 ++--- dlls/opengl32/unix_wgl.c | 44 +++++++++++++------------------------ dlls/opengl32/unixlib.h | 6 +++++ dlls/opengl32/wgl.c | 12 +++++----- 6 files changed, 69 insertions(+), 43 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 4109fa1102f..25c9f27d4db 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, - "glMapNamedBufferRange" => 1, - "glMapNamedBufferRangeEXT" => 1, "glPathGlyphIndexRangeNV" => 1, "wglCreatePbufferARB" => 1, "wglGetPbufferDCARB" => 1, @@ -238,6 +236,8 @@ my %manual_wow64_wrappers = "glMapBufferRange" => 1, "glMapNamedBuffer" => 1, "glMapNamedBufferEXT" => 1, + "glMapNamedBufferRange" => 1, + "glMapNamedBufferRangeEXT" => 1, "glUnmapBuffer" => 1, "glUnmapBufferARB" => 1, "glUnmapNamedBuffer" => 1, diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 69fa7add2af..c394f36bec3 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -13123,7 +13123,7 @@ static NTSTATUS ext_glMapNamedBufferEXT( void *args ) return STATUS_SUCCESS; }
-NTSTATUS ext_glMapNamedBufferRange( void *args ) +static NTSTATUS ext_glMapNamedBufferRange( void *args ) { struct glMapNamedBufferRange_params *params = args; const struct opengl_funcs *funcs = params->teb->glTable; @@ -13132,7 +13132,7 @@ NTSTATUS ext_glMapNamedBufferRange( void *args ) return STATUS_SUCCESS; }
-NTSTATUS ext_glMapNamedBufferRangeEXT( void *args ) +static NTSTATUS ext_glMapNamedBufferRangeEXT( void *args ) { struct glMapNamedBufferRangeEXT_params *params = args; const struct opengl_funcs *funcs = params->teb->glTable; @@ -53828,6 +53828,42 @@ static NTSTATUS wow64_ext_glMapNamedBufferEXT( void *args ) return STATUS_SUCCESS; }
+static NTSTATUS wow64_ext_glMapNamedBufferRange( void *args ) +{ + struct + { + PTR32 teb; + GLuint buffer; + PTR32 offset; + PTR32 length; + GLbitfield access; + PTR32 ret; + PTR32 client_ptr; + } *params = args; + TEB *teb = get_teb64( params->teb ); + params->ret = wow64_glMapNamedBufferRange( teb, params->buffer, (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_glMapNamedBufferRangeEXT( void *args ) +{ + struct + { + PTR32 teb; + GLuint buffer; + PTR32 offset; + PTR32 length; + GLbitfield access; + PTR32 ret; + PTR32 client_ptr; + } *params = args; + TEB *teb = get_teb64( params->teb ); + params->ret = wow64_glMapNamedBufferRangeEXT( teb, params->buffer, (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_glMapObjectBufferATI( void *args ) { struct diff --git a/dlls/opengl32/unix_thunks.h b/dlls/opengl32/unix_thunks.h index f3d6d37bd33..4b97e1d56ed 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -42,6 +42,8 @@ extern PTR32 wow64_glMapBufferARB( TEB *teb, GLenum target, GLenum access, PTR32 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 PTR32 wow64_glMapNamedBufferRange( TEB *teb, GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access, PTR32 *client_ptr ); +extern PTR32 wow64_glMapNamedBufferRangeEXT( TEB *teb, GLuint buffer, 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 ); @@ -59,10 +61,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_glMapNamedBufferRange( void *args ); -extern NTSTATUS wow64_ext_glMapNamedBufferRange( void *args ); -extern NTSTATUS ext_glMapNamedBufferRangeEXT( void *args ); -extern NTSTATUS wow64_ext_glMapNamedBufferRangeEXT( void *args ); extern NTSTATUS ext_glPathGlyphIndexRangeNV( void *args ); extern NTSTATUS wow64_ext_glPathGlyphIndexRangeNV( void *args ); extern NTSTATUS ext_wglCreatePbufferARB( void *args ); diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 50b21568a3e..1dd29481500 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1869,46 +1869,32 @@ PTR32 wow64_glMapNamedBufferEXT( TEB *teb, GLuint buffer, GLenum access, PTR32 * 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 *) ) +static NTSTATUS wow64_gl_map_named_buffer_range( TEB *teb, GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access, + PTR32 *client_ptr, PFN_glMapNamedBufferRange gl_map_named_buffer_range64 ) { - struct - { - PTR32 teb; - GLuint buffer; - PTR32 offset; - PTR32 length; - GLbitfield access; - PTR32 ret; - } *params32 = args; - struct glMapNamedBufferRange_params params = - { - .teb = get_teb64(params32->teb), - .buffer = params32->buffer, - .offset = (GLintptr)ULongToPtr(params32->offset), - .length = (GLsizeiptr)ULongToPtr(params32->length), - .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_buffer_range64( ¶ms ))) return status; - - status = wow64_map_buffer( params.teb, params.buffer, 0, params.ret, params.length, params.access, ¶ms32->ret ); - if (!status || status == STATUS_INVALID_ADDRESS) return status; + if (*client_ptr) ptr = get_named_buffer_pointer( teb, buffer ); + else ptr = gl_map_named_buffer_range64( buffer, offset, length, access );
- unmap_named_buffer( params.teb, params.buffer ); - return status; + status = wow64_map_buffer( teb, buffer, 0, ptr, length, access, client_ptr ); + if (!status) return *client_ptr; + if (status != STATUS_INVALID_ADDRESS) unmap_named_buffer( teb, buffer ); + return 0; }
-NTSTATUS wow64_ext_glMapNamedBufferRange( void *args ) +PTR32 wow64_glMapNamedBufferRange( TEB *teb, GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access, PTR32 *client_ptr ) { - return wow64_gl_map_named_buffer_range( args, ext_glMapNamedBufferRange ); + const struct opengl_funcs *funcs = teb->glTable; + return wow64_gl_map_named_buffer_range( teb, buffer, offset, length, access, client_ptr, funcs->p_glMapNamedBufferRange ); }
-NTSTATUS wow64_ext_glMapNamedBufferRangeEXT( void *args ) +PTR32 wow64_glMapNamedBufferRangeEXT( TEB *teb, GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access, PTR32 *client_ptr ) { - return wow64_gl_map_named_buffer_range( args, ext_glMapNamedBufferRangeEXT ); + const struct opengl_funcs *funcs = teb->glTable; + return wow64_gl_map_named_buffer_range( teb, buffer, offset, length, access, client_ptr, funcs->p_glMapNamedBufferRangeEXT ); }
static PTR32 wow64_unmap_client_buffer( TEB *teb, GLenum target ) diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index 3322812f43e..afd349a5601 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -12470,6 +12470,9 @@ struct glMapNamedBufferRange_params GLsizeiptr length; GLbitfield access; void *ret; +#ifndef _WIN64 + void *client_ptr; +#endif };
struct glMapNamedBufferRangeEXT_params @@ -12480,6 +12483,9 @@ struct glMapNamedBufferRangeEXT_params GLsizeiptr length; GLbitfield access; void *ret; +#ifndef _WIN64 + void *client_ptr; +#endif };
struct glMapObjectBufferATI_params diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 7aa375d8aa8..ed5a12ffa98 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1791,17 +1791,17 @@ static void *gl_map_named_buffer_range( enum unix_funcs code, GLuint buffer, GLi
TRACE( "buffer %d, offset %Id, length %Id, access %d\n", buffer, offset, length, 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( length, 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( length, 16 ))) return NULL; + status = WINE_UNIX_CALL( code, &args ); + if (args.ret != args.client_ptr) _aligned_free( args.ret ); } #endif - WARN( "glMapNamedBufferRange returned %#lx\n", status ); + if (status) WARN( "glMapNamedBufferRange returned %#lx\n", status ); return args.ret; }