[PATCH 0/7] MR10582: opengl32: Misc simplifications to make_opengl and tests.
In preparation for GLES support. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10582
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 cc5b6b83f94..1358f2178fb 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -225,6 +225,7 @@ my %manual_unix_thunks = "wglCopyContext" => 1, "wglCreateContext" => 1, "wglCreateContextAttribsARB" => 1, + "wglCreatePbufferARB" => 1, "wglDeleteContext" => 1, "wglGetProcAddress" => 1, "wglMakeContextCurrentARB" => 1, @@ -374,17 +375,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) = @_; @@ -417,27 +407,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; } @@ -445,7 +433,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; @@ -678,8 +666,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 =~ /\*$/; @@ -716,8 +704,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 = ""; @@ -767,8 +755,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"; @@ -1453,37 +1441,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"; @@ -1714,8 +1702,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 59df91add84..31584ddb1b5 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -30385,7 +30385,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; } @@ -86687,9 +86687,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; } @@ -90109,7 +90110,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 2c0824e0268..6eb9ac516fd 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -41,6 +41,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 4adeb1a6766..12091b76797 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1599,6 +1599,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 6452ab019ed..89c3be57e53 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1470,7 +1470,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; @@ -1609,7 +1609,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 { @@ -1963,8 +1963,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; @@ -1976,17 +1976,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 ) @@ -2781,7 +2781,8 @@ static void display_funcs_init(void) display_funcs.p_wglMakeContextCurrentARB = win32u_wglMakeContextCurrentARB; register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_pbuffer" ); - 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 7b2cea0a87b..edf6fb2aae1 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -132,7 +132,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 1e39c8e988d..71fe01dd921 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/10582
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/tests/opengl.c | 238 +++++++++++++++-------------------- 1 file changed, 104 insertions(+), 134 deletions(-) diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index ed1138c8327..2000fbc3719 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -56,7 +56,8 @@ static const char *debugstr_ok( const char *cond ) t v = (r); \ ok( v op (e), "%s " f "\n", debugstr_ok( #r ), v, ##__VA_ARGS__ ); \ } while (0) -#define ok_ret( e, r ) ok_ex( r, ==, e, UINT, "%#x" ) +#define ok_ptr( r, op, e ) ok_ex( r, op, e, const void *, "%p" ) +#define ok_ret( e, r ) ok_ex( r, ==, e, UINT_PTR, "%Iu, error %ld", GetLastError() ) static NTSTATUS (WINAPI *pD3DKMTCreateDCFromMemory)( D3DKMT_CREATEDCFROMMEMORY *desc ); static NTSTATUS (WINAPI *pD3DKMTDestroyDCFromMemory)( const D3DKMT_DESTROYDCFROMMEMORY *desc ); @@ -3528,7 +3529,7 @@ static void test_copy_context(HDC hdc) ok(ret, "wglMakeCurrent failed, last error %#lx.\n", GetLastError()); } -static void test_child_window(HWND hwnd, PIXELFORMATDESCRIPTOR *pfd) +static void test_child_window( HWND hwnd, const PIXELFORMATDESCRIPTOR *pfd ) { int pixel_format; DWORD t1, t; @@ -3858,153 +3859,122 @@ static void test_memory_map( HDC hdc) START_TEST(opengl) { - HWND hwnd; - PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, /* version */ - PFD_DRAW_TO_WINDOW | - PFD_SUPPORT_OPENGL | - PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 24, /* 24-bit color depth */ - 0, 0, 0, 0, 0, 0, /* color bits */ - 0, /* alpha buffer */ - 0, /* shift bit */ - 0, /* accumulation buffer */ - 0, 0, 0, 0, /* accum bits */ - 32, /* z-buffer */ - 0, /* stencil buffer */ - 0, /* auxiliary buffer */ - PFD_MAIN_PLANE, /* main layer */ - 0, /* reserved */ - 0, 0, 0 /* layer masks */ + const PIXELFORMATDESCRIPTOR pfd = + { + .nSize = sizeof(PIXELFORMATDESCRIPTOR), + .nVersion = 1, + .dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + .iPixelType = PFD_TYPE_RGBA, + .cColorBits = 24, }; - hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW, 10, 10, 200, 200, NULL, NULL, - NULL, NULL); - ok(hwnd != NULL, "err: %ld\n", GetLastError()); - if (hwnd) + HMODULE gdi32 = GetModuleHandleA( "gdi32.dll" ); + int format, res; + HGLRC hglrc; + HWND hwnd; + HDC hdc; + + pD3DKMTCreateDCFromMemory = (void *)GetProcAddress( gdi32, "D3DKMTCreateDCFromMemory" ); + pD3DKMTDestroyDCFromMemory = (void *)GetProcAddress( gdi32, "D3DKMTDestroyDCFromMemory" ); + + hwnd = CreateWindowW( L"static", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 10, 10, 200, 200, NULL, NULL, NULL, NULL ); + ok_ptr( hwnd, !=, NULL ); + + check_gl_error( GL_INVALID_OPERATION ); + + hdc = GetDC( hwnd ); + format = ChoosePixelFormat( hdc, &pfd ); + if (!format) { - HMODULE gdi32 = GetModuleHandleA("gdi32.dll"); - HDC hdc; - int iPixelFormat, res; - HGLRC hglrc; - DWORD error; + win_skip( "Unable to find pixel format.\n" ); + goto cleanup; + } - pD3DKMTCreateDCFromMemory = (void *)GetProcAddress( gdi32, "D3DKMTCreateDCFromMemory" ); - pD3DKMTDestroyDCFromMemory = (void *)GetProcAddress( gdi32, "D3DKMTDestroyDCFromMemory" ); + hglrc = wglCreateContext( hdc ); + ok_ptr( hglrc, ==, NULL ); + ok_ret( ERROR_INVALID_PIXEL_FORMAT, GetLastError() ); + ok_ret( TRUE, SetPixelFormat( hdc, format, &pfd ) ); + ok_ptr( glGetString( GL_RENDERER ), ==, NULL ); + ok_ptr( glGetString( GL_VERSION ), ==, NULL ); + ok_ptr( glGetString( GL_VENDOR ), ==, NULL ); + + test_bitmap_rendering( TRUE ); + test_bitmap_rendering( FALSE ); + test_16bit_bitmap_rendering(); + test_d3dkmt_rendering(); + test_minimized(); + test_window_dc(); + test_message_window(); + test_dc( hwnd, hdc ); - check_gl_error( GL_INVALID_OPERATION ); - ShowWindow(hwnd, SW_SHOW); + hglrc = wglCreateContext( hdc ); + res = wglMakeCurrent( hdc, hglrc ); + ok( res, "wglMakeCurrent failed!\n" ); + if (!res) + { + skip( "Skipping OpenGL tests without a current context\n" ); + goto cleanup; + } + trace( "OpenGL renderer: %s\n", glGetString( GL_RENDERER ) ); + trace( "OpenGL driver version: %s\n", glGetString( GL_VERSION ) ); + trace( "OpenGL vendor: %s\n", glGetString( GL_VENDOR ) ); - hdc = GetDC(hwnd); + /* Initialisation of WGL functions depends on an implicit WGL context. For this reason we can't load them before making + * any WGL call :( On Wine this would work but not on real Windows because there can be different implementations (software, ICD, MCD). + */ + init_functions(); - iPixelFormat = ChoosePixelFormat(hdc, &pfd); - if(iPixelFormat == 0) - { - /* This should never happen as ChoosePixelFormat always returns a closest match, but currently this fails in Wine if we don't have glX */ - win_skip("Unable to find pixel format.\n"); - goto cleanup; - } + test_getprocaddress( hdc ); + test_deletecontext( hwnd, hdc ); + test_makecurrent( hdc ); + test_copy_context( hdc ); - /* We shouldn't be able to create a context from a hdc which doesn't have a pixel format set */ - hglrc = wglCreateContext(hdc); - ok(hglrc == NULL, "wglCreateContext should fail when no pixel format has been set, but it passed\n"); - error = GetLastError(); - ok(error == ERROR_INVALID_PIXEL_FORMAT, "expected ERROR_INVALID_PIXEL_FORMAT for wglCreateContext without a pixelformat set, but received %#lx\n", error); - - res = SetPixelFormat(hdc, iPixelFormat, &pfd); - ok(res, "SetPixelformat failed: %lx\n", GetLastError()); - - test_bitmap_rendering( TRUE ); - test_bitmap_rendering( FALSE ); - test_16bit_bitmap_rendering(); - test_d3dkmt_rendering(); - test_minimized(); - test_window_dc(); - test_message_window(); - test_dc(hwnd, hdc); - - ok(!glGetString(GL_RENDERER) && !glGetString(GL_VERSION) && !glGetString(GL_VENDOR), - "Expected NULL string when no active context is set\n"); - hglrc = wglCreateContext(hdc); - res = wglMakeCurrent(hdc, hglrc); - ok(res, "wglMakeCurrent failed!\n"); - if(res) - { - trace("OpenGL renderer: %s\n", glGetString(GL_RENDERER)); - trace("OpenGL driver version: %s\n", glGetString(GL_VERSION)); - trace("OpenGL vendor: %s\n", glGetString(GL_VENDOR)); - } - else - { - skip("Skipping OpenGL tests without a current context\n"); - return; - } + /* The lack of wglGetExtensionsStringARB in general means broken software rendering or the lack of decent OpenGL support, skip tests in such cases */ + if (!pwglGetExtensionsStringARB) + { + win_skip( "wglGetExtensionsStringARB is not available\n" ); + goto cleanup; + } - /* Initialisation of WGL functions depends on an implicit WGL context. For this reason we can't load them before making - * any WGL call :( On Wine this would work but not on real Windows because there can be different implementations (software, ICD, MCD). - */ - init_functions(); + test_choosepixelformat(); + test_choosepixelformat_flag_is_ignored_when_unset( PFD_DRAW_TO_WINDOW ); + test_choosepixelformat_flag_is_ignored_when_unset( PFD_DRAW_TO_BITMAP ); + test_choosepixelformat_flag_is_ignored_when_unset( PFD_SUPPORT_GDI ); + test_choosepixelformat_flag_is_ignored_when_unset( PFD_SUPPORT_OPENGL ); + test_wglChoosePixelFormatARB( hdc ); + test_debug_message_callback(); + test_setpixelformat( hdc ); + test_destroy( hdc ); + test_sharelists( hdc ); + test_colorbits( hdc ); + test_gdi_dbuf( hdc ); + test_acceleration( hdc ); + test_framebuffer(); + test_memory_map( hdc ); + test_gl_error( hdc ); - test_getprocaddress(hdc); - test_deletecontext(hwnd, hdc); - test_makecurrent(hdc); - test_copy_context(hdc); + wgl_extensions = pwglGetExtensionsStringARB( hdc ); + if (wgl_extensions == NULL) skip( "Skipping opengl32 tests because this OpenGL implementation " + "doesn't support WGL extensions!\n" ); - /* The lack of wglGetExtensionsStringARB in general means broken software rendering or the lack of decent OpenGL support, skip tests in such cases */ - if (!pwglGetExtensionsStringARB) - { - win_skip("wglGetExtensionsStringARB is not available\n"); - return; - } + if (strstr( wgl_extensions, "WGL_ARB_create_context" )) test_opengl3( hdc ); - test_choosepixelformat(); - test_choosepixelformat_flag_is_ignored_when_unset(PFD_DRAW_TO_WINDOW); - test_choosepixelformat_flag_is_ignored_when_unset(PFD_DRAW_TO_BITMAP); - test_choosepixelformat_flag_is_ignored_when_unset(PFD_SUPPORT_GDI); - test_choosepixelformat_flag_is_ignored_when_unset(PFD_SUPPORT_OPENGL); - test_wglChoosePixelFormatARB(hdc); - test_debug_message_callback(); - test_setpixelformat(hdc); - test_destroy(hdc); - test_sharelists(hdc); - test_colorbits(hdc); - test_gdi_dbuf(hdc); - test_acceleration(hdc); - test_framebuffer(); - test_memory_map(hdc); - test_gl_error(hdc); - - wgl_extensions = pwglGetExtensionsStringARB(hdc); - if(wgl_extensions == NULL) skip("Skipping opengl32 tests because this OpenGL implementation doesn't support WGL extensions!\n"); - - if(strstr(wgl_extensions, "WGL_ARB_create_context")) - test_opengl3(hdc); - - if(strstr(wgl_extensions, "WGL_ARB_make_current_read")) - { - test_make_current_read(hdc); - test_destroy_read(hdc); - } - else - skip("WGL_ARB_make_current_read not supported, skipping test\n"); + if (strstr( wgl_extensions, "WGL_ARB_make_current_read" )) + { + test_make_current_read( hdc ); + test_destroy_read( hdc ); + } + else skip( "WGL_ARB_make_current_read not supported, skipping test\n" ); - if(strstr(wgl_extensions, "WGL_ARB_pbuffer")) - test_pbuffers(hdc); - else - skip("WGL_ARB_pbuffer not supported, skipping pbuffer test\n"); + if (strstr( wgl_extensions, "WGL_ARB_pbuffer" )) test_pbuffers( hdc ); + else skip( "WGL_ARB_pbuffer not supported, skipping pbuffer test\n" ); - if(strstr(wgl_extensions, "WGL_EXT_swap_control")) - test_swap_control(hdc); - else - skip("WGL_EXT_swap_control not supported, skipping test\n"); + if (strstr( wgl_extensions, "WGL_EXT_swap_control" )) test_swap_control( hdc ); + else skip( "WGL_EXT_swap_control not supported, skipping test\n" ); - if (winetest_interactive) - test_child_window(hwnd, &pfd); + if (winetest_interactive) test_child_window( hwnd, &pfd ); cleanup: - ReleaseDC(hwnd, hdc); - DestroyWindow(hwnd); - } + ReleaseDC( hwnd, hdc ); + DestroyWindow( hwnd ); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10582
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/make_opengl | 7 ++++++- dlls/opengl32/unix_thunks.c | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 1358f2178fb..9f7ba6b99ce 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -1056,13 +1056,14 @@ my %extension_aliases = "GL_ARB_ES3_1_compatibility" => ["GL_NV_ES3_1_compatibility"], "GL_ARB_texture_compression" => ["GL_VERSION_1_3"], "GL_EXT_blend_equation_separate" => ["GL_ATI_blend_equation_separate"], - "GL_EXT_copy_texture" => ["GL_VERSION_1_2"], "GL_EXT_texture_cube_map_array" => ["GL_AMD_texture_cube_map_array"], "GL_EXT_texture_snorm" => ["GL_ARB_texture_snorm"], "GL_NV_gpu_program5" => ["GL_NV_gpu_program_fp64"], "GL_NV_packed_float" => ["GL_NV_packed_float_linear"], "GL_NV_texgen_reflection" => ["GL_EXT_texgen_reflection"], "GL_SGIS_texture_lod" => ["GL_EXT_texture_lod"], + "glColorSubTableEXT" => ["GL_EXT_paletted_texture"], + "glCopyTexSubImage3DEXT" => ["GL_VERSION_1_2"], "WGL_ARB_robustness_application_isolation" => ["WGL_ARB_robustness_isolation"], "WGL_NV_DX_interop" => ["WGL_NVX_DX_interop"], ); @@ -1933,6 +1934,10 @@ foreach (sort keys %ext_functions) push @exts, $alias; } } + foreach my $alias (@{$extension_aliases{$_}}) + { + push @exts, $alias; + } printf OUT " { \"%s\", \"%s\\0\", offsetof(struct opengl_funcs, p_$_) },\n", $_, join("\\0", sort @exts); } print OUT "};\n"; diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 31584ddb1b5..81a3d85bb09 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -92076,7 +92076,7 @@ const struct registry_entry extension_registry[2758] = { "glColorPointerListIBM", "GL_IBM_vertex_array_lists\0", offsetof(struct opengl_funcs, p_glColorPointerListIBM) }, { "glColorPointervINTEL", "GL_INTEL_parallel_arrays\0", offsetof(struct opengl_funcs, p_glColorPointervINTEL) }, { "glColorSubTable", "GL_ARB_imaging\0", offsetof(struct opengl_funcs, p_glColorSubTable) }, - { "glColorSubTableEXT", "GL_EXT_color_subtable\0", offsetof(struct opengl_funcs, p_glColorSubTableEXT) }, + { "glColorSubTableEXT", "GL_EXT_color_subtable\0GL_EXT_paletted_texture\0", offsetof(struct opengl_funcs, p_glColorSubTableEXT) }, { "glColorTable", "GL_ARB_imaging\0", offsetof(struct opengl_funcs, p_glColorTable) }, { "glColorTableEXT", "GL_EXT_paletted_texture\0", offsetof(struct opengl_funcs, p_glColorTableEXT) }, { "glColorTableParameterfv", "GL_ARB_imaging\0", offsetof(struct opengl_funcs, p_glColorTableParameterfv) }, @@ -92157,10 +92157,10 @@ const struct registry_entry extension_registry[2758] = { "glCopyMultiTexSubImage3DEXT", "GL_EXT_direct_state_access\0", offsetof(struct opengl_funcs, p_glCopyMultiTexSubImage3DEXT) }, { "glCopyNamedBufferSubData", "GL_ARB_direct_state_access\0GL_VERSION_4_5\0", offsetof(struct opengl_funcs, p_glCopyNamedBufferSubData) }, { "glCopyPathNV", "GL_NV_path_rendering\0", offsetof(struct opengl_funcs, p_glCopyPathNV) }, - { "glCopyTexImage1DEXT", "GL_EXT_copy_texture\0GL_VERSION_1_2\0", offsetof(struct opengl_funcs, p_glCopyTexImage1DEXT) }, - { "glCopyTexImage2DEXT", "GL_EXT_copy_texture\0GL_VERSION_1_2\0", offsetof(struct opengl_funcs, p_glCopyTexImage2DEXT) }, - { "glCopyTexSubImage1DEXT", "GL_EXT_copy_texture\0GL_VERSION_1_2\0", offsetof(struct opengl_funcs, p_glCopyTexSubImage1DEXT) }, - { "glCopyTexSubImage2DEXT", "GL_EXT_copy_texture\0GL_VERSION_1_2\0", offsetof(struct opengl_funcs, p_glCopyTexSubImage2DEXT) }, + { "glCopyTexImage1DEXT", "GL_EXT_copy_texture\0", offsetof(struct opengl_funcs, p_glCopyTexImage1DEXT) }, + { "glCopyTexImage2DEXT", "GL_EXT_copy_texture\0", offsetof(struct opengl_funcs, p_glCopyTexImage2DEXT) }, + { "glCopyTexSubImage1DEXT", "GL_EXT_copy_texture\0", offsetof(struct opengl_funcs, p_glCopyTexSubImage1DEXT) }, + { "glCopyTexSubImage2DEXT", "GL_EXT_copy_texture\0", offsetof(struct opengl_funcs, p_glCopyTexSubImage2DEXT) }, { "glCopyTexSubImage3D", "GL_VERSION_1_2\0", offsetof(struct opengl_funcs, p_glCopyTexSubImage3D) }, { "glCopyTexSubImage3DEXT", "GL_EXT_copy_texture\0GL_VERSION_1_2\0", offsetof(struct opengl_funcs, p_glCopyTexSubImage3DEXT) }, { "glCopyTextureImage1DEXT", "GL_EXT_direct_state_access\0", offsetof(struct opengl_funcs, p_glCopyTextureImage1DEXT) }, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10582
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 9f7ba6b99ce..645ece29d0f 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 # @@ -732,7 +729,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/10582
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 645ece29d0f..4e7193f623f 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 @@ -835,31 +823,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 # @@ -878,9 +841,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 : @@ -1282,7 +1243,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}}; @@ -1310,7 +1271,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/10582
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 4e7193f623f..581da035075 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -1109,7 +1109,7 @@ sub parse_registry($) my $alias = ""; my $number = ""; my $depth = 0; - my $api = ""; + my %apis = (); open IN, "$file" or die "cannot open $file"; @@ -1121,9 +1121,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 =~ /\{/; @@ -1137,13 +1137,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 ); @@ -1154,7 +1156,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/10582
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 581da035075..2f7bf4257f8 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -866,6 +866,7 @@ my %wgl_extensions; my %wgl_functions; my %egl_extensions; my %egl_functions; +my %all_functions; my %all_enums; my %gl_types = @@ -1029,9 +1030,10 @@ my %extension_aliases = my %supported_apis = ( "gl" => 1, - "gles" => 1, "gles1" => 1, "gles2" => 1, + "wgl" => 1, + "egl" => 1, ); sub is_supported_api($) @@ -1067,7 +1069,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); } @@ -1183,21 +1185,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 @@ -1217,127 +1250,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")) @@ -1890,7 +1840,7 @@ foreach (sort keys %ext_functions) next unless is_exposed_function( $ext_functions{$_} ); my $func = $ext_functions{$_}; my @exts; - foreach my $ext (@{$func->[2]}) + foreach my $ext (sort keys %{$func->[2]}) { push @exts, $ext; foreach my $alias (@{$extension_aliases{$ext}}) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10582
participants (2)
-
Rémi Bernon -
Rémi Bernon (@rbernon)