From: Jacek Caban jacek@codeweavers.com
--- dlls/opengl32/make_opengl | 10 +++++-- dlls/opengl32/unix_private.h | 5 ++-- dlls/opengl32/unix_thunks.c | 55 +++++++++++++++++++++++++++--------- dlls/opengl32/unix_wgl.c | 25 +++++++++------- 4 files changed, 67 insertions(+), 28 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 011b3d21878..61eafbec33e 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -443,6 +443,7 @@ sub generate_unix_thunk($$$$) my $manual_wow64_wrapper = $is_wow64 && defined $manual_wow64_wrappers{$name}; my $need_wrap = $manual_wow64_wrapper || needs_wrapper( $name, $func ); my $need_lock = $func_ret =~ /HGLRC|HPBUFFERARB/; + my $need_funcs = !$need_wrap; my $teb = $is_wow64 ? "teb" : "params->teb"; my $ret_stat = "return STATUS_SUCCESS;"; my $invalidation = ""; @@ -544,9 +545,12 @@ sub generate_unix_thunk($$$$) if (defined $wow64_invalidate_buffer{$name}) { $need_lock = 1; + $need_funcs = 1; + $input_conv .= " struct buffer *buffer;\n"; $invalidation .= $name =~ /NamedBuffer/ - ? " invalidate_buffer_name( $teb, params->buffer );\n" - : " invalidate_buffer_target( $teb, params->target );\n"; + ? " buffer = invalidate_buffer_name( $teb, params->buffer );\n" + : " buffer = invalidate_buffer_target( $teb, params->target );\n"; + $output_conv .= " if (buffer) free_buffer( funcs, buffer );\n"; } $ret .= " TEB *teb = get_teb64( params->teb );\n" if $need_wrap || !$use_dc; } @@ -575,7 +579,7 @@ sub generate_unix_thunk($$$$) $ret .= " const struct opengl_funcs *funcs = get_dc_funcs( $param );\n"; $ret .= " if (!funcs || !funcs->p_$name) return STATUS_NOT_IMPLEMENTED;\n"; } - elsif (!$need_wrap) + elsif ($need_funcs) { $ret .= " const struct opengl_funcs *funcs = $teb->glTable;\n"; } diff --git a/dlls/opengl32/unix_private.h b/dlls/opengl32/unix_private.h index 9ced126e3ab..138578210f8 100644 --- a/dlls/opengl32/unix_private.h +++ b/dlls/opengl32/unix_private.h @@ -71,8 +71,9 @@ static inline TEB *get_teb64( ULONG teb32 ) return (TEB *)((char *)teb32_ptr + teb32_ptr->WowTebOffset); }
-extern void invalidate_buffer_name( TEB *teb, GLuint name ); -extern void invalidate_buffer_target( TEB *teb, GLenum target ); +extern struct buffer *invalidate_buffer_name( TEB *teb, GLuint name ); +extern struct buffer *invalidate_buffer_target( TEB *teb, GLenum target ); +extern void free_buffer( const struct opengl_funcs *funcs, struct buffer *buffer ); extern NTSTATUS return_wow64_string( const void *str, PTR32 *wow64_str );
#endif diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 19596967d23..7d4c00edbe9 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -37981,12 +37981,14 @@ static NTSTATUS wow64_ext_glBufferAttachMemoryNV( void *args ) GLuint64 offset; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_target( teb, params->target ); + buffer = invalidate_buffer_target( teb, params->target ); funcs->p_glBufferAttachMemoryNV( params->target, params->memory, params->offset ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -38001,12 +38003,14 @@ static NTSTATUS wow64_ext_glBufferData( void *args ) GLenum usage; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_target( teb, params->target ); + buffer = invalidate_buffer_target( teb, params->target ); funcs->p_glBufferData( params->target, (GLsizeiptr)ULongToPtr(params->size), ULongToPtr(params->data), params->usage ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -38021,12 +38025,14 @@ static NTSTATUS wow64_ext_glBufferDataARB( void *args ) GLenum usage; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_target( teb, params->target ); + buffer = invalidate_buffer_target( teb, params->target ); funcs->p_glBufferDataARB( params->target, (GLsizeiptrARB)ULongToPtr(params->size), ULongToPtr(params->data), params->usage ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -38107,11 +38113,14 @@ static NTSTATUS wow64_ext_glBufferStorage( void *args ) GLbitfield flags; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; + const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_target( teb, params->target ); + buffer = invalidate_buffer_target( teb, params->target ); wow64_glBufferStorage( teb, params->target, (GLsizeiptr)ULongToPtr(params->size), ULongToPtr(params->data), params->flags ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -38127,12 +38136,14 @@ static NTSTATUS wow64_ext_glBufferStorageExternalEXT( void *args ) GLbitfield flags; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_target( teb, params->target ); + buffer = invalidate_buffer_target( teb, params->target ); funcs->p_glBufferStorageExternalEXT( params->target, (GLintptr)ULongToPtr(params->offset), (GLsizeiptr)ULongToPtr(params->size), ULongToPtr(params->clientBuffer), params->flags ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -38147,12 +38158,14 @@ static NTSTATUS wow64_ext_glBufferStorageMemEXT( void *args ) GLuint64 offset; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_target( teb, params->target ); + buffer = invalidate_buffer_target( teb, params->target ); funcs->p_glBufferStorageMemEXT( params->target, (GLsizeiptr)ULongToPtr(params->size), params->memory, params->offset ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -59295,12 +59308,14 @@ static NTSTATUS wow64_ext_glNamedBufferAttachMemoryNV( void *args ) GLuint64 offset; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_name( teb, params->buffer ); + buffer = invalidate_buffer_name( teb, params->buffer ); funcs->p_glNamedBufferAttachMemoryNV( params->buffer, params->memory, params->offset ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -59315,12 +59330,14 @@ static NTSTATUS wow64_ext_glNamedBufferData( void *args ) GLenum usage; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_name( teb, params->buffer ); + buffer = invalidate_buffer_name( teb, params->buffer ); funcs->p_glNamedBufferData( params->buffer, (GLsizeiptr)ULongToPtr(params->size), ULongToPtr(params->data), params->usage ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -59335,12 +59352,14 @@ static NTSTATUS wow64_ext_glNamedBufferDataEXT( void *args ) GLenum usage; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_name( teb, params->buffer ); + buffer = invalidate_buffer_name( teb, params->buffer ); funcs->p_glNamedBufferDataEXT( params->buffer, (GLsizeiptr)ULongToPtr(params->size), ULongToPtr(params->data), params->usage ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -59408,11 +59427,14 @@ static NTSTATUS wow64_ext_glNamedBufferStorage( void *args ) GLbitfield flags; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; + const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_name( teb, params->buffer ); + buffer = invalidate_buffer_name( teb, params->buffer ); wow64_glNamedBufferStorage( teb, params->buffer, (GLsizeiptr)ULongToPtr(params->size), ULongToPtr(params->data), params->flags ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -59427,11 +59449,14 @@ static NTSTATUS wow64_ext_glNamedBufferStorageEXT( void *args ) GLbitfield flags; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; + const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_name( teb, params->buffer ); + buffer = invalidate_buffer_name( teb, params->buffer ); wow64_glNamedBufferStorageEXT( teb, params->buffer, (GLsizeiptr)ULongToPtr(params->size), ULongToPtr(params->data), params->flags ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -59447,12 +59472,14 @@ static NTSTATUS wow64_ext_glNamedBufferStorageExternalEXT( void *args ) GLbitfield flags; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_name( teb, params->buffer ); + buffer = invalidate_buffer_name( teb, params->buffer ); funcs->p_glNamedBufferStorageExternalEXT( params->buffer, (GLintptr)ULongToPtr(params->offset), (GLsizeiptr)ULongToPtr(params->size), ULongToPtr(params->clientBuffer), params->flags ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
@@ -59467,12 +59494,14 @@ static NTSTATUS wow64_ext_glNamedBufferStorageMemEXT( void *args ) GLuint64 offset; } *params = args; TEB *teb = get_teb64( params->teb ); + struct buffer *buffer; const struct opengl_funcs *funcs = teb->glTable; pthread_mutex_lock( &wgl_lock ); - invalidate_buffer_name( teb, params->buffer ); + buffer = invalidate_buffer_name( teb, params->buffer ); funcs->p_glNamedBufferStorageMemEXT( params->buffer, (GLsizeiptr)ULongToPtr(params->size), params->memory, params->offset ); pthread_mutex_unlock( &wgl_lock ); set_context_attribute( teb, -1 /* unsupported */, NULL, 0 ); + if (buffer) free_buffer( funcs, buffer ); return STATUS_SUCCESS; }
diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 1d9e1573a7e..2ab0cdfb10c 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -398,7 +398,7 @@ static int compare_buffer_name( const void *key, const struct rb_entry *entry ) return memcmp( key, &buffer->name, sizeof(buffer->name) ); }
-static void free_buffer( const struct opengl_funcs *funcs, struct buffer *buffer ) +void free_buffer( const struct opengl_funcs *funcs, struct buffer *buffer ) { if (buffer->vk_memory) { @@ -2323,20 +2323,21 @@ static struct buffer *get_named_buffer( TEB *teb, GLuint name ) return NULL; }
-void invalidate_buffer_name( TEB *teb, GLuint name ) +struct buffer *invalidate_buffer_name( TEB *teb, GLuint name ) { struct buffer *buffer = get_named_buffer( teb, name ); - struct context *ctx; - - if (!buffer || !(ctx = get_current_context( teb, NULL, NULL ))) return; - rb_remove( &ctx->buffers->map, &buffer->entry ); - free_buffer( teb->glTable, buffer ); + if (buffer) + { + struct context *ctx = get_current_context( teb, NULL, NULL ); + rb_remove( &ctx->buffers->map, &buffer->entry ); + } + return buffer; }
-void invalidate_buffer_target( TEB *teb, GLenum target ) +struct buffer *invalidate_buffer_target( TEB *teb, GLenum target ) { GLuint name = get_target_name( teb, target ); - if (name) invalidate_buffer_name( teb, name ); + return name ? invalidate_buffer_name( teb, name ) : NULL; }
static struct buffer *get_target_buffer( TEB *teb, GLenum target ) @@ -2605,12 +2606,16 @@ static GLbitfield map_range_flags_from_map_flags( GLenum flags ) void wow64_glDeleteBuffers( TEB *teb, GLsizei n, const GLuint *buffers ) { const struct opengl_funcs *funcs = teb->glTable; + struct buffer *buffer; GLsizei i;
pthread_mutex_lock( &wgl_lock );
funcs->p_glDeleteBuffers( n, buffers ); - for (i = 0; i < n; i++) invalidate_buffer_name( teb, buffers[i] ); + for (i = 0; i < n; i++) + { + if ((buffer = invalidate_buffer_name( teb, buffers[i] ))) free_buffer( funcs, buffer ); + }
pthread_mutex_unlock( &wgl_lock ); }