This MR extends the `wgl_pixel_format` struct with extra fields required to implement `wglGetPixelFormatAttribivARB` in opengl32.dll. I have added only fields that are relevant to the current needs of the drivers. The default implementation will be used automatically if the driver populates the extra fields, which this MR does for the winex11 driver.
The new winex11 implementation tries to remain faithful to the previous behavior in terms of error handling and fallbacks. To achieve this the `wgl_pixel_format` extra fields can be marked as invalid in order for the default implementation to return errors accordingly. Note, however, that error handling around `glXGetFBConfigAttrib` is not very consistent (e.g., the parts of `describe_pixel_format` dealing with PIXELFORMATDESCRIPTOR generally disregard errors).
The MR also adds a default implementation for `wglGetPixelFormatAttribfvARB` which piggy-backs on the integer variant of this function, and removes the need for the corresponding code in the drivers. Note that we could potentially remove this function completely from `struct opengl_funcs` (i.e., place it in `manual_win_functions` in `make_opengl`), but it seems the pattern is to maintain a complete list of extension functions (and wined3d also populates the field internally, although it doesn't seem to do anything with it).
Finally, the `winex11.drv/opengl.c` file contains a mix of coding styles. I chose to be consistent with the style of the closest context (e.g., the function) I was making changes/additions in.
-- v3: winex11: Use default wglGetPixelFormatAttribivARB implementation. winex11: Pass wgl_pixel_format to describe_pixel_format. winex11: Update describe_pixel_format coding style. opengl32: Add default implementation for wglGetPixelFormatAttribfvARB. opengl32: Add default implementation for wglGetPixelFormatAttribivARB.
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Extend the wgl_pixel_format struct with extra fields required to implement wglGetPixelFormatAttribivARB in opengl32.dll. The default implementation will be used automatically if the driver populates the extra fields. --- dlls/opengl32/make_opengl | 26 +++++ dlls/opengl32/thunks.c | 10 +- dlls/opengl32/wgl.c | 219 +++++++++++++++++++++++++++++++++++++- include/wine/wgl_driver.h | 27 ++++- 4 files changed, 271 insertions(+), 11 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index f1fddb6dcfa..42cc0c78ab3 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, + "wglGetPixelFormatAttribivARB" => 1, "wglGetProcAddress" => 1, "wglQueryCurrentRendererStringWINE" => 1, "wglQueryRendererStringWINE" => 1, @@ -884,6 +885,31 @@ print HEADER "struct wgl_pbuffer;\n\n"; print HEADER "struct wgl_pixel_format\n"; print HEADER "{\n"; print HEADER " PIXELFORMATDESCRIPTOR pfd;\n"; +print HEADER " int swap_method;\n"; +print HEADER " int transparent;\n"; +print HEADER " int pixel_type;\n"; +print HEADER " int draw_to_pbuffer;\n"; +print HEADER " int max_pbuffer_pixels;\n"; +print HEADER " int max_pbuffer_width;\n"; +print HEADER " int max_pbuffer_height;\n"; +print HEADER " int transparent_red_value;\n"; +print HEADER " int transparent_red_value_valid;\n"; +print HEADER " int transparent_green_value;\n"; +print HEADER " int transparent_green_value_valid;\n"; +print HEADER " int transparent_blue_value;\n"; +print HEADER " int transparent_blue_value_valid;\n"; +print HEADER " int transparent_alpha_value;\n"; +print HEADER " int transparent_alpha_value_valid;\n"; +print HEADER " int transparent_index_value;\n"; +print HEADER " int transparent_index_value_valid;\n"; +print HEADER " int sample_buffers;\n"; +print HEADER " int samples;\n"; +print HEADER " int bind_to_texture_rgb;\n"; +print HEADER " int bind_to_texture_rgba;\n"; +print HEADER " int bind_to_texture_rectangle_rgb;\n"; +print HEADER " int bind_to_texture_rectangle_rgba;\n"; +print HEADER " int framebuffer_srgb_capable;\n"; +print HEADER " int float_components;\n"; print HEADER "};\n\n";
print HEADER "struct opengl_funcs\n{\n"; diff --git a/dlls/opengl32/thunks.c b/dlls/opengl32/thunks.c index 49f32461de5..2bd1dd302ee 100644 --- a/dlls/opengl32/thunks.c +++ b/dlls/opengl32/thunks.c @@ -24226,15 +24226,6 @@ static BOOL WINAPI wglGetPixelFormatAttribfvARB( HDC hdc, int iPixelFormat, int return args.ret; }
-static BOOL WINAPI wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues ) -{ - struct wglGetPixelFormatAttribivARB_params args = { .teb = NtCurrentTeb(), .hdc = hdc, .iPixelFormat = iPixelFormat, .iLayerPlane = iLayerPlane, .nAttributes = nAttributes, .piAttributes = piAttributes, .piValues = piValues }; - NTSTATUS status; - TRACE( "hdc %p, iPixelFormat %d, iLayerPlane %d, nAttributes %u, piAttributes %p, piValues %p\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues ); - if ((status = UNIX_CALL( wglGetPixelFormatAttribivARB, &args ))) WARN( "wglGetPixelFormatAttribivARB returned %#lx\n", status ); - return args.ret; -} - static int WINAPI wglGetSwapIntervalEXT(void) { struct wglGetSwapIntervalEXT_params args = { .teb = NtCurrentTeb() }; @@ -24340,6 +24331,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 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 ); const void *extension_procs[] = diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 903e402d0d0..6c4e82a548f 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -322,7 +322,9 @@ static struct wgl_pixel_format *get_pixel_formats( HDC hdc, UINT *num_formats, }
if ((status = UNIX_CALL( get_pixel_formats, &args ))) goto error; - if (!(args.formats = malloc( sizeof(*args.formats) * args.num_formats ))) goto error; + /* Clear formats memory since not all drivers deal with all wgl_pixel_format + * fields at the moment. */ + if (!(args.formats = calloc( args.num_formats, sizeof(*args.formats) ))) goto error; args.max_formats = args.num_formats; if ((status = UNIX_CALL( get_pixel_formats, &args ))) goto error;
@@ -343,6 +345,153 @@ error: return NULL; }
+static BOOL wgl_attrib_uses_layer( int attrib ) +{ + switch (attrib) + { + case WGL_ACCELERATION_ARB: + case WGL_TRANSPARENT_ARB: + case WGL_SHARE_DEPTH_ARB: + case WGL_SHARE_STENCIL_ARB: + case WGL_SHARE_ACCUM_ARB: + case WGL_TRANSPARENT_RED_VALUE_ARB: + case WGL_TRANSPARENT_GREEN_VALUE_ARB: + case WGL_TRANSPARENT_BLUE_VALUE_ARB: + case WGL_TRANSPARENT_ALPHA_VALUE_ARB: + case WGL_TRANSPARENT_INDEX_VALUE_ARB: + case WGL_SUPPORT_GDI_ARB: + case WGL_SUPPORT_OPENGL_ARB: + case WGL_DOUBLE_BUFFER_ARB: + case WGL_STEREO_ARB: + case WGL_PIXEL_TYPE_ARB: + case WGL_COLOR_BITS_ARB: + case WGL_RED_BITS_ARB: + case WGL_RED_SHIFT_ARB: + case WGL_GREEN_BITS_ARB: + case WGL_GREEN_SHIFT_ARB: + case WGL_BLUE_BITS_ARB: + case WGL_BLUE_SHIFT_ARB: + case WGL_ALPHA_BITS_ARB: + case WGL_ALPHA_SHIFT_ARB: + case WGL_ACCUM_BITS_ARB: + case WGL_ACCUM_RED_BITS_ARB: + case WGL_ACCUM_GREEN_BITS_ARB: + case WGL_ACCUM_BLUE_BITS_ARB: + case WGL_ACCUM_ALPHA_BITS_ARB: + case WGL_DEPTH_BITS_ARB: + case WGL_STENCIL_BITS_ARB: + case WGL_AUX_BUFFERS_ARB: + case WGL_SAMPLE_BUFFERS_ARB: + case WGL_SAMPLES_ARB: + case WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB: + case WGL_FLOAT_COMPONENTS_NV: + return TRUE; + default: + return FALSE; + } +} + +static BOOL wgl_pixel_format_get_attrib( const struct wgl_pixel_format *fmt, int attrib, int *value ) +{ + int val = 0; + int valid = -1; + + switch (attrib) + { + case WGL_DRAW_TO_WINDOW_ARB: val = !!(fmt->pfd.dwFlags & PFD_DRAW_TO_WINDOW); break; + case WGL_DRAW_TO_BITMAP_ARB: val = !!(fmt->pfd.dwFlags & PFD_DRAW_TO_BITMAP); break; + case WGL_ACCELERATION_ARB: + if (fmt->pfd.dwFlags & PFD_GENERIC_ACCELERATED) + val = WGL_GENERIC_ACCELERATION_ARB; + else if (fmt->pfd.dwFlags & PFD_GENERIC_FORMAT) + val = WGL_NO_ACCELERATION_ARB; + else + val = WGL_FULL_ACCELERATION_ARB; + break; + case WGL_NEED_PALETTE_ARB: val = !!(fmt->pfd.dwFlags & PFD_NEED_PALETTE); break; + case WGL_NEED_SYSTEM_PALETTE_ARB: val = !!(fmt->pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE); break; + case WGL_SWAP_LAYER_BUFFERS_ARB: val = !!(fmt->pfd.dwFlags & PFD_SWAP_LAYER_BUFFERS); break; + case WGL_SWAP_METHOD_ARB: val = fmt->swap_method; break; + case WGL_NUMBER_OVERLAYS_ARB: + case WGL_NUMBER_UNDERLAYS_ARB: + /* We don't support any overlays/underlays. */ + val = 0; + break; + case WGL_TRANSPARENT_ARB: val = fmt->transparent; break; + case WGL_SHARE_DEPTH_ARB: + case WGL_SHARE_STENCIL_ARB: + case WGL_SHARE_ACCUM_ARB: + /* We support only a main plane at the moment which by definition + * shares the depth/stencil/accum buffers with itself. */ + val = GL_TRUE; + break; + case WGL_SUPPORT_GDI_ARB: val = !!(fmt->pfd.dwFlags & PFD_SUPPORT_GDI); break; + case WGL_SUPPORT_OPENGL_ARB: val = !!(fmt->pfd.dwFlags & PFD_SUPPORT_OPENGL); break; + case WGL_DOUBLE_BUFFER_ARB: val = !!(fmt->pfd.dwFlags & PFD_DOUBLEBUFFER); break; + case WGL_STEREO_ARB: val = !!(fmt->pfd.dwFlags & PFD_STEREO); break; + case WGL_PIXEL_TYPE_ARB: val = fmt->pixel_type; break; + case WGL_COLOR_BITS_ARB: val = fmt->pfd.cColorBits; break; + case WGL_RED_BITS_ARB: val = fmt->pfd.cRedBits; break; + case WGL_RED_SHIFT_ARB: val = fmt->pfd.cRedShift; break; + case WGL_GREEN_BITS_ARB: val = fmt->pfd.cGreenBits; break; + case WGL_GREEN_SHIFT_ARB: val = fmt->pfd.cGreenShift; break; + case WGL_BLUE_BITS_ARB: val = fmt->pfd.cBlueBits; break; + case WGL_BLUE_SHIFT_ARB: val = fmt->pfd.cBlueShift; break; + case WGL_ALPHA_BITS_ARB: val = fmt->pfd.cAlphaBits; break; + case WGL_ALPHA_SHIFT_ARB: val = fmt->pfd.cAlphaShift; break; + case WGL_ACCUM_BITS_ARB: val = fmt->pfd.cAccumBits; break; + case WGL_ACCUM_RED_BITS_ARB: val = fmt->pfd.cAccumRedBits; break; + case WGL_ACCUM_GREEN_BITS_ARB: val = fmt->pfd.cAccumGreenBits; break; + case WGL_ACCUM_BLUE_BITS_ARB: val = fmt->pfd.cAccumBlueBits; break; + case WGL_ACCUM_ALPHA_BITS_ARB: val = fmt->pfd.cAccumAlphaBits; break; + case WGL_DEPTH_BITS_ARB: val = fmt->pfd.cDepthBits; break; + case WGL_STENCIL_BITS_ARB: val = fmt->pfd.cStencilBits; break; + case WGL_AUX_BUFFERS_ARB: val = fmt->pfd.cAuxBuffers; break; + case WGL_DRAW_TO_PBUFFER_ARB: val = fmt->draw_to_pbuffer; break; + case WGL_MAX_PBUFFER_PIXELS_ARB: val = fmt->max_pbuffer_pixels; break; + case WGL_MAX_PBUFFER_WIDTH_ARB: val = fmt->max_pbuffer_width; break; + case WGL_MAX_PBUFFER_HEIGHT_ARB: val = fmt->max_pbuffer_height; break; + case WGL_TRANSPARENT_RED_VALUE_ARB: + val = fmt->transparent_red_value; + valid = !!fmt->transparent_red_value_valid; + break; + case WGL_TRANSPARENT_GREEN_VALUE_ARB: + val = fmt->transparent_green_value; + valid = !!fmt->transparent_green_value_valid; + break; + case WGL_TRANSPARENT_BLUE_VALUE_ARB: + val = fmt->transparent_blue_value; + valid = !!fmt->transparent_blue_value_valid; + break; + case WGL_TRANSPARENT_ALPHA_VALUE_ARB: + val = fmt->transparent_alpha_value; + valid = !!fmt->transparent_alpha_value_valid; + break; + case WGL_TRANSPARENT_INDEX_VALUE_ARB: + val = fmt->transparent_index_value; + valid = !!fmt->transparent_index_value_valid; + break; + case WGL_SAMPLE_BUFFERS_ARB: val = fmt->sample_buffers; break; + case WGL_SAMPLES_ARB: val = fmt->samples; break; + case WGL_BIND_TO_TEXTURE_RGB_ARB: val = fmt->bind_to_texture_rgb; break; + case WGL_BIND_TO_TEXTURE_RGBA_ARB: val = fmt->bind_to_texture_rgba; break; + case WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV: val = fmt->bind_to_texture_rectangle_rgb; break; + case WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV: val = fmt->bind_to_texture_rectangle_rgba; break; + case WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB: val = fmt->framebuffer_srgb_capable; break; + case WGL_FLOAT_COMPONENTS_NV: val = fmt->float_components; break; + default: + FIXME( "unsupported 0x%x WGL attribute\n", attrib ); + valid = 0; + break; + } + + /* If we haven't already determined validity, use the default check */ + if (valid == -1) valid = val != -1; + if (valid) *value = val; + + return valid; +} + INT WINAPI wglDescribePixelFormat( HDC hdc, int index, UINT size, PIXELFORMATDESCRIPTOR *ppfd ) { struct wgl_pixel_format *formats; @@ -360,6 +509,74 @@ INT WINAPI wglDescribePixelFormat( HDC hdc, int index, UINT size, PIXELFORMATDES return num_onscreen_formats; }
+/*********************************************************************** + * wglGetPixelFormatAttribivARB (OPENGL32.@) + */ +BOOL WINAPI wglGetPixelFormatAttribivARB( HDC hdc, int index, int plane, UINT count, + const int *attributes, int *values ) +{ + static const DWORD invalid_data_error = 0xC007000D; + struct wgl_pixel_format *formats; + UINT i, num_formats, num_onscreen_formats; + + TRACE( "hdc %p, index %d, plane %d, count %u, attributes %p, values %p\n", + hdc, index, plane, count, attributes, values ); + + formats = get_pixel_formats( hdc, &num_formats, &num_onscreen_formats ); + + /* If the driver doesn't yet provide ARB attrib information in + * wgl_pixel_format, fall back to an explicit call. */ + if (num_formats && !formats[0].pixel_type) + { + struct wglGetPixelFormatAttribivARB_params args = + { + .teb = NtCurrentTeb(), + .hdc = hdc, + .iPixelFormat = index, + .iLayerPlane = plane, + .nAttributes = count, + .piAttributes = attributes, + .piValues = values + }; + NTSTATUS status; + + if ((status = UNIX_CALL( wglGetPixelFormatAttribivARB, &args ))) + WARN( "wglGetPixelFormatAttribivARB returned %#lx\n", status ); + + return args.ret; + } + + if (!count) return TRUE; + if (count == 1 && attributes[0] == WGL_NUMBER_PIXEL_FORMATS_ARB) + { + values[0] = num_formats; + return TRUE; + } + if (index <= 0 || index > num_formats) + { + SetLastError( invalid_data_error ); + return FALSE; + } + + for (i = 0; i < count; ++i) + { + int attrib = attributes[i]; + + if (attrib == WGL_NUMBER_PIXEL_FORMATS_ARB) + { + values[i] = num_formats; + } + else if ((plane != 0 && wgl_attrib_uses_layer( attrib )) || + !wgl_pixel_format_get_attrib( &formats[index - 1], attrib, &values[i] )) + { + SetLastError( invalid_data_error ); + return FALSE; + } + } + + return TRUE; +} + /*********************************************************************** * wglGetPixelFormat (OPENGL32.@) */ diff --git a/include/wine/wgl_driver.h b/include/wine/wgl_driver.h index b08ab4befde..2d0c2f562ab 100644 --- a/include/wine/wgl_driver.h +++ b/include/wine/wgl_driver.h @@ -7,7 +7,7 @@ #define WINE_GLAPI #endif
-#define WINE_WGL_DRIVER_VERSION 25 +#define WINE_WGL_DRIVER_VERSION 26
struct wgl_context; struct wgl_pbuffer; @@ -15,6 +15,31 @@ struct wgl_pbuffer; struct wgl_pixel_format { PIXELFORMATDESCRIPTOR pfd; + int swap_method; + int transparent; + int pixel_type; + int draw_to_pbuffer; + int max_pbuffer_pixels; + int max_pbuffer_width; + int max_pbuffer_height; + int transparent_red_value; + int transparent_red_value_valid; + int transparent_green_value; + int transparent_green_value_valid; + int transparent_blue_value; + int transparent_blue_value_valid; + int transparent_alpha_value; + int transparent_alpha_value_valid; + int transparent_index_value; + int transparent_index_value_valid; + int sample_buffers; + int samples; + int bind_to_texture_rgb; + int bind_to_texture_rgba; + int bind_to_texture_rectangle_rgb; + int bind_to_texture_rectangle_rgba; + int framebuffer_srgb_capable; + int float_components; };
struct opengl_funcs
From: Alexandros Frantzis alexandros.frantzis@collabora.com
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<nAttributes;i++) { - pfValues[i] = attr[i]; - } - } - - free( attr ); - return ret; -} - /** * X11DRV_wglBindTexImageARB * @@ -3260,7 +3225,7 @@ static void X11DRV_WineGL_LoadExtensions(void)
register_extension( "WGL_ARB_pixel_format" ); opengl_funcs.ext.p_wglChoosePixelFormatARB = X11DRV_wglChoosePixelFormatARB; - opengl_funcs.ext.p_wglGetPixelFormatAttribfvARB = X11DRV_wglGetPixelFormatAttribfvARB; + opengl_funcs.ext.p_wglGetPixelFormatAttribfvARB = (void *)1; /* never called */ opengl_funcs.ext.p_wglGetPixelFormatAttribivARB = X11DRV_wglGetPixelFormatAttribivARB;
if (has_extension( glxExtensions, "GLX_ARB_fbconfig_float"))
From: Alexandros Frantzis alexandros.frantzis@collabora.com
--- dlls/winex11.drv/opengl.c | 221 +++++++++++++++++++------------------- 1 file changed, 112 insertions(+), 109 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index ab5c7b7776c..ff96a63b06c 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1559,126 +1559,129 @@ void destroy_gl_drawable( HWND hwnd ) */ static int describe_pixel_format( int iPixelFormat, PIXELFORMATDESCRIPTOR *ppfd ) { - /*XVisualInfo *vis;*/ - int value; - int rb,gb,bb,ab; - const struct glx_pixel_format *fmt; - - if (!has_opengl()) return 0; - - /* Look for the iPixelFormat in our list of supported formats. If it is supported we get the index in the FBConfig table and the number of supported formats back */ - fmt = get_pixel_format(gdi_display, iPixelFormat, TRUE /* Offscreen */); - if (!fmt) { - WARN("unexpected format %d\n", iPixelFormat); - return 0; - } + int value; + int rb, gb, bb, ab; + const struct glx_pixel_format *fmt;
- memset(ppfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); - ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR); - ppfd->nVersion = 1; - - /* These flags are always the same... */ - ppfd->dwFlags = PFD_SUPPORT_OPENGL; - /* Now the flags extracted from the Visual */ - - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value); - if(value & GLX_WINDOW_BIT) - ppfd->dwFlags |= PFD_DRAW_TO_WINDOW; - - /* On Windows bitmap rendering is only offered using the GDI Software renderer. We reserve some formats (see get_formats for more info) - * for bitmap rendering since we require indirect rendering for this. Further pixel format logs of a GeforceFX, Geforce8800GT, Radeon HD3400 and a - * Radeon 9000 indicated that all bitmap formats have PFD_SUPPORT_GDI. Except for 2 formats on the Radeon 9000 none of the hw accelerated formats - * offered the GDI bit either. */ - ppfd->dwFlags |= fmt->dwFlags & (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI); - - /* PFD_GENERIC_FORMAT - gdi software rendering - * PFD_GENERIC_ACCELERATED - some parts are accelerated by a display driver (MCD e.g. 3dfx minigl) - * none set - full hardware accelerated by a ICD - * - * We only set PFD_GENERIC_FORMAT on bitmap formats (see get_formats) as that's what ATI and Nvidia Windows drivers do */ - ppfd->dwFlags |= fmt->dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED); - - if (!(ppfd->dwFlags & PFD_GENERIC_FORMAT)) - ppfd->dwFlags |= PFD_SUPPORT_COMPOSITION; - - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value); - if (value) { - ppfd->dwFlags |= PFD_DOUBLEBUFFER; - ppfd->dwFlags &= ~PFD_SUPPORT_GDI; - } - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STEREO, &value); if (value) ppfd->dwFlags |= PFD_STEREO; - - /* Pixel type */ - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &value); - if (value & GLX_RGBA_BIT) - ppfd->iPixelType = PFD_TYPE_RGBA; - else - ppfd->iPixelType = PFD_TYPE_COLORINDEX; - - /* Color bits */ - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_BUFFER_SIZE, &value); - ppfd->cColorBits = value; - - /* Red, green, blue and alpha bits / shifts */ - if (ppfd->iPixelType == PFD_TYPE_RGBA) { - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_RED_SIZE, &rb); - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_GREEN_SIZE, &gb); - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_BLUE_SIZE, &bb); - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &ab); - - ppfd->cBlueBits = bb; - ppfd->cBlueShift = 0; - ppfd->cGreenBits = gb; - ppfd->cGreenShift = bb; - ppfd->cRedBits = rb; - ppfd->cRedShift = gb + bb; - ppfd->cAlphaBits = ab; - if (ab) - ppfd->cAlphaShift = rb + gb + bb; + if (!has_opengl()) return 0; + + /* Look for the iPixelFormat in our list of supported formats. If it is + * supported we get the index in the FBConfig table and the number of + * supported formats back */ + fmt = get_pixel_format( gdi_display, iPixelFormat, TRUE /* Offscreen */); + if (!fmt) + { + WARN( "unexpected format %d\n", iPixelFormat ); + return 0; + } + + memset( ppfd, 0, sizeof(PIXELFORMATDESCRIPTOR) ); + ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR); + ppfd->nVersion = 1; + + /* These flags are always the same... */ + ppfd->dwFlags = PFD_SUPPORT_OPENGL; + /* Now the flags extracted from the Visual */ + + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value ); + if (value & GLX_WINDOW_BIT) ppfd->dwFlags |= PFD_DRAW_TO_WINDOW; + + /* On Windows bitmap rendering is only offered using the GDI Software + * renderer. We reserve some formats (see get_formats for more info) for + * bitmap rendering since we require indirect rendering for this. Further + * pixel format logs of a GeforceFX, Geforce8800GT, Radeon HD3400 and a + * Radeon 9000 indicated that all bitmap formats have PFD_SUPPORT_GDI. + * Except for 2 formats on the Radeon 9000 none of the hw accelerated + * formats offered the GDI bit either. */ + ppfd->dwFlags |= fmt->dwFlags & (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI); + + /* PFD_GENERIC_FORMAT - gdi software rendering + * PFD_GENERIC_ACCELERATED - some parts are accelerated by a display driver + * (MCD e.g. 3dfx minigl) none set - full hardware accelerated by a ICD + * + * We only set PFD_GENERIC_FORMAT on bitmap formats (see get_formats) as + * that's what ATI and Nvidia Windows drivers do */ + ppfd->dwFlags |= fmt->dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED); + + if (!(ppfd->dwFlags & PFD_GENERIC_FORMAT)) ppfd->dwFlags |= PFD_SUPPORT_COMPOSITION; + + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value ); + if (value) + { + ppfd->dwFlags |= PFD_DOUBLEBUFFER; + ppfd->dwFlags &= ~PFD_SUPPORT_GDI; + } + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_STEREO, &value ); + if (value) ppfd->dwFlags |= PFD_STEREO; + + /* Pixel type */ + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &value ); + if (value & GLX_RGBA_BIT) ppfd->iPixelType = PFD_TYPE_RGBA; + else ppfd->iPixelType = PFD_TYPE_COLORINDEX; + + /* Color bits */ + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_BUFFER_SIZE, &value ); + ppfd->cColorBits = value; + + /* Red, green, blue and alpha bits / shifts */ + if (ppfd->iPixelType == PFD_TYPE_RGBA) + { + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RED_SIZE, &rb ); + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_GREEN_SIZE, &gb ); + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_BLUE_SIZE, &bb ); + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &ab ); + + ppfd->cBlueBits = bb; + ppfd->cBlueShift = 0; + ppfd->cGreenBits = gb; + ppfd->cGreenShift = bb; + ppfd->cRedBits = rb; + ppfd->cRedShift = gb + bb; + ppfd->cAlphaBits = ab; + if (ab) ppfd->cAlphaShift = rb + gb + bb; + else ppfd->cAlphaShift = 0; + } else + { + ppfd->cRedBits = 0; + ppfd->cRedShift = 0; + ppfd->cBlueBits = 0; + ppfd->cBlueShift = 0; + ppfd->cGreenBits = 0; + ppfd->cGreenShift = 0; + ppfd->cAlphaBits = 0; ppfd->cAlphaShift = 0; - } else { - ppfd->cRedBits = 0; - ppfd->cRedShift = 0; - ppfd->cBlueBits = 0; - ppfd->cBlueShift = 0; - ppfd->cGreenBits = 0; - ppfd->cGreenShift = 0; - ppfd->cAlphaBits = 0; - ppfd->cAlphaShift = 0; - } + }
- /* Accum RGBA bits */ - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ACCUM_RED_SIZE, &rb); - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ACCUM_GREEN_SIZE, &gb); - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ACCUM_BLUE_SIZE, &bb); - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ACCUM_ALPHA_SIZE, &ab); + /* Accum RGBA bits */ + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_RED_SIZE, &rb ); + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_GREEN_SIZE, &gb ); + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_BLUE_SIZE, &bb ); + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_ALPHA_SIZE, &ab );
- ppfd->cAccumBits = rb+gb+bb+ab; - ppfd->cAccumRedBits = rb; - ppfd->cAccumGreenBits = gb; - ppfd->cAccumBlueBits = bb; - ppfd->cAccumAlphaBits = ab; + ppfd->cAccumBits = rb + gb + bb + ab; + ppfd->cAccumRedBits = rb; + ppfd->cAccumGreenBits = gb; + ppfd->cAccumBlueBits = bb; + ppfd->cAccumAlphaBits = ab;
- /* Aux bits */ - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_AUX_BUFFERS, &value); - ppfd->cAuxBuffers = value; + /* Aux bits */ + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_AUX_BUFFERS, &value ); + ppfd->cAuxBuffers = value;
- /* Depth bits */ - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DEPTH_SIZE, &value); - ppfd->cDepthBits = value; + /* Depth bits */ + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DEPTH_SIZE, &value ); + ppfd->cDepthBits = value;
- /* stencil bits */ - pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STENCIL_SIZE, &value); - ppfd->cStencilBits = value; + /* stencil bits */ + pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_STENCIL_SIZE, &value ); + ppfd->cStencilBits = value;
- ppfd->iLayerType = PFD_MAIN_PLANE; + ppfd->iLayerType = PFD_MAIN_PLANE;
- if (TRACE_ON(wgl)) { - dump_PIXELFORMATDESCRIPTOR(ppfd); - } + if (TRACE_ON(wgl)) dump_PIXELFORMATDESCRIPTOR( ppfd );
- return nb_onscreen_formats; + return nb_onscreen_formats; }
From: Alexandros Frantzis alexandros.frantzis@collabora.com
--- dlls/winex11.drv/opengl.c | 132 +++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 66 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index ff96a63b06c..89176d1423a 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1553,11 +1553,11 @@ void destroy_gl_drawable( HWND hwnd )
/** - * glxdrv_DescribePixelFormat + * describe_pixel_format * - * Get the pixel-format descriptor associated to the given id + * Get the wgl_pixel_format description for the given id */ -static int describe_pixel_format( int iPixelFormat, PIXELFORMATDESCRIPTOR *ppfd ) +static int describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf ) { int value; int rb, gb, bb, ab; @@ -1575,16 +1575,16 @@ static int describe_pixel_format( int iPixelFormat, PIXELFORMATDESCRIPTOR *ppfd return 0; }
- memset( ppfd, 0, sizeof(PIXELFORMATDESCRIPTOR) ); - ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR); - ppfd->nVersion = 1; + memset( pf, 0, sizeof(*pf) ); + pf->pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); + pf->pfd.nVersion = 1;
/* These flags are always the same... */ - ppfd->dwFlags = PFD_SUPPORT_OPENGL; + pf->pfd.dwFlags = PFD_SUPPORT_OPENGL; /* Now the flags extracted from the Visual */
pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value ); - if (value & GLX_WINDOW_BIT) ppfd->dwFlags |= PFD_DRAW_TO_WINDOW; + if (value & GLX_WINDOW_BIT) pf->pfd.dwFlags |= PFD_DRAW_TO_WINDOW;
/* On Windows bitmap rendering is only offered using the GDI Software * renderer. We reserve some formats (see get_formats for more info) for @@ -1593,7 +1593,7 @@ static int describe_pixel_format( int iPixelFormat, PIXELFORMATDESCRIPTOR *ppfd * Radeon 9000 indicated that all bitmap formats have PFD_SUPPORT_GDI. * Except for 2 formats on the Radeon 9000 none of the hw accelerated * formats offered the GDI bit either. */ - ppfd->dwFlags |= fmt->dwFlags & (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI); + pf->pfd.dwFlags |= fmt->dwFlags & (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI);
/* PFD_GENERIC_FORMAT - gdi software rendering * PFD_GENERIC_ACCELERATED - some parts are accelerated by a display driver @@ -1601,56 +1601,56 @@ static int describe_pixel_format( int iPixelFormat, PIXELFORMATDESCRIPTOR *ppfd * * We only set PFD_GENERIC_FORMAT on bitmap formats (see get_formats) as * that's what ATI and Nvidia Windows drivers do */ - ppfd->dwFlags |= fmt->dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED); + pf->pfd.dwFlags |= fmt->dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED);
- if (!(ppfd->dwFlags & PFD_GENERIC_FORMAT)) ppfd->dwFlags |= PFD_SUPPORT_COMPOSITION; + if (!(pf->pfd.dwFlags & PFD_GENERIC_FORMAT)) pf->pfd.dwFlags |= PFD_SUPPORT_COMPOSITION;
pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value ); if (value) { - ppfd->dwFlags |= PFD_DOUBLEBUFFER; - ppfd->dwFlags &= ~PFD_SUPPORT_GDI; + pf->pfd.dwFlags |= PFD_DOUBLEBUFFER; + pf->pfd.dwFlags &= ~PFD_SUPPORT_GDI; } pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_STEREO, &value ); - if (value) ppfd->dwFlags |= PFD_STEREO; + if (value) pf->pfd.dwFlags |= PFD_STEREO;
/* Pixel type */ pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &value ); - if (value & GLX_RGBA_BIT) ppfd->iPixelType = PFD_TYPE_RGBA; - else ppfd->iPixelType = PFD_TYPE_COLORINDEX; + if (value & GLX_RGBA_BIT) pf->pfd.iPixelType = PFD_TYPE_RGBA; + else pf->pfd.iPixelType = PFD_TYPE_COLORINDEX;
/* Color bits */ pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_BUFFER_SIZE, &value ); - ppfd->cColorBits = value; + pf->pfd.cColorBits = value;
/* Red, green, blue and alpha bits / shifts */ - if (ppfd->iPixelType == PFD_TYPE_RGBA) + if (pf->pfd.iPixelType == PFD_TYPE_RGBA) { pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RED_SIZE, &rb ); pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_GREEN_SIZE, &gb ); pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_BLUE_SIZE, &bb ); pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &ab );
- ppfd->cBlueBits = bb; - ppfd->cBlueShift = 0; - ppfd->cGreenBits = gb; - ppfd->cGreenShift = bb; - ppfd->cRedBits = rb; - ppfd->cRedShift = gb + bb; - ppfd->cAlphaBits = ab; - if (ab) ppfd->cAlphaShift = rb + gb + bb; - else ppfd->cAlphaShift = 0; + pf->pfd.cBlueBits = bb; + pf->pfd.cBlueShift = 0; + pf->pfd.cGreenBits = gb; + pf->pfd.cGreenShift = bb; + pf->pfd.cRedBits = rb; + pf->pfd.cRedShift = gb + bb; + pf->pfd.cAlphaBits = ab; + if (ab) pf->pfd.cAlphaShift = rb + gb + bb; + else pf->pfd.cAlphaShift = 0; } else { - ppfd->cRedBits = 0; - ppfd->cRedShift = 0; - ppfd->cBlueBits = 0; - ppfd->cBlueShift = 0; - ppfd->cGreenBits = 0; - ppfd->cGreenShift = 0; - ppfd->cAlphaBits = 0; - ppfd->cAlphaShift = 0; + pf->pfd.cRedBits = 0; + pf->pfd.cRedShift = 0; + pf->pfd.cBlueBits = 0; + pf->pfd.cBlueShift = 0; + pf->pfd.cGreenBits = 0; + pf->pfd.cGreenShift = 0; + pf->pfd.cAlphaBits = 0; + pf->pfd.cAlphaShift = 0; }
/* Accum RGBA bits */ @@ -1659,27 +1659,27 @@ static int describe_pixel_format( int iPixelFormat, PIXELFORMATDESCRIPTOR *ppfd pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_BLUE_SIZE, &bb ); pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_ALPHA_SIZE, &ab );
- ppfd->cAccumBits = rb + gb + bb + ab; - ppfd->cAccumRedBits = rb; - ppfd->cAccumGreenBits = gb; - ppfd->cAccumBlueBits = bb; - ppfd->cAccumAlphaBits = ab; + pf->pfd.cAccumBits = rb + gb + bb + ab; + pf->pfd.cAccumRedBits = rb; + pf->pfd.cAccumGreenBits = gb; + pf->pfd.cAccumBlueBits = bb; + pf->pfd.cAccumAlphaBits = ab;
/* Aux bits */ pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_AUX_BUFFERS, &value ); - ppfd->cAuxBuffers = value; + pf->pfd.cAuxBuffers = value;
/* Depth bits */ pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DEPTH_SIZE, &value ); - ppfd->cDepthBits = value; + pf->pfd.cDepthBits = value;
/* stencil bits */ pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_STENCIL_SIZE, &value ); - ppfd->cStencilBits = value; + pf->pfd.cStencilBits = value;
- ppfd->iLayerType = PFD_MAIN_PLANE; + pf->pfd.iLayerType = PFD_MAIN_PLANE;
- if (TRACE_ON(wgl)) dump_PIXELFORMATDESCRIPTOR( ppfd ); + if (TRACE_ON(wgl)) dump_PIXELFORMATDESCRIPTOR( &pf->pfd );
return nb_onscreen_formats; } @@ -2523,7 +2523,7 @@ struct choose_pixel_format_arb_format { int format; int original_index; - PIXELFORMATDESCRIPTOR pfd; + struct wgl_pixel_format pf; int depth, stencil; };
@@ -2540,7 +2540,7 @@ static int compare_formats(const void *a, const void *b)
if (offscreen_a != offscreen_b) return offscreen_a - offscreen_b; - if (memcmp(&fmt_a->pfd, &fmt_b->pfd, sizeof(fmt_a->pfd))) + if (memcmp(&fmt_a->pf.pfd, &fmt_b->pf.pfd, sizeof(fmt_a->pf.pfd))) return fmt_a->original_index - fmt_b->original_index; if (fmt_a->depth != fmt_b->depth) return fmt_a->depth - fmt_b->depth; @@ -2655,16 +2655,16 @@ static BOOL X11DRV_wglChoosePixelFormatARB( HDC hdc, const int *piAttribIList, c format->format = i + 1; format->original_index = it;
- memset(&format->pfd, 0, sizeof(format->pfd)); - if (!describe_pixel_format(format->format, &format->pfd)) + memset(&format->pf, 0, sizeof(format->pf)); + if (!describe_pixel_format(format->format, &format->pf)) ERR("describe_pixel_format failed, format %d.\n", format->format);
- format->depth = format->pfd.cDepthBits; - format->stencil = format->pfd.cStencilBits; - if (!depth_bits && !(format->pfd.dwFlags & PFD_GENERIC_FORMAT)) + format->depth = format->pf.pfd.cDepthBits; + format->stencil = format->pf.pfd.cStencilBits; + if (!depth_bits && !(format->pf.pfd.dwFlags & PFD_GENERIC_FORMAT)) { - format->pfd.cDepthBits = 0; - format->pfd.cStencilBits = 0; + format->pf.pfd.cDepthBits = 0; + format->pf.pfd.cStencilBits = 0; }
++format_count; @@ -2694,7 +2694,7 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int int hTest; int tmp; int curGLXAttr = 0; - PIXELFORMATDESCRIPTOR pfd; + struct wgl_pixel_format pf;
TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues);
@@ -2711,10 +2711,10 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat); }
- if (!describe_pixel_format(iPixelFormat, &pfd)) + if (!describe_pixel_format(iPixelFormat, &pf)) { WARN("describe_pixel_format failed.\n"); - memset(&pfd, 0, sizeof(pfd)); + memset(&pf, 0, sizeof(pf)); }
for (i = 0; i < nAttributes; ++i) { @@ -2819,20 +2819,20 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int break;
case WGL_RED_SHIFT_ARB: - if (!pfd.nSize) goto pix_error; - piValues[i] = pfd.cRedShift; + if (!pf.pfd.nSize) goto pix_error; + piValues[i] = pf.pfd.cRedShift; continue; case WGL_GREEN_SHIFT_ARB: - if (!pfd.nSize) goto pix_error; - piValues[i] = pfd.cGreenShift; + if (!pf.pfd.nSize) goto pix_error; + piValues[i] = pf.pfd.cGreenShift; continue; case WGL_BLUE_SHIFT_ARB: - if (!pfd.nSize) goto pix_error; - piValues[i] = pfd.cBlueShift; + if (!pf.pfd.nSize) goto pix_error; + piValues[i] = pf.pfd.cBlueShift; continue; case WGL_ALPHA_SHIFT_ARB: - if (!pfd.nSize) goto pix_error; - piValues[i] = pfd.cAlphaShift; + if (!pf.pfd.nSize) goto pix_error; + piValues[i] = pf.pfd.cAlphaShift; continue;
case WGL_SUPPORT_GDI_ARB: @@ -3413,7 +3413,7 @@ static void glxdrv_get_pixel_formats( struct wgl_pixel_format *formats, if (formats) { for (i = 0; i < min( max_formats, nb_pixel_formats ); ++i) - describe_pixel_format( i + 1, &formats[i].pfd ); + describe_pixel_format( i + 1, &formats[i] ); } *num_formats = nb_pixel_formats; *num_onscreen_formats = nb_onscreen_formats;
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Populate all the ARB related fields of advertised pixel formats, so that the default implementation of wglGetPixelFormatAttribivARB (in opengl32) will be used to get the pixel format attributes. --- dlls/winex11.drv/opengl.c | 373 ++++++++------------------------------ 1 file changed, 79 insertions(+), 294 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 89176d1423a..3979d31a334 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1559,7 +1559,7 @@ void destroy_gl_drawable( HWND hwnd ) */ static int describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf ) { - int value; + int value, drawable_type = 0, render_type = 0; int rb, gb, bb, ab; const struct glx_pixel_format *fmt;
@@ -1575,6 +1575,10 @@ static int describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf return 0; }
+ /* If we can't get basic information, there is no point continuing */ + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &drawable_type )) return 0; + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &render_type )) return 0; + memset( pf, 0, sizeof(*pf) ); pf->pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pf->pfd.nVersion = 1; @@ -1583,8 +1587,7 @@ static int describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf pf->pfd.dwFlags = PFD_SUPPORT_OPENGL; /* Now the flags extracted from the Visual */
- pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value ); - if (value & GLX_WINDOW_BIT) pf->pfd.dwFlags |= PFD_DRAW_TO_WINDOW; + if (drawable_type & GLX_WINDOW_BIT) pf->pfd.dwFlags |= PFD_DRAW_TO_WINDOW;
/* On Windows bitmap rendering is only offered using the GDI Software * renderer. We reserve some formats (see get_formats for more info) for @@ -1615,8 +1618,7 @@ static int describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf if (value) pf->pfd.dwFlags |= PFD_STEREO;
/* Pixel type */ - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &value ); - if (value & GLX_RGBA_BIT) pf->pfd.iPixelType = PFD_TYPE_RGBA; + if (render_type & GLX_RGBA_BIT) pf->pfd.iPixelType = PFD_TYPE_RGBA; else pf->pfd.iPixelType = PFD_TYPE_COLORINDEX;
/* Color bits */ @@ -1679,6 +1681,77 @@ static int describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf
pf->pfd.iLayerType = PFD_MAIN_PLANE;
+ if (!has_swap_method) pf->swap_method = WGL_SWAP_EXCHANGE_ARB; + else if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_SWAP_METHOD_OML, &value )) + { + switch (value) { + case GLX_SWAP_EXCHANGE_OML: pf->swap_method = WGL_SWAP_EXCHANGE_ARB; break; + case GLX_SWAP_COPY_OML: pf->swap_method = WGL_SWAP_COPY_ARB; break; + case GLX_SWAP_UNDEFINED_OML: pf->swap_method = WGL_SWAP_UNDEFINED_ARB; break; + default: { ERR( "Unexpected swap method %x.\n", value ); pf->swap_method = -1; break; } + } + } + else pf->swap_method = -1; + + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_TYPE, &value) ) pf->transparent = -1; + else pf->transparent = value != GLX_NONE; + + if (render_type & GLX_RGBA_BIT) pf->pixel_type = WGL_TYPE_RGBA_ARB; + else if (render_type & GLX_COLOR_INDEX_BIT) pf->pixel_type = WGL_TYPE_COLORINDEX_ARB; + else if (render_type & GLX_RGBA_FLOAT_BIT) pf->pixel_type = WGL_TYPE_RGBA_FLOAT_ATI; + else if (render_type & GLX_RGBA_FLOAT_ATI_BIT) pf->pixel_type = WGL_TYPE_RGBA_FLOAT_ATI; + else if (render_type & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) pf->pixel_type = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT; + else { ERR( "unexpected RenderType(%x)\n", render_type ); pf->pixel_type = -1; } + + pf->draw_to_pbuffer = (drawable_type & GLX_PBUFFER_BIT) ? GL_TRUE : GL_FALSE; + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_MAX_PBUFFER_PIXELS, &value )) value = -1; + pf->max_pbuffer_pixels = value; + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_MAX_PBUFFER_WIDTH, &value )) value = -1; + pf->max_pbuffer_width = value; + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_MAX_PBUFFER_HEIGHT, &value )) value = -1; + pf->max_pbuffer_height = value; + + if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_RED_VALUE, &value )) + { + pf->transparent_red_value_valid = GL_TRUE; + pf->transparent_red_value = value; + } + if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &value )) + { + pf->transparent_green_value_valid = GL_TRUE; + pf->transparent_green_value = value; + } + if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &value )) + { + pf->transparent_blue_value_valid = GL_TRUE; + pf->transparent_blue_value = value; + } + if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &value )) + { + pf->transparent_alpha_value_valid = GL_TRUE; + pf->transparent_alpha_value = value; + } + if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &value )) + { + pf->transparent_index_value_valid = GL_TRUE; + pf->transparent_index_value = value; + } + + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_SAMPLE_BUFFERS_ARB, &value )) value = -1; + pf->sample_buffers = value; + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_SAMPLES_ARB, &value )) value = -1; + pf->samples = value; + + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, &value )) value = -1; + pf->framebuffer_srgb_capable = value; + + pf->bind_to_texture_rgb = pf->bind_to_texture_rgba = + use_render_texture_emulation && render_type != GLX_COLOR_INDEX_BIT && (render_type & GLX_PBUFFER_BIT); + pf->bind_to_texture_rectangle_rgb = pf->bind_to_texture_rectangle_rgba = GL_FALSE; + + if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_FLOAT_COMPONENTS_NV, &value )) value = -1; + pf->float_components = value; + if (TRACE_ON(wgl)) dump_PIXELFORMATDESCRIPTOR( &pf->pfd );
return nb_onscreen_formats; @@ -2681,294 +2754,6 @@ static BOOL X11DRV_wglChoosePixelFormatARB( HDC hdc, const int *piAttribIList, c return GL_TRUE; }
-/** - * X11DRV_wglGetPixelFormatAttribivARB - * - * WGL_ARB_pixel_format: wglGetPixelFormatAttribivARB - */ -static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int iLayerPlane, - UINT nAttributes, const int *piAttributes, int *piValues ) -{ - UINT i; - const struct glx_pixel_format *fmt; - int hTest; - int tmp; - int curGLXAttr = 0; - struct wgl_pixel_format pf; - - TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues); - - if (0 < iLayerPlane) { - FIXME("unsupported iLayerPlane(%d) > 0, returns FALSE\n", iLayerPlane); - return GL_FALSE; - } - - /* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supported. - * We don't have to fail yet as a program can specify an invalid iPixelFormat (lets say 0) if it wants to query - * the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */ - fmt = get_pixel_format(gdi_display, iPixelFormat, TRUE /* Offscreen */); - if(!fmt) { - WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat); - } - - if (!describe_pixel_format(iPixelFormat, &pf)) - { - WARN("describe_pixel_format failed.\n"); - memset(&pf, 0, sizeof(pf)); - } - - for (i = 0; i < nAttributes; ++i) { - const int curWGLAttr = piAttributes[i]; - TRACE("pAttr[%d] = %x\n", i, curWGLAttr); - - switch (curWGLAttr) { - case WGL_NUMBER_PIXEL_FORMATS_ARB: - piValues[i] = nb_pixel_formats; - continue; - - case WGL_SUPPORT_OPENGL_ARB: - piValues[i] = GL_TRUE; - continue; - - case WGL_ACCELERATION_ARB: - curGLXAttr = GLX_CONFIG_CAVEAT; - if (!fmt) goto pix_error; - if(fmt->dwFlags & PFD_GENERIC_FORMAT) - piValues[i] = WGL_NO_ACCELERATION_ARB; - else if(fmt->dwFlags & PFD_GENERIC_ACCELERATED) - piValues[i] = WGL_GENERIC_ACCELERATION_ARB; - else - piValues[i] = WGL_FULL_ACCELERATION_ARB; - continue; - - case WGL_TRANSPARENT_ARB: - curGLXAttr = GLX_TRANSPARENT_TYPE; - if (!fmt) goto pix_error; - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, &tmp); - if (hTest) goto get_error; - piValues[i] = GL_FALSE; - if (GLX_NONE != tmp) piValues[i] = GL_TRUE; - continue; - - case WGL_PIXEL_TYPE_ARB: - curGLXAttr = GLX_RENDER_TYPE; - if (!fmt) goto pix_error; - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, &tmp); - if (hTest) goto get_error; - TRACE("WGL_PIXEL_TYPE_ARB: GLX_RENDER_TYPE = 0x%x\n", tmp); - if (tmp & GLX_RGBA_BIT) { piValues[i] = WGL_TYPE_RGBA_ARB; } - else if (tmp & GLX_COLOR_INDEX_BIT) { piValues[i] = WGL_TYPE_COLORINDEX_ARB; } - else if (tmp & GLX_RGBA_FLOAT_BIT) { piValues[i] = WGL_TYPE_RGBA_FLOAT_ATI; } - else if (tmp & GLX_RGBA_FLOAT_ATI_BIT) { piValues[i] = WGL_TYPE_RGBA_FLOAT_ATI; } - else if (tmp & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) { piValues[i] = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT; } - else { - ERR("unexpected RenderType(%x)\n", tmp); - piValues[i] = WGL_TYPE_RGBA_ARB; - } - continue; - - case WGL_COLOR_BITS_ARB: - curGLXAttr = GLX_BUFFER_SIZE; - break; - - case WGL_BIND_TO_TEXTURE_RGB_ARB: - case WGL_BIND_TO_TEXTURE_RGBA_ARB: - if (!use_render_texture_emulation) { - piValues[i] = GL_FALSE; - continue; - } - curGLXAttr = GLX_RENDER_TYPE; - if (!fmt) goto pix_error; - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, &tmp); - if (hTest) goto get_error; - if (GLX_COLOR_INDEX_BIT == tmp) { - piValues[i] = GL_FALSE; - continue; - } - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &tmp); - if (hTest) goto get_error; - piValues[i] = (tmp & GLX_PBUFFER_BIT) ? GL_TRUE : GL_FALSE; - continue; - - case WGL_BLUE_BITS_ARB: - curGLXAttr = GLX_BLUE_SIZE; - break; - case WGL_RED_BITS_ARB: - curGLXAttr = GLX_RED_SIZE; - break; - case WGL_GREEN_BITS_ARB: - curGLXAttr = GLX_GREEN_SIZE; - break; - case WGL_ALPHA_BITS_ARB: - curGLXAttr = GLX_ALPHA_SIZE; - break; - case WGL_DEPTH_BITS_ARB: - curGLXAttr = GLX_DEPTH_SIZE; - break; - case WGL_STENCIL_BITS_ARB: - curGLXAttr = GLX_STENCIL_SIZE; - break; - case WGL_DOUBLE_BUFFER_ARB: - curGLXAttr = GLX_DOUBLEBUFFER; - break; - case WGL_STEREO_ARB: - curGLXAttr = GLX_STEREO; - break; - case WGL_AUX_BUFFERS_ARB: - curGLXAttr = GLX_AUX_BUFFERS; - break; - - case WGL_RED_SHIFT_ARB: - if (!pf.pfd.nSize) goto pix_error; - piValues[i] = pf.pfd.cRedShift; - continue; - case WGL_GREEN_SHIFT_ARB: - if (!pf.pfd.nSize) goto pix_error; - piValues[i] = pf.pfd.cGreenShift; - continue; - case WGL_BLUE_SHIFT_ARB: - if (!pf.pfd.nSize) goto pix_error; - piValues[i] = pf.pfd.cBlueShift; - continue; - case WGL_ALPHA_SHIFT_ARB: - if (!pf.pfd.nSize) goto pix_error; - piValues[i] = pf.pfd.cAlphaShift; - continue; - - case WGL_SUPPORT_GDI_ARB: - if (!fmt) goto pix_error; - piValues[i] = (fmt->dwFlags & PFD_SUPPORT_GDI) != 0; - continue; - - case WGL_DRAW_TO_BITMAP_ARB: - if (!fmt) goto pix_error; - piValues[i] = (fmt->dwFlags & PFD_DRAW_TO_BITMAP) != 0; - continue; - - case WGL_DRAW_TO_WINDOW_ARB: - case WGL_DRAW_TO_PBUFFER_ARB: - if (!fmt) goto pix_error; - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &tmp); - if (hTest) goto get_error; - if((curWGLAttr == WGL_DRAW_TO_WINDOW_ARB && (tmp&GLX_WINDOW_BIT)) || - (curWGLAttr == WGL_DRAW_TO_PBUFFER_ARB && (tmp&GLX_PBUFFER_BIT))) - piValues[i] = GL_TRUE; - else - piValues[i] = GL_FALSE; - continue; - - case WGL_SWAP_METHOD_ARB: - if (has_swap_method) - { - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_SWAP_METHOD_OML, &tmp); - if (hTest) goto get_error; - switch (tmp) - { - case GLX_SWAP_EXCHANGE_OML: - piValues[i] = WGL_SWAP_EXCHANGE_ARB; - break; - case GLX_SWAP_COPY_OML: - piValues[i] = WGL_SWAP_COPY_ARB; - break; - case GLX_SWAP_UNDEFINED_OML: - piValues[i] = WGL_SWAP_UNDEFINED_ARB; - break; - default: - ERR("Unexpected swap method %x.\n", tmp); - } - } - else - { - WARN("GLX_OML_swap_method not supported, returning WGL_SWAP_EXCHANGE_ARB.\n"); - piValues[i] = WGL_SWAP_EXCHANGE_ARB; - } - continue; - - case WGL_PBUFFER_LARGEST_ARB: - curGLXAttr = GLX_LARGEST_PBUFFER; - break; - - case WGL_SAMPLE_BUFFERS_ARB: - curGLXAttr = GLX_SAMPLE_BUFFERS_ARB; - break; - - case WGL_SAMPLES_ARB: - curGLXAttr = GLX_SAMPLES_ARB; - break; - - case WGL_FLOAT_COMPONENTS_NV: - curGLXAttr = GLX_FLOAT_COMPONENTS_NV; - break; - - case WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT: - curGLXAttr = GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT; - break; - - case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT: - curGLXAttr = GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT; - break; - - case WGL_ACCUM_RED_BITS_ARB: - curGLXAttr = GLX_ACCUM_RED_SIZE; - break; - case WGL_ACCUM_GREEN_BITS_ARB: - curGLXAttr = GLX_ACCUM_GREEN_SIZE; - break; - case WGL_ACCUM_BLUE_BITS_ARB: - curGLXAttr = GLX_ACCUM_BLUE_SIZE; - break; - case WGL_ACCUM_ALPHA_BITS_ARB: - curGLXAttr = GLX_ACCUM_ALPHA_SIZE; - break; - case WGL_ACCUM_BITS_ARB: - if (!fmt) goto pix_error; - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ACCUM_RED_SIZE, &tmp); - if (hTest) goto get_error; - piValues[i] = tmp; - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ACCUM_GREEN_SIZE, &tmp); - if (hTest) goto get_error; - piValues[i] += tmp; - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ACCUM_BLUE_SIZE, &tmp); - if (hTest) goto get_error; - piValues[i] += tmp; - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ACCUM_ALPHA_SIZE, &tmp); - if (hTest) goto get_error; - piValues[i] += tmp; - continue; - - default: - FIXME("unsupported %x WGL Attribute\n", curWGLAttr); - } - - /* Retrieve a GLX FBConfigAttrib when the attribute to query is valid and - * iPixelFormat != 0. When iPixelFormat is 0 the only value which makes - * sense to query is WGL_NUMBER_PIXEL_FORMATS_ARB. - * - * TODO: properly test the behavior of wglGetPixelFormatAttrib*v on Windows - * and check which options can work using iPixelFormat=0 and which not. - * A problem would be that this function is an extension. This would - * mean that the behavior could differ between different vendors (ATI, Nvidia, ..). - */ - if (0 != curGLXAttr && iPixelFormat != 0) { - if (!fmt) goto pix_error; - hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, piValues + i); - if (hTest) goto get_error; - curGLXAttr = 0; - } else { - piValues[i] = GL_FALSE; - } - } - return GL_TRUE; - -get_error: - ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc, curGLXAttr); - return GL_FALSE; - -pix_error: - ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc, iPixelFormat, nb_pixel_formats); - return GL_FALSE; -} - /** * X11DRV_wglBindTexImageARB * @@ -3229,7 +3014,7 @@ static void X11DRV_WineGL_LoadExtensions(void) register_extension( "WGL_ARB_pixel_format" ); opengl_funcs.ext.p_wglChoosePixelFormatARB = X11DRV_wglChoosePixelFormatARB; opengl_funcs.ext.p_wglGetPixelFormatAttribfvARB = (void *)1; /* never called */ - opengl_funcs.ext.p_wglGetPixelFormatAttribivARB = X11DRV_wglGetPixelFormatAttribivARB; + opengl_funcs.ext.p_wglGetPixelFormatAttribivARB = (void *)1; /* never called */
if (has_extension( glxExtensions, "GLX_ARB_fbconfig_float")) {
On Wed Jun 19 07:18:23 2024 +0000, Rémi Bernon wrote:
if (!count) return TRUE; if (count == 1 && attributes[0] == WGL_NUMBER_PIXEL_FORMATS_ARB) { values[0] = num_formats; return TRUE; } if (index <= 0 || index > num_formats) { SetLastError( invalid_data_error ); return FALSE; }
Sorry, I used GL_ prefixed constants in my suggestion, but I think it's better to use the same constants everywhere in this function. As the return type is BOOL and not GLboolean, I'd suggest to use TRUE/FALSE instead.
Ack, updated in v3.
On Wed Jun 19 07:18:24 2024 +0000, Rémi Bernon wrote:
switch (value) { case GLX_SWAP_EXCHANGE_OML: pf->swap_method = WGL_SWAP_EXCHANGE_ARB; break; case GLX_SWAP_COPY_OML: pf->swap_method = WGL_SWAP_COPY_ARB; break; case GLX_SWAP_UNDEFINED_OML: pf->swap_method = WGL_SWAP_UNDEFINED_ARB; break; default: ERR( "Unexpected swap method %x.\n", value ); pf->swap_method = 0; break; }
Then, should this be `swap_method = -1` maybe? Or use `WGL_SWAP_EXCHANGE_ARB` as a default?
In the unexpected value cases for `swap_method` and `pixel_type` I tried to maintain the existing winex11 behavior (`swap_method` value was not set at all, `pixel_type` defaulted to RGBA), since I wasn't sure if this behavior was on purpose (possibly as a workaround for some driver?), although my guess is that this a scenario we don't ever expect in practice and we want to do something somewhat reasonable "just in case". Another possible reason would be future-proofing, e.g., new values for the GLX attributes in extensions.
If we are not concerned about maintaining the existing behavior, my preference is to set to `-1` to make driver brokenness (or the fact that we are not handling a new value) more explicit, and I have changed v3 accordingly. If we find that we do in fact want to work around misbehaving GL(X) drivers we can always revisit to handle new values, use defaults or not expose problematic formats to WGL at all.
On Wed Jun 19 11:26:19 2024 +0000, Alexandros Frantzis wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/5844/diffs?diff_id=118581&start_sha=760a03b2211a285fbf4c77cd91508653bfd5717b#37d83fe5f345d9f4061a00daee669514c12850b5_1704_1704)
I have changed this to `-1` in v3 (also see comment about `swap_method`).
v3: * Mark `wgl_pixel_format` `swap_method` and `pixel_type` as invalid if the corresponding GLX value is not handled. * Some updates/fixes to the list of attributes that depend on the layer plane. * Use `BOOL` values instead of `GLboolean` values as needed.
This merge request was approved by Rémi Bernon.