-- v3: winewayland: Use win32u for EGL display and pixel formats. wineandroid: Use win32u for EGL display and pixel formats. win32u: Implement OpenGL pixel formats over EGL configs. win32u: Introduce an EGL opengl_driver_function table. winewayland: Use the EGL display opened from win32u. wineandroid: Use the EGL display opened from win32u. win32u: Open and initialize an EGL platform display.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 53 ++++++++++++++++++++++++++++++++++-- include/wine/opengl_driver.h | 10 ++++++- 2 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index f0cca3b06b4..fea74a59313 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -70,6 +70,7 @@ struct wgl_pbuffer };
static const struct opengl_funcs *default_funcs; /* default GL function table from opengl32 */ +static struct egl_platform display_egl; static struct opengl_funcs display_funcs; static struct opengl_funcs memory_funcs;
@@ -226,11 +227,53 @@ static BOOL egl_init(void) return TRUE;
failed: - dlclose( display_funcs.egl_handle ); - display_funcs.egl_handle = NULL; + dlclose( funcs->egl_handle ); + funcs->egl_handle = NULL; return FALSE; }
+static void init_egl_platform( struct egl_platform *egl, struct opengl_funcs *funcs, + const struct opengl_driver_funcs *driver_funcs ) +{ + EGLNativeDisplayType platform_display; + const char *extensions; + EGLint major, minor; + EGLenum platform; + + if (!funcs->egl_handle || !driver_funcs->p_init_egl_platform) return; + + platform = driver_funcs->p_init_egl_platform( egl, &platform_display ); + if (!platform) egl->display = funcs->p_eglGetDisplay( EGL_DEFAULT_DISPLAY ); + else egl->display = funcs->p_eglGetPlatformDisplay( platform, platform_display, NULL ); + + if (!egl->display) + { + ERR( "Failed to open EGL display\n" ); + return; + } + + if (!funcs->p_eglInitialize( egl->display, &major, &minor )) return; + TRACE( "Initialized EGL display %p, version %d.%d\n", egl->display, major, minor ); + + if (!(extensions = funcs->p_eglQueryString( egl->display, EGL_EXTENSIONS ))) return; + TRACE( "EGL display extensions:\n" ); + dump_extensions( extensions ); + +#define CHECK_EXTENSION( ext ) \ + if (!has_extension( extensions, #ext )) \ + { \ + ERR( "Failed to find required extension %s\n", #ext ); \ + return; \ + } + CHECK_EXTENSION( EGL_KHR_create_context ); + CHECK_EXTENSION( EGL_KHR_create_context_no_error ); + CHECK_EXTENSION( EGL_KHR_no_config_context ); +#undef CHECK_EXTENSION + + egl->has_EGL_EXT_present_opaque = has_extension( extensions, "EGL_EXT_present_opaque" ); + egl->has_EGL_EXT_pixel_format_float = has_extension( extensions, "EGL_EXT_pixel_format_float" ); +} + #else /* SONAME_LIBEGL */
static BOOL egl_init(void) @@ -239,6 +282,11 @@ static BOOL egl_init(void) return FALSE; }
+static void init_egl_platform( struct egl_platform *egl, struct opengl_funcs *funcs, + const struct opengl_driver_funcs *driver_funcs ) +{ +} + #endif /* SONAME_LIBEGL */
#ifdef SONAME_LIBOSMESA @@ -1422,6 +1470,7 @@ static void display_funcs_init(void)
if ((status = user_driver->pOpenGLInit( WINE_OPENGL_DRIVER_VERSION, &display_funcs, &display_driver_funcs ))) WARN( "Failed to initialize the driver OpenGL functions, status %#x\n", status ); + init_egl_platform( &display_egl, &display_funcs, display_driver_funcs );
display_formats_count = display_driver_funcs->p_init_pixel_formats( &display_onscreen_count ); init_opengl_funcs( &display_funcs, display_driver_funcs ); diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 6d271e4fc73..693c2b80d2e 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -61,7 +61,7 @@ struct wgl_pixel_format #ifdef WINE_UNIX_LIB
/* Wine internal opengl driver version, needs to be bumped upon opengl_funcs changes. */ -#define WINE_OPENGL_DRIVER_VERSION 33 +#define WINE_OPENGL_DRIVER_VERSION 34
struct wgl_context; struct wgl_pbuffer; @@ -113,9 +113,17 @@ struct opengl_funcs void *egl_handle; };
+struct egl_platform +{ + EGLDisplay display; + BOOL has_EGL_EXT_present_opaque; + BOOL has_EGL_EXT_pixel_format_float; +}; + /* interface between win32u and the user drivers */ struct opengl_driver_funcs { + GLenum (*p_init_egl_platform)(const struct egl_platform*,EGLNativeDisplayType*); void *(*p_get_proc_address)(const char *); UINT (*p_init_pixel_formats)(UINT*); BOOL (*p_describe_pixel_format)(int,struct wgl_pixel_format*);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/wineandroid.drv/opengl.c | 82 ++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 40 deletions(-)
diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index dd3de7fc25a..73804e4918b 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -46,6 +46,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(android);
+static const struct egl_platform *egl; static const struct opengl_funcs *funcs; static const int egl_client_version = 2;
@@ -79,7 +80,6 @@ struct gl_drawable static void *opengl_handle; static struct egl_pixel_format *pixel_formats; static int nb_pixel_formats, nb_onscreen_formats; -static EGLDisplay display; static char wgl_extensions[4096];
static struct list gl_contexts = LIST_INIT( gl_contexts ); @@ -97,7 +97,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, HDC hdc, int format ) gl->format = format; gl->window = create_ioctl_window( hwnd, TRUE, 1.0f ); gl->surface = 0; - gl->pbuffer = funcs->p_eglCreatePbufferSurface( display, pixel_formats[gl->format - 1].config, attribs ); + gl->pbuffer = funcs->p_eglCreatePbufferSurface( egl->display, pixel_formats[gl->format - 1].config, attribs ); pthread_mutex_lock( &drawable_mutex ); list_add_head( &gl_drawables, &gl->entry ); return gl; @@ -131,8 +131,8 @@ void destroy_gl_drawable( HWND hwnd ) { if (gl->hwnd != hwnd) continue; list_remove( &gl->entry ); - if (gl->surface) funcs->p_eglDestroySurface( display, gl->surface ); - if (gl->pbuffer) funcs->p_eglDestroySurface( display, gl->pbuffer ); + if (gl->surface) funcs->p_eglDestroySurface( egl->display, gl->surface ); + if (gl->pbuffer) funcs->p_eglDestroySurface( egl->display, gl->pbuffer ); release_ioctl_window( gl->window ); free( gl ); break; @@ -147,7 +147,7 @@ static BOOL refresh_context( struct android_context *ctx ) if (ret) { TRACE( "refreshing hwnd %p context %p surface %p\n", ctx->hwnd, ctx->context, ctx->surface ); - funcs->p_eglMakeCurrent( display, ctx->surface, ctx->surface, ctx->context ); + funcs->p_eglMakeCurrent( egl->display, ctx->surface, ctx->surface, ctx->context ); NtUserRedrawWindow( ctx->hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE ); } return ret; @@ -161,7 +161,7 @@ void update_gl_drawable( HWND hwnd ) if ((gl = get_gl_drawable( hwnd, 0 ))) { if (!gl->surface && - (gl->surface = funcs->p_eglCreateWindowSurface( display, pixel_formats[gl->format - 1].config, + (gl->surface = funcs->p_eglCreateWindowSurface( egl->display, pixel_formats[gl->format - 1].config, gl->window, NULL ))) { LIST_FOR_EACH_ENTRY( ctx, &gl_contexts, struct android_context, entry ) @@ -170,7 +170,7 @@ void update_gl_drawable( HWND hwnd ) TRACE( "hwnd %p refreshing %p %scurrent\n", hwnd, ctx, NtCurrentTeb()->glReserved2 == ctx ? "" : "not " ); ctx->surface = gl->surface; if (NtCurrentTeb()->glReserved2 == ctx) - funcs->p_eglMakeCurrent( display, ctx->surface, ctx->surface, ctx->context ); + funcs->p_eglMakeCurrent( egl->display, ctx->surface, ctx->surface, ctx->context ); else InterlockedExchange( &ctx->refresh, TRUE ); } @@ -191,7 +191,7 @@ static BOOL android_set_pixel_format( HWND hwnd, int old_format, int new_format, if (internal) { EGLint pf; - funcs->p_eglGetConfigAttrib( display, pixel_formats[new_format - 1].config, EGL_NATIVE_VISUAL_ID, &pf ); + funcs->p_eglGetConfigAttrib( egl->display, pixel_formats[new_format - 1].config, EGL_NATIVE_VISUAL_ID, &pf ); gl->window->perform( gl->window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, pf ); gl->format = new_format; } @@ -244,7 +244,7 @@ static BOOL android_context_create( HDC hdc, int format, void *share, const int ctx->config = pixel_formats[format - 1].config; ctx->surface = 0; ctx->refresh = FALSE; - ctx->context = funcs->p_eglCreateContext( display, ctx->config, shared_ctx ? shared_ctx->context : EGL_NO_CONTEXT, attribs ); + ctx->context = funcs->p_eglCreateContext( egl->display, ctx->config, shared_ctx ? shared_ctx->context : EGL_NO_CONTEXT, attribs ); TRACE( "%p fmt %d ctx %p\n", hdc, format, ctx->context ); list_add_head( &gl_contexts, &ctx->entry );
@@ -268,19 +268,19 @@ static BOOL android_describe_pixel_format( int format, struct wgl_pixel_format * pfd->iPixelType = PFD_TYPE_RGBA; pfd->iLayerType = PFD_MAIN_PLANE;
- funcs->p_eglGetConfigAttrib( display, config, EGL_BUFFER_SIZE, &val ); + funcs->p_eglGetConfigAttrib( egl->display, config, EGL_BUFFER_SIZE, &val ); pfd->cColorBits = val; - funcs->p_eglGetConfigAttrib( display, config, EGL_RED_SIZE, &val ); + funcs->p_eglGetConfigAttrib( egl->display, config, EGL_RED_SIZE, &val ); pfd->cRedBits = val; - funcs->p_eglGetConfigAttrib( display, config, EGL_GREEN_SIZE, &val ); + funcs->p_eglGetConfigAttrib( egl->display, config, EGL_GREEN_SIZE, &val ); pfd->cGreenBits = val; - funcs->p_eglGetConfigAttrib( display, config, EGL_BLUE_SIZE, &val ); + funcs->p_eglGetConfigAttrib( egl->display, config, EGL_BLUE_SIZE, &val ); pfd->cBlueBits = val; - funcs->p_eglGetConfigAttrib( display, config, EGL_ALPHA_SIZE, &val ); + funcs->p_eglGetConfigAttrib( egl->display, config, EGL_ALPHA_SIZE, &val ); pfd->cAlphaBits = val; - funcs->p_eglGetConfigAttrib( display, config, EGL_DEPTH_SIZE, &val ); + funcs->p_eglGetConfigAttrib( egl->display, config, EGL_DEPTH_SIZE, &val ); pfd->cDepthBits = val; - funcs->p_eglGetConfigAttrib( display, config, EGL_STENCIL_SIZE, &val ); + funcs->p_eglGetConfigAttrib( egl->display, config, EGL_STENCIL_SIZE, &val ); pfd->cStencilBits = val;
pfd->cAlphaShift = 0; @@ -302,7 +302,7 @@ static BOOL android_context_make_current( HDC draw_hdc, HDC read_hdc, void *priv
if (!private) { - funcs->p_eglMakeCurrent( display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); + funcs->p_eglMakeCurrent( egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); NtCurrentTeb()->glReserved2 = NULL; return TRUE; } @@ -315,7 +315,7 @@ static BOOL android_context_make_current( HDC draw_hdc, HDC read_hdc, void *priv read_surface = read_gl->surface ? read_gl->surface : read_gl->pbuffer; TRACE( "%p/%p context %p surface %p/%p\n", draw_hdc, read_hdc, ctx->context, draw_surface, read_surface ); - ret = funcs->p_eglMakeCurrent( display, draw_surface, read_surface, ctx->context ); + ret = funcs->p_eglMakeCurrent( egl->display, draw_surface, read_surface, ctx->context ); if (ret) { ctx->surface = draw_gl->surface; @@ -351,11 +351,18 @@ static BOOL android_context_destroy( void *private ) pthread_mutex_lock( &drawable_mutex ); list_remove( &ctx->entry ); pthread_mutex_unlock( &drawable_mutex ); - funcs->p_eglDestroyContext( display, ctx->context ); + funcs->p_eglDestroyContext( egl->display, ctx->context ); free( ctx ); return TRUE; }
+static EGLenum android_init_egl_platform( const struct egl_platform *platform, EGLNativeDisplayType *platform_display ) +{ + egl = platform; + *platform_display = EGL_DEFAULT_DISPLAY; + return EGL_PLATFORM_ANDROID_KHR; +} + static void *android_get_proc_address( const char *name ) { void *ptr; @@ -373,7 +380,7 @@ static void set_swap_interval( struct gl_drawable *gl, int interval ) { if (interval < 0) interval = -interval; if (gl->swap_interval == interval) return; - funcs->p_eglSwapInterval( display, interval ); + funcs->p_eglSwapInterval( egl->display, interval ); gl->swap_interval = interval; }
@@ -394,7 +401,7 @@ static BOOL android_swap_buffers( void *private, HWND hwnd, HDC hdc, int interva release_gl_drawable( gl ); }
- if (ctx->surface) funcs->p_eglSwapBuffers( display, ctx->surface ); + if (ctx->surface) funcs->p_eglSwapBuffers( egl->display, ctx->surface ); return TRUE; }
@@ -432,10 +439,10 @@ static UINT android_init_pixel_formats( UINT *onscreen_count ) EGLConfig *configs; EGLint count, i, pass;
- funcs->p_eglGetConfigs( display, NULL, 0, &count ); + funcs->p_eglGetConfigs( egl->display, NULL, 0, &count ); configs = malloc( count * sizeof(*configs) ); pixel_formats = malloc( count * sizeof(*pixel_formats) ); - funcs->p_eglGetConfigs( display, configs, count, &count ); + funcs->p_eglGetConfigs( egl->display, configs, count, &count ); if (!count || !configs || !pixel_formats) { free( configs ); @@ -450,22 +457,22 @@ static UINT android_init_pixel_formats( UINT *onscreen_count ) { EGLint id, type, visual_id, native, render, color, r, g, b, d, s;
- funcs->p_eglGetConfigAttrib( display, configs[i], EGL_SURFACE_TYPE, &type ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_SURFACE_TYPE, &type ); if (!(type & EGL_WINDOW_BIT) == !pass) continue; - funcs->p_eglGetConfigAttrib( display, configs[i], EGL_RENDERABLE_TYPE, &render ); + funcs->p_eglGetConfigAttrib( egl->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];
- funcs->p_eglGetConfigAttrib( display, configs[i], EGL_CONFIG_ID, &id ); - funcs->p_eglGetConfigAttrib( display, configs[i], EGL_NATIVE_VISUAL_ID, &visual_id ); - funcs->p_eglGetConfigAttrib( display, configs[i], EGL_NATIVE_RENDERABLE, &native ); - funcs->p_eglGetConfigAttrib( display, configs[i], EGL_COLOR_BUFFER_TYPE, &color ); - funcs->p_eglGetConfigAttrib( display, configs[i], EGL_RED_SIZE, &r ); - funcs->p_eglGetConfigAttrib( display, configs[i], EGL_GREEN_SIZE, &g ); - funcs->p_eglGetConfigAttrib( display, configs[i], EGL_BLUE_SIZE, &b ); - funcs->p_eglGetConfigAttrib( display, configs[i], EGL_DEPTH_SIZE, &d ); - funcs->p_eglGetConfigAttrib( display, configs[i], EGL_STENCIL_SIZE, &s ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_CONFIG_ID, &id ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_NATIVE_VISUAL_ID, &visual_id ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_NATIVE_RENDERABLE, &native ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_COLOR_BUFFER_TYPE, &color ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_RED_SIZE, &r ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_GREEN_SIZE, &g ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_BLUE_SIZE, &b ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_DEPTH_SIZE, &d ); + funcs->p_eglGetConfigAttrib( egl->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 ); } @@ -478,6 +485,7 @@ static UINT android_init_pixel_formats( UINT *onscreen_count )
static const struct opengl_driver_funcs android_driver_funcs = { + .p_init_egl_platform = android_init_egl_platform, .p_get_proc_address = android_get_proc_address, .p_init_pixel_formats = android_init_pixel_formats, .p_describe_pixel_format = android_describe_pixel_format, @@ -497,8 +505,6 @@ static const struct opengl_driver_funcs android_driver_funcs = */ UINT ANDROID_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs ) { - EGLint major, minor; - if (version != WINE_OPENGL_DRIVER_VERSION) { ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version, WINE_OPENGL_DRIVER_VERSION ); @@ -512,10 +518,6 @@ UINT ANDROID_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, } funcs = opengl_funcs;
- display = funcs->p_eglGetDisplay( EGL_DEFAULT_DISPLAY ); - if (!funcs->p_eglInitialize( display, &major, &minor )) return 0; - TRACE( "display %p version %u.%u\n", display, major, minor ); - *driver_funcs = &android_driver_funcs; return STATUS_SUCCESS; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/opengl.c | 139 +++++++++++++--------------------- 1 file changed, 54 insertions(+), 85 deletions(-)
diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index 6b16d61de32..c2080afc908 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -42,11 +42,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv);
#include "wine/opengl_driver.h"
-static EGLDisplay egl_display; static char wgl_extensions[4096]; static EGLConfig *egl_configs; static int num_egl_configs; -static BOOL has_egl_ext_pixel_format_float; +static const struct egl_platform *egl; static const struct opengl_funcs *funcs;
#define DECL_FUNCPTR(f) static PFN_##f p_##f @@ -131,7 +130,7 @@ static struct wayland_gl_drawable *wayland_gl_drawable_get(HWND hwnd, HDC hdc) static void wayland_gl_drawable_release(struct wayland_gl_drawable *gl) { if (InterlockedDecrement(&gl->ref)) return; - if (gl->surface) funcs->p_eglDestroySurface(egl_display, gl->surface); + if (gl->surface) funcs->p_eglDestroySurface(egl->display, gl->surface); if (gl->wl_egl_window) wl_egl_window_destroy(gl->wl_egl_window); if (gl->client) { @@ -162,10 +161,19 @@ static inline EGLConfig egl_config_for_format(int format) static struct wayland_gl_drawable *wayland_gl_drawable_create(HWND hwnd, HDC hdc, int format, int width, int height) { struct wayland_gl_drawable *gl; - const EGLint attribs[] = {EGL_PRESENT_OPAQUE_EXT, EGL_TRUE, EGL_NONE}; + EGLint attribs[4], *attrib = attribs;
TRACE("hwnd=%p format=%d\n", hwnd, format);
+ if (!egl->has_EGL_EXT_present_opaque) + WARN("Missing EGL_EXT_present_opaque extension\n"); + else + { + *attrib++ = EGL_PRESENT_OPAQUE_EXT; + *attrib++ = EGL_TRUE; + } + *attrib++ = EGL_NONE; + gl = calloc(1, sizeof(*gl)); if (!gl) return NULL;
@@ -186,7 +194,7 @@ static struct wayland_gl_drawable *wayland_gl_drawable_create(HWND hwnd, HDC hdc goto err; }
- gl->surface = funcs->p_eglCreateWindowSurface(egl_display, egl_config_for_format(format), + gl->surface = funcs->p_eglCreateWindowSurface(egl->display, egl_config_for_format(format), gl->wl_egl_window, attribs); if (!gl->surface) { @@ -259,7 +267,7 @@ static BOOL wayland_context_make_current(HDC draw_hdc, HDC read_hdc, void *priva
if (!private) { - funcs->p_eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + funcs->p_eglMakeCurrent(egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); NtCurrentTeb()->glReserved2 = NULL; return TRUE; } @@ -278,7 +286,7 @@ static BOOL wayland_context_make_current(HDC draw_hdc, HDC read_hdc, void *priva
pthread_mutex_lock(&gl_object_mutex);
- ret = funcs->p_eglMakeCurrent(egl_display, + ret = funcs->p_eglMakeCurrent(egl->display, draw ? draw->surface : EGL_NO_SURFACE, read ? read->surface : EGL_NO_SURFACE, ctx->context); @@ -389,7 +397,7 @@ static void wayland_context_refresh(struct wayland_context *ctx) ctx->new_read = NULL; refresh = TRUE; } - if (refresh) funcs->p_eglMakeCurrent(egl_display, ctx->draw, ctx->read, ctx->context); + if (refresh) funcs->p_eglMakeCurrent(egl->display, ctx->draw, ctx->read, ctx->context);
pthread_mutex_unlock(&gl_object_mutex);
@@ -443,7 +451,7 @@ static BOOL wayland_context_create(HDC hdc, int format, void *share_private, con * > purposes except eglCreateContext. */ funcs->p_eglBindAPI(EGL_OPENGL_API); - ctx->context = funcs->p_eglCreateContext(egl_display, EGL_NO_CONFIG_KHR, + ctx->context = funcs->p_eglCreateContext(egl->display, EGL_NO_CONFIG_KHR, share ? share->context : EGL_NO_CONTEXT, ctx->attribs);
@@ -479,13 +487,20 @@ static BOOL wayland_context_destroy(void *private) pthread_mutex_lock(&gl_object_mutex); list_remove(&ctx->entry); pthread_mutex_unlock(&gl_object_mutex); - funcs->p_eglDestroyContext(egl_display, ctx->context); + funcs->p_eglDestroyContext(egl->display, ctx->context); if (ctx->draw) wayland_gl_drawable_release(ctx->draw); if (ctx->read) wayland_gl_drawable_release(ctx->read); free(ctx); return TRUE; }
+static EGLenum wayland_init_egl_platform(const struct egl_platform *platform, EGLNativeDisplayType *platform_display) +{ + egl = platform; + *platform_display = process_wayland.wl_display; + return EGL_PLATFORM_WAYLAND_KHR; +} + static void *wayland_get_proc_address(const char *name) { if (!strcmp(name, "glClear")) return wayland_glClear; @@ -524,8 +539,8 @@ static BOOL wayland_context_share(void *src_private, void *dst_private) return FALSE; }
- funcs->p_eglDestroyContext(egl_display, clobber->context); - clobber->context = funcs->p_eglCreateContext(egl_display, EGL_NO_CONFIG_KHR, + funcs->p_eglDestroyContext(egl->display, clobber->context); + clobber->context = funcs->p_eglCreateContext(egl->display, EGL_NO_CONFIG_KHR, keep->context, clobber->attribs); TRACE("re-created context (%p) for Wine context %p (%p) " "sharing lists with ctx %p (%p)\n", @@ -553,7 +568,7 @@ static BOOL wayland_swap_buffers(void *private, HWND hwnd, HDC hdc, int interval if (interval < 0) interval = -interval; if (gl->swap_interval != interval) { - funcs->p_eglSwapInterval(egl_display, interval); + funcs->p_eglSwapInterval(egl->display, interval); gl->swap_interval = interval; }
@@ -561,7 +576,7 @@ static BOOL wayland_swap_buffers(void *private, HWND hwnd, HDC hdc, int interval ensure_window_surface_contents(toplevel); /* Although all the EGL surfaces we create are double-buffered, we want to * use some as single-buffered, so avoid swapping those. */ - if (gl->double_buffered) funcs->p_eglSwapBuffers(egl_display, gl->surface); + if (gl->double_buffered) funcs->p_eglSwapBuffers(egl->display, gl->surface); wayland_gl_drawable_sync_size(gl);
wayland_gl_drawable_release(gl); @@ -621,7 +636,7 @@ static BOOL describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt PIXELFORMATDESCRIPTOR *pfd = &fmt->pfd;
/* If we can't get basic information, there is no point continuing */ - if (!funcs->p_eglGetConfigAttrib(egl_display, config, EGL_SURFACE_TYPE, &surface_type)) return FALSE; + if (!funcs->p_eglGetConfigAttrib(egl->display, config, EGL_SURFACE_TYPE, &surface_type)) return FALSE;
memset(fmt, 0, sizeof(*fmt)); pfd->nSize = sizeof(*pfd); @@ -637,10 +652,10 @@ static BOOL describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt
#define SET_ATTRIB(field, attrib) \ value = 0; \ - funcs->p_eglGetConfigAttrib(egl_display, config, attrib, &value); \ + funcs->p_eglGetConfigAttrib(egl->display, config, attrib, &value); \ pfd->field = value; #define SET_ATTRIB_ARB(field, attrib) \ - if (!funcs->p_eglGetConfigAttrib(egl_display, config, attrib, &value)) value = -1; \ + if (!funcs->p_eglGetConfigAttrib(egl->display, config, attrib, &value)) value = -1; \ fmt->field = value;
/* Although the documentation describes cColorBits as excluding alpha, real @@ -665,7 +680,7 @@ static BOOL describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt
fmt->swap_method = WGL_SWAP_UNDEFINED_ARB;
- if (funcs->p_eglGetConfigAttrib(egl_display, config, EGL_TRANSPARENT_TYPE, &value)) + if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_TRANSPARENT_TYPE, &value)) { switch (value) { @@ -679,8 +694,8 @@ static BOOL describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt } else fmt->transparent = -1;
- if (!has_egl_ext_pixel_format_float) fmt->pixel_type = WGL_TYPE_RGBA_ARB; - else if (funcs->p_eglGetConfigAttrib(egl_display, config, EGL_COLOR_COMPONENT_TYPE_EXT, &value)) + if (!egl->has_EGL_EXT_pixel_format_float) fmt->pixel_type = WGL_TYPE_RGBA_ARB; + else if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_COLOR_COMPONENT_TYPE_EXT, &value)) { switch (value) { @@ -704,17 +719,17 @@ static BOOL describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt fmt->max_pbuffer_height = 4096; fmt->max_pbuffer_pixels = fmt->max_pbuffer_width * fmt->max_pbuffer_height;
- if (funcs->p_eglGetConfigAttrib(egl_display, config, EGL_TRANSPARENT_RED_VALUE, &value)) + if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_TRANSPARENT_RED_VALUE, &value)) { fmt->transparent_red_value_valid = GL_TRUE; fmt->transparent_red_value = value; } - if (funcs->p_eglGetConfigAttrib(egl_display, config, EGL_TRANSPARENT_GREEN_VALUE, &value)) + if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_TRANSPARENT_GREEN_VALUE, &value)) { fmt->transparent_green_value_valid = GL_TRUE; fmt->transparent_green_value = value; } - if (funcs->p_eglGetConfigAttrib(egl_display, config, EGL_TRANSPARENT_BLUE_VALUE, &value)) + if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_TRANSPARENT_BLUE_VALUE, &value)) { fmt->transparent_blue_value_valid = GL_TRUE; fmt->transparent_blue_value = value; @@ -754,21 +769,6 @@ static BOOL wayland_describe_pixel_format(int format, struct wgl_pixel_format *d return FALSE; }
-static BOOL has_extension(const char *list, const char *ext) -{ - size_t len = strlen(ext); - const char *cur = list; - - while (cur && (cur = strstr(cur, ext))) - { - if ((!cur[len] || cur[len] == ' ') && (cur == list || cur[-1] == ' ')) - return TRUE; - cur = strchr(cur, ' '); - } - - return FALSE; -} - static void register_extension(const char *ext) { if (wgl_extensions[0]) strcat(wgl_extensions, " "); @@ -784,7 +784,7 @@ static BOOL init_opengl_funcs(void)
static const char *wayland_init_wgl_extensions(struct opengl_funcs *funcs) { - if (has_egl_ext_pixel_format_float) + if (egl->has_EGL_EXT_pixel_format_float) { register_extension("WGL_ARB_pixel_format_float"); register_extension("WGL_ATI_pixel_format_float"); @@ -803,13 +803,13 @@ static UINT wayland_init_pixel_formats(UINT *onscreen_count) EGL_NONE };
- funcs->p_eglChooseConfig(egl_display, attribs, NULL, 0, &num_egl_configs); + funcs->p_eglChooseConfig(egl->display, attribs, NULL, 0, &num_egl_configs); if (!(egl_configs = malloc(num_egl_configs * sizeof(*egl_configs)))) { ERR("Failed to allocate memory for EGL configs\n"); return 0; } - if (!funcs->p_eglChooseConfig(egl_display, attribs, egl_configs, num_egl_configs, + if (!funcs->p_eglChooseConfig(egl->display, attribs, egl_configs, num_egl_configs, &num_egl_configs) || !num_egl_configs) { @@ -825,18 +825,18 @@ static UINT wayland_init_pixel_formats(UINT *onscreen_count) for (i = 0; i < num_egl_configs; i++) { EGLint id, type, visual_id, native, render, color, r, g, b, a, d, s; - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_NATIVE_VISUAL_ID, &visual_id); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_SURFACE_TYPE, &type); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_RENDERABLE_TYPE, &render); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_CONFIG_ID, &id); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_NATIVE_RENDERABLE, &native); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_COLOR_BUFFER_TYPE, &color); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_RED_SIZE, &r); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_GREEN_SIZE, &g); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_BLUE_SIZE, &b); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_ALPHA_SIZE, &a); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_DEPTH_SIZE, &d); - funcs->p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_STENCIL_SIZE, &s); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_NATIVE_VISUAL_ID, &visual_id); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_SURFACE_TYPE, &type); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_RENDERABLE_TYPE, &render); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_CONFIG_ID, &id); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_NATIVE_RENDERABLE, &native); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_COLOR_BUFFER_TYPE, &color); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_RED_SIZE, &r); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_GREEN_SIZE, &g); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_BLUE_SIZE, &b); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_ALPHA_SIZE, &a); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_DEPTH_SIZE, &d); + funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_STENCIL_SIZE, &s); TRACE("%u: config %d id %d type %x visual %d native %d render %x " "colortype %d rgba %d,%d,%d,%d depth %u stencil %d\n", num_egl_configs, i, id, type, visual_id, native, render, @@ -850,6 +850,7 @@ static UINT wayland_init_pixel_formats(UINT *onscreen_count)
static const struct opengl_driver_funcs wayland_driver_funcs = { + .p_init_egl_platform = wayland_init_egl_platform, .p_get_proc_address = wayland_get_proc_address, .p_init_pixel_formats = wayland_init_pixel_formats, .p_describe_pixel_format = wayland_describe_pixel_format, @@ -873,9 +874,6 @@ static const struct opengl_driver_funcs wayland_driver_funcs = */ UINT WAYLAND_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs) { - EGLint egl_version[2]; - const char *egl_exts; - if (version != WINE_OPENGL_DRIVER_VERSION) { ERR("Version mismatch, opengl32 wants %u but driver has %u\n", @@ -886,35 +884,6 @@ UINT WAYLAND_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, c if (!opengl_funcs->egl_handle) return STATUS_NOT_SUPPORTED; funcs = opengl_funcs;
- egl_display = funcs->p_eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, - process_wayland.wl_display, - NULL); - if (egl_display == EGL_NO_DISPLAY) - { - ERR("Failed to get EGLDisplay\n"); - goto err; - } - if (!funcs->p_eglInitialize(egl_display, &egl_version[0], &egl_version[1])) - { - ERR("Failed to initialized EGLDisplay with error %d\n", funcs->p_eglGetError()); - goto err; - } - TRACE("EGL version %u.%u\n", egl_version[0], egl_version[1]); - - egl_exts = funcs->p_eglQueryString(egl_display, EGL_EXTENSIONS); -#define REQUIRE_EXT(ext) \ - do { \ - if (!has_extension(egl_exts, #ext)) \ - { ERR("Failed to find required extension %s\n", #ext); goto err; } \ - } while(0) - REQUIRE_EXT(EGL_KHR_create_context); - REQUIRE_EXT(EGL_KHR_create_context_no_error); - REQUIRE_EXT(EGL_KHR_no_config_context); - REQUIRE_EXT(EGL_EXT_present_opaque); -#undef REQUIRE_EXT - - has_egl_ext_pixel_format_float = has_extension(egl_exts, "EGL_EXT_pixel_format_float"); - if (!init_opengl_funcs()) goto err; *driver_funcs = &wayland_driver_funcs; return STATUS_SUCCESS;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 123 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 120 insertions(+), 3 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index fea74a59313..96b5d3fc8c5 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -176,7 +176,123 @@ static void register_extension( char *list, size_t size, const char *name )
#ifdef SONAME_LIBEGL
-static BOOL egl_init(void) +static void *egldrv_get_proc_address( const char *name ) +{ + return display_funcs.p_eglGetProcAddress( name ); +} + +static UINT egldrv_init_pixel_formats( UINT *onscreen_count ) +{ + FIXME( "stub!\n" ); + return *onscreen_count = 0; +} + +static BOOL egldrv_describe_pixel_format( int format, struct wgl_pixel_format *desc ) +{ + FIXME( "stub!\n" ); + return FALSE; +} + +static const char *egldrv_init_wgl_extensions( struct opengl_funcs *funcs ) +{ + FIXME( "stub!\n" ); + return ""; +} + +static BOOL egldrv_set_pixel_format( HWND hwnd, int old_format, int new_format, BOOL internal ) +{ + FIXME( "stub!\n" ); + return TRUE; +} + +static BOOL egldrv_swap_buffers( void *private, HWND hwnd, HDC hdc, int interval ) +{ + FIXME( "stub!\n" ); + return TRUE; +} + +static BOOL egldrv_pbuffer_create( HDC hdc, int format, BOOL largest, GLenum texture_format, GLenum texture_target, + GLint max_level, GLsizei *width, GLsizei *height, void **private ) +{ + FIXME( "stub!\n" ); + return FALSE; +} + +static BOOL egldrv_pbuffer_destroy( HDC hdc, void *private ) +{ + FIXME( "stub!\n" ); + return FALSE; +} + +static BOOL egldrv_pbuffer_updated( HDC hdc, void *private, GLenum cube_face, GLint mipmap_level ) +{ + FIXME( "stub!\n" ); + return GL_TRUE; +} + +static UINT egldrv_pbuffer_bind( HDC hdc, void *private, GLenum buffer ) +{ + FIXME( "stub!\n" ); + return -1; /* use default implementation */ +} + +static BOOL egldrv_context_create( HDC hdc, int format, void *share, const int *attribs, void **private ) +{ + FIXME( "stub!\n" ); + return TRUE; +} + +static BOOL egldrv_context_destroy( void *private ) +{ + FIXME( "stub!\n" ); + return FALSE; +} + +static BOOL egldrv_context_copy( void *src_private, void *dst_private, UINT mask ) +{ + FIXME( "stub!\n" ); + return FALSE; +} + +static BOOL egldrv_context_share( void *src_private, void *dst_private ) +{ + FIXME( "stub!\n" ); + return FALSE; +} + +static BOOL egldrv_context_flush( void *private, HWND hwnd, HDC hdc, int interval, BOOL finish ) +{ + FIXME( "stub!\n" ); + return FALSE; +} + +static BOOL egldrv_context_make_current( HDC draw_hdc, HDC read_hdc, void *private ) +{ + FIXME( "stub!\n" ); + return FALSE; +} + +static const struct opengl_driver_funcs egldrv_funcs = +{ + .p_get_proc_address = egldrv_get_proc_address, + .p_init_pixel_formats = egldrv_init_pixel_formats, + .p_describe_pixel_format = egldrv_describe_pixel_format, + .p_init_wgl_extensions = egldrv_init_wgl_extensions, + .p_set_pixel_format = egldrv_set_pixel_format, + .p_swap_buffers = egldrv_swap_buffers, + .p_pbuffer_create = egldrv_pbuffer_create, + .p_pbuffer_destroy = egldrv_pbuffer_destroy, + .p_pbuffer_updated = egldrv_pbuffer_updated, + .p_pbuffer_bind = egldrv_pbuffer_bind, + .p_context_create = egldrv_context_create, + .p_context_destroy = egldrv_context_destroy, + .p_context_copy = egldrv_context_copy, + .p_context_share = egldrv_context_share, + .p_context_flush = egldrv_context_flush, + .p_context_make_current = egldrv_context_make_current, +}; + +static BOOL egl_init( const struct opengl_driver_funcs **driver_funcs ) { struct opengl_funcs *funcs = &display_funcs; const char *extensions; @@ -224,6 +340,7 @@ static BOOL egl_init(void) ALL_EGL_FUNCS #undef USE_GL_FUNC
+ *driver_funcs = &egldrv_funcs; return TRUE;
failed: @@ -276,7 +393,7 @@ static void init_egl_platform( struct egl_platform *egl, struct opengl_funcs *fu
#else /* SONAME_LIBEGL */
-static BOOL egl_init(void) +static BOOL egl_init( struct opengl_driver_funcs **driver_funcs ) { WARN( "EGL support not compiled in!\n" ); return FALSE; @@ -1466,7 +1583,7 @@ static void display_funcs_init(void) { UINT status;
- if (egl_init()) TRACE( "Initialized EGL library\n" ); + if (egl_init( &display_driver_funcs )) TRACE( "Initialized EGL library\n" );
if ((status = user_driver->pOpenGLInit( WINE_OPENGL_DRIVER_VERSION, &display_funcs, &display_driver_funcs ))) WARN( "Failed to initialize the driver OpenGL functions, status %#x\n", status );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 192 ++++++++++++++++++++++++++++++++++- include/wine/opengl_driver.h | 4 +- 2 files changed, 190 insertions(+), 6 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 96b5d3fc8c5..09335adb135 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -183,19 +183,195 @@ static void *egldrv_get_proc_address( const char *name )
static UINT egldrv_init_pixel_formats( UINT *onscreen_count ) { - FIXME( "stub!\n" ); - return *onscreen_count = 0; + const struct opengl_funcs *funcs = &display_funcs; + struct egl_platform *egl = &display_egl; + const EGLint attribs[] = + { + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_NONE + }; + EGLConfig *configs; + EGLint i, count; + + funcs->p_eglChooseConfig( egl->display, attribs, NULL, 0, &count ); + if (!(configs = malloc( count * sizeof(*configs) ))) return 0; + if (!funcs->p_eglChooseConfig( egl->display, attribs, configs, count, &count ) || !count) + { + ERR( "Failed to get any configs from eglChooseConfig\n" ); + free( configs ); + return 0; + } + + if (TRACE_ON(wgl)) for (i = 0; i < count; i++) + { + EGLint id, type, visual_id, native, render, color, r, g, b, a, d, s; + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_NATIVE_VISUAL_ID, &visual_id ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_SURFACE_TYPE, &type ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_RENDERABLE_TYPE, &render ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_CONFIG_ID, &id ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_NATIVE_RENDERABLE, &native ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_COLOR_BUFFER_TYPE, &color ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_RED_SIZE, &r ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_GREEN_SIZE, &g ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_BLUE_SIZE, &b ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_ALPHA_SIZE, &a ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_DEPTH_SIZE, &d ); + funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_STENCIL_SIZE, &s ); + TRACE( "%u: config %d id %d type %x visual %d native %d render %x colortype %d rgba %d,%d,%d,%d depth %u stencil %d\n", + count, i, id, type, visual_id, native, render, color, r, g, b, a, d, s ); + } + + egl->configs = configs; + egl->config_count = count; + *onscreen_count = count; + return 2 * count; +} + +static BOOL describe_egl_config( EGLConfig config, struct wgl_pixel_format *fmt, BOOL onscreen ) +{ + const struct opengl_funcs *funcs = &display_funcs; + struct egl_platform *egl = &display_egl; + EGLint value, surface_type; + PIXELFORMATDESCRIPTOR *pfd = &fmt->pfd; + + /* If we can't get basic information, there is no point continuing */ + if (!funcs->p_eglGetConfigAttrib( egl->display, config, EGL_SURFACE_TYPE, &surface_type )) return FALSE; + + memset( fmt, 0, sizeof(*fmt) ); + pfd->nSize = sizeof(*pfd); + pfd->nVersion = 1; + pfd->dwFlags = PFD_SUPPORT_OPENGL | PFD_SUPPORT_COMPOSITION; + if (onscreen) + { + pfd->dwFlags |= PFD_DOUBLEBUFFER; + if (surface_type & EGL_WINDOW_BIT) pfd->dwFlags |= PFD_DRAW_TO_WINDOW; + } + pfd->iPixelType = PFD_TYPE_RGBA; + pfd->iLayerType = PFD_MAIN_PLANE; + +#define SET_ATTRIB( field, attrib ) \ + value = 0; \ + funcs->p_eglGetConfigAttrib( egl->display, config, attrib, &value ); \ + pfd->field = value; +#define SET_ATTRIB_ARB( field, attrib ) \ + if (!funcs->p_eglGetConfigAttrib( egl->display, config, attrib, &value )) value = -1; \ + fmt->field = value; + + /* Although the documentation describes cColorBits as excluding alpha, real + * drivers tend to return the full pixel size, so do the same. */ + SET_ATTRIB( cColorBits, EGL_BUFFER_SIZE ); + SET_ATTRIB( cRedBits, EGL_RED_SIZE ); + SET_ATTRIB( cGreenBits, EGL_GREEN_SIZE ); + SET_ATTRIB( cBlueBits, EGL_BLUE_SIZE ); + SET_ATTRIB( cAlphaBits, EGL_ALPHA_SIZE ); + /* Although we don't get information from EGL about the component shifts + * or the native format, the 0xARGB order is the most common. */ + pfd->cBlueShift = 0; + pfd->cGreenShift = pfd->cBlueBits; + pfd->cRedShift = pfd->cGreenBits + pfd->cBlueBits; + if (!pfd->cAlphaBits) pfd->cAlphaShift = 0; + else pfd->cAlphaShift = pfd->cRedBits + pfd->cGreenBits + pfd->cBlueBits; + + SET_ATTRIB( cDepthBits, EGL_DEPTH_SIZE ); + SET_ATTRIB( cStencilBits, EGL_STENCIL_SIZE ); + + fmt->swap_method = WGL_SWAP_UNDEFINED_ARB; + + if (funcs->p_eglGetConfigAttrib( egl->display, config, EGL_TRANSPARENT_TYPE, &value )) + { + switch (value) + { + case EGL_TRANSPARENT_RGB: + fmt->transparent = GL_TRUE; + break; + case EGL_NONE: + fmt->transparent = GL_FALSE; + break; + default: + ERR( "unexpected transparency type 0x%x\n", value ); + fmt->transparent = -1; + break; + } + } + else fmt->transparent = -1; + + if (!egl->has_EGL_EXT_pixel_format_float) fmt->pixel_type = WGL_TYPE_RGBA_ARB; + else if (funcs->p_eglGetConfigAttrib( egl->display, config, EGL_COLOR_COMPONENT_TYPE_EXT, &value )) + { + switch (value) + { + case EGL_COLOR_COMPONENT_TYPE_FIXED_EXT: + fmt->pixel_type = WGL_TYPE_RGBA_ARB; + break; + case EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT: + fmt->pixel_type = WGL_TYPE_RGBA_FLOAT_ARB; + break; + default: + ERR( "unexpected color component type 0x%x\n", value ); + fmt->pixel_type = -1; + break; + } + } + else fmt->pixel_type = -1; + + fmt->draw_to_pbuffer = TRUE; + /* Use some arbitrary but reasonable limits (4096 is also Mesa's default) */ + fmt->max_pbuffer_width = 4096; + fmt->max_pbuffer_height = 4096; + fmt->max_pbuffer_pixels = fmt->max_pbuffer_width * fmt->max_pbuffer_height; + + if (funcs->p_eglGetConfigAttrib( egl->display, config, EGL_TRANSPARENT_RED_VALUE, &value )) + { + fmt->transparent_red_value_valid = GL_TRUE; + fmt->transparent_red_value = value; + } + if (funcs->p_eglGetConfigAttrib( egl->display, config, EGL_TRANSPARENT_GREEN_VALUE, &value )) + { + fmt->transparent_green_value_valid = GL_TRUE; + fmt->transparent_green_value = value; + } + if (funcs->p_eglGetConfigAttrib( egl->display, config, EGL_TRANSPARENT_BLUE_VALUE, &value )) + { + fmt->transparent_blue_value_valid = GL_TRUE; + fmt->transparent_blue_value = value; + } + fmt->transparent_alpha_value_valid = GL_TRUE; + fmt->transparent_alpha_value = 0; + fmt->transparent_index_value_valid = GL_TRUE; + fmt->transparent_index_value = 0; + + SET_ATTRIB_ARB( sample_buffers, EGL_SAMPLE_BUFFERS ); + SET_ATTRIB_ARB( samples, EGL_SAMPLES ); + + fmt->bind_to_texture_rgb = GL_TRUE; + fmt->bind_to_texture_rgba = GL_TRUE; + fmt->bind_to_texture_rectangle_rgb = GL_TRUE; + fmt->bind_to_texture_rectangle_rgba = GL_TRUE; + + /* TODO: Support SRGB surfaces and enable the attribute */ + fmt->framebuffer_srgb_capable = GL_FALSE; + + fmt->float_components = GL_FALSE; + +#undef SET_ATTRIB +#undef SET_ATTRIB_ARB + return TRUE; }
static BOOL egldrv_describe_pixel_format( int format, struct wgl_pixel_format *desc ) { - FIXME( "stub!\n" ); - return FALSE; + struct egl_platform *egl = &display_egl; + int count = egl->config_count; + BOOL onscreen = TRUE; + + if (--format < 0 || format > 2 * count) return FALSE; + if (format >= count) onscreen = FALSE; + return describe_egl_config( egl->configs[format % count], desc, onscreen ); }
static const char *egldrv_init_wgl_extensions( struct opengl_funcs *funcs ) { - FIXME( "stub!\n" ); return ""; }
@@ -1611,6 +1787,12 @@ static void display_funcs_init(void) p_display_glFlush = display_funcs.p_glFlush; display_funcs.p_glFlush = win32u_glFlush;
+ if (display_egl.has_EGL_EXT_pixel_format_float) + { + register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_pixel_format_float" ); + register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ATI_pixel_format_float" ); + } + register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_extensions_string" ); display_funcs.p_wglGetExtensionsStringARB = win32u_wglGetExtensionsStringARB;
diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 693c2b80d2e..2de585d8ce5 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -61,7 +61,7 @@ struct wgl_pixel_format #ifdef WINE_UNIX_LIB
/* Wine internal opengl driver version, needs to be bumped upon opengl_funcs changes. */ -#define WINE_OPENGL_DRIVER_VERSION 34 +#define WINE_OPENGL_DRIVER_VERSION 35
struct wgl_context; struct wgl_pbuffer; @@ -116,6 +116,8 @@ struct opengl_funcs struct egl_platform { EGLDisplay display; + UINT config_count; + EGLConfig *configs; BOOL has_EGL_EXT_present_opaque; BOOL has_EGL_EXT_pixel_format_float; };
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/wineandroid.drv/opengl.c | 123 +++++----------------------------- 1 file changed, 16 insertions(+), 107 deletions(-)
diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index 73804e4918b..79204b5e277 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -78,15 +78,18 @@ struct gl_drawable };
static void *opengl_handle; -static struct egl_pixel_format *pixel_formats; -static int nb_pixel_formats, nb_onscreen_formats; -static char wgl_extensions[4096]; - static struct list gl_contexts = LIST_INIT( gl_contexts ); static struct list gl_drawables = LIST_INIT( gl_drawables );
pthread_mutex_t drawable_mutex;
+static inline EGLConfig egl_config_for_format(int format) +{ + assert(format > 0 && format <= 2 * egl->config_count); + if (format <= egl->config_count) return egl->configs[format - 1]; + return egl->configs[format - egl->config_count - 1]; +} + static struct gl_drawable *create_gl_drawable( HWND hwnd, HDC hdc, int format ) { static const int attribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE }; @@ -97,7 +100,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, HDC hdc, int format ) gl->format = format; gl->window = create_ioctl_window( hwnd, TRUE, 1.0f ); gl->surface = 0; - gl->pbuffer = funcs->p_eglCreatePbufferSurface( egl->display, pixel_formats[gl->format - 1].config, attribs ); + gl->pbuffer = funcs->p_eglCreatePbufferSurface( egl->display, egl_config_for_format(gl->format), attribs ); pthread_mutex_lock( &drawable_mutex ); list_add_head( &gl_drawables, &gl->entry ); return gl; @@ -161,7 +164,7 @@ void update_gl_drawable( HWND hwnd ) if ((gl = get_gl_drawable( hwnd, 0 ))) { if (!gl->surface && - (gl->surface = funcs->p_eglCreateWindowSurface( egl->display, pixel_formats[gl->format - 1].config, + (gl->surface = funcs->p_eglCreateWindowSurface( egl->display, egl_config_for_format(gl->format), gl->window, NULL ))) { LIST_FOR_EACH_ENTRY( ctx, &gl_contexts, struct android_context, entry ) @@ -191,7 +194,7 @@ static BOOL android_set_pixel_format( HWND hwnd, int old_format, int new_format, if (internal) { EGLint pf; - funcs->p_eglGetConfigAttrib( egl->display, pixel_formats[new_format - 1].config, EGL_NATIVE_VISUAL_ID, &pf ); + funcs->p_eglGetConfigAttrib( egl->display, egl_config_for_format(new_format), EGL_NATIVE_VISUAL_ID, &pf ); gl->window->perform( gl->window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, pf ); gl->format = new_format; } @@ -241,7 +244,7 @@ static BOOL android_context_create( HDC hdc, int format, void *share, const int
ctx = malloc( sizeof(*ctx) );
- ctx->config = pixel_formats[format - 1].config; + ctx->config = egl_config_for_format(format); ctx->surface = 0; ctx->refresh = FALSE; ctx->context = funcs->p_eglCreateContext( egl->display, ctx->config, shared_ctx ? shared_ctx->context : EGL_NO_CONTEXT, attribs ); @@ -252,44 +255,6 @@ static BOOL android_context_create( HDC hdc, int format, void *share, const int return TRUE; }
-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; - pfd->dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER | PFD_SUPPORT_COMPOSITION; - pfd->iPixelType = PFD_TYPE_RGBA; - pfd->iLayerType = PFD_MAIN_PLANE; - - funcs->p_eglGetConfigAttrib( egl->display, config, EGL_BUFFER_SIZE, &val ); - pfd->cColorBits = val; - funcs->p_eglGetConfigAttrib( egl->display, config, EGL_RED_SIZE, &val ); - pfd->cRedBits = val; - funcs->p_eglGetConfigAttrib( egl->display, config, EGL_GREEN_SIZE, &val ); - pfd->cGreenBits = val; - funcs->p_eglGetConfigAttrib( egl->display, config, EGL_BLUE_SIZE, &val ); - pfd->cBlueBits = val; - funcs->p_eglGetConfigAttrib( egl->display, config, EGL_ALPHA_SIZE, &val ); - pfd->cAlphaBits = val; - funcs->p_eglGetConfigAttrib( egl->display, config, EGL_DEPTH_SIZE, &val ); - pfd->cDepthBits = val; - funcs->p_eglGetConfigAttrib( egl->display, config, EGL_STENCIL_SIZE, &val ); - pfd->cStencilBits = val; - - pfd->cAlphaShift = 0; - pfd->cBlueShift = pfd->cAlphaShift + pfd->cAlphaBits; - pfd->cGreenShift = pfd->cBlueShift + pfd->cBlueBits; - pfd->cRedShift = pfd->cGreenShift + pfd->cGreenBits; - return TRUE; -} - static BOOL android_context_make_current( HDC draw_hdc, HDC read_hdc, void *private ) { struct android_context *ctx = private; @@ -421,74 +386,15 @@ static BOOL android_context_flush( void *private, HWND hwnd, HDC hdc, int interv return FALSE; }
-static void register_extension( const char *ext ) -{ - if (wgl_extensions[0]) strcat( wgl_extensions, " " ); - strcat( wgl_extensions, ext ); - TRACE( "%s\n", ext ); -} - static const char *android_init_wgl_extensions( struct opengl_funcs *funcs ) { - register_extension("WGL_EXT_framebuffer_sRGB"); - return wgl_extensions; + return "WGL_EXT_framebuffer_sRGB"; }
-static UINT android_init_pixel_formats( UINT *onscreen_count ) -{ - EGLConfig *configs; - EGLint count, i, pass; - - funcs->p_eglGetConfigs( egl->display, NULL, 0, &count ); - configs = malloc( count * sizeof(*configs) ); - pixel_formats = malloc( count * sizeof(*pixel_formats) ); - funcs->p_eglGetConfigs( egl->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; - - funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_SURFACE_TYPE, &type ); - if (!(type & EGL_WINDOW_BIT) == !pass) continue; - funcs->p_eglGetConfigAttrib( egl->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]; - - funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_CONFIG_ID, &id ); - funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_NATIVE_VISUAL_ID, &visual_id ); - funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_NATIVE_RENDERABLE, &native ); - funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_COLOR_BUFFER_TYPE, &color ); - funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_RED_SIZE, &r ); - funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_GREEN_SIZE, &g ); - funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_BLUE_SIZE, &b ); - funcs->p_eglGetConfigAttrib( egl->display, configs[i], EGL_DEPTH_SIZE, &d ); - funcs->p_eglGetConfigAttrib( egl->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 = +static struct opengl_driver_funcs android_driver_funcs = { .p_init_egl_platform = android_init_egl_platform, .p_get_proc_address = android_get_proc_address, - .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, .p_swap_buffers = android_swap_buffers, @@ -518,6 +424,9 @@ UINT ANDROID_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, } funcs = opengl_funcs;
+ android_driver_funcs.p_init_pixel_formats = (*driver_funcs)->p_init_pixel_formats; + android_driver_funcs.p_describe_pixel_format = (*driver_funcs)->p_describe_pixel_format; + *driver_funcs = &android_driver_funcs; return STATUS_SUCCESS; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/opengl.c | 233 ++-------------------------------- 1 file changed, 10 insertions(+), 223 deletions(-)
diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index c2080afc908..dfda1972dcf 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -42,9 +42,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv);
#include "wine/opengl_driver.h"
-static char wgl_extensions[4096]; -static EGLConfig *egl_configs; -static int num_egl_configs; static const struct egl_platform *egl; static const struct opengl_funcs *funcs;
@@ -148,14 +145,14 @@ static void wayland_gl_drawable_release(struct wayland_gl_drawable *gl)
static inline BOOL is_onscreen_format(int format) { - return format > 0 && format <= num_egl_configs; + return format > 0 && format <= egl->config_count; }
static inline EGLConfig egl_config_for_format(int format) { - assert(format > 0 && format <= 2 * num_egl_configs); - if (format <= num_egl_configs) return egl_configs[format - 1]; - return egl_configs[format - num_egl_configs - 1]; + assert(format > 0 && format <= 2 * egl->config_count); + if (format <= egl->config_count) return egl->configs[format - 1]; + return egl->configs[format - egl->config_count - 1]; }
static struct wayland_gl_drawable *wayland_gl_drawable_create(HWND hwnd, HDC hdc, int format, int width, int height) @@ -630,231 +627,16 @@ static UINT wayland_pbuffer_bind(HDC hdc, void *private, GLenum buffer) return -1; /* use default implementation */ }
-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 (!funcs->p_eglGetConfigAttrib(egl->display, config, EGL_SURFACE_TYPE, &surface_type)) return FALSE; - - memset(fmt, 0, sizeof(*fmt)); - pfd->nSize = sizeof(*pfd); - pfd->nVersion = 1; - pfd->dwFlags = PFD_SUPPORT_OPENGL | PFD_SUPPORT_COMPOSITION; - if (!pbuffer_single) - { - pfd->dwFlags |= PFD_DOUBLEBUFFER; - if (surface_type & EGL_WINDOW_BIT) pfd->dwFlags |= PFD_DRAW_TO_WINDOW; - } - pfd->iPixelType = PFD_TYPE_RGBA; - pfd->iLayerType = PFD_MAIN_PLANE; - -#define SET_ATTRIB(field, attrib) \ - value = 0; \ - funcs->p_eglGetConfigAttrib(egl->display, config, attrib, &value); \ - pfd->field = value; -#define SET_ATTRIB_ARB(field, attrib) \ - if (!funcs->p_eglGetConfigAttrib(egl->display, config, attrib, &value)) value = -1; \ - fmt->field = value; - - /* Although the documentation describes cColorBits as excluding alpha, real - * drivers tend to return the full pixel size, so do the same. */ - SET_ATTRIB(cColorBits, EGL_BUFFER_SIZE); - SET_ATTRIB(cRedBits, EGL_RED_SIZE); - SET_ATTRIB(cGreenBits, EGL_GREEN_SIZE); - SET_ATTRIB(cBlueBits, EGL_BLUE_SIZE); - SET_ATTRIB(cAlphaBits, EGL_ALPHA_SIZE); - /* Although we don't get information from EGL about the component shifts - * or the native format, the 0xARGB order is the most common. */ - pfd->cBlueShift = 0; - pfd->cGreenShift = pfd->cBlueBits; - pfd->cRedShift = pfd->cGreenBits + pfd->cBlueBits; - if (pfd->cAlphaBits) - pfd->cAlphaShift = pfd->cRedBits + pfd->cGreenBits + pfd->cBlueBits; - else - pfd->cAlphaShift = 0; - - SET_ATTRIB(cDepthBits, EGL_DEPTH_SIZE); - SET_ATTRIB(cStencilBits, EGL_STENCIL_SIZE); - - fmt->swap_method = WGL_SWAP_UNDEFINED_ARB; - - if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_TRANSPARENT_TYPE, &value)) - { - switch (value) - { - case EGL_TRANSPARENT_RGB: fmt->transparent = GL_TRUE; break; - case EGL_NONE: fmt->transparent = GL_FALSE; break; - default: - ERR("unexpected transparency type 0x%x\n", value); - fmt->transparent = -1; - break; - } - } - else fmt->transparent = -1; - - if (!egl->has_EGL_EXT_pixel_format_float) fmt->pixel_type = WGL_TYPE_RGBA_ARB; - else if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_COLOR_COMPONENT_TYPE_EXT, &value)) - { - switch (value) - { - case EGL_COLOR_COMPONENT_TYPE_FIXED_EXT: - fmt->pixel_type = WGL_TYPE_RGBA_ARB; - break; - case EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT: - fmt->pixel_type = WGL_TYPE_RGBA_FLOAT_ARB; - break; - default: - ERR("unexpected color component type 0x%x\n", value); - fmt->pixel_type = -1; - break; - } - } - else fmt->pixel_type = -1; - - fmt->draw_to_pbuffer = TRUE; - /* Use some arbitrary but reasonable limits (4096 is also Mesa's default) */ - fmt->max_pbuffer_width = 4096; - fmt->max_pbuffer_height = 4096; - fmt->max_pbuffer_pixels = fmt->max_pbuffer_width * fmt->max_pbuffer_height; - - if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_TRANSPARENT_RED_VALUE, &value)) - { - fmt->transparent_red_value_valid = GL_TRUE; - fmt->transparent_red_value = value; - } - if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_TRANSPARENT_GREEN_VALUE, &value)) - { - fmt->transparent_green_value_valid = GL_TRUE; - fmt->transparent_green_value = value; - } - if (funcs->p_eglGetConfigAttrib(egl->display, config, EGL_TRANSPARENT_BLUE_VALUE, &value)) - { - fmt->transparent_blue_value_valid = GL_TRUE; - fmt->transparent_blue_value = value; - } - fmt->transparent_alpha_value_valid = GL_TRUE; - fmt->transparent_alpha_value = 0; - fmt->transparent_index_value_valid = GL_TRUE; - fmt->transparent_index_value = 0; - - SET_ATTRIB_ARB(sample_buffers, EGL_SAMPLE_BUFFERS); - SET_ATTRIB_ARB(samples, EGL_SAMPLES); - - fmt->bind_to_texture_rgb = GL_TRUE; - fmt->bind_to_texture_rgba = GL_TRUE; - fmt->bind_to_texture_rectangle_rgb = GL_TRUE; - fmt->bind_to_texture_rectangle_rgba = GL_TRUE; - - /* TODO: Support SRGB surfaces and enable the attribute */ - fmt->framebuffer_srgb_capable = GL_FALSE; - - fmt->float_components = GL_FALSE; - -#undef SET_ATTRIB -#undef SET_ATTRIB_ARB - return TRUE; -} - -static BOOL wayland_describe_pixel_format(int format, struct wgl_pixel_format *desc) -{ - 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 void register_extension(const char *ext) -{ - if (wgl_extensions[0]) strcat(wgl_extensions, " "); - strcat(wgl_extensions, ext); - TRACE("%s\n", ext); -} - static BOOL init_opengl_funcs(void) { p_glClear = (void *)funcs->p_eglGetProcAddress("glClear"); return TRUE; }
-static const char *wayland_init_wgl_extensions(struct opengl_funcs *funcs) -{ - if (egl->has_EGL_EXT_pixel_format_float) - { - register_extension("WGL_ARB_pixel_format_float"); - register_extension("WGL_ATI_pixel_format_float"); - } - - return wgl_extensions; -} - -static UINT wayland_init_pixel_formats(UINT *onscreen_count) -{ - EGLint i; - const EGLint attribs[] = - { - EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_NONE - }; - - funcs->p_eglChooseConfig(egl->display, attribs, NULL, 0, &num_egl_configs); - if (!(egl_configs = malloc(num_egl_configs * sizeof(*egl_configs)))) - { - ERR("Failed to allocate memory for EGL configs\n"); - return 0; - } - if (!funcs->p_eglChooseConfig(egl->display, attribs, egl_configs, num_egl_configs, - &num_egl_configs) || - !num_egl_configs) - { - free(egl_configs); - egl_configs = NULL; - num_egl_configs = 0; - ERR("Failed to get any configs from eglChooseConfig\n"); - return 0; - } - - if (TRACE_ON(waylanddrv)) - { - for (i = 0; i < num_egl_configs; i++) - { - EGLint id, type, visual_id, native, render, color, r, g, b, a, d, s; - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_NATIVE_VISUAL_ID, &visual_id); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_SURFACE_TYPE, &type); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_RENDERABLE_TYPE, &render); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_CONFIG_ID, &id); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_NATIVE_RENDERABLE, &native); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_COLOR_BUFFER_TYPE, &color); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_RED_SIZE, &r); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_GREEN_SIZE, &g); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_BLUE_SIZE, &b); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_ALPHA_SIZE, &a); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_DEPTH_SIZE, &d); - funcs->p_eglGetConfigAttrib(egl->display, egl_configs[i], EGL_STENCIL_SIZE, &s); - TRACE("%u: config %d id %d type %x visual %d native %d render %x " - "colortype %d rgba %d,%d,%d,%d depth %u stencil %d\n", - num_egl_configs, i, id, type, visual_id, native, render, - color, r, g, b, a, d, s); - } - } - - *onscreen_count = num_egl_configs; - return 2 * num_egl_configs; -} - -static const struct opengl_driver_funcs wayland_driver_funcs = +static struct opengl_driver_funcs wayland_driver_funcs = { .p_init_egl_platform = wayland_init_egl_platform, .p_get_proc_address = wayland_get_proc_address, - .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, .p_swap_buffers = wayland_swap_buffers, .p_context_create = wayland_context_create, @@ -885,6 +667,11 @@ UINT WAYLAND_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, c funcs = opengl_funcs;
if (!init_opengl_funcs()) goto err; + + wayland_driver_funcs.p_init_pixel_formats = (*driver_funcs)->p_init_pixel_formats; + wayland_driver_funcs.p_describe_pixel_format = (*driver_funcs)->p_describe_pixel_format; + wayland_driver_funcs.p_init_wgl_extensions = (*driver_funcs)->p_init_wgl_extensions; + *driver_funcs = &wayland_driver_funcs; return STATUS_SUCCESS;
On Fri May 23 05:23:14 2025 +0000, Alexandre Julliard wrote:
It doesn't seem very nice to add a bunch of variables to opengl_funcs. Some kind of separate egl_info structure would be cleaner IMO.
Moved it to a separate egl_platform struct, which I feel could indeed be useful to eventually implement multiple EGL backends (as EGL_EXT_platform_device can be used to create per-GPU offscreen displays).