From 3ecd3ff8532ed7e0db5361f9ce5b17077fb887da Mon Sep 17 00:00:00 2001 From: Alexandros Frantzis Date: Wed, 12 Jun 2024 11:26:55 +0300 Subject: [PATCH] opengl32: Add default implementation for wglGetPixelFormatAttribfvARB. The default implementation is always used, and never calls the driver implementation of this function, so we can remove all the driver implementations. --- dlls/opengl32/make_opengl | 1 + dlls/opengl32/thunks.c | 10 +--------- dlls/opengl32/wgl.c | 28 ++++++++++++++++++++++++++ dlls/winemac.drv/opengl.c | 41 +-------------------------------------- dlls/winex11.drv/opengl.c | 37 +---------------------------------- 5 files changed, 32 insertions(+), 85 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 42cc0c78ab3..771793b9049 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -181,6 +181,7 @@ my %manual_win_thunks = "wglGetExtensionsStringARB" => 1, "wglGetExtensionsStringEXT" => 1, "wglGetPixelFormat" => 1, + "wglGetPixelFormatAttribfvARB" => 1, "wglGetPixelFormatAttribivARB" => 1, "wglGetProcAddress" => 1, "wglQueryCurrentRendererStringWINE" => 1, diff --git a/dlls/opengl32/thunks.c b/dlls/opengl32/thunks.c index 2bd1dd302ee..3ee1776daef 100644 --- a/dlls/opengl32/thunks.c +++ b/dlls/opengl32/thunks.c @@ -24217,15 +24217,6 @@ static HDC WINAPI wglGetPbufferDCARB( HPBUFFERARB hPbuffer ) return args.ret; } -static BOOL WINAPI wglGetPixelFormatAttribfvARB( HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues ) -{ - struct wglGetPixelFormatAttribfvARB_params args = { .teb = NtCurrentTeb(), .hdc = hdc, .iPixelFormat = iPixelFormat, .iLayerPlane = iLayerPlane, .nAttributes = nAttributes, .piAttributes = piAttributes, .pfValues = pfValues }; - NTSTATUS status; - TRACE( "hdc %p, iPixelFormat %d, iLayerPlane %d, nAttributes %u, piAttributes %p, pfValues %p\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, pfValues ); - if ((status = UNIX_CALL( wglGetPixelFormatAttribfvARB, &args ))) WARN( "wglGetPixelFormatAttribfvARB returned %#lx\n", status ); - return args.ret; -} - static int WINAPI wglGetSwapIntervalEXT(void) { struct wglGetSwapIntervalEXT_params args = { .teb = NtCurrentTeb() }; @@ -24331,6 +24322,7 @@ extern GLboolean WINAPI glUnmapNamedBufferEXT( GLuint buffer ); extern HDC WINAPI wglGetCurrentReadDCARB(void); extern const char * WINAPI wglGetExtensionsStringARB( HDC hdc ); extern const char * WINAPI wglGetExtensionsStringEXT(void); +extern BOOL WINAPI wglGetPixelFormatAttribfvARB( HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues ); extern BOOL WINAPI wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues ); extern const GLchar * WINAPI wglQueryCurrentRendererStringWINE( GLenum attribute ); extern const GLchar * WINAPI wglQueryRendererStringWINE( HDC dc, GLint renderer, GLenum attribute ); diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 6c4e82a548f..2ae79a56f9e 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -577,6 +577,34 @@ BOOL WINAPI wglGetPixelFormatAttribivARB( HDC hdc, int index, int plane, UINT co return TRUE; } +/*********************************************************************** + * wglGetPixelFormatAttribfvARB (OPENGL32.@) + */ +BOOL WINAPI wglGetPixelFormatAttribfvARB( HDC hdc, int index, int plane, UINT count, + const int *attributes, FLOAT *values ) +{ + int *ivalues; + BOOL ret; + UINT i; + + TRACE( "hdc %p, index %d, plane %d, count %u, attributes %p, values %p\n", + hdc, index, plane, count, attributes, values ); + + if (!(ivalues = malloc( count * sizeof(int) ))) return FALSE; + + /* For now we can piggy-back on wglGetPixelFormatAttribivARB, since we don't support + * any non-integer attributes. */ + ret = wglGetPixelFormatAttribivARB( hdc, index, plane, count, attributes, ivalues ); + if (ret) + { + for (i = 0; i < count; i++) + values[i] = ivalues[i]; + } + + free( ivalues ); + return ret; +} + /*********************************************************************** * wglGetPixelFormat (OPENGL32.@) */ diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index a614a5b076b..90e99844d4c 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -3391,45 +3391,6 @@ invalid_layer: } -/********************************************************************** - * macdrv_wglGetPixelFormatAttribfvARB - * - * WGL_ARB_pixel_format: wglGetPixelFormatAttribfvARB - */ -static BOOL macdrv_wglGetPixelFormatAttribfvARB(HDC hdc, int iPixelFormat, int iLayerPlane, - UINT nAttributes, const int *piAttributes, FLOAT *pfValues) -{ - int *attr; - int ret; - - TRACE("hdc %p iPixelFormat %d iLayerPlane %d nAttributes %u piAttributes %p pfValues %p\n", - hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, pfValues); - - /* Allocate a temporary array to store integer values */ - attr = malloc(nAttributes * sizeof(int)); - if (!attr) - { - ERR("couldn't allocate %d array\n", nAttributes); - return GL_FALSE; - } - - /* Piggy-back on wglGetPixelFormatAttribivARB */ - ret = macdrv_wglGetPixelFormatAttribivARB(hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, attr); - if (ret) - { - UINT i; - - /* Convert integer values to float. Should also check for attributes - that can give decimal values here */ - for (i = 0; i < nAttributes; i++) - pfValues[i] = attr[i]; - } - - free(attr); - return ret; -} - - /********************************************************************** * macdrv_wglGetSwapIntervalEXT * @@ -4136,7 +4097,7 @@ static void load_extensions(void) register_extension("WGL_ARB_pixel_format"); opengl_funcs.ext.p_wglChoosePixelFormatARB = macdrv_wglChoosePixelFormatARB; - opengl_funcs.ext.p_wglGetPixelFormatAttribfvARB = macdrv_wglGetPixelFormatAttribfvARB; + opengl_funcs.ext.p_wglGetPixelFormatAttribfvARB = (void *)1; /* never called */ opengl_funcs.ext.p_wglGetPixelFormatAttribivARB = macdrv_wglGetPixelFormatAttribivARB; if (gluCheckExtension((GLubyte*)"GL_ARB_color_buffer_float", (GLubyte*)gl_info.glExtensions)) diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 09105a8c842..ab5c7b7776c 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -2966,41 +2966,6 @@ pix_error: return GL_FALSE; } -/** - * X11DRV_wglGetPixelFormatAttribfvARB - * - * WGL_ARB_pixel_format: wglGetPixelFormatAttribfvARB - */ -static BOOL X11DRV_wglGetPixelFormatAttribfvARB( HDC hdc, int iPixelFormat, int iLayerPlane, - UINT nAttributes, const int *piAttributes, FLOAT *pfValues ) -{ - int *attr; - int ret; - UINT i; - - TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, pfValues); - - /* Allocate a temporary array to store integer values */ - attr = malloc( nAttributes * sizeof(int) ); - if (!attr) { - ERR("couldn't allocate %d array\n", nAttributes); - return GL_FALSE; - } - - /* Piggy-back on wglGetPixelFormatAttribivARB */ - ret = X11DRV_wglGetPixelFormatAttribivARB(hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, attr); - if (ret) { - /* Convert integer values to float. Should also check for attributes - that can give decimal values here */ - for (i=0; i