[PATCH 0/5] MR10681: opengl32: Misc make_opengl cleanups.
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/make_opengl | 64 +++++++++++++++--------------------- dlls/opengl32/unix_thunks.c | 7 ++-- dlls/opengl32/unix_thunks.h | 1 + dlls/opengl32/unix_wgl.c | 7 ++++ dlls/win32u/opengl.c | 19 ++++++----- include/wine/opengl_driver.h | 2 +- include/wine/wgl.h | 8 ++--- 7 files changed, 53 insertions(+), 55 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index cfba9205333..d095fb70a59 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -229,6 +229,7 @@ my %manual_unix_thunks = "wglCopyContext" => 1, "wglCreateContext" => 1, "wglCreateContextAttribsARB" => 1, + "wglCreatePbufferARB" => 1, "wglDeleteContext" => 1, "wglMakeContextCurrentARB" => 1, "wglMakeCurrent" => 1, @@ -377,17 +378,6 @@ my %state_attrib_funcs = "glLightModeli" => "params->pname, ¶ms->param, sizeof(params->param)", ); -# -# Used to convert some types -# -sub ConvertType($) -{ - my $arg = shift; - my $ret = $arg->textContent(); - my @type = $arg->findnodes("./ptype"); - return $ret; -} - sub get_func_trace($$$) { my ($name, $func, $param_names) = @_; @@ -420,27 +410,25 @@ sub get_func_trace($$$) return "TRACE( \"$trace_fmt\\n\"$trace_arg );\n"; } -sub get_func_args($$) +sub get_func_args($) { - my ($func, $unix) = @_; + my $func = shift; my $ret = ""; foreach my $arg (@{$func->[1]}) { my $ptype = get_arg_type( $arg ); my $pname = get_arg_name( $arg ); - $ret .= " " . ($unix ? ConvertType( $arg ) : $arg->textContent()) . ","; + $ret .= " " . $arg->textContent() . ","; } - $ret .= " HPBUFFERARB client_pbuffer," if $unix && $func->[0] =~ /HPBUFFERARB/; - $ret .= " HGLRC client_context," if $unix && $func->[0] =~ /HGLRC/ && @{$func->[1]}; $ret =~ s/,$/ /; $ret ||= "void"; return $ret; } -sub get_func_ret($$) +sub get_func_ret($) { - my ($func, $unix) = @_; - my $ret = $unix ? ConvertType( $func->[0] ) : $func->[0]->textContent(); + my $func = shift; + my $ret = $func->[0]->textContent(); $ret =~ s/ $//; return $ret; } @@ -448,7 +436,7 @@ sub get_func_ret($$) sub generate_unix_thunk($$$$) { my ($name, $func, $is_wow64, $prefix) = @_; - my $func_ret = get_func_ret( $func, 0 ); + my $func_ret = get_func_ret( $func ); my $manual_wow64_wrapper = $is_wow64 && defined $manual_wow64_wrappers{$name}; my $need_wrap = $manual_wow64_wrapper || needs_wrapper( $name, $func ); my $need_lock = 0; @@ -681,8 +669,8 @@ sub generate_unix_thunk($$$$) sub generate_wrapper_declaration($$$) { my ($name, $func, $is_wow64) = @_; - my $decl_args = get_func_args( $func, 0 ); - my $ret_type = get_func_ret( $func, 0 ); + my $decl_args = get_func_args( $func ); + my $ret_type = get_func_ret( $func ); my $ret = "extern "; $ret .= $ret_type; $ret .= " " unless $ret_type =~ /\*$/; @@ -719,8 +707,8 @@ sub get_handle_function($) sub generate_win_thunk($$) { my ($name, $func) = @_; - my $decl_args = get_func_args( $func, 0 ); - my $func_ret = get_func_ret( $func, 0 ); + my $decl_args = get_func_args( $func ); + my $func_ret = get_func_ret( $func ); my $params = ""; my $checks = ""; my $ret = ""; @@ -770,8 +758,8 @@ sub get_wow64_arg_type($) sub generate_null_func($$) { my ($name, $func) = @_; - my $decl_args = get_func_args( $func, 1 ); - my $func_ret = get_func_ret( $func, 1 ); + my $decl_args = get_func_args( $func ); + my $func_ret = get_func_ret( $func ); my $ret = ""; $ret .= "static $func_ret null_$name($decl_args)\n"; @@ -1456,37 +1444,37 @@ print HEADER "\n"; print HEADER "#ifndef GL_NO_PROTOTYPES\n"; foreach (sort keys %norm_functions) { - my $decl_args = get_func_args( $norm_functions{$_}, 1 ); - my $func_ret = get_func_ret( $norm_functions{$_}, 1 ); + my $decl_args = get_func_args( $norm_functions{$_} ); + my $func_ret = get_func_ret( $norm_functions{$_} ); printf HEADER "%-10s GLAPIENTRY $_($decl_args);\n", $func_ret; } print HEADER "#endif\n\n"; foreach (sort keys %wgl_functions) { - my $decl_args = get_func_args( $wgl_functions{$_}, 1 ); - my $func_ret = get_func_ret( $wgl_functions{$_}, 1 ); + my $decl_args = get_func_args( $wgl_functions{$_} ); + my $func_ret = get_func_ret( $wgl_functions{$_} ); printf HEADER "typedef %-10s (GLAPIENTRY *PFN_$_)($decl_args);\n", $func_ret; } foreach (sort keys %egl_functions) { - my $decl_args = get_func_args( $egl_functions{$_}, 1 ); - my $func_ret = get_func_ret( $egl_functions{$_}, 1 ); + my $decl_args = get_func_args( $egl_functions{$_} ); + my $func_ret = get_func_ret( $egl_functions{$_} ); printf HEADER "typedef %-10s (GLAPIENTRY *PFN_$_)($decl_args);\n", $func_ret; } foreach (sort keys %norm_functions) { - my $decl_args = get_func_args( $norm_functions{$_}, 1 ); - my $func_ret = get_func_ret( $norm_functions{$_}, 1 ); + my $decl_args = get_func_args( $norm_functions{$_} ); + my $func_ret = get_func_ret( $norm_functions{$_} ); printf HEADER "typedef %-10s (GLAPIENTRY *PFN_$_)($decl_args);\n", $func_ret; } foreach (sort keys %ext_functions) { - my $decl_args = get_func_args( $ext_functions{$_}, 1 ); - my $func_ret = get_func_ret( $ext_functions{$_}, 1 ); + my $decl_args = get_func_args( $ext_functions{$_} ); + my $func_ret = get_func_ret( $ext_functions{$_} ); printf HEADER "typedef %-10s (GLAPIENTRY *PFN_$_)($decl_args);\n", $func_ret; } print HEADER "\n"; @@ -1712,8 +1700,8 @@ foreach (sort keys %ext_functions) { next unless is_exposed_function( $ext_functions{$_} ); next unless defined $manual_win_functions{$_} || $manual_win_thunks{$_}; - my $decl_args = get_func_args( $ext_functions{$_}, 0 ); - my $func_ret = get_func_ret( $ext_functions{$_}, 0 ); + my $decl_args = get_func_args( $ext_functions{$_} ); + my $func_ret = get_func_ret( $ext_functions{$_} ); printf OUT "extern %s WINAPI %s(%s);\n", $func_ret, $_, $decl_args; } diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 52ab27e590a..2bb541f5e5c 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -30378,7 +30378,7 @@ static NTSTATUS ext_wglCreatePbufferARB( void *args ) struct wglCreatePbufferARB_params *params = args; const struct opengl_funcs *funcs = get_dc_funcs( params->hDC ); if (!funcs || !funcs->p_wglCreatePbufferARB) return STATUS_NOT_IMPLEMENTED; - params->ret = funcs->p_wglCreatePbufferARB( params->hDC, params->iPixelFormat, params->iWidth, params->iHeight, params->piAttribList, params->ret ); + params->ret = wrap_wglCreatePbufferARB( params->teb, params->hDC, params->iPixelFormat, params->iWidth, params->iHeight, params->piAttribList, params->ret ); return STATUS_SUCCESS; } @@ -86646,9 +86646,10 @@ static NTSTATUS wow64_ext_wglCreatePbufferARB( void *args ) PTR32 piAttribList; PTR32 ret; } *params = args; + TEB *teb = get_teb64( params->teb ); const struct opengl_funcs *funcs = get_dc_funcs( ULongToPtr(params->hDC) ); if (!funcs || !funcs->p_wglCreatePbufferARB) return STATUS_NOT_IMPLEMENTED; - params->ret = (UINT_PTR)funcs->p_wglCreatePbufferARB( ULongToPtr(params->hDC), params->iPixelFormat, params->iWidth, params->iHeight, ULongToPtr(params->piAttribList), UlongToHandle( params->ret ) ); + params->ret = (UINT_PTR)wrap_wglCreatePbufferARB( teb, ULongToPtr(params->hDC), params->iPixelFormat, params->iWidth, params->iHeight, ULongToPtr(params->piAttribList), UlongToHandle( params->ret ) ); return STATUS_SUCCESS; } @@ -90035,7 +90036,7 @@ static BOOL null_wglCopyContext( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ) WARN( "unsupported\n" ); return 0; } -static HGLRC null_wglCreateContext( HDC hDc, HGLRC client_context ) +static HGLRC null_wglCreateContext( HDC hDc ) { WARN( "unsupported\n" ); return 0; diff --git a/dlls/opengl32/unix_thunks.h b/dlls/opengl32/unix_thunks.h index b2911b7e2a1..b9b5f0a0096 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -39,6 +39,7 @@ extern void wrap_glNamedFramebufferDrawBuffer( TEB *teb, GLuint framebuffer, GLe extern void wrap_glNamedFramebufferDrawBuffers( TEB *teb, GLuint framebuffer, GLsizei n, const GLenum *bufs ); extern void wrap_glNamedFramebufferReadBuffer( TEB *teb, GLuint framebuffer, GLenum src ); extern HGLRC wrap_wglCreateContextAttribsARB( TEB *teb, HDC hDC, HGLRC hShareContext, const int *attribList, HGLRC handle ); +extern HPBUFFERARB wrap_wglCreatePbufferARB( TEB *teb, HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList, HPBUFFERARB handle ); extern BOOL wrap_wglMakeContextCurrentARB( TEB *teb, HDC hDrawDC, HDC hReadDC, HGLRC hglrc ); #ifdef _WIN64 diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 6ac3e5ffb10..fd17d4aafda 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1442,6 +1442,13 @@ BOOL wrap_wglMakeContextCurrentARB( TEB *teb, HDC draw_hdc, HDC read_hdc, HGLRC return TRUE; } +HPBUFFERARB wrap_wglCreatePbufferARB( TEB *teb, HDC hdc, int format, int width, int height, const int *attribs, HPBUFFERARB client_pbuffer ) +{ + const struct opengl_funcs *funcs = get_dc_funcs( hdc ); + if (!funcs->p_pbuffer_create( hdc, format, width, height, attribs, client_pbuffer )) return 0; + return client_pbuffer; +} + static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *user ) { diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index dd8b243f9f3..0815f4378e8 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1443,7 +1443,7 @@ static void pbuffer_destroy( struct pbuffer *pbuffer ) free( pbuffer ); } -static struct pbuffer *pbuffer_create( HDC hdc, int format, int width, int height, const int *attribs ) +static struct pbuffer *pbuffer_create( int format, int width, int height, const int *attribs ) { struct pbuffer *pbuffer; UINT size, max_level = 0; @@ -1582,7 +1582,7 @@ static BOOL create_memory_pbuffer( HDC hdc ) int width = dib.rect.right - dib.rect.left, height = dib.rect.bottom - dib.rect.top; struct pbuffer *pbuffer; - if (!(pbuffer = pbuffer_create( hdc, format, width, height, NULL ))) + if (!(pbuffer = pbuffer_create( format, width, height, NULL ))) WARN( "Failed to create pbuffer for memory DC %p\n", hdc ); else { @@ -1941,8 +1941,8 @@ static void opengl_client_pbuffer_init( HPBUFFERARB client_pbuffer, struct pbuff client->unix_funcs = (UINT_PTR)funcs; } -static HPBUFFERARB win32u_wglCreatePbufferARB( HDC hdc, int format, int width, int height, const int *attribs, - HPBUFFERARB client_pbuffer ) +static BOOL win32u_pbuffer_create( HDC hdc, int format, int width, int height, const int *attribs, + HPBUFFERARB client_pbuffer ) { const struct opengl_funcs *funcs = &display_funcs; struct pbuffer *pbuffer; @@ -1954,17 +1954,17 @@ static HPBUFFERARB win32u_wglCreatePbufferARB( HDC hdc, int format, int width, i if (format <= 0 || format > total) { RtlSetLastWin32Error( ERROR_INVALID_PIXEL_FORMAT ); - return 0; + return FALSE; } if (width <= 0 || height <= 0) { RtlSetLastWin32Error( ERROR_INVALID_DATA ); - return 0; + return FALSE; } - if (!(pbuffer = pbuffer_create( hdc, format, width, height, attribs ))) return 0; + if (!(pbuffer = pbuffer_create( format, width, height, attribs ))) return FALSE; opengl_client_pbuffer_init( client_pbuffer, pbuffer, funcs ); - return client_pbuffer; + return TRUE; } static BOOL win32u_wglDestroyPbufferARB( HPBUFFERARB client_pbuffer ) @@ -2745,7 +2745,8 @@ static void display_funcs_init(void) display_funcs.p_wglMakeContextCurrentARB = win32u_wglMakeContextCurrentARB; global_extensions[WGL_ARB_pbuffer] = 1; - display_funcs.p_wglCreatePbufferARB = win32u_wglCreatePbufferARB; + display_funcs.p_pbuffer_create = win32u_pbuffer_create; + display_funcs.p_wglCreatePbufferARB = (void *)1; /* never called */ display_funcs.p_wglDestroyPbufferARB = win32u_wglDestroyPbufferARB; display_funcs.p_wglGetPbufferDCARB = win32u_wglGetPbufferDCARB; display_funcs.p_wglReleasePbufferDCARB = win32u_wglReleasePbufferDCARB; diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index d94229ea269..777a82c338a 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -147,7 +147,7 @@ struct opengl_funcs BOOL (*p_context_create)( struct opengl_context *context, HDC hdc, struct opengl_context *share, const int *attribs ); BOOL (*p_context_destroy)( struct opengl_context *context ); BOOL (*p_context_reset)( struct opengl_context *context, struct opengl_context *share, const int *attribs ); - + BOOL (*p_pbuffer_create)( HDC hdc, int format, int width, int height, const int *attribs, HPBUFFERARB client_pbuffer ); void *egl_handle; }; diff --git a/include/wine/wgl.h b/include/wine/wgl.h index 9240740ab33..3b46ee51b87 100644 --- a/include/wine/wgl.h +++ b/include/wine/wgl.h @@ -7202,8 +7202,8 @@ void GLAPIENTRY glViewport( GLint x, GLint y, GLsizei width, GLsizei heigh typedef int (GLAPIENTRY *PFN_wglChoosePixelFormat)( HDC hDc, const PIXELFORMATDESCRIPTOR *pPfd ); typedef BOOL (GLAPIENTRY *PFN_wglCopyContext)( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ); -typedef HGLRC (GLAPIENTRY *PFN_wglCreateContext)( HDC hDc, HGLRC client_context ); -typedef HGLRC (GLAPIENTRY *PFN_wglCreateLayerContext)( HDC hDc, int level, HGLRC client_context ); +typedef HGLRC (GLAPIENTRY *PFN_wglCreateContext)( HDC hDc ); +typedef HGLRC (GLAPIENTRY *PFN_wglCreateLayerContext)( HDC hDc, int level ); typedef BOOL (GLAPIENTRY *PFN_wglDeleteContext)( HGLRC oldContext ); typedef BOOL (GLAPIENTRY *PFN_wglDescribeLayerPlane)( HDC hDc, int pixelFormat, int layerPlane, UINT nBytes, LAYERPLANEDESCRIPTOR *plpd ); typedef int (GLAPIENTRY *PFN_wglDescribePixelFormat)( HDC hdc, int ipfd, UINT cjpfd, PIXELFORMATDESCRIPTOR *ppfd ); @@ -10698,8 +10698,8 @@ typedef void (GLAPIENTRY *PFN_glWriteMaskEXT)( GLuint res, GLuint in, GLen typedef void * (GLAPIENTRY *PFN_wglAllocateMemoryNV)( GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority ); typedef BOOL (GLAPIENTRY *PFN_wglBindTexImageARB)( HPBUFFERARB hPbuffer, int iBuffer ); typedef BOOL (GLAPIENTRY *PFN_wglChoosePixelFormatARB)( HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats ); -typedef HGLRC (GLAPIENTRY *PFN_wglCreateContextAttribsARB)( HDC hDC, HGLRC hShareContext, const int *attribList, HGLRC client_context ); -typedef HPBUFFERARB (GLAPIENTRY *PFN_wglCreatePbufferARB)( HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList, HPBUFFERARB client_pbuffer ); +typedef HGLRC (GLAPIENTRY *PFN_wglCreateContextAttribsARB)( HDC hDC, HGLRC hShareContext, const int *attribList ); +typedef HPBUFFERARB (GLAPIENTRY *PFN_wglCreatePbufferARB)( HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList ); typedef BOOL (GLAPIENTRY *PFN_wglDestroyPbufferARB)( HPBUFFERARB hPbuffer ); typedef void (GLAPIENTRY *PFN_wglFreeMemoryNV)( void *pointer ); typedef HDC (GLAPIENTRY *PFN_wglGetCurrentReadDCARB)(void); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10681
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/make_opengl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index d095fb70a59..4b24342ae90 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -54,9 +54,6 @@ use File::Basename; my $spec_file = "opengl32.spec"; my $wgl_file = "../../include/wine/wgl.h"; -# If set to 1, generate TRACEs for each OpenGL function -my $gen_traces = 1; - # # List of norm categories # @@ -735,7 +732,7 @@ sub generate_win_thunk($$) $ret .= " = {$params }"; $ret .= ";\n"; $ret .= " NTSTATUS status;\n"; - $ret .= " " . get_func_trace( $name, $func, 1 ) if $gen_traces; + $ret .= " " . get_func_trace( $name, $func, 1 ); $ret .= $checks; $ret .= " if ((status = UNIX_CALL( $name, &args ))) WARN( \"$name returned %#lx\\n\", status );\n"; $ret .= " return args.ret;\n" unless is_void_func($func); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10681
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/make_opengl | 45 +++------------------------------------ 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 4b24342ae90..ea49cf07a0c 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -54,18 +54,6 @@ use File::Basename; my $spec_file = "opengl32.spec"; my $wgl_file = "../../include/wine/wgl.h"; -# -# List of norm categories -# -my %cat_1_0 = ( "GL_VERSION_1_0" => 1 ); -my %cat_1_1 = ( %cat_1_0, "GL_VERSION_1_1" => 1 ); -my %cat_1_2 = ( %cat_1_1, "GL_VERSION_1_2" => 1 ); -my %cat_1_3 = ( %cat_1_2, "GL_VERSION_1_3" => 1 ); -my %cat_1_4 = ( %cat_1_3, "GL_VERSION_1_4" => 1 ); -my %cat_1_5 = ( %cat_1_4, "GL_VERSION_1_5" => 1 ); - -my %norm_categories = (); - # # This hash table gives the conversion between OpenGL types and # the .spec type and debug format @@ -838,31 +826,6 @@ sub get_arg_name($) return $name[0]->textContent(); } -# -# Extract and checks the number of arguments -# -if (@ARGV > 1) { - my $name0=$0; - $name0=~s%^.*/%%; - die "Usage: $name0 [version]\n"; -} -my $version = $ARGV[0] || "1.1"; -if ($version eq "1.0") { - %norm_categories = %cat_1_0; -} elsif ($version eq "1.1") { - %norm_categories = %cat_1_1; -} elsif ($version eq "1.2") { - %norm_categories = %cat_1_2; -} elsif ($version eq "1.3") { - %norm_categories = %cat_1_3; -} elsif ($version eq "1.4") { - %norm_categories = %cat_1_4; -} elsif ($version eq "1.5") { - %norm_categories = %cat_1_5; -} else { - die "Incorrect OpenGL version.\n"; -} - # # Fetch the registry files # @@ -881,9 +844,7 @@ chdir(dirname($0)); # # Then, create the list of all OpenGL functions using the registry -# files. This will create two hash-tables, one with all the function -# whose category matches the one listed in '@norm_categories', the other -# with all other functions. +# files. # # An element of the hash table is a reference to an array with these # elements : @@ -1284,7 +1245,7 @@ sub parse_file($) $all_enums{$enum->{name}} = $enums{$enum->{name}}; } } - next unless defined $norm_categories{$feature->{name}}; + next unless $feature->{name} =~ /^GL_VERSION_1_[01]$/; foreach my $cmd ($feature->findnodes("./require/command")) { $norm_functions{$cmd->{name}} = $functions{$cmd->{name}}; @@ -1312,7 +1273,7 @@ sub parse_file($) { next unless is_supported_api( $feature->{api} ); } - next if defined $norm_categories{$feature_name}; + next if $feature->{name} =~ /^GL_VERSION_1_[01]$/; foreach my $cmd ($feature->findnodes("./require/command")) { my $name = $cmd->{name}; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10681
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/make_opengl | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index ea49cf07a0c..01e743ec3b0 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -1111,7 +1111,7 @@ sub parse_registry($) my $alias = ""; my $number = ""; my $depth = 0; - my $api = ""; + my %apis = (); open IN, "$file" or die "cannot open $file"; @@ -1123,9 +1123,9 @@ sub parse_registry($) if ($depth == 1 and ($key) = ($line =~ /'(\w+)' : \{/)) { $name = $key; - $api = "gl" if $name =~ /^WGL_/; - $api = "glx" if $name =~ /^GLX_/; - $api = "glu" if $name =~ /^GLU_/; + $apis{"gl"} = 1 if $name =~ /^WGL_/; + $apis{"glx"} = 1 if $name =~ /^GLX_/; + $apis{"glu"} = 1 if $name =~ /^GLU_/; } $depth++ if $line =~ /\{/; @@ -1139,13 +1139,15 @@ sub parse_registry($) elsif (($key, $val) = ($line =~ /'(.*)' : (.*),/)) { $number = $val if $key =~ /(|arb|es|sc)number/; - $api = "gl" if $key =~ /^(arb)?number$/ and $api eq ""; - $api = "gles" if $key eq "esnumber" and $api eq ""; - $api = "glsc" if $key eq "scnumber" and $api eq ""; + next if defined $apis{"glx"} or defined $apis{"glu"}; + $apis{"gl"} = 1 if $key =~ /^(arb)?number$/; + $apis{"gles"} = 1 if $key eq "esnumber"; + $apis{"glsc"} = 1 if $key eq "scnumber"; } - $api = "gl" if $depth == 1 and $api eq ""; - if ($depth == 1 and is_supported_api( $api ) and is_supported_extension( $name ) and $flags =~ /public/ and $number ne "") + $apis{"gl"} = 1 if $depth == 1 and length( keys %apis ) == 0; + if ($depth == 1 and (defined $apis{"gl"} or defined $apis{"gles"}) and + is_supported_extension( $name ) and $flags =~ /public/ and $number ne "") { add_extension( $name ); @@ -1156,7 +1158,11 @@ sub parse_registry($) } } - $name = $flags = $alias = $api = $number = "" if $depth == 1; + if ($depth == 1) + { + $name = $flags = $alias = $number = ""; + %apis = (); + } } close IN; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10681
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/make_opengl | 168 +++++++++++++------------------------- 1 file changed, 59 insertions(+), 109 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 01e743ec3b0..719e05f64b5 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -869,6 +869,7 @@ my %wgl_extensions; my %wgl_functions; my %egl_extensions; my %egl_functions; +my %all_functions; my %all_enums; my %gl_types = @@ -1031,9 +1032,10 @@ my %extension_aliases = my %supported_apis = ( "gl" => 1, - "gles" => 1, "gles1" => 1, "gles2" => 1, + "wgl" => 1, + "egl" => 1, ); sub is_supported_api($) @@ -1069,7 +1071,7 @@ sub is_exposed_extension($) sub is_exposed_function($) { my $func = shift; - foreach my $ext (@{$func->[2]}) + foreach my $ext (keys %{$func->[2]}) { return 1 if is_exposed_extension($ext); } @@ -1185,21 +1187,52 @@ sub parse_registry($) } } +sub add_function($$$$) +{ + my ($name, $api, $feature, $append) = @_; + + if ($feature =~ /^WGL_VERSION_\d+_\d+/) + { + return if defined $remapped_wgl_functions{$name} and !$remapped_wgl_functions{$name}; + my $mapped = $remapped_wgl_functions{$name} || $name; + $wgl_functions{$mapped} = $all_functions{$name}; + } + elsif ($feature =~ /^EGL_VERSION_\d+_\d+/) + { + $egl_functions{$name} = $all_functions{$name}; + } + elsif ($feature =~ /^GL_VERSION_1_[01]$/) + { + $norm_functions{$name} = $all_functions{$name}; + } + elsif ($feature =~ /^GL_ES_VERSION_/) + { + return; + } + elsif (is_supported_api( $api ) and !defined $norm_functions{$name}) + { + return if defined $ext_functions{$name} and not $append; + if (!defined $ext_functions{$name}) + { + $ext_functions{$name} = [ $all_functions{$name}[0], $all_functions{$name}[1], () ]; + } + $ext_functions{$name}->[2]->{$feature} = 1; + } +} + sub parse_file($) { my $file = shift; my $xml = XML::LibXML->load_xml( location => $file ); - my %functions; my %enums; - # save all functions foreach my $command ($xml->findnodes("/registry/commands/command")) { my $proto = @{$command->findnodes("./proto")}[0]; my $name = @{$command->findnodes("./proto/name")}[0]; $proto->removeChild( $name ); my @params = $command->findnodes("./param"); - $functions{$name->textContent()} = [ $proto, \@params ]; + $all_functions{$name->textContent()} = [ $proto, \@params ]; } # save all enums @@ -1219,127 +1252,44 @@ sub parse_file($) $gl_types{$name} = $type->textContent; } - # generate norm functions - foreach my $feature ($xml->findnodes("/registry/feature")) + foreach my $feat ($xml->findnodes("/registry/feature")) { - if ($feature->{api} eq "wgl") - { - foreach my $cmd ($feature->findnodes("./require/command")) - { - my $name = $cmd->{name}; - if (defined $remapped_wgl_functions{$name}) - { - next unless $remapped_wgl_functions{$name}; - $name = $remapped_wgl_functions{$name}; - } - $wgl_functions{$name} = $functions{$cmd->{name}}; - } - foreach my $name (@extra_wgl_functions) - { - $wgl_functions{$name} = $functions{$name} if defined $functions{$name}; - } - } - elsif ($feature->{api} eq "egl") + my ($api, $feature) = ($feat->{api}, $feat->{name}); + my $compat; + + $feature =~ s/^GL_VERSION_ES_.*_(1_\d+)$/GL_ES_VERSION_$1/; + if (my ($version) = ($feature =~ /GL_ES_VERSION_(\d+_\d+)$/)) { - foreach my $cmd ($feature->findnodes("./require/command")) - { - my $name = $cmd->{name}; - $egl_functions{$name} = $functions{$cmd->{name}}; - } - foreach my $enum ($feature->findnodes("./require/enum")) - { - $all_enums{$enum->{name}} = $enums{$enum->{name}}; - } + $compat = ($version =~ /^1_/ ? "GL_NV_ES1_1" : "GL_ARB_ES" . $version); + add_extension( $compat . "_compatibility" ) if $version =~ /^1_/; } - next unless $feature->{name} =~ /^GL_VERSION_1_[01]$/; - foreach my $cmd ($feature->findnodes("./require/command")) + + foreach my $cmd ($feat->findnodes("./require/command")) { - $norm_functions{$cmd->{name}} = $functions{$cmd->{name}}; + add_function( $cmd->{name}, $api, $compat . "_compatibility", 0 ) if $compat; + add_function( $cmd->{name}, $api, $feature, 0 ); } - foreach my $enum ($feature->findnodes("./require/enum")) + + next if $api eq "wgl"; + foreach my $enum ($feat->findnodes("./require/enum")) { $all_enums{$enum->{name}} = $enums{$enum->{name}}; } } - - # generate extension functions from norm functions, if they are newer than the category - foreach my $feature ($xml->findnodes("/registry/feature")) + foreach my $name (@extra_wgl_functions) { - my $feature_name = $feature->{name}; - if ($feature_name =~ /GL_VERSION_ES_.*_1_/) - { - $feature_name = "GL_NV_ES1_1_compatibility"; - add_extension( $feature_name ); - } - elsif (my ($version) = ($feature_name =~ /GL_ES_VERSION_(.*)/)) - { - $feature_name = "GL_ARB_ES" . $version . "_compatibility"; - } - else - { - next unless is_supported_api( $feature->{api} ); - } - next if $feature->{name} =~ /^GL_VERSION_1_[01]$/; - foreach my $cmd ($feature->findnodes("./require/command")) - { - my $name = $cmd->{name}; - next if $norm_functions{$name} || $ext_functions{$name}; - $ext_functions{$name} = [ $functions{$name}[0], $functions{$name}[1], [ $feature_name ] ]; - } - foreach my $enum ($feature->findnodes("./require/enum")) - { - $all_enums{$enum->{name}} = $enums{$enum->{name}}; - } + add_function( $name, "wgl", "WGL_VERSION_1_0", 0 ); } - # generate extension functions foreach my $ext ($xml->findnodes("/registry/extensions/extension")) { - next unless is_supported_extension( $ext->{name} ); - if ($ext->{supported} eq "wgl") - { - foreach my $cmd ($ext->findnodes("./require/command")) - { - my $name = $cmd->{name}; - $ext_functions{$name} = [ $functions{$name}[0], $functions{$name}[1], [ $ext->{name} ] ]; - } - foreach my $enum ($ext->findnodes("./require/enum")) - { - $all_enums{$enum->{name}} = $enums{$enum->{name}}; - } - add_extension( $ext->{name} ); - next; - } - if ($ext->{supported} eq "egl") - { - foreach my $cmd ($ext->findnodes("./require/command")) - { - my $name = $cmd->{name}; - $ext_functions{$name} = [ $functions{$name}[0], $functions{$name}[1], [ $ext->{name} ] ]; - } - foreach my $enum ($ext->findnodes("./require/enum")) - { - $all_enums{$enum->{name}} = $enums{$enum->{name}}; - } - add_extension( $ext->{name} ); - next; - } - next unless is_supported_api( $ext->{supported} ); + next unless is_supported_extension( $ext->{name} ) and is_supported_api( $ext->{supported} ); foreach my $req ($ext->findnodes("./require")) { - next unless !$req->{api} || $req->{api} eq "gl"; + next unless ($req->{api} || "gl") eq "gl"; foreach my $cmd ($req->findnodes("./command")) { - my $name = $cmd->{name}; - next if $norm_functions{$name}; - if (!$ext_functions{$name}) - { - $ext_functions{$name} = [ $functions{$name}[0], $functions{$name}[1], [ $ext->{name} ] ]; - } - else - { - push @{$ext_functions{$name}->[2]}, $ext->{name}; - } + add_function( $cmd->{name}, $req->{api} || "gl", $ext->{name}, 1 ); } } foreach my $enum ($ext->findnodes("./require/enum")) @@ -1687,7 +1637,7 @@ foreach (sort keys %ext_functions) my $major = 0; my $minor = 0; my @exts; - foreach my $ext (@{$func->[2]}) + foreach my $ext (sort keys %{$func->[2]}) { if ($ext =~ /GL_VERSION_(\d+)_(\d+)/) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10681
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10681
participants (3)
-
Jacek Caban (@jacek) -
Rémi Bernon -
Rémi Bernon (@rbernon)