From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/make_opengl | 15 ++ dlls/opengl32/unix_thunks.c | 252 ++++---------------------- dlls/opengl32/unix_wgl.c | 346 ++++++++++++++++++++++++++++++++++++ dlls/opengl32/wgl.c | 97 ++++++++++ 4 files changed, 492 insertions(+), 218 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 7bfe0f219a2..43199f56981 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -189,11 +189,26 @@ my %manual_wow64_thunks = "glClientWaitSync" => 1, "glDeleteSync" => 1, "glFenceSync" => 1, + "glGetBufferPointerv" => 1, + "glGetBufferPointervARB" => 1, + "glGetNamedBufferPointerv" => 1, + "glGetNamedBufferPointervEXT" => 1, "glGetString" => 1, "glGetStringi" => 1, "glGetSynciv" => 1, "glIsSync" => 1, + "glMapBuffer" => 1, + "glMapBufferARB" => 1, + "glMapBufferRange" => 1, + "glMapNamedBuffer" => 1, + "glMapNamedBufferEXT" => 1, + "glMapNamedBufferRange" => 1, + "glMapNamedBufferRangeEXT" => 1, "glPathGlyphIndexRangeNV" => 1, + "glUnmapBuffer" => 1, + "glUnmapBufferARB" => 1, + "glUnmapNamedBuffer" => 1, + "glUnmapNamedBufferEXT" => 1, "glWaitSync" => 1, "wglCreateContext" => 1, "wglCreateContextAttribsARB" => 1, diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index ea8d7910450..1ba8fc3bf2f 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -7748,7 +7748,7 @@ static NTSTATUS ext_glGetBufferParameterui64vNV( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glGetBufferPointerv( void *args ) +NTSTATUS ext_glGetBufferPointerv( void *args ) { struct glGetBufferPointerv_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -7756,7 +7756,7 @@ static NTSTATUS ext_glGetBufferPointerv( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glGetBufferPointervARB( void *args ) +NTSTATUS ext_glGetBufferPointervARB( void *args ) { struct glGetBufferPointervARB_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -8796,7 +8796,7 @@ static NTSTATUS ext_glGetNamedBufferParameterui64vNV( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glGetNamedBufferPointerv( void *args ) +NTSTATUS ext_glGetNamedBufferPointerv( void *args ) { struct glGetNamedBufferPointerv_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -8804,7 +8804,7 @@ static NTSTATUS ext_glGetNamedBufferPointerv( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glGetNamedBufferPointervEXT( void *args ) +NTSTATUS ext_glGetNamedBufferPointervEXT( void *args ) { struct glGetNamedBufferPointervEXT_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -11971,7 +11971,7 @@ static NTSTATUS ext_glMap2xOES( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glMapBuffer( void *args ) +NTSTATUS ext_glMapBuffer( void *args ) { struct glMapBuffer_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -11979,7 +11979,7 @@ static NTSTATUS ext_glMapBuffer( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glMapBufferARB( void *args ) +NTSTATUS ext_glMapBufferARB( void *args ) { struct glMapBufferARB_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -11987,7 +11987,7 @@ static NTSTATUS ext_glMapBufferARB( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glMapBufferRange( void *args ) +NTSTATUS ext_glMapBufferRange( void *args ) { struct glMapBufferRange_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -12019,7 +12019,7 @@ static NTSTATUS ext_glMapGrid2xOES( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glMapNamedBuffer( void *args ) +NTSTATUS ext_glMapNamedBuffer( void *args ) { struct glMapNamedBuffer_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -12027,7 +12027,7 @@ static NTSTATUS ext_glMapNamedBuffer( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glMapNamedBufferEXT( void *args ) +NTSTATUS ext_glMapNamedBufferEXT( void *args ) { struct glMapNamedBufferEXT_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -12035,7 +12035,7 @@ static NTSTATUS ext_glMapNamedBufferEXT( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glMapNamedBufferRange( void *args ) +NTSTATUS ext_glMapNamedBufferRange( void *args ) { struct glMapNamedBufferRange_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -12043,7 +12043,7 @@ static NTSTATUS ext_glMapNamedBufferRange( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glMapNamedBufferRangeEXT( void *args ) +NTSTATUS ext_glMapNamedBufferRangeEXT( void *args ) { struct glMapNamedBufferRangeEXT_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -20515,7 +20515,7 @@ static NTSTATUS ext_glUnlockArraysEXT( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glUnmapBuffer( void *args ) +NTSTATUS ext_glUnmapBuffer( void *args ) { struct glUnmapBuffer_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -20523,7 +20523,7 @@ static NTSTATUS ext_glUnmapBuffer( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glUnmapBufferARB( void *args ) +NTSTATUS ext_glUnmapBufferARB( void *args ) { struct glUnmapBufferARB_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -20531,7 +20531,7 @@ static NTSTATUS ext_glUnmapBufferARB( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glUnmapNamedBuffer( void *args ) +NTSTATUS ext_glUnmapNamedBuffer( void *args ) { struct glUnmapNamedBuffer_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -20539,7 +20539,7 @@ static NTSTATUS ext_glUnmapNamedBuffer( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glUnmapNamedBufferEXT( void *args ) +NTSTATUS ext_glUnmapNamedBufferEXT( void *args ) { struct glUnmapNamedBufferEXT_params *params = args; const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; @@ -36058,40 +36058,6 @@ static NTSTATUS wow64_ext_glGetBufferParameterui64vNV( void *args ) return status; }
-static NTSTATUS wow64_ext_glGetBufferPointerv( void *args ) -{ - struct - { - GLenum target; - GLenum pname; - PTR32 params; - } *params32 = args; - struct glGetBufferPointerv_params params = - { - .target = params32->target, - .pname = params32->pname, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS wow64_ext_glGetBufferPointervARB( void *args ) -{ - struct - { - GLenum target; - GLenum pname; - PTR32 params; - } *params32 = args; - struct glGetBufferPointervARB_params params = - { - .target = params32->target, - .pname = params32->pname, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - static NTSTATUS wow64_ext_glGetBufferSubData( void *args ) { struct @@ -38539,40 +38505,6 @@ static NTSTATUS wow64_ext_glGetNamedBufferParameterui64vNV( void *args ) return status; }
-static NTSTATUS wow64_ext_glGetNamedBufferPointerv( void *args ) -{ - struct - { - GLuint buffer; - GLenum pname; - PTR32 params; - } *params32 = args; - struct glGetNamedBufferPointerv_params params = - { - .buffer = params32->buffer, - .pname = params32->pname, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS wow64_ext_glGetNamedBufferPointervEXT( void *args ) -{ - struct - { - GLuint buffer; - GLenum pname; - PTR32 params; - } *params32 = args; - struct glGetNamedBufferPointervEXT_params params = - { - .buffer = params32->buffer, - .pname = params32->pname, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - static NTSTATUS wow64_ext_glGetNamedBufferSubData( void *args ) { struct @@ -44486,61 +44418,6 @@ static NTSTATUS wow64_ext_glMTexCoord2fvSGIS( void *args ) return status; }
-static NTSTATUS wow64_ext_glMapBuffer( void *args ) -{ - struct - { - GLenum target; - GLenum access; - PTR32 ret; - } *params32 = args; - struct glMapBuffer_params params = - { - .target = params32->target, - .access = params32->access, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS wow64_ext_glMapBufferARB( void *args ) -{ - struct - { - GLenum target; - GLenum access; - PTR32 ret; - } *params32 = args; - struct glMapBufferARB_params params = - { - .target = params32->target, - .access = params32->access, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS wow64_ext_glMapBufferRange( void *args ) -{ - struct - { - GLenum target; - PTR32 offset; - PTR32 length; - GLbitfield access; - PTR32 ret; - } *params32 = args; - struct glMapBufferRange_params params = - { - .target = params32->target, - .offset = (GLintptr)ULongToPtr(params32->offset), - .length = (GLsizeiptr)ULongToPtr(params32->length), - .access = params32->access, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - static NTSTATUS wow64_ext_glMapControlPointsNV( void *args ) { struct @@ -44572,82 +44449,6 @@ static NTSTATUS wow64_ext_glMapControlPointsNV( void *args ) return status; }
-static NTSTATUS wow64_ext_glMapNamedBuffer( void *args ) -{ - struct - { - GLuint buffer; - GLenum access; - PTR32 ret; - } *params32 = args; - struct glMapNamedBuffer_params params = - { - .buffer = params32->buffer, - .access = params32->access, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS wow64_ext_glMapNamedBufferEXT( void *args ) -{ - struct - { - GLuint buffer; - GLenum access; - PTR32 ret; - } *params32 = args; - struct glMapNamedBufferEXT_params params = - { - .buffer = params32->buffer, - .access = params32->access, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS wow64_ext_glMapNamedBufferRange( void *args ) -{ - struct - { - GLuint buffer; - PTR32 offset; - PTR32 length; - GLbitfield access; - PTR32 ret; - } *params32 = args; - struct glMapNamedBufferRange_params params = - { - .buffer = params32->buffer, - .offset = (GLintptr)ULongToPtr(params32->offset), - .length = (GLsizeiptr)ULongToPtr(params32->length), - .access = params32->access, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS wow64_ext_glMapNamedBufferRangeEXT( void *args ) -{ - struct - { - GLuint buffer; - PTR32 offset; - PTR32 length; - GLbitfield access; - PTR32 ret; - } *params32 = args; - struct glMapNamedBufferRangeEXT_params params = - { - .buffer = params32->buffer, - .offset = (GLintptr)ULongToPtr(params32->offset), - .length = (GLsizeiptr)ULongToPtr(params32->length), - .access = params32->access, - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - static NTSTATUS wow64_ext_glMapObjectBufferATI( void *args ) { struct @@ -60803,10 +60604,25 @@ extern NTSTATUS wow64_gl_glGetString( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_glClientWaitSync( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_glDeleteSync( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_glFenceSync( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glGetBufferPointerv( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glGetBufferPointervARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glGetNamedBufferPointerv( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glGetNamedBufferPointervEXT( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_glGetStringi( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_glGetSynciv( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_glIsSync( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glMapBuffer( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glMapBufferARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glMapBufferRange( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glMapNamedBuffer( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glMapNamedBufferEXT( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glMapNamedBufferRange( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glMapNamedBufferRangeEXT( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_glPathGlyphIndexRangeNV( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glUnmapBuffer( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glUnmapBufferARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glUnmapNamedBuffer( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_glUnmapNamedBufferEXT( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_glWaitSync( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_wglCreateContextAttribsARB( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_wglCreatePbufferARB( void *args ) DECLSPEC_HIDDEN; @@ -63397,10 +63213,10 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] = &ext_glUniformui64NV, &wow64_ext_glUniformui64vNV, &ext_glUnlockArraysEXT, - &ext_glUnmapBuffer, - &ext_glUnmapBufferARB, - &ext_glUnmapNamedBuffer, - &ext_glUnmapNamedBufferEXT, + &wow64_ext_glUnmapBuffer, + &wow64_ext_glUnmapBufferARB, + &wow64_ext_glUnmapNamedBuffer, + &wow64_ext_glUnmapNamedBufferEXT, &ext_glUnmapObjectBufferATI, &ext_glUnmapTexture2DINTEL, &wow64_ext_glUpdateObjectBufferATI, diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 4c1533fa55e..a963ba0e110 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1067,8 +1067,25 @@ typedef ULONG PTR32; extern NTSTATUS ext_glClientWaitSync( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS ext_glDeleteSync( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS ext_glFenceSync( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glGetBufferPointerv( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glGetBufferPointervARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glGetNamedBufferPointerv( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glGetNamedBufferPointervEXT( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS ext_glGetSynciv( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS ext_glIsSync( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glMapBuffer( void *args ) DECLSPEC_HIDDEN; + +extern NTSTATUS ext_glUnmapBuffer( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glUnmapBufferARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glUnmapNamedBuffer( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glUnmapNamedBufferEXT( void *args ) DECLSPEC_HIDDEN; + +extern NTSTATUS ext_glMapBufferARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glMapBufferRange( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glMapNamedBuffer( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glMapNamedBufferEXT( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glMapNamedBufferRange( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glMapNamedBufferRangeEXT( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS ext_glPathGlyphIndexRangeNV( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS ext_glWaitSync( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS ext_wglGetExtensionsStringARB( void *args ) DECLSPEC_HIDDEN; @@ -1640,6 +1657,335 @@ NTSTATUS wow64_ext_glWaitSync( void *args ) return status; }
+static GLint get_buffer_param( GLenum target, GLenum param ) +{ + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + typeof(*funcs->ext.p_glGetBufferParameteriv) *func; + GLint size = 0; + if (!(func = funcs->ext.p_glGetBufferParameteriv)) func = (void *)funcs->wgl.p_wglGetProcAddress( "glGetBufferParameteriv" ); + if (func) func( target, param, &size ); + return size; +} + +static void *get_buffer_pointer( GLenum target ) +{ + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + typeof(*funcs->ext.p_glGetBufferPointerv) *func; + void *ptr = NULL; + if (!(func = funcs->ext.p_glGetBufferPointerv)) func = (void *)funcs->wgl.p_wglGetProcAddress( "glGetBufferPointerv" ); + if (func) func( target, GL_BUFFER_MAP_POINTER, &ptr ); + return ptr; +} + +static GLint get_named_buffer_param( GLint buffer, GLenum param ) +{ + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + typeof(*funcs->ext.p_glGetNamedBufferParameteriv) *func; + GLint size = 0; + if (!(func = funcs->ext.p_glGetNamedBufferParameteriv)) func = (void *)funcs->wgl.p_wglGetProcAddress( "glGetNamedBufferParameteriv" ); + if (func) func( buffer, param, &size ); + return size; +} + +static void *get_named_buffer_pointer( GLint buffer ) +{ + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + typeof(*funcs->ext.p_glGetNamedBufferPointerv) *func; + void *ptr = NULL; + if (!(func = funcs->ext.p_glGetNamedBufferPointerv)) func = (void *)funcs->wgl.p_wglGetProcAddress( "glGetNamedBufferPointerv" ); + if (func) func( buffer, GL_BUFFER_MAP_POINTER, &ptr ); + return ptr; +} + +static NTSTATUS wow64_map_buffer( GLint buffer, GLenum target, void *ptr, SIZE_T size, GLbitfield access, PTR32 *ret ) +{ + if (*ret) /* wow64 pointer provided, map buffer to it */ + { + if (access & GL_MAP_READ_BIT) + { + TRACE( "Copying %#zx from buffer at %p to wow64 buffer %p\n", size, ptr, UlongToPtr(*ret) ); + memcpy( UlongToPtr(*ret), ptr, size ); + } + + /* save the wow64 pointer in the buffer data, we'll overwrite it on unmap */ + *(PTR32 *)ptr = (UINT_PTR)*ret; + return STATUS_SUCCESS; + } + + if (ULongToPtr(*ret = PtrToUlong(ptr)) == ptr) return STATUS_SUCCESS; /* we're lucky */ + if (access & GL_MAP_PERSISTENT_BIT) + { + FIXME( "GL_MAP_PERSISTENT_BIT not supported!\n" ); + return STATUS_NOT_SUPPORTED; + } + + if (!size) size = buffer ? get_named_buffer_param( buffer, GL_BUFFER_SIZE ) : get_buffer_param( target, GL_BUFFER_SIZE ); + if ((PTR32)size != size) return STATUS_NO_MEMORY; /* overflow */ + if (size < sizeof(PTR32)) + { + FIXME( "Buffer too small for metadata!\n" ); + return STATUS_BUFFER_TOO_SMALL; + } + + *ret = size; + return STATUS_INVALID_ADDRESS; +} + +static NTSTATUS wow64_unmap_buffer( void *ptr, SIZE_T size, GLbitfield access ) +{ + void *wow_ptr; + + if (ULongToPtr(PtrToUlong(ptr)) == ptr) return STATUS_SUCCESS; /* we're lucky */ + + wow_ptr = UlongToPtr(*(PTR32 *)ptr); + if (access & GL_MAP_WRITE_BIT) + { + TRACE( "Copying %#zx from wow64 buffer %p to buffer %p\n", size, wow_ptr, ptr ); + memcpy( ptr, wow_ptr, size ); + } + + return STATUS_SUCCESS; +} + +NTSTATUS wow64_ext_glGetBufferPointerv( void *args ) +{ + PTR32 *ptr; /* pointer to the buffer data, where we saved the wow64 pointer */ + struct + { + GLenum target; + GLenum pname; + PTR32 params; + } *params32 = args; + struct glGetBufferPointerv_params params = + { + .target = params32->target, + .pname = params32->pname, + .params = (void **)&ptr, + }; + PTR32 *wow_ptr = UlongToPtr(params32->params); + NTSTATUS status; + + if ((status = ext_glGetBufferPointerv( ¶ms ))) return status; + if (params.pname != GL_BUFFER_MAP_POINTER) return STATUS_NOT_IMPLEMENTED; + if (ULongToPtr(*wow_ptr = PtrToUlong(ptr)) == ptr) return STATUS_SUCCESS; /* we're lucky */ + *wow_ptr = ptr[0]; + return STATUS_SUCCESS; +} + +NTSTATUS wow64_ext_glGetBufferPointervARB( void *args ) +{ + return wow64_ext_glGetBufferPointerv( args ); +} + +NTSTATUS wow64_ext_glGetNamedBufferPointerv( void *args ) +{ + PTR32 *ptr; /* pointer to the buffer data, where we saved the wow64 pointer */ + struct + { + GLuint buffer; + GLenum pname; + PTR32 params; + } *params32 = args; + struct glGetNamedBufferPointerv_params params = + { + .buffer = params32->buffer, + .pname = params32->pname, + .params = (void **)&ptr, + }; + PTR32 *wow_ptr = UlongToPtr(params32->params); + NTSTATUS status; + + if ((status = ext_glGetNamedBufferPointerv( ¶ms ))) return status; + if (params.pname != GL_BUFFER_MAP_POINTER) return STATUS_NOT_IMPLEMENTED; + if (ULongToPtr(*wow_ptr = PtrToUlong(ptr)) == ptr) return STATUS_SUCCESS; /* we're lucky */ + *wow_ptr = ptr[0]; + return STATUS_SUCCESS; +} + +NTSTATUS wow64_ext_glGetNamedBufferPointervEXT( void *args ) +{ + return wow64_ext_glGetNamedBufferPointerv( args ); +} + +NTSTATUS wow64_ext_glMapBuffer( void *args ) +{ + struct + { + GLenum target; + GLenum access; + PTR32 ret; + } *params32 = args; + struct glMapBuffer_params params = + { + .target = params32->target, + .access = params32->access, + }; + struct glUnmapBuffer_params unmap_params = { .target = params.target }; + NTSTATUS status; + + /* already mapped, we're being called again with a wow64 pointer */ + if (params32->ret) params.ret = get_buffer_pointer( params.target ); + else if ((status = ext_glMapBuffer( ¶ms ))) return status; + + status = wow64_map_buffer( 0, params.target, params.ret, 0, params.access, ¶ms32->ret ); + if (!status || status == STATUS_INVALID_ADDRESS) return status; + + ext_glUnmapBuffer( &unmap_params ); + return status; +} + +NTSTATUS wow64_ext_glMapBufferARB( void *args ) +{ + return wow64_ext_glMapBuffer( args ); +} + +NTSTATUS wow64_ext_glMapBufferRange( void *args ) +{ + struct + { + GLenum target; + PTR32 offset; + PTR32 length; + GLbitfield access; + PTR32 ret; + } *params32 = args; + struct glMapBufferRange_params params = + { + .target = params32->target, + .offset = (GLintptr)ULongToPtr(params32->offset), + .length = (GLsizeiptr)ULongToPtr(params32->length), + .access = params32->access, + }; + struct glUnmapBuffer_params unmap_params = { .target = params.target }; + NTSTATUS status; + + /* already mapped, we're being called again with a wow64 pointer */ + if (params32->ret) params.ret = (char *)get_buffer_pointer( params.target ); + else if ((status = ext_glMapBufferRange( ¶ms ))) return status; + + status = wow64_map_buffer( 0, params.target, params.ret, params.length, params.access, ¶ms32->ret ); + if (!status || status == STATUS_INVALID_ADDRESS) return status; + + ext_glUnmapBuffer( &unmap_params ); + return status; +} + +NTSTATUS wow64_ext_glMapNamedBuffer( void *args ) +{ + struct + { + GLuint buffer; + GLenum access; + PTR32 ret; + } *params32 = args; + struct glMapNamedBuffer_params params = + { + .buffer = params32->buffer, + .access = params32->access, + }; + struct glUnmapNamedBuffer_params unmap_params = { .buffer = params.buffer }; + NTSTATUS status; + + /* already mapped, we're being called again with a wow64 pointer */ + if (params32->ret) params.ret = get_named_buffer_pointer( params.buffer ); + else if ((status = ext_glMapNamedBuffer( ¶ms ))) return status; + + status = wow64_map_buffer( params.buffer, 0, params.ret, 0, params.access, ¶ms32->ret ); + if (!status || status == STATUS_INVALID_ADDRESS) return status; + + ext_glUnmapNamedBuffer( &unmap_params ); + return status; +} + +NTSTATUS wow64_ext_glMapNamedBufferEXT( void *args ) +{ + return wow64_ext_glMapNamedBuffer( args ); +} + +NTSTATUS wow64_ext_glMapNamedBufferRange( void *args ) +{ + struct + { + GLuint buffer; + PTR32 offset; + PTR32 length; + GLbitfield access; + PTR32 ret; + } *params32 = args; + struct glMapNamedBufferRange_params params = + { + .buffer = params32->buffer, + .offset = (GLintptr)ULongToPtr(params32->offset), + .length = (GLsizeiptr)ULongToPtr(params32->length), + .access = params32->access, + }; + struct glUnmapNamedBuffer_params unmap_params = { .buffer = params.buffer }; + NTSTATUS status; + + /* already mapped, we're being called again with a wow64 pointer */ + if (params32->ret) params.ret = get_named_buffer_pointer( params.buffer ); + else if ((status = ext_glMapNamedBufferRange( ¶ms ))) return status; + + status = wow64_map_buffer( params.buffer, 0, params.ret, params.length, params.access, ¶ms32->ret ); + if (!status || status == STATUS_INVALID_ADDRESS) return status; + + ext_glUnmapNamedBuffer( &unmap_params ); + return status; +} + +NTSTATUS wow64_ext_glMapNamedBufferRangeEXT( void *args ) +{ + return wow64_ext_glMapNamedBufferRange( args ); +} + +NTSTATUS wow64_ext_glUnmapBuffer( void *args ) +{ + PTR32 *ptr; + struct + { + GLenum target; + GLboolean ret; + } *params32 = args; + NTSTATUS status; + + if (!(ptr = get_buffer_pointer( params32->target ))) return STATUS_SUCCESS; + + status = wow64_unmap_buffer( ptr, get_buffer_param( params32->target, GL_BUFFER_MAP_LENGTH ), + get_buffer_param( params32->target, GL_BUFFER_ACCESS_FLAGS ) ); + ext_glUnmapBuffer( args ); + + return status; +} + +NTSTATUS wow64_ext_glUnmapBufferARB( void *args ) +{ + return wow64_ext_glUnmapBuffer( args ); +} + +NTSTATUS wow64_ext_glUnmapNamedBuffer( void *args ) +{ + PTR32 *ptr; + struct + { + GLint buffer; + GLboolean ret; + } *params32 = args; + NTSTATUS status; + + if (!(ptr = get_named_buffer_pointer( params32->buffer ))) return STATUS_SUCCESS; + + status = wow64_unmap_buffer( ptr, get_named_buffer_param( params32->buffer, GL_BUFFER_MAP_LENGTH ), + get_named_buffer_param( params32->buffer, GL_BUFFER_ACCESS_FLAGS ) ); + ext_glUnmapNamedBuffer( args ); + + return status; +} + +NTSTATUS wow64_ext_glUnmapNamedBufferEXT( void *args ) +{ + return wow64_ext_glUnmapNamedBuffer( args ); +} + NTSTATUS WINAPI wow64_process_detach( void *args ) { NTSTATUS status; diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index ff9e6164c89..a8318fcd21f 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -28,6 +28,7 @@ #include "winbase.h" #include "winreg.h" #include "ntuser.h" +#include "malloc.h"
#include "unixlib.h" #include "private.h" @@ -1036,6 +1037,44 @@ const GLchar * WINAPI wglQueryRendererStringWINE( HDC dc, GLint renderer, GLenum return args.ret; }
+#ifndef _WIN64 +static GLint get_buffer_size( GLenum target ) +{ + void (WINAPI *p_glGetBufferParameteriv)( GLenum target, GLenum pname, GLint *params ); + GLint size; + if (!(p_glGetBufferParameteriv = (void *)wglGetProcAddress( "glGetBufferParameteriv" ))) return 0; + p_glGetBufferParameteriv( target, GL_BUFFER_SIZE, &size ); + return size; +} + +static void *get_buffer_pointer( GLenum target ) +{ + void (WINAPI *p_glGetBufferPointerv)( GLenum target, GLenum pname, void **params ); + void *ptr; + if (!(p_glGetBufferPointerv = (void *)wglGetProcAddress( "glGetBufferPointerv" ))) return 0; + p_glGetBufferPointerv( target, GL_BUFFER_MAP_POINTER, &ptr ); + return ptr; +} + +static GLint get_named_buffer_size( GLint buffer ) +{ + void (WINAPI *p_glGetNamedBufferParameteriv)( GLuint buffer, GLenum pname, GLint *params ); + GLint size; + if (!(p_glGetNamedBufferParameteriv = (void *)wglGetProcAddress( "glGetNamedBufferParameteriv" ))) return 0; + p_glGetNamedBufferParameteriv( buffer, GL_BUFFER_SIZE, &size ); + return size; +} + +static void *get_named_buffer_pointer( GLint buffer ) +{ + void (WINAPI *p_glGetNamedBufferPointerv)( GLuint buffer, GLenum pname, void **params ); + void *ptr; + if (!(p_glGetNamedBufferPointerv = (void *)wglGetProcAddress( "glGetNamedBufferPointerv" ))) return 0; + p_glGetNamedBufferPointerv( buffer, GL_BUFFER_MAP_POINTER, &ptr ); + return ptr; +} +#endif + void * WINAPI glMapBuffer( GLenum target, GLenum access ) { struct glMapBuffer_params args = @@ -1048,6 +1087,15 @@ void * WINAPI glMapBuffer( GLenum target, GLenum access ) TRACE( "target %d, access %d\n", target, access );
if (!(status = UNIX_CALL( glMapBuffer, &args ))) return args.ret; +#ifndef _WIN64 + if (status == STATUS_INVALID_ADDRESS) + { + args.ret = _aligned_malloc( get_buffer_size( target ), 16 ); + TRACE( "Unable to map wow64 buffer directly, using copy buffer %p!\n", args.ret ); + if (!(status = UNIX_CALL( glMapBuffer, &args ))) return args.ret; + _aligned_free( args.ret ); + } +#endif WARN( "glMapBuffer returned %#lx\n", status ); return args.ret; } @@ -1071,6 +1119,15 @@ 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; +#ifndef _WIN64 + if (status == STATUS_INVALID_ADDRESS) + { + args.ret = _aligned_malloc( length, 16 ); + TRACE( "Unable to map wow64 buffer directly, using copy buffer %p!\n", args.ret ); + if (!(status = UNIX_CALL( glMapBufferRange, &args ))) return args.ret; + _aligned_free( args.ret ); + } +#endif WARN( "glMapBufferRange returned %#lx\n", status ); return args.ret; } @@ -1087,6 +1144,15 @@ void * WINAPI glMapNamedBuffer( GLuint buffer, GLenum access ) TRACE( "(%d, %d)\n", buffer, access );
if (!(status = UNIX_CALL( glMapNamedBuffer, &args ))) return args.ret; +#ifndef _WIN64 + if (status == STATUS_INVALID_ADDRESS) + { + args.ret = _aligned_malloc( get_named_buffer_size( buffer ), 16 ); + TRACE( "Unable to map wow64 buffer directly, using copy buffer %p!\n", args.ret ); + if (!(status = UNIX_CALL( glMapNamedBuffer, &args ))) return args.ret; + _aligned_free( args.ret ); + } +#endif WARN( "glMapNamedBuffer returned %#lx\n", status ); return args.ret; } @@ -1110,6 +1176,15 @@ void * WINAPI glMapNamedBufferRange( GLuint buffer, GLintptr offset, GLsizeiptr TRACE( "buffer %d, offset %Id, length %Id, access %d\n", buffer, offset, length, access );
if (!(status = UNIX_CALL( glMapNamedBufferRange, &args ))) return args.ret; +#ifndef _WIN64 + if (status == STATUS_INVALID_ADDRESS) + { + args.ret = _aligned_malloc( length, 16 ); + TRACE( "Unable to map wow64 buffer directly, using copy buffer %p!\n", args.ret ); + if (!(status = UNIX_CALL( glMapNamedBufferRange, &args ))) return args.ret; + _aligned_free( args.ret ); + } +#endif WARN( "glMapNamedBufferRange returned %#lx\n", status ); return args.ret; } @@ -1126,10 +1201,21 @@ GLboolean WINAPI glUnmapBuffer( GLenum target ) .target = target, }; NTSTATUS status; +#ifndef _WIN64 + void *ptr = get_buffer_pointer( target ); +#endif
TRACE( "target %d\n", target );
if (!(status = UNIX_CALL( glUnmapBuffer, &args ))) return args.ret; +#ifndef _WIN64 + if (status == STATUS_INVALID_ADDRESS) + { + TRACE( "Releasing wow64 copy buffer %p\n", ptr ); + _aligned_free( ptr ); + return args.ret; + } +#endif WARN( "glUnmapBuffer returned %#lx\n", status ); return args.ret; } @@ -1146,10 +1232,21 @@ GLboolean WINAPI glUnmapNamedBuffer( GLuint buffer ) .buffer = buffer, }; NTSTATUS status; +#ifndef _WIN64 + void *ptr = get_named_buffer_pointer( buffer ); +#endif
TRACE( "buffer %d\n", buffer );
if (!(status = UNIX_CALL( glUnmapNamedBuffer, &args ))) return args.ret; +#ifndef _WIN64 + if (status == STATUS_INVALID_ADDRESS) + { + TRACE( "Releasing wow64 copy buffer %p\n", ptr ); + _aligned_free( ptr ); + return args.ret; + } +#endif WARN( "glUnmapNamedBuffer returned %#lx\n", status ); return args.ret; }