From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 148 ++++++++++++++++++++-------------- dlls/wineandroid.drv/opengl.c | 120 +++++++++++++-------------- dlls/winemac.drv/opengl.c | 48 +++++------ dlls/winewayland.drv/opengl.c | 42 +++++----- dlls/winex11.drv/opengl.c | 55 +++++-------- include/wine/opengl_driver.h | 2 + 6 files changed, 201 insertions(+), 214 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 36db698edae..9686f64ab2b 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -41,6 +41,59 @@ WINE_DEFAULT_DEBUG_CHANNEL(wgl);
static struct opengl_funcs *get_dc_funcs( HDC hdc, void *null_funcs );
+static const struct +{ + BYTE color_bits; + BYTE red_bits, red_shift; + BYTE green_bits, green_shift; + BYTE blue_bits, blue_shift; + BYTE alpha_bits, alpha_shift; + BYTE accum_bits; + BYTE depth_bits; + BYTE stencil_bits; +} pixel_formats[] = +{ + { 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 32, 8 }, + { 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 16, 8 }, + { 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 32, 8 }, + { 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 16, 8 }, + { 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 32, 8 }, + { 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 16, 8 }, + { 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 32, 8 }, + { 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 16, 8 }, + { 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 32, 8 }, + { 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 16, 8 }, + { 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 32, 8 }, + { 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 16, 8 }, +}; + +static void describe_pixel_format( int fmt, PIXELFORMATDESCRIPTOR *descr ) +{ + memset( descr, 0, sizeof(*descr) ); + descr->nSize = sizeof(*descr); + descr->nVersion = 1; + descr->dwFlags = PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_GENERIC_FORMAT; + descr->iPixelType = PFD_TYPE_RGBA; + descr->cColorBits = pixel_formats[fmt - 1].color_bits; + descr->cRedBits = pixel_formats[fmt - 1].red_bits; + descr->cRedShift = pixel_formats[fmt - 1].red_shift; + descr->cGreenBits = pixel_formats[fmt - 1].green_bits; + descr->cGreenShift = pixel_formats[fmt - 1].green_shift; + descr->cBlueBits = pixel_formats[fmt - 1].blue_bits; + descr->cBlueShift = pixel_formats[fmt - 1].blue_shift; + descr->cAlphaBits = pixel_formats[fmt - 1].alpha_bits; + descr->cAlphaShift = pixel_formats[fmt - 1].alpha_shift; + descr->cAccumBits = pixel_formats[fmt - 1].accum_bits; + descr->cAccumRedBits = pixel_formats[fmt - 1].accum_bits / 4; + descr->cAccumGreenBits = pixel_formats[fmt - 1].accum_bits / 4; + descr->cAccumBlueBits = pixel_formats[fmt - 1].accum_bits / 4; + descr->cAccumAlphaBits = pixel_formats[fmt - 1].accum_bits / 4; + descr->cDepthBits = pixel_formats[fmt - 1].depth_bits; + descr->cStencilBits = pixel_formats[fmt - 1].stencil_bits; + descr->cAuxBuffers = 0; + descr->iLayerType = PFD_MAIN_PLANE; +} + static BOOL has_extension( const char *list, const char *ext ) { size_t len = strlen( ext ); @@ -220,59 +273,6 @@ static BOOL osmesa_make_current( struct wgl_context *context, void *bits, return ret; }
-static const struct -{ - BYTE color_bits; - BYTE red_bits, red_shift; - BYTE green_bits, green_shift; - BYTE blue_bits, blue_shift; - BYTE alpha_bits, alpha_shift; - BYTE accum_bits; - BYTE depth_bits; - BYTE stencil_bits; -} pixel_formats[] = -{ - { 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 32, 8 }, - { 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 16, 8 }, - { 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 32, 8 }, - { 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 16, 8 }, - { 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 32, 8 }, - { 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 16, 8 }, - { 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 32, 8 }, - { 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 16, 8 }, - { 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 32, 8 }, - { 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 16, 8 }, - { 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 32, 8 }, - { 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 16, 8 }, -}; - -static void describe_pixel_format( int fmt, PIXELFORMATDESCRIPTOR *descr ) -{ - memset( descr, 0, sizeof(*descr) ); - descr->nSize = sizeof(*descr); - descr->nVersion = 1; - descr->dwFlags = PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_GENERIC_FORMAT; - descr->iPixelType = PFD_TYPE_RGBA; - descr->cColorBits = pixel_formats[fmt - 1].color_bits; - descr->cRedBits = pixel_formats[fmt - 1].red_bits; - descr->cRedShift = pixel_formats[fmt - 1].red_shift; - descr->cGreenBits = pixel_formats[fmt - 1].green_bits; - descr->cGreenShift = pixel_formats[fmt - 1].green_shift; - descr->cBlueBits = pixel_formats[fmt - 1].blue_bits; - descr->cBlueShift = pixel_formats[fmt - 1].blue_shift; - descr->cAlphaBits = pixel_formats[fmt - 1].alpha_bits; - descr->cAlphaShift = pixel_formats[fmt - 1].alpha_shift; - descr->cAccumBits = pixel_formats[fmt - 1].accum_bits; - descr->cAccumRedBits = pixel_formats[fmt - 1].accum_bits / 4; - descr->cAccumGreenBits = pixel_formats[fmt - 1].accum_bits / 4; - descr->cAccumBlueBits = pixel_formats[fmt - 1].accum_bits / 4; - descr->cAccumAlphaBits = pixel_formats[fmt - 1].accum_bits / 4; - descr->cDepthBits = pixel_formats[fmt - 1].depth_bits; - descr->cStencilBits = pixel_formats[fmt - 1].stencil_bits; - descr->cAuxBuffers = 0; - descr->iLayerType = PFD_MAIN_PLANE; -} - static BOOL osmesa_wglCopyContext( struct wgl_context *src, struct wgl_context *dst, UINT mask ) { FIXME( "not supported yet\n" ); @@ -377,6 +377,19 @@ static struct opengl_funcs *osmesa_get_wgl_driver(void)
#endif /* SONAME_LIBOSMESA */
+static UINT nulldrv_init_pixel_formats( UINT *onscreen_count ) +{ + *onscreen_count = ARRAY_SIZE(pixel_formats); + return ARRAY_SIZE(pixel_formats); +} + +static BOOL nulldrv_describe_pixel_format( int format, struct wgl_pixel_format *desc ) +{ + if (format <= 0 || format > ARRAY_SIZE(pixel_formats)) return FALSE; + describe_pixel_format( format, &desc->pfd ); + return TRUE; +} + static const char *nulldrv_init_wgl_extensions(void) { return ""; @@ -389,10 +402,13 @@ static BOOL nulldrv_set_pixel_format( HWND hwnd, int old_format, int new_format,
static const struct opengl_driver_funcs nulldrv_funcs = { + .p_init_pixel_formats = nulldrv_init_pixel_formats, + .p_describe_pixel_format = nulldrv_describe_pixel_format, .p_init_wgl_extensions = nulldrv_init_wgl_extensions, .p_set_pixel_format = nulldrv_set_pixel_format, }; static const struct opengl_driver_funcs *driver_funcs = &nulldrv_funcs; +static UINT formats_count, onscreen_count;
static char wgl_extensions[4096];
@@ -422,18 +438,13 @@ static int win32u_wglGetPixelFormat( HDC hdc ) else if ((dc = get_dc_ptr( hdc ))) { BOOL is_display = dc->is_display; - UINT total, onscreen; ret = dc->pixel_format; release_dc_ptr( dc );
- if (is_display && ret >= 0) - { - /* Offscreen formats can't be used with traditional WGL calls. As has been - * verified on Windows GetPixelFormat doesn't fail but returns 1. - */ - display_funcs->p_get_pixel_formats( NULL, 0, &total, &onscreen ); - if (ret > onscreen) ret = 1; - } + /* Offscreen formats can't be used with traditional WGL calls. As has been + * verified on Windows GetPixelFormat doesn't fail but returns 1. + */ + if (is_display && ret >= 0 && ret > onscreen_count) ret = 1; }
TRACE( "%p/%p -> %d\n", hdc, hwnd, ret ); @@ -481,6 +492,16 @@ static BOOL win32u_wglSetPixelFormatWINE( HDC hdc, int format ) return set_dc_pixel_format( hdc, format, TRUE ); }
+static void win32u_get_pixel_formats( struct wgl_pixel_format *formats, UINT max_formats, + UINT *num_formats, UINT *num_onscreen_formats ) +{ + UINT i = 0; + + if (formats) while (i < max_formats && driver_funcs->p_describe_pixel_format( i + 1, &formats[i] )) i++; + *num_formats = formats_count; + *num_onscreen_formats = onscreen_count; +} + static void memory_funcs_init(void) { memory_funcs = osmesa_get_wgl_driver(); @@ -500,8 +521,11 @@ static void display_funcs_init(void) ERR( "Failed to initialize the driver opengl functions, status %#x\n", status ); return; } + if (display_funcs && !(formats_count = driver_funcs->p_init_pixel_formats( &onscreen_count ))) display_funcs = NULL; if (!display_funcs) return;
+ display_funcs->p_get_pixel_formats = win32u_get_pixel_formats; + strcpy( wgl_extensions, driver_funcs->p_init_wgl_extensions() ); display_funcs->p_wglGetPixelFormat = win32u_wglGetPixelFormat; display_funcs->p_wglSetPixelFormat = win32u_wglSetPixelFormat; diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index c6c42a3bf2b..9b48b9d3ba0 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -244,11 +244,15 @@ static struct wgl_context *create_context( HDC hdc, struct wgl_context *share, c return ctx; }
-static void describe_pixel_format( struct egl_pixel_format *fmt, PIXELFORMATDESCRIPTOR *pfd ) +static BOOL android_describe_pixel_format( int format, struct wgl_pixel_format *desc ) { + struct egl_pixel_format *fmt = pixel_formats + format - 1; + PIXELFORMATDESCRIPTOR *pfd = &desc->pfd; EGLint val; EGLConfig config = fmt->config;
+ if (format <= 0 || format > nb_pixel_formats) return FALSE; + memset( pfd, 0, sizeof(*pfd) ); pfd->nSize = sizeof(*pfd); pfd->nVersion = 1; @@ -275,6 +279,7 @@ static void describe_pixel_format( struct egl_pixel_format *fmt, PIXELFORMATDESC pfd->cBlueShift = pfd->cAlphaShift + pfd->cAlphaBits; pfd->cGreenShift = pfd->cBlueShift + pfd->cBlueBits; pfd->cRedShift = pfd->cGreenShift + pfd->cGreenBits; + return TRUE; }
/*********************************************************************** @@ -505,24 +510,6 @@ static BOOL android_wglSwapBuffers( HDC hdc ) return TRUE; }
-/********************************************************************** - * android_get_pixel_formats - */ -static void android_get_pixel_formats( struct wgl_pixel_format *formats, - UINT max_formats, UINT *num_formats, - UINT *num_onscreen_formats ) -{ - UINT i; - - if (formats) - { - for (i = 0; i < min( max_formats, nb_pixel_formats ); ++i) - describe_pixel_format( &pixel_formats[i], &formats[i].pfd ); - } - *num_formats = nb_pixel_formats; - *num_onscreen_formats = nb_onscreen_formats; -} - static void wglFinish(void) { struct wgl_context *ctx = NtCurrentTeb()->glContext; @@ -863,8 +850,59 @@ static void init_opengl_funcs(void) #undef REDIRECT }
+static UINT android_init_pixel_formats( UINT *onscreen_count ) +{ + EGLConfig *configs; + EGLint count, i, pass; + + p_eglGetConfigs( display, NULL, 0, &count ); + configs = malloc( count * sizeof(*configs) ); + pixel_formats = malloc( count * sizeof(*pixel_formats) ); + p_eglGetConfigs( display, configs, count, &count ); + if (!count || !configs || !pixel_formats) + { + free( configs ); + free( pixel_formats ); + ERR( "eglGetConfigs returned no configs\n" ); + return 0; + } + + for (pass = 0; pass < 2; pass++) + { + for (i = 0; i < count; i++) + { + EGLint id, type, visual_id, native, render, color, r, g, b, d, s; + + p_eglGetConfigAttrib( display, configs[i], EGL_SURFACE_TYPE, &type ); + if (!(type & EGL_WINDOW_BIT) == !pass) continue; + p_eglGetConfigAttrib( display, configs[i], EGL_RENDERABLE_TYPE, &render ); + if (egl_client_version == 2 && !(render & EGL_OPENGL_ES2_BIT)) continue; + + pixel_formats[nb_pixel_formats++].config = configs[i]; + + p_eglGetConfigAttrib( display, configs[i], EGL_CONFIG_ID, &id ); + p_eglGetConfigAttrib( display, configs[i], EGL_NATIVE_VISUAL_ID, &visual_id ); + p_eglGetConfigAttrib( display, configs[i], EGL_NATIVE_RENDERABLE, &native ); + p_eglGetConfigAttrib( display, configs[i], EGL_COLOR_BUFFER_TYPE, &color ); + p_eglGetConfigAttrib( display, configs[i], EGL_RED_SIZE, &r ); + p_eglGetConfigAttrib( display, configs[i], EGL_GREEN_SIZE, &g ); + p_eglGetConfigAttrib( display, configs[i], EGL_BLUE_SIZE, &b ); + p_eglGetConfigAttrib( display, configs[i], EGL_DEPTH_SIZE, &d ); + p_eglGetConfigAttrib( display, configs[i], EGL_STENCIL_SIZE, &s ); + TRACE( "%u: config %u id %u type %x visual %u native %u render %x colortype %u rgb %u,%u,%u depth %u stencil %u\n", + nb_pixel_formats, i, id, type, visual_id, native, render, color, r, g, b, d, s ); + } + if (!pass) nb_onscreen_formats = nb_pixel_formats; + } + + *onscreen_count = nb_onscreen_formats; + return nb_pixel_formats; +} + static const struct opengl_driver_funcs android_driver_funcs = { + .p_init_pixel_formats = android_init_pixel_formats, + .p_describe_pixel_format = android_describe_pixel_format, .p_init_wgl_extensions = android_init_wgl_extensions, .p_set_pixel_format = android_set_pixel_format, }; @@ -874,8 +912,7 @@ static const struct opengl_driver_funcs android_driver_funcs = */ UINT ANDROID_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs ) { - EGLConfig *configs; - EGLint major, minor, count, i, pass; + EGLint major, minor;
if (version != WINE_OPENGL_DRIVER_VERSION) { @@ -916,46 +953,6 @@ UINT ANDROID_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct if (!p_eglInitialize( display, &major, &minor )) return 0; TRACE( "display %p version %u.%u\n", display, major, minor );
- p_eglGetConfigs( display, NULL, 0, &count ); - configs = malloc( count * sizeof(*configs) ); - pixel_formats = malloc( count * sizeof(*pixel_formats) ); - p_eglGetConfigs( display, configs, count, &count ); - if (!count || !configs || !pixel_formats) - { - free( configs ); - free( pixel_formats ); - ERR( "eglGetConfigs returned no configs\n" ); - return 0; - } - - for (pass = 0; pass < 2; pass++) - { - for (i = 0; i < count; i++) - { - EGLint id, type, visual_id, native, render, color, r, g, b, d, s; - - p_eglGetConfigAttrib( display, configs[i], EGL_SURFACE_TYPE, &type ); - if (!(type & EGL_WINDOW_BIT) == !pass) continue; - p_eglGetConfigAttrib( display, configs[i], EGL_RENDERABLE_TYPE, &render ); - if (egl_client_version == 2 && !(render & EGL_OPENGL_ES2_BIT)) continue; - - pixel_formats[nb_pixel_formats++].config = configs[i]; - - p_eglGetConfigAttrib( display, configs[i], EGL_CONFIG_ID, &id ); - p_eglGetConfigAttrib( display, configs[i], EGL_NATIVE_VISUAL_ID, &visual_id ); - p_eglGetConfigAttrib( display, configs[i], EGL_NATIVE_RENDERABLE, &native ); - p_eglGetConfigAttrib( display, configs[i], EGL_COLOR_BUFFER_TYPE, &color ); - p_eglGetConfigAttrib( display, configs[i], EGL_RED_SIZE, &r ); - p_eglGetConfigAttrib( display, configs[i], EGL_GREEN_SIZE, &g ); - p_eglGetConfigAttrib( display, configs[i], EGL_BLUE_SIZE, &b ); - p_eglGetConfigAttrib( display, configs[i], EGL_DEPTH_SIZE, &d ); - p_eglGetConfigAttrib( display, configs[i], EGL_STENCIL_SIZE, &s ); - TRACE( "%u: config %u id %u type %x visual %u native %u render %x colortype %u rgb %u,%u,%u depth %u stencil %u\n", - nb_pixel_formats, i, id, type, visual_id, native, render, color, r, g, b, d, s ); - } - if (!pass) nb_onscreen_formats = nb_pixel_formats; - } - init_opengl_funcs(); *funcs = &egl_funcs; *driver_funcs = &android_driver_funcs; @@ -985,7 +982,6 @@ static struct opengl_funcs egl_funcs = .p_wglMakeCurrent = android_wglMakeCurrent, .p_wglShareLists = android_wglShareLists, .p_wglSwapBuffers = android_wglSwapBuffers, - .p_get_pixel_formats = android_get_pixel_formats, #define USE_GL_FUNC(name) .p_##name = (void *)glstub_##name, ALL_GL_FUNCS #undef USE_GL_FUNC diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 429c3913f6d..a9a4dc53da0 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -1106,9 +1106,8 @@ static CFComparisonResult pixel_format_comparator(const void *val1, const void * }
-static BOOL init_pixel_formats(void) +static UINT macdrv_init_pixel_formats(UINT *onscreen_count) { - BOOL ret = FALSE; CGLRendererInfoObj renderer_info; GLint rendererCount; CGLError err; @@ -1123,7 +1122,7 @@ static BOOL init_pixel_formats(void) if (err) { WARN("CGLQueryRendererInfo failed (%d) %s\n", err, CGLErrorString(err)); - return FALSE; + return 0; }
pixel_format_set = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks); @@ -1131,7 +1130,7 @@ static BOOL init_pixel_formats(void) { WARN("CFSetCreateMutable failed\n"); CGLDestroyRendererInfo(renderer_info); - return FALSE; + return 0; }
pixel_format_array = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); @@ -1140,7 +1139,7 @@ static BOOL init_pixel_formats(void) WARN("CFArrayCreateMutable failed\n"); CFRelease(pixel_format_set); CGLDestroyRendererInfo(renderer_info); - return FALSE; + return 0; }
for (i = 0; i < rendererCount; i++) @@ -1180,16 +1179,20 @@ static BOOL init_pixel_formats(void)
nb_formats = range.length; TRACE("Total number of unique pixel formats: %d\n", nb_formats); - ret = TRUE; } else + { WARN("failed to allocate pixel format list\n"); + nb_formats = 0; + } } else WARN("got no pixel formats\n");
CFRelease(pixel_format_array); - return ret; + + *onscreen_count = nb_displayable_formats; + return nb_formats; }
@@ -3498,9 +3501,6 @@ UINT macdrv_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct o if (gluCheckExtension((GLubyte*)"GL_APPLE_flush_render", (GLubyte*)gl_info.glExtensions)) pglFlushRenderAPPLE = dlsym(opengl_handle, "glFlushRenderAPPLE");
- if (!init_pixel_formats()) - goto failed; - *funcs = &opengl_funcs; *driver_funcs = &macdrv_driver_funcs; return STATUS_SUCCESS; @@ -3535,10 +3535,13 @@ void sync_gl_view(struct macdrv_win_data* data, const struct window_rects *old_r }
-static void describe_pixel_format(const pixel_format *pf, struct wgl_pixel_format *descr) +static BOOL macdrv_describe_pixel_format(int format, struct wgl_pixel_format *descr) { + const pixel_format *pf = pixel_formats + format - 1; const struct color_mode *mode;
+ if (format <= 0 || format > nb_formats) return FALSE; + memset(descr, 0, sizeof(*descr)); descr->pfd.nSize = sizeof(*descr); descr->pfd.nVersion = 1; @@ -3618,6 +3621,8 @@ static void describe_pixel_format(const pixel_format *pf, struct wgl_pixel_forma descr->max_pbuffer_width = gl_info.max_viewport_dims[0]; descr->max_pbuffer_height = gl_info.max_viewport_dims[1]; descr->max_pbuffer_pixels = gl_info.max_viewport_dims[0] * gl_info.max_viewport_dims[1]; + + return TRUE; }
/*********************************************************************** @@ -3821,26 +3826,10 @@ static BOOL macdrv_wglSwapBuffers(HDC hdc) return TRUE; }
-/********************************************************************** - * macdrv_get_pixel_formats - */ -static void macdrv_get_pixel_formats(struct wgl_pixel_format *formats, - UINT max_formats, UINT *num_formats, - UINT *num_onscreen_formats) -{ - UINT i; - - if (formats) - { - for (i = 0; i < min(max_formats, nb_formats); ++i) - describe_pixel_format(&pixel_formats[i], &formats[i]); - } - *num_formats = nb_formats; - *num_onscreen_formats = nb_displayable_formats; -} - static const struct opengl_driver_funcs macdrv_driver_funcs = { + .p_init_pixel_formats = macdrv_init_pixel_formats, + .p_describe_pixel_format = macdrv_describe_pixel_format, .p_init_wgl_extensions = macdrv_init_wgl_extensions, .p_set_pixel_format = macdrv_set_pixel_format, }; @@ -3854,5 +3843,4 @@ static struct opengl_funcs opengl_funcs = .p_wglMakeCurrent = macdrv_wglMakeCurrent, .p_wglShareLists = macdrv_wglShareLists, .p_wglSwapBuffers = macdrv_wglSwapBuffers, - .p_get_pixel_formats = macdrv_get_pixel_formats, }; diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index 849a2c3730b..9c4e7234d3d 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -992,13 +992,13 @@ static BOOL wayland_wglSetPbufferAttribARB(struct wgl_pbuffer *pbuffer, const in return GL_TRUE; }
-static void describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt, BOOL pbuffer_single) +static BOOL describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt, BOOL pbuffer_single) { EGLint value, surface_type; PIXELFORMATDESCRIPTOR *pfd = &fmt->pfd;
/* If we can't get basic information, there is no point continuing */ - if (!p_eglGetConfigAttrib(egl_display, config, EGL_SURFACE_TYPE, &surface_type)) return; + if (!p_eglGetConfigAttrib(egl_display, config, EGL_SURFACE_TYPE, &surface_type)) return FALSE;
memset(fmt, 0, sizeof(*fmt)); pfd->nSize = sizeof(*pfd); @@ -1116,24 +1116,19 @@ static void describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt
#undef SET_ATTRIB #undef SET_ATTRIB_ARB + return TRUE; }
-static void wayland_get_pixel_formats(struct wgl_pixel_format *formats, - UINT max_formats, UINT *num_formats, - UINT *num_onscreen_formats) +static BOOL wayland_describe_pixel_format(int format, struct wgl_pixel_format *desc) { - UINT i; - - if (formats) - { - for (i = 0; i < min(max_formats, num_egl_configs); ++i) - describe_pixel_format(egl_configs[i], &formats[i], FALSE); - /* Add single-buffered pbuffer capable configs. */ - for (i = num_egl_configs; i < min(max_formats, 2 * num_egl_configs); ++i) - describe_pixel_format(egl_configs[i - num_egl_configs], &formats[i], TRUE); - } - *num_formats = 2 * num_egl_configs; - *num_onscreen_formats = num_egl_configs; + if (format <= 0) + return FALSE; + if (format <= num_egl_configs) + return describe_pixel_format(egl_configs[format - 1], desc, FALSE); + /* Add single-buffered pbuffer capable configs. */ + if (format <= 2 * num_egl_configs) + return describe_pixel_format(egl_configs[format - 1 - num_egl_configs], desc, TRUE); + return FALSE; }
static BOOL has_extension(const char *list, const char *ext) @@ -1211,7 +1206,7 @@ static const char *wayland_init_wgl_extensions(void) return wgl_extensions; }
-static BOOL init_egl_configs(void) +static UINT wayland_init_pixel_formats(UINT *onscreen_count) { EGLint i; const EGLint attribs[] = @@ -1225,7 +1220,7 @@ static BOOL init_egl_configs(void) if (!(egl_configs = malloc(num_egl_configs * sizeof(*egl_configs)))) { ERR("Failed to allocate memory for EGL configs\n"); - return FALSE; + return 0; } if (!p_eglChooseConfig(egl_display, attribs, egl_configs, num_egl_configs, &num_egl_configs) || @@ -1235,7 +1230,7 @@ static BOOL init_egl_configs(void) egl_configs = NULL; num_egl_configs = 0; ERR("Failed to get any configs from eglChooseConfig\n"); - return FALSE; + return 0; }
if (TRACE_ON(waylanddrv)) @@ -1262,11 +1257,14 @@ static BOOL init_egl_configs(void) } }
- return TRUE; + *onscreen_count = num_egl_configs; + return 2 * num_egl_configs; }
static const struct opengl_driver_funcs wayland_driver_funcs = { + .p_init_pixel_formats = wayland_init_pixel_formats, + .p_describe_pixel_format = wayland_describe_pixel_format, .p_init_wgl_extensions = wayland_init_wgl_extensions, .p_set_pixel_format = wayland_set_pixel_format, }; @@ -1364,7 +1362,6 @@ UINT WAYLAND_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct has_egl_ext_pixel_format_float = has_extension(egl_exts, "EGL_EXT_pixel_format_float");
if (!init_opengl_funcs()) goto err; - if (!init_egl_configs()) goto err; *funcs = &opengl_funcs; *driver_funcs = &wayland_driver_funcs; return STATUS_SUCCESS; @@ -1384,7 +1381,6 @@ static struct opengl_funcs opengl_funcs = .p_wglMakeCurrent = wayland_wglMakeCurrent, .p_wglShareLists = wayland_wglShareLists, .p_wglSwapBuffers = wayland_wglSwapBuffers, - .p_get_pixel_formats = wayland_get_pixel_formats, };
/********************************************************************** diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index a4c41e1289b..239511b1679 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -280,7 +280,6 @@ static const BOOL is_win64 = sizeof(void *) > sizeof(int);
static struct opengl_funcs opengl_funcs;
-static void init_pixel_formats( Display *display ); static BOOL glxRequireVersion(int requiredVersion);
static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) { @@ -713,8 +712,6 @@ UINT X11DRV_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct pglXSwapBuffersMscOML = pglXGetProcAddressARB( (const GLubyte *)"glXSwapBuffersMscOML" ); }
- init_pixel_formats( gdi_display ); - *funcs = &opengl_funcs; *driver_funcs = &x11drv_driver_funcs; return STATUS_SUCCESS; @@ -773,7 +770,7 @@ static BOOL check_fbconfig_bitmap_capability(Display *display, GLXFBConfig fbcon return !dbuf && (value & GLX_PIXMAP_BIT); }
-static void init_pixel_formats( Display *display ) +static UINT x11drv_init_pixel_formats( UINT *onscreen_count ) { struct glx_pixel_format *list; int size = 0, onscreen_size = 0; @@ -781,11 +778,11 @@ static void init_pixel_formats( Display *display ) GLXFBConfig* cfgs; XVisualInfo *visinfo;
- cfgs = pglXGetFBConfigs(display, DefaultScreen(display), &nCfgs); + cfgs = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs); if (NULL == cfgs || 0 == nCfgs) { if(cfgs != NULL) XFree(cfgs); ERR("glXChooseFBConfig returns NULL\n"); - return; + return 0; }
/* Bitmap rendering on Windows implies the use of the Microsoft GDI software renderer. @@ -797,7 +794,7 @@ static void init_pixel_formats( Display *display ) */ for(i=0, bmp_formats=0; i<nCfgs; i++) { - if(check_fbconfig_bitmap_capability(display, cfgs[i])) + if(check_fbconfig_bitmap_capability(gdi_display, cfgs[i])) bmp_formats++; } TRACE("Found %d bitmap capable fbconfigs\n", bmp_formats); @@ -809,8 +806,8 @@ static void init_pixel_formats( Display *display ) for(run=0; run < 2; run++) { for(i=0; i<nCfgs; i++) { - pglXGetFBConfigAttrib(display, cfgs[i], GLX_FBCONFIG_ID, &fmt_id); - visinfo = pglXGetVisualFromFBConfig(display, cfgs[i]); + pglXGetFBConfigAttrib(gdi_display, cfgs[i], GLX_FBCONFIG_ID, &fmt_id); + visinfo = pglXGetVisualFromFBConfig(gdi_display, cfgs[i]);
/* The first run we only add onscreen formats (ones which have an associated X Visual). * The second run we only set offscreen formats. */ @@ -833,19 +830,19 @@ static void init_pixel_formats( Display *display ) list[size].fbconfig = cfgs[i]; list[size].visual = visinfo; list[size].fmt_id = fmt_id; - list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]); + list[size].render_type = get_render_type_from_fbconfig(gdi_display, cfgs[i]); list[size].dwFlags = 0; size++; onscreen_size++;
/* Clone a format if it is bitmap capable for indirect rendering to bitmaps */ - if(check_fbconfig_bitmap_capability(display, cfgs[i])) + if(check_fbconfig_bitmap_capability(gdi_display, cfgs[i])) { TRACE("Found bitmap capable format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id, size+1, i); list[size].fbconfig = cfgs[i]; list[size].visual = visinfo; list[size].fmt_id = fmt_id; - list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]); + list[size].render_type = get_render_type_from_fbconfig(gdi_display, cfgs[i]); list[size].dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_GENERIC_FORMAT; size++; onscreen_size++; @@ -869,7 +866,7 @@ static void init_pixel_formats( Display *display ) TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id, size+1, i); list[size].fbconfig = cfgs[i]; list[size].fmt_id = fmt_id; - list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]); + list[size].render_type = get_render_type_from_fbconfig(gdi_display, cfgs[i]); list[size].dwFlags = 0; size++; } @@ -882,6 +879,9 @@ static void init_pixel_formats( Display *display ) pixel_formats = list; nb_pixel_formats = size; nb_onscreen_formats = onscreen_size; + + *onscreen_count = onscreen_size; + return size; }
static inline BOOL is_valid_pixel_format( int format ) @@ -1337,12 +1337,7 @@ void destroy_gl_drawable( HWND hwnd ) }
-/** - * describe_pixel_format - * - * Get the wgl_pixel_format description for the given id - */ -static int describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf ) +static BOOL x11drv_describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf ) { int value, drawable_type = 0, render_type = 0; int rb, gb, bb, ab; @@ -1355,7 +1350,7 @@ static int describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf if (!fmt) { WARN( "unexpected format %d\n", iPixelFormat ); - return 0; + return FALSE; }
/* If we can't get basic information, there is no point continuing */ @@ -1536,7 +1531,7 @@ static int describe_pixel_format( int iPixelFormat, struct wgl_pixel_format *pf
if (TRACE_ON(wgl)) dump_PIXELFORMATDESCRIPTOR( &pf->pfd );
- return nb_onscreen_formats; + return TRUE; }
/*********************************************************************** @@ -2677,23 +2672,10 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc ) return TRUE; }
-static void glxdrv_get_pixel_formats( struct wgl_pixel_format *formats, - UINT max_formats, UINT *num_formats, - UINT *num_onscreen_formats ) -{ - UINT i; - - if (formats) - { - for (i = 0; i < min( max_formats, nb_pixel_formats ); ++i) - describe_pixel_format( i + 1, &formats[i] ); - } - *num_formats = nb_pixel_formats; - *num_onscreen_formats = nb_onscreen_formats; -} - static const struct opengl_driver_funcs x11drv_driver_funcs = { + .p_init_pixel_formats = x11drv_init_pixel_formats, + .p_describe_pixel_format = x11drv_describe_pixel_format, .p_init_wgl_extensions = x11drv_init_wgl_extensions, .p_set_pixel_format = x11drv_set_pixel_format, }; @@ -2707,7 +2689,6 @@ static struct opengl_funcs opengl_funcs = .p_wglMakeCurrent = glxdrv_wglMakeCurrent, .p_wglShareLists = glxdrv_wglShareLists, .p_wglSwapBuffers = glxdrv_wglSwapBuffers, - .p_get_pixel_formats = glxdrv_get_pixel_formats, };
#else /* no OpenGL includes */ diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index c18edb5476b..f652a58c920 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -113,6 +113,8 @@ struct opengl_funcs /* interface between win32u and the user drivers */ struct opengl_driver_funcs { + UINT (*p_init_pixel_formats)(UINT*); + BOOL (*p_describe_pixel_format)(int,struct wgl_pixel_format*); const char *(*p_init_wgl_extensions)(void); BOOL (*p_set_pixel_format)(HWND,int,int,BOOL); };