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