-- v2: wineandroid: Use the EGL functions loaded from win32u. winewayland: Use the EGL functions loaded from win32u. win32u: Load EGL and expose functions in opengl_funcs. win32u: Move the opengl_funcs tables out of the drivers. win32u: Initialize opengl_funcs tables even on failure. win32u: Pass opengl_funcs pointer to init_wgl_extensions.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 6 +++--- dlls/wineandroid.drv/opengl.c | 2 +- dlls/winemac.drv/opengl.c | 10 +++++----- dlls/winewayland.drv/opengl.c | 2 +- dlls/winex11.drv/opengl.c | 14 +++++++------- include/wine/opengl_driver.h | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 5bde88ae3c6..651448b62f2 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -231,7 +231,7 @@ failed: return NULL; }
-static const char *osmesa_init_wgl_extensions(void) +static const char *osmesa_init_wgl_extensions( struct opengl_funcs *funcs ) { return ""; } @@ -426,7 +426,7 @@ static BOOL nulldrv_describe_pixel_format( int format, struct wgl_pixel_format * return TRUE; }
-static const char *nulldrv_init_wgl_extensions(void) +static const char *nulldrv_init_wgl_extensions( struct opengl_funcs *funcs ) { return ""; } @@ -1366,7 +1366,7 @@ static void display_funcs_init(void) display_funcs->p_wglGetProcAddress = win32u_display_wglGetProcAddress; display_funcs->p_get_pixel_formats = win32u_display_get_pixel_formats;
- strcpy( wgl_extensions, display_driver_funcs->p_init_wgl_extensions() ); + strcpy( wgl_extensions, display_driver_funcs->p_init_wgl_extensions( display_funcs ) ); 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 ba71c717f4a..d65d4f2d565 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -440,7 +440,7 @@ static void register_extension( const char *ext ) TRACE( "%s\n", ext ); }
-static const char *android_init_wgl_extensions(void) +static const char *android_init_wgl_extensions( struct opengl_funcs *funcs ) { register_extension("WGL_EXT_framebuffer_sRGB"); return wgl_extensions; diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 0fc78f247c7..c5ad5e18a09 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -2729,7 +2729,7 @@ static void register_extension(const char *ext) TRACE("'%s'\n", ext); }
-static const char *macdrv_init_wgl_extensions(void) +static const char *macdrv_init_wgl_extensions(struct opengl_funcs *funcs) { /* * ARB Extensions @@ -2767,10 +2767,10 @@ static const char *macdrv_init_wgl_extensions(void) */
register_extension("WGL_WINE_query_renderer"); - opengl_funcs.p_wglQueryCurrentRendererIntegerWINE = macdrv_wglQueryCurrentRendererIntegerWINE; - opengl_funcs.p_wglQueryCurrentRendererStringWINE = macdrv_wglQueryCurrentRendererStringWINE; - opengl_funcs.p_wglQueryRendererIntegerWINE = macdrv_wglQueryRendererIntegerWINE; - opengl_funcs.p_wglQueryRendererStringWINE = macdrv_wglQueryRendererStringWINE; + funcs->p_wglQueryCurrentRendererIntegerWINE = macdrv_wglQueryCurrentRendererIntegerWINE; + funcs->p_wglQueryCurrentRendererStringWINE = macdrv_wglQueryCurrentRendererStringWINE; + funcs->p_wglQueryRendererIntegerWINE = macdrv_wglQueryRendererIntegerWINE; + funcs->p_wglQueryRendererStringWINE = macdrv_wglQueryRendererStringWINE;
return gl_info.wglExtensions; } diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index ef7c348a584..3285af9a505 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -811,7 +811,7 @@ static BOOL init_opengl_funcs(void) return TRUE; }
-static const char *wayland_init_wgl_extensions(void) +static const char *wayland_init_wgl_extensions(struct opengl_funcs *funcs) { if (has_egl_ext_pixel_format_float) { diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index de0917062b7..d6f18867f7a 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1930,7 +1930,7 @@ static void register_extension(const char *ext) TRACE("'%s'\n", ext); }
-static const char *x11drv_init_wgl_extensions(void) +static const char *x11drv_init_wgl_extensions( struct opengl_funcs *funcs ) { wglExtensions[0] = 0;
@@ -1982,8 +1982,8 @@ static const char *x11drv_init_wgl_extensions(void) if (has_extension(glExtensions, "GL_NV_vertex_array_range")) { register_extension( "WGL_NV_vertex_array_range" ); - opengl_funcs.p_wglAllocateMemoryNV = pglXAllocateMemoryNV; - opengl_funcs.p_wglFreeMemoryNV = pglXFreeMemoryNV; + funcs->p_wglAllocateMemoryNV = pglXAllocateMemoryNV; + funcs->p_wglFreeMemoryNV = pglXFreeMemoryNV; }
if (has_extension(glxExtensions, "GLX_OML_swap_method")) @@ -1994,10 +1994,10 @@ static const char *x11drv_init_wgl_extensions(void) if (has_extension( glxExtensions, "GLX_MESA_query_renderer" )) { register_extension( "WGL_WINE_query_renderer" ); - opengl_funcs.p_wglQueryCurrentRendererIntegerWINE = X11DRV_wglQueryCurrentRendererIntegerWINE; - opengl_funcs.p_wglQueryCurrentRendererStringWINE = X11DRV_wglQueryCurrentRendererStringWINE; - opengl_funcs.p_wglQueryRendererIntegerWINE = X11DRV_wglQueryRendererIntegerWINE; - opengl_funcs.p_wglQueryRendererStringWINE = X11DRV_wglQueryRendererStringWINE; + funcs->p_wglQueryCurrentRendererIntegerWINE = X11DRV_wglQueryCurrentRendererIntegerWINE; + funcs->p_wglQueryCurrentRendererStringWINE = X11DRV_wglQueryCurrentRendererStringWINE; + funcs->p_wglQueryRendererIntegerWINE = X11DRV_wglQueryRendererIntegerWINE; + funcs->p_wglQueryRendererStringWINE = X11DRV_wglQueryRendererStringWINE; }
return wglExtensions; diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index decdaec270d..7d8bed72d60 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 31 +#define WINE_OPENGL_DRIVER_VERSION 32
struct wgl_context; struct wgl_pbuffer; @@ -116,7 +116,7 @@ struct opengl_driver_funcs void *(*p_get_proc_address)(const char *); UINT (*p_init_pixel_formats)(UINT*); BOOL (*p_describe_pixel_format)(int,struct wgl_pixel_format*); - const char *(*p_init_wgl_extensions)(void); + const char *(*p_init_wgl_extensions)(struct opengl_funcs *funcs); BOOL (*p_set_pixel_format)(HWND,int,int,BOOL); BOOL (*p_swap_buffers)(void*,HWND,HDC,int); BOOL (*p_context_create)(HDC,int,void*,const int*,void**);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 651448b62f2..4aa6d8ad162 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -69,6 +69,14 @@ struct wgl_pbuffer struct wgl_context *prev_context; };
+static const struct opengl_funcs *default_funcs; /* default GL function table from opengl32 */ +static struct opengl_funcs null_memory_funcs, null_display_funcs; +static struct opengl_funcs *display_funcs = &null_display_funcs; +static struct opengl_funcs *memory_funcs = &null_memory_funcs; + +static PFN_glFinish p_memory_glFinish, p_display_glFinish; +static PFN_glFlush p_memory_glFlush, p_display_glFlush; + static const struct opengl_funcs *get_dc_funcs( HDC hdc, const struct opengl_funcs *null_funcs );
static const struct @@ -531,13 +539,6 @@ static const char *win32u_wglGetExtensionsStringEXT(void) return wgl_extensions; }
-static const struct opengl_funcs *default_funcs; /* default GL function table from opengl32 */ -static struct opengl_funcs *display_funcs; -static struct opengl_funcs *memory_funcs; - -static PFN_glFinish p_memory_glFinish, p_display_glFinish; -static PFN_glFlush p_memory_glFlush, p_display_glFlush; - static int get_dc_pixel_format( HDC hdc, BOOL internal ) { int ret = 0; @@ -808,7 +809,7 @@ static struct wgl_pbuffer *win32u_wglCreatePbufferARB( HDC hdc, int format, int return NULL; } NtGdiSetPixelFormat( pbuffer->hdc, format ); - pbuffer->driver_funcs = funcs == memory_funcs ? memory_driver_funcs : display_driver_funcs; + pbuffer->driver_funcs = funcs == display_funcs ? display_driver_funcs : memory_driver_funcs; pbuffer->funcs = funcs; pbuffer->width = width; pbuffer->height = height; @@ -1323,10 +1324,9 @@ static void init_opengl_funcs( struct opengl_funcs *funcs, const struct opengl_d
static void memory_funcs_init(void) { - memory_funcs = osmesa_get_wgl_driver( &memory_driver_funcs ); - if (memory_funcs && !(memory_formats_count = memory_driver_funcs->p_init_pixel_formats( &memory_onscreen_count ))) memory_funcs = NULL; - if (!memory_funcs) return; + if (!osmesa_get_wgl_driver( &memory_driver_funcs )) WARN( "Failed to initialize OSMesa functions\n" );
+ memory_formats_count = memory_driver_funcs->p_init_pixel_formats( &memory_onscreen_count ); init_opengl_funcs( memory_funcs, memory_driver_funcs );
memory_funcs->p_wglGetProcAddress = win32u_memory_wglGetProcAddress; @@ -1352,15 +1352,10 @@ static void display_funcs_init(void) { UINT status;
- if ((status = user_driver->pOpenGLInit( WINE_OPENGL_DRIVER_VERSION, &display_funcs, &display_driver_funcs )) && - status != STATUS_NOT_IMPLEMENTED) - { - ERR( "Failed to initialize the driver opengl functions, status %#x\n", status ); - return; - } - if (display_funcs && !(display_formats_count = display_driver_funcs->p_init_pixel_formats( &display_onscreen_count ))) display_funcs = NULL; - if (!display_funcs) return; + 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 );
+ display_formats_count = display_driver_funcs->p_init_pixel_formats( &display_onscreen_count ); init_opengl_funcs( display_funcs, display_driver_funcs );
display_funcs->p_wglGetProcAddress = win32u_display_wglGetProcAddress; @@ -1442,13 +1437,13 @@ static const struct opengl_funcs *get_dc_funcs( HDC hdc, const struct opengl_fun { static pthread_once_t display_init_once = PTHREAD_ONCE_INIT; pthread_once( &display_init_once, display_funcs_init ); - return display_funcs ? display_funcs : null_funcs; + return display_funcs; } if (is_memdc) { static pthread_once_t memory_init_once = PTHREAD_ONCE_INIT; pthread_once( &memory_init_once, memory_funcs_init ); - return memory_funcs ? memory_funcs : null_funcs; + return memory_funcs; } return NULL; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/driver.c | 2 +- dlls/win32u/opengl.c | 132 +++++++++++++++--------------- dlls/wineandroid.drv/android.h | 2 +- dlls/wineandroid.drv/opengl.c | 6 +- dlls/winemac.drv/macdrv.h | 2 +- dlls/winemac.drv/opengl.c | 5 +- dlls/winewayland.drv/opengl.c | 6 +- dlls/winewayland.drv/waylanddrv.h | 2 +- dlls/winex11.drv/opengl.c | 7 +- dlls/winex11.drv/x11drv.h | 2 +- include/wine/gdi_driver.h | 4 +- 11 files changed, 78 insertions(+), 92 deletions(-)
diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index 5e32e714b24..cf3be4be949 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -911,7 +911,7 @@ static UINT nulldrv_VulkanInit( UINT version, void *vulkan_handle, const struct return STATUS_NOT_IMPLEMENTED; }
-static UINT nulldrv_OpenGLInit( UINT version, struct opengl_funcs **opengl_funcs, const struct opengl_driver_funcs **driver_funcs ) +static UINT nulldrv_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs ) { return STATUS_NOT_IMPLEMENTED; } diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 4aa6d8ad162..7b3910c5ab4 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -70,9 +70,8 @@ struct wgl_pbuffer };
static const struct opengl_funcs *default_funcs; /* default GL function table from opengl32 */ -static struct opengl_funcs null_memory_funcs, null_display_funcs; -static struct opengl_funcs *display_funcs = &null_display_funcs; -static struct opengl_funcs *memory_funcs = &null_memory_funcs; +static struct opengl_funcs display_funcs; +static struct opengl_funcs memory_funcs;
static PFN_glFinish p_memory_glFinish, p_display_glFinish; static PFN_glFlush p_memory_glFlush, p_display_glFlush; @@ -194,7 +193,6 @@ struct osmesa_context UINT format; };
-static struct opengl_funcs osmesa_opengl_funcs; static const struct opengl_driver_funcs osmesa_driver_funcs;
static OSMesaContext (*pOSMesaCreateContextExt)( GLenum format, GLint depthBits, GLint stencilBits, @@ -206,7 +204,7 @@ static GLboolean (*pOSMesaMakeCurrent)( OSMesaContext ctx, void *buffer, GLenum static void (*pOSMesaPixelStore)( GLint pname, GLint value ); static void describe_pixel_format( int fmt, PIXELFORMATDESCRIPTOR *descr );
-static struct opengl_funcs *osmesa_get_wgl_driver( const struct opengl_driver_funcs **driver_funcs ) +static BOOL osmesa_get_wgl_driver( const struct opengl_driver_funcs **driver_funcs ) { static void *osmesa_handle;
@@ -214,7 +212,7 @@ static struct opengl_funcs *osmesa_get_wgl_driver( const struct opengl_driver_fu if (osmesa_handle == NULL) { ERR( "Failed to load OSMesa: %s\n", dlerror() ); - return NULL; + return FALSE; }
#define LOAD_FUNCPTR(f) do if (!(p##f = dlsym( osmesa_handle, #f ))) \ @@ -231,12 +229,12 @@ static struct opengl_funcs *osmesa_get_wgl_driver( const struct opengl_driver_fu #undef LOAD_FUNCPTR
*driver_funcs = &osmesa_driver_funcs; - return &osmesa_opengl_funcs; + return TRUE;
failed: dlclose( osmesa_handle ); osmesa_handle = NULL; - return NULL; + return FALSE; }
static const char *osmesa_init_wgl_extensions( struct opengl_funcs *funcs ) @@ -409,9 +407,9 @@ static const struct opengl_driver_funcs osmesa_driver_funcs =
#else /* SONAME_LIBOSMESA */
-static struct opengl_funcs *osmesa_get_wgl_driver( const struct opengl_driver_funcs **driver_funcs ) +static BOOL osmesa_get_wgl_driver( const struct opengl_driver_funcs **driver_funcs ) { - return NULL; + return FALSE; }
#endif /* SONAME_LIBOSMESA */ @@ -671,14 +669,14 @@ static struct wgl_context *context_create( HDC hdc, struct wgl_context *shared, }
if (!(funcs = get_dc_funcs( hdc, NULL ))) return NULL; - driver_funcs = funcs == display_funcs ? display_driver_funcs : memory_driver_funcs; + driver_funcs = funcs == &display_funcs ? display_driver_funcs : memory_driver_funcs;
if (!(context = calloc( 1, sizeof(*context) ))) return NULL; context->driver_funcs = driver_funcs; context->funcs = funcs; context->pixel_format = format; - context->p_glFinish = funcs == display_funcs ? p_display_glFinish : p_memory_glFinish; - context->p_glFlush = funcs == display_funcs ? p_display_glFlush : p_memory_glFlush; + context->p_glFinish = funcs == &display_funcs ? p_display_glFinish : p_memory_glFinish; + context->p_glFlush = funcs == &display_funcs ? p_display_glFlush : p_memory_glFlush;
if (!driver_funcs->p_context_create( hdc, format, shared_private, attribs, &context->driver_private )) { @@ -809,7 +807,7 @@ static struct wgl_pbuffer *win32u_wglCreatePbufferARB( HDC hdc, int format, int return NULL; } NtGdiSetPixelFormat( pbuffer->hdc, format ); - pbuffer->driver_funcs = funcs == display_funcs ? display_driver_funcs : memory_driver_funcs; + pbuffer->driver_funcs = funcs == &display_funcs ? display_driver_funcs : memory_driver_funcs; pbuffer->funcs = funcs; pbuffer->width = width; pbuffer->height = height; @@ -1237,7 +1235,7 @@ static BOOL win32u_wglSwapBuffers( HDC hdc ) RtlSetLastWin32Error( ERROR_DC_NOT_FOUND ); return FALSE; } - driver_funcs = funcs == display_funcs ? display_driver_funcs : memory_driver_funcs; + driver_funcs = funcs == &display_funcs ? display_driver_funcs : memory_driver_funcs;
if (!(hwnd = NtUserWindowFromDC( hdc ))) interval = 0; else interval = get_window_swap_interval( hwnd ); @@ -1327,25 +1325,25 @@ static void memory_funcs_init(void) if (!osmesa_get_wgl_driver( &memory_driver_funcs )) WARN( "Failed to initialize OSMesa functions\n" );
memory_formats_count = memory_driver_funcs->p_init_pixel_formats( &memory_onscreen_count ); - init_opengl_funcs( memory_funcs, memory_driver_funcs ); + init_opengl_funcs( &memory_funcs, memory_driver_funcs );
- memory_funcs->p_wglGetProcAddress = win32u_memory_wglGetProcAddress; - memory_funcs->p_get_pixel_formats = win32u_memory_get_pixel_formats; + memory_funcs.p_wglGetProcAddress = win32u_memory_wglGetProcAddress; + memory_funcs.p_get_pixel_formats = win32u_memory_get_pixel_formats;
- memory_funcs->p_wglGetPixelFormat = win32u_wglGetPixelFormat; - memory_funcs->p_wglSetPixelFormat = win32u_wglSetPixelFormat; + memory_funcs.p_wglGetPixelFormat = win32u_wglGetPixelFormat; + memory_funcs.p_wglSetPixelFormat = win32u_wglSetPixelFormat;
- memory_funcs->p_wglCreateContext = win32u_wglCreateContext; - memory_funcs->p_wglDeleteContext = win32u_wglDeleteContext; - memory_funcs->p_wglCopyContext = win32u_wglCopyContext; - memory_funcs->p_wglShareLists = win32u_wglShareLists; - memory_funcs->p_wglMakeCurrent = win32u_wglMakeCurrent; + memory_funcs.p_wglCreateContext = win32u_wglCreateContext; + memory_funcs.p_wglDeleteContext = win32u_wglDeleteContext; + memory_funcs.p_wglCopyContext = win32u_wglCopyContext; + memory_funcs.p_wglShareLists = win32u_wglShareLists; + memory_funcs.p_wglMakeCurrent = win32u_wglMakeCurrent;
- memory_funcs->p_wglSwapBuffers = win32u_wglSwapBuffers; - p_memory_glFinish = memory_funcs->p_glFinish; - memory_funcs->p_glFinish = win32u_glFinish; - p_memory_glFlush = memory_funcs->p_glFlush; - memory_funcs->p_glFlush = win32u_glFlush; + memory_funcs.p_wglSwapBuffers = win32u_wglSwapBuffers; + p_memory_glFinish = memory_funcs.p_glFinish; + memory_funcs.p_glFinish = win32u_glFinish; + p_memory_glFlush = memory_funcs.p_glFlush; + memory_funcs.p_glFlush = win32u_glFlush; }
static void display_funcs_init(void) @@ -1356,69 +1354,69 @@ static void display_funcs_init(void) WARN( "Failed to initialize the driver OpenGL functions, status %#x\n", status );
display_formats_count = display_driver_funcs->p_init_pixel_formats( &display_onscreen_count ); - init_opengl_funcs( display_funcs, display_driver_funcs ); + init_opengl_funcs( &display_funcs, display_driver_funcs );
- display_funcs->p_wglGetProcAddress = win32u_display_wglGetProcAddress; - display_funcs->p_get_pixel_formats = win32u_display_get_pixel_formats; + display_funcs.p_wglGetProcAddress = win32u_display_wglGetProcAddress; + display_funcs.p_get_pixel_formats = win32u_display_get_pixel_formats;
- strcpy( wgl_extensions, display_driver_funcs->p_init_wgl_extensions( display_funcs ) ); - display_funcs->p_wglGetPixelFormat = win32u_wglGetPixelFormat; - display_funcs->p_wglSetPixelFormat = win32u_wglSetPixelFormat; + strcpy( wgl_extensions, display_driver_funcs->p_init_wgl_extensions( &display_funcs ) ); + display_funcs.p_wglGetPixelFormat = win32u_wglGetPixelFormat; + display_funcs.p_wglSetPixelFormat = win32u_wglSetPixelFormat;
- display_funcs->p_wglCreateContext = win32u_wglCreateContext; - display_funcs->p_wglDeleteContext = win32u_wglDeleteContext; - display_funcs->p_wglCopyContext = win32u_wglCopyContext; - display_funcs->p_wglShareLists = win32u_wglShareLists; - display_funcs->p_wglMakeCurrent = win32u_wglMakeCurrent; + display_funcs.p_wglCreateContext = win32u_wglCreateContext; + display_funcs.p_wglDeleteContext = win32u_wglDeleteContext; + display_funcs.p_wglCopyContext = win32u_wglCopyContext; + display_funcs.p_wglShareLists = win32u_wglShareLists; + display_funcs.p_wglMakeCurrent = win32u_wglMakeCurrent;
- display_funcs->p_wglSwapBuffers = win32u_wglSwapBuffers; - p_display_glFinish = display_funcs->p_glFinish; - display_funcs->p_glFinish = win32u_glFinish; - p_display_glFlush = display_funcs->p_glFlush; - display_funcs->p_glFlush = win32u_glFlush; + display_funcs.p_wglSwapBuffers = win32u_wglSwapBuffers; + p_display_glFinish = display_funcs.p_glFinish; + display_funcs.p_glFinish = win32u_glFinish; + p_display_glFlush = display_funcs.p_glFlush; + display_funcs.p_glFlush = win32u_glFlush;
register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_extensions_string" ); - display_funcs->p_wglGetExtensionsStringARB = win32u_wglGetExtensionsStringARB; + display_funcs.p_wglGetExtensionsStringARB = win32u_wglGetExtensionsStringARB;
register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_EXT_extensions_string" ); - display_funcs->p_wglGetExtensionsStringEXT = win32u_wglGetExtensionsStringEXT; + display_funcs.p_wglGetExtensionsStringEXT = win32u_wglGetExtensionsStringEXT;
/* In WineD3D we need the ability to set the pixel format more than once (e.g. after a device reset). * The default wglSetPixelFormat doesn't allow this, so add our own which allows it. */ register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_WINE_pixel_format_passthrough" ); - display_funcs->p_wglSetPixelFormatWINE = win32u_wglSetPixelFormatWINE; + display_funcs.p_wglSetPixelFormatWINE = win32u_wglSetPixelFormatWINE;
register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_pixel_format" ); - display_funcs->p_wglChoosePixelFormatARB = (void *)1; /* never called */ - display_funcs->p_wglGetPixelFormatAttribfvARB = (void *)1; /* never called */ - display_funcs->p_wglGetPixelFormatAttribivARB = (void *)1; /* never called */ + display_funcs.p_wglChoosePixelFormatARB = (void *)1; /* never called */ + display_funcs.p_wglGetPixelFormatAttribfvARB = (void *)1; /* never called */ + display_funcs.p_wglGetPixelFormatAttribivARB = (void *)1; /* never called */
register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_create_context" ); register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_create_context_no_error" ); register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_create_context_profile" ); - display_funcs->p_wglCreateContextAttribsARB = win32u_wglCreateContextAttribsARB; + display_funcs.p_wglCreateContextAttribsARB = win32u_wglCreateContextAttribsARB;
register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_make_current_read" ); - display_funcs->p_wglGetCurrentReadDCARB = (void *)1; /* never called */ - display_funcs->p_wglMakeContextCurrentARB = win32u_wglMakeContextCurrentARB; + display_funcs.p_wglGetCurrentReadDCARB = (void *)1; /* never called */ + display_funcs.p_wglMakeContextCurrentARB = win32u_wglMakeContextCurrentARB;
register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_pbuffer" ); - display_funcs->p_wglCreatePbufferARB = win32u_wglCreatePbufferARB; - display_funcs->p_wglDestroyPbufferARB = win32u_wglDestroyPbufferARB; - display_funcs->p_wglGetPbufferDCARB = win32u_wglGetPbufferDCARB; - display_funcs->p_wglReleasePbufferDCARB = win32u_wglReleasePbufferDCARB; - display_funcs->p_wglQueryPbufferARB = win32u_wglQueryPbufferARB; + display_funcs.p_wglCreatePbufferARB = win32u_wglCreatePbufferARB; + display_funcs.p_wglDestroyPbufferARB = win32u_wglDestroyPbufferARB; + display_funcs.p_wglGetPbufferDCARB = win32u_wglGetPbufferDCARB; + display_funcs.p_wglReleasePbufferDCARB = win32u_wglReleasePbufferDCARB; + display_funcs.p_wglQueryPbufferARB = win32u_wglQueryPbufferARB;
register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_render_texture" ); - display_funcs->p_wglBindTexImageARB = win32u_wglBindTexImageARB; - display_funcs->p_wglReleaseTexImageARB = win32u_wglReleaseTexImageARB; - display_funcs->p_wglSetPbufferAttribARB = win32u_wglSetPbufferAttribARB; + display_funcs.p_wglBindTexImageARB = win32u_wglBindTexImageARB; + display_funcs.p_wglReleaseTexImageARB = win32u_wglReleaseTexImageARB; + display_funcs.p_wglSetPbufferAttribARB = win32u_wglSetPbufferAttribARB;
register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_EXT_swap_control" ); register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_EXT_swap_control_tear" ); - display_funcs->p_wglSwapIntervalEXT = win32u_wglSwapIntervalEXT; - display_funcs->p_wglGetSwapIntervalEXT = win32u_wglGetSwapIntervalEXT; + display_funcs.p_wglSwapIntervalEXT = win32u_wglSwapIntervalEXT; + display_funcs.p_wglGetSwapIntervalEXT = win32u_wglGetSwapIntervalEXT; }
static const struct opengl_funcs *get_dc_funcs( HDC hdc, const struct opengl_funcs *null_funcs ) @@ -1437,13 +1435,13 @@ static const struct opengl_funcs *get_dc_funcs( HDC hdc, const struct opengl_fun { static pthread_once_t display_init_once = PTHREAD_ONCE_INIT; pthread_once( &display_init_once, display_funcs_init ); - return display_funcs; + return &display_funcs; } if (is_memdc) { static pthread_once_t memory_init_once = PTHREAD_ONCE_INIT; pthread_once( &memory_init_once, memory_funcs_init ); - return memory_funcs; + return &memory_funcs; } return NULL; } diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index d744202e6c9..291d2f0d299 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -56,7 +56,7 @@ DECL_FUNCPTR( ANativeWindow_release ); extern pthread_mutex_t drawable_mutex; extern void update_gl_drawable( HWND hwnd ); extern void destroy_gl_drawable( HWND hwnd ); -extern UINT ANDROID_OpenGLInit( UINT version, struct opengl_funcs **opengl_funcs, const struct opengl_driver_funcs **driver_funcs ); +extern UINT ANDROID_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs );
/************************************************************************** diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index d65d4f2d565..aacb0c6a1fc 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -100,7 +100,6 @@ 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 opengl_funcs egl_funcs;
static struct list gl_contexts = LIST_INIT( gl_contexts ); static struct list gl_drawables = LIST_INIT( gl_drawables ); @@ -514,7 +513,7 @@ static const struct opengl_driver_funcs android_driver_funcs = /********************************************************************** * ANDROID_OpenGLInit */ -UINT ANDROID_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs ) +UINT ANDROID_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs ) { EGLint major, minor;
@@ -557,9 +556,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 );
- *funcs = &egl_funcs; *driver_funcs = &android_driver_funcs; return STATUS_SUCCESS; } - -static struct opengl_funcs egl_funcs; diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 2e2de456ddf..715997eb482 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -240,7 +240,7 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p extern BOOL query_pasteboard_data(HWND hwnd, CFStringRef type); extern void macdrv_lost_pasteboard_ownership(HWND hwnd);
-extern UINT macdrv_OpenGLInit(UINT version, struct opengl_funcs **opengl_funcs, const struct opengl_driver_funcs **driver_funcs); +extern UINT macdrv_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs); extern UINT macdrv_VulkanInit(UINT version, void *vulkan_handle, const struct vulkan_driver_funcs **driver_funcs); extern void sync_gl_view(struct macdrv_win_data* data, const struct window_rects *old_rects);
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index c5ad5e18a09..2715a0708d4 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -88,8 +88,6 @@ static pthread_mutex_t context_mutex = PTHREAD_MUTEX_INITIALIZER; static CFMutableDictionaryRef dc_pbuffers; static pthread_mutex_t dc_pbuffers_mutex = PTHREAD_MUTEX_INITIALIZER;
- -static struct opengl_funcs opengl_funcs; static const struct opengl_driver_funcs macdrv_driver_funcs;
static void (*pglCopyColorTable)(GLenum target, GLenum internalformat, GLint x, GLint y, @@ -2778,7 +2776,7 @@ static const char *macdrv_init_wgl_extensions(struct opengl_funcs *funcs) /********************************************************************** * macdrv_OpenGLInit */ -UINT macdrv_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs) +UINT macdrv_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs) { TRACE("()\n");
@@ -2823,7 +2821,6 @@ UINT macdrv_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct o LOAD_FUNCPTR(glFlushRenderAPPLE); #undef LOAD_FUNCPTR
- *funcs = &opengl_funcs; *driver_funcs = &macdrv_driver_funcs; return STATUS_SUCCESS;
diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index 3285af9a505..ef1fb49368b 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -51,7 +51,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv); #endif
static void *egl_handle; -static struct opengl_funcs opengl_funcs; static EGLDisplay egl_display; static char wgl_extensions[4096]; static EGLConfig *egl_configs; @@ -900,7 +899,7 @@ static const struct opengl_driver_funcs wayland_driver_funcs = /********************************************************************** * WAYLAND_OpenGLInit */ -UINT WAYLAND_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **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_client_exts, *egl_exts; @@ -990,7 +989,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; - *funcs = &opengl_funcs; *driver_funcs = &wayland_driver_funcs; return STATUS_SUCCESS;
@@ -1024,7 +1022,7 @@ void wayland_resize_gl_drawable(HWND hwnd)
#else /* No GL */
-UINT WAYLAND_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs) +UINT WAYLAND_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs) { return STATUS_NOT_IMPLEMENTED; } diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 7ed3f75e3f3..251a23a4032 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -456,6 +456,6 @@ void WAYLAND_WindowPosChanged(HWND hwnd, HWND insert_after, HWND owner_hint, UIN BOOL WAYLAND_WindowPosChanging(HWND hwnd, UINT swp_flags, BOOL shaped, const struct window_rects *rects); BOOL WAYLAND_CreateWindowSurface(HWND hwnd, BOOL layered, const RECT *surface_rect, struct window_surface **surface); UINT WAYLAND_VulkanInit(UINT version, void *vulkan_handle, const struct vulkan_driver_funcs **driver_funcs); -UINT WAYLAND_OpenGLInit(UINT version, struct opengl_funcs **opengl_funcs, const struct opengl_driver_funcs **driver_funcs); +UINT WAYLAND_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs);
#endif /* __WINE_WAYLANDDRV_H */ diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index d6f18867f7a..6e1b914b55f 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -261,8 +261,6 @@ static pthread_mutex_t context_mutex = PTHREAD_MUTEX_INITIALIZER;
static const BOOL is_win64 = sizeof(void *) > sizeof(int);
-static struct opengl_funcs opengl_funcs; - static BOOL glxRequireVersion(int requiredVersion);
static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) { @@ -502,7 +500,7 @@ static const struct opengl_driver_funcs x11drv_driver_funcs; /********************************************************************** * X11DRV_OpenglInit */ -UINT X11DRV_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs ) +UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs ) { int error_base, event_base;
@@ -680,7 +678,6 @@ UINT X11DRV_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct pglXSwapBuffersMscOML = pglXGetProcAddressARB( (const GLubyte *)"glXSwapBuffersMscOML" ); }
- *funcs = &opengl_funcs; *driver_funcs = &x11drv_driver_funcs; return STATUS_SUCCESS;
@@ -2099,7 +2096,7 @@ static const struct opengl_driver_funcs x11drv_driver_funcs = /********************************************************************** * X11DRV_OpenglInit */ -UINT X11DRV_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs ) +UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs ) { return STATUS_NOT_IMPLEMENTED; } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index eed34cf1cae..4cd2c7fa48f 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -282,7 +282,7 @@ extern BOOL client_side_with_render; extern BOOL shape_layered_windows; extern const struct gdi_dc_funcs *X11DRV_XRender_Init(void);
-extern UINT X11DRV_OpenGLInit( UINT, struct opengl_funcs **, const struct opengl_driver_funcs ** ); +extern UINT X11DRV_OpenGLInit( UINT, const struct opengl_funcs *, const struct opengl_driver_funcs ** ); extern UINT X11DRV_VulkanInit( UINT, void *, const struct vulkan_driver_funcs ** );
extern struct format_entry *import_xdnd_selection( Display *display, Window win, Atom selection, diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 560e75ca591..51e9efd20d9 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -219,7 +219,7 @@ struct gdi_dc_funcs };
/* increment this when you change the DC function table */ -#define WINE_GDI_DRIVER_VERSION 104 +#define WINE_GDI_DRIVER_VERSION 105
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */ #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */ @@ -395,7 +395,7 @@ struct user_driver_funcs /* vulkan support */ UINT (*pVulkanInit)(UINT,void *,const struct vulkan_driver_funcs **); /* opengl support */ - UINT (*pOpenGLInit)(UINT,struct opengl_funcs **,const struct opengl_driver_funcs **); + UINT (*pOpenGLInit)(UINT,const struct opengl_funcs *,const struct opengl_driver_funcs **); /* thread management */ void (*pThreadDetach)(void); };
From: Rémi Bernon rbernon@codeweavers.com
--- configure.ac | 15 +++++-- dlls/opengl32/make_opengl | 1 + dlls/opengl32/unix_thunks.c | 1 + dlls/win32u/opengl.c | 86 ++++++++++++++++++++++++++++++++++++ include/wine/opengl_driver.h | 32 +++++++++++++- 5 files changed, 130 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac index fd6e78a204b..d7bcbddffd1 100644 --- a/configure.ac +++ b/configure.ac @@ -984,7 +984,6 @@ case $host_os in WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],[WINELOADER_LDFLAGS="-Wl,--export-dynamic"]) WINEPRELOADER_LDFLAGS="-static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7d400000"
- WINE_CHECK_SONAME(EGL,eglGetProcAddress) WINE_CHECK_SONAME(GLESv2,glFlush)
if test "x$exec_prefix" = xNONE @@ -1214,6 +1213,17 @@ WINE_ERROR_WITH(pthread,[test "x$ac_cv_func_pthread_create" != xyes -a "x$PTHREA [pthread ${notice_platform}development files not found. Wine cannot support threads without libpthread.])
+dnl **** Check for EGL **** + +if test "x$with_opengl" != "xno" +then + WINE_PACKAGE_FLAGS(EGL,[egl],[-lEGL],,, + [AC_CHECK_HEADER([EGL/egl.h], + [WINE_CHECK_SONAME(EGL,eglGetProcAddress,,,[$EGL_LIBS])])]) + WINE_NOTICE_WITH(opengl, [test -z "$ac_cv_lib_soname_EGL"], + [EGL ${notice_platform}development files not found]) +fi + dnl **** Check for X11 ****
AC_PATH_X @@ -1402,9 +1412,6 @@ then AC_CHECK_LIB(xkbregistry,rxkb_context_new,[:],[XKBREGISTRY_LIBS=""],[$XKBREGISTRY_LIBS])]) if test "x$with_opengl" != "xno" then - WINE_PACKAGE_FLAGS(EGL,[egl],[-lEGL],,, - [AC_CHECK_HEADER([EGL/egl.h], - [WINE_CHECK_SONAME(EGL,eglGetProcAddress,,,[$EGL_LIBS])])]) WINE_PACKAGE_FLAGS(WAYLAND_EGL,[wayland-egl],,,, [AC_CHECK_HEADER([wayland-egl.h], [AC_CHECK_LIB(wayland-egl,wl_egl_window_create, diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index df877b1c07c..9537d26c13c 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -1137,6 +1137,7 @@ print OUT "#if 0\n"; print OUT "#pragma makedep unix\n"; print OUT "#endif\n\n";
+print OUT "#include <config.h>\n"; print OUT "#include <stdarg.h>\n"; print OUT "#include <stddef.h>\n\n";
diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 26f89bfc1eb..0f0154f9e17 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -4,6 +4,7 @@ #pragma makedep unix #endif
+#include <config.h> #include <stdarg.h> #include <stddef.h>
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 7b3910c5ab4..8f8bae1f817 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -173,6 +173,90 @@ static void register_extension( char *list, size_t size, const char *name ) } }
+#ifdef SONAME_LIBEGL + +static BOOL egl_init(void) +{ + const char *extensions; + + if (!(display_funcs.egl_handle = dlopen( SONAME_LIBEGL, RTLD_NOW | RTLD_GLOBAL ))) + { + ERR( "Failed to load %s: %s\n", SONAME_LIBEGL, dlerror() ); + goto failed; + } + +#define LOAD_FUNCPTR( name ) \ + if (!(display_funcs.p_##name = dlsym( display_funcs.egl_handle, #name ))) \ + { \ + ERR( "Failed to find EGL function %s\n", #name ); \ + goto failed; \ + } + LOAD_FUNCPTR( eglGetProcAddress ); + LOAD_FUNCPTR( eglQueryString ); +#undef LOAD_FUNCPTR + + if (!(extensions = display_funcs.p_eglQueryString( EGL_NO_DISPLAY, EGL_EXTENSIONS ))) + { + ERR( "Failed to find client extensions\n" ); + goto failed; + } + TRACE( "EGL client extensions:\n" ); + dump_extensions( extensions ); + +#define CHECK_EXTENSION( ext ) \ + if (!has_extension( extensions, #ext )) \ + { \ + ERR( "Failed to find required extension %s\n", #ext ); \ + goto failed; \ + } + CHECK_EXTENSION( EGL_KHR_client_get_all_proc_addresses ); + CHECK_EXTENSION( EGL_EXT_platform_base ); +#undef CHECK_EXTENSION + +#define LOAD_FUNCPTR( func ) \ + if (!(display_funcs.p_##func = (void *)display_funcs.p_eglGetProcAddress( #func ))) \ + { \ + ERR( "Failed to load symbol %s\n", #func ); \ + goto failed; \ + } + LOAD_FUNCPTR( eglBindAPI ); + LOAD_FUNCPTR( eglChooseConfig ); + LOAD_FUNCPTR( eglCreateContext ); + LOAD_FUNCPTR( eglCreatePbufferSurface ); + LOAD_FUNCPTR( eglCreateWindowSurface ); + LOAD_FUNCPTR( eglDestroyContext ); + LOAD_FUNCPTR( eglDestroySurface ); + LOAD_FUNCPTR( eglGetConfigAttrib ); + LOAD_FUNCPTR( eglGetConfigs ); + LOAD_FUNCPTR( eglGetCurrentContext ); + LOAD_FUNCPTR( eglGetCurrentSurface ); + LOAD_FUNCPTR( eglGetDisplay ); + LOAD_FUNCPTR( eglGetError ); + LOAD_FUNCPTR( eglGetPlatformDisplay ); + LOAD_FUNCPTR( eglInitialize ); + LOAD_FUNCPTR( eglMakeCurrent ); + LOAD_FUNCPTR( eglSwapBuffers ); + LOAD_FUNCPTR( eglSwapInterval ); +#undef LOAD_FUNCPTR + + return TRUE; + +failed: + dlclose( display_funcs.egl_handle ); + display_funcs.egl_handle = NULL; + return FALSE; +} + +#else /* SONAME_LIBEGL */ + +static BOOL egl_init(void) +{ + WARN( "EGL support not compiled in!\n" ); + return FALSE; +} + +#endif /* SONAME_LIBEGL */ + #ifdef SONAME_LIBOSMESA
#define OSMESA_COLOR_INDEX GL_COLOR_INDEX @@ -1350,6 +1434,8 @@ static void display_funcs_init(void) { UINT status;
+ if (egl_init()) 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 );
diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 7d8bed72d60..37f4bc38c1b 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -60,8 +60,14 @@ struct wgl_pixel_format
#ifdef WINE_UNIX_LIB
+#ifdef HAVE_EGL_EGL_H +#define EGL_EGLEXT_PROTOTYPES +#include <EGL/egl.h> +#include <EGL/eglext.h> +#endif /* HAVE_EGL_EGL_H */ + /* Wine internal opengl driver version, needs to be bumped upon opengl_funcs changes. */ -#define WINE_OPENGL_DRIVER_VERSION 32 +#define WINE_OPENGL_DRIVER_VERSION 33
struct wgl_context; struct wgl_pbuffer; @@ -108,6 +114,30 @@ struct opengl_funcs ALL_GL_FUNCS ALL_GL_EXT_FUNCS #undef USE_GL_FUNC + +#ifdef HAVE_EGL_EGL_H + void *egl_handle; + PFNEGLBINDAPIPROC p_eglBindAPI; + PFNEGLCHOOSECONFIGPROC p_eglChooseConfig; + PFNEGLCREATECONTEXTPROC p_eglCreateContext; + PFNEGLCREATEPBUFFERSURFACEPROC p_eglCreatePbufferSurface; + PFNEGLCREATEWINDOWSURFACEPROC p_eglCreateWindowSurface; + PFNEGLDESTROYCONTEXTPROC p_eglDestroyContext; + PFNEGLDESTROYSURFACEPROC p_eglDestroySurface; + PFNEGLGETCONFIGATTRIBPROC p_eglGetConfigAttrib; + PFNEGLGETCONFIGSPROC p_eglGetConfigs; + PFNEGLGETCURRENTCONTEXTPROC p_eglGetCurrentContext; + PFNEGLGETCURRENTSURFACEPROC p_eglGetCurrentSurface; + PFNEGLGETDISPLAYPROC p_eglGetDisplay; + PFNEGLGETERRORPROC p_eglGetError; + PFNEGLGETPLATFORMDISPLAYPROC p_eglGetPlatformDisplay; + PFNEGLGETPROCADDRESSPROC p_eglGetProcAddress; + PFNEGLINITIALIZEPROC p_eglInitialize; + PFNEGLMAKECURRENTPROC p_eglMakeCurrent; + PFNEGLQUERYSTRINGPROC p_eglQueryString; + PFNEGLSWAPBUFFERSPROC p_eglSwapBuffers; + PFNEGLSWAPINTERVALPROC p_eglSwapInterval; +#endif /* HAVE_EGL_EGL_H */ };
/* interface between win32u and the user drivers */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/opengl.c | 175 +++++++++++----------------------- 1 file changed, 54 insertions(+), 121 deletions(-)
diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index ef1fb49368b..8501c7abb78 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -50,32 +50,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv); #define EGL_PRESENT_OPAQUE_EXT 0x31DF #endif
-static void *egl_handle; 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; - -#define DECL_FUNCPTR(f) static typeof(f) * p_##f -DECL_FUNCPTR(eglBindAPI); -DECL_FUNCPTR(eglChooseConfig); -DECL_FUNCPTR(eglCreateContext); -DECL_FUNCPTR(eglCreateWindowSurface); -DECL_FUNCPTR(eglDestroyContext); -DECL_FUNCPTR(eglDestroySurface); -DECL_FUNCPTR(eglGetConfigAttrib); -DECL_FUNCPTR(eglGetCurrentContext); -DECL_FUNCPTR(eglGetCurrentSurface); -DECL_FUNCPTR(eglGetError); -DECL_FUNCPTR(eglGetPlatformDisplay); -DECL_FUNCPTR(eglGetProcAddress); -DECL_FUNCPTR(eglInitialize); -DECL_FUNCPTR(eglMakeCurrent); -DECL_FUNCPTR(eglQueryString); -DECL_FUNCPTR(eglSwapBuffers); -DECL_FUNCPTR(eglSwapInterval); -#undef DECL_FUNCPTR +static const struct opengl_funcs *funcs;
#define DECL_FUNCPTR(f) static PFN_##f p_##f DECL_FUNCPTR(glClear); @@ -159,7 +139,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) 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) { @@ -214,8 +194,8 @@ static struct wayland_gl_drawable *wayland_gl_drawable_create(HWND hwnd, HDC hdc goto err; }
- gl->surface = p_eglCreateWindowSurface(egl_display, egl_config_for_format(format), - gl->wl_egl_window, attribs); + gl->surface = funcs->p_eglCreateWindowSurface(egl_display, egl_config_for_format(format), + gl->wl_egl_window, attribs); if (!gl->surface) { ERR("Failed to create EGL surface\n"); @@ -287,7 +267,7 @@ static BOOL wayland_context_make_current(HDC draw_hdc, HDC read_hdc, void *priva
if (!private) { - 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; } @@ -306,10 +286,10 @@ static BOOL wayland_context_make_current(HDC draw_hdc, HDC read_hdc, void *priva
pthread_mutex_lock(&gl_object_mutex);
- ret = p_eglMakeCurrent(egl_display, - draw ? draw->surface : EGL_NO_SURFACE, - read ? read->surface : EGL_NO_SURFACE, - ctx->context); + ret = funcs->p_eglMakeCurrent(egl_display, + draw ? draw->surface : EGL_NO_SURFACE, + read ? read->surface : EGL_NO_SURFACE, + ctx->context); if (ret) { old_draw = ctx->draw; @@ -417,7 +397,7 @@ static void wayland_context_refresh(struct wayland_context *ctx) ctx->new_read = NULL; refresh = TRUE; } - if (refresh) 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);
@@ -470,10 +450,10 @@ static BOOL wayland_context_create(HDC hdc, int format, void *share_private, con * > EGL_OPENGL_API and EGL_OPENGL_ES_API are interchangeable for all * > purposes except eglCreateContext. */ - p_eglBindAPI(EGL_OPENGL_API); - ctx->context = p_eglCreateContext(egl_display, EGL_NO_CONFIG_KHR, - share ? share->context : EGL_NO_CONTEXT, - ctx->attribs); + funcs->p_eglBindAPI(EGL_OPENGL_API); + ctx->context = funcs->p_eglCreateContext(egl_display, EGL_NO_CONFIG_KHR, + share ? share->context : EGL_NO_CONTEXT, + ctx->attribs);
pthread_mutex_lock(&gl_object_mutex); list_add_head(&gl_contexts, &ctx->entry); @@ -507,7 +487,7 @@ static BOOL wayland_context_destroy(void *private) pthread_mutex_lock(&gl_object_mutex); list_remove(&ctx->entry); pthread_mutex_unlock(&gl_object_mutex); - 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); @@ -518,7 +498,7 @@ static void *wayland_get_proc_address(const char *name) { if (!strcmp(name, "glClear")) return wayland_glClear;
- return p_eglGetProcAddress(name); + return funcs->p_eglGetProcAddress(name); }
static BOOL wayland_context_share(void *src_private, void *dst_private) @@ -552,9 +532,9 @@ static BOOL wayland_context_share(void *src_private, void *dst_private) return FALSE; }
- p_eglDestroyContext(egl_display, clobber->context); - clobber->context = p_eglCreateContext(egl_display, EGL_NO_CONFIG_KHR, - keep->context, clobber->attribs); + 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", clobber->context, clobber, clobber->config, @@ -581,7 +561,7 @@ static BOOL wayland_swap_buffers(void *private, HWND hwnd, HDC hdc, int interval if (interval < 0) interval = -interval; if (gl->swap_interval != interval) { - p_eglSwapInterval(egl_display, interval); + funcs->p_eglSwapInterval(egl_display, interval); gl->swap_interval = interval; }
@@ -589,7 +569,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) 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); @@ -649,7 +629,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 (!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); @@ -665,10 +645,10 @@ static BOOL describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt
#define SET_ATTRIB(field, attrib) \ value = 0; \ - 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 (!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 @@ -693,7 +673,7 @@ static BOOL describe_pixel_format(EGLConfig config, struct wgl_pixel_format *fmt
fmt->swap_method = WGL_SWAP_UNDEFINED_ARB;
- if (p_eglGetConfigAttrib(egl_display, config, EGL_TRANSPARENT_TYPE, &value)) + if (funcs->p_eglGetConfigAttrib(egl_display, config, EGL_TRANSPARENT_TYPE, &value)) { switch (value) { @@ -708,7 +688,7 @@ 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 (p_eglGetConfigAttrib(egl_display, config, EGL_COLOR_COMPONENT_TYPE_EXT, &value)) + else if (funcs->p_eglGetConfigAttrib(egl_display, config, EGL_COLOR_COMPONENT_TYPE_EXT, &value)) { switch (value) { @@ -732,17 +712,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 (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 (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 (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; @@ -806,7 +786,7 @@ static void register_extension(const char *ext)
static BOOL init_opengl_funcs(void) { - p_glClear = (void *)p_eglGetProcAddress("glClear"); + p_glClear = (void *)funcs->p_eglGetProcAddress("glClear"); return TRUE; }
@@ -831,14 +811,14 @@ static UINT wayland_init_pixel_formats(UINT *onscreen_count) EGL_NONE };
- 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 (!p_eglChooseConfig(egl_display, attribs, egl_configs, num_egl_configs, - &num_egl_configs) || + if (!funcs->p_eglChooseConfig(egl_display, attribs, egl_configs, num_egl_configs, + &num_egl_configs) || !num_egl_configs) { free(egl_configs); @@ -853,18 +833,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; - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_NATIVE_VISUAL_ID, &visual_id); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_SURFACE_TYPE, &type); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_RENDERABLE_TYPE, &render); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_CONFIG_ID, &id); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_NATIVE_RENDERABLE, &native); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_COLOR_BUFFER_TYPE, &color); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_RED_SIZE, &r); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_GREEN_SIZE, &g); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_BLUE_SIZE, &b); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_ALPHA_SIZE, &a); - p_eglGetConfigAttrib(egl_display, egl_configs[i], EGL_DEPTH_SIZE, &d); - 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, @@ -902,7 +882,7 @@ 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_client_exts, *egl_exts; + const char *egl_exts;
if (version != WINE_OPENGL_DRIVER_VERSION) { @@ -911,70 +891,25 @@ UINT WAYLAND_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, c return STATUS_INVALID_PARAMETER; }
- if (!(egl_handle = dlopen(SONAME_LIBEGL, RTLD_NOW|RTLD_GLOBAL))) - { - ERR("Failed to load %s: %s\n", SONAME_LIBEGL, dlerror()); - return STATUS_NOT_SUPPORTED; - } - -#define LOAD_FUNCPTR_DLSYM(func) \ - do { \ - if (!(p_##func = dlsym(egl_handle, #func))) \ - { ERR("Failed to load symbol %s\n", #func); goto err; } \ - } while(0) - LOAD_FUNCPTR_DLSYM(eglGetProcAddress); - LOAD_FUNCPTR_DLSYM(eglQueryString); -#undef LOAD_FUNCPTR_DLSYM - - egl_client_exts = p_eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + if (!opengl_funcs->egl_handle) return STATUS_NOT_SUPPORTED; + funcs = opengl_funcs;
-#define REQUIRE_CLIENT_EXT(ext) \ - do { \ - if (!has_extension(egl_client_exts, #ext)) \ - { ERR("Failed to find required extension %s\n", #ext); goto err; } \ - } while(0) - REQUIRE_CLIENT_EXT(EGL_KHR_client_get_all_proc_addresses); - REQUIRE_CLIENT_EXT(EGL_KHR_platform_wayland); -#undef REQUIRE_CLIENT_EXT - -#define LOAD_FUNCPTR_EGL(func) \ - do { \ - if (!(p_##func = (void *)p_eglGetProcAddress(#func))) \ - { ERR("Failed to load symbol %s\n", #func); goto err; } \ - } while(0) - LOAD_FUNCPTR_EGL(eglBindAPI); - LOAD_FUNCPTR_EGL(eglChooseConfig); - LOAD_FUNCPTR_EGL(eglCreateContext); - LOAD_FUNCPTR_EGL(eglCreateWindowSurface); - LOAD_FUNCPTR_EGL(eglDestroyContext); - LOAD_FUNCPTR_EGL(eglDestroySurface); - LOAD_FUNCPTR_EGL(eglGetConfigAttrib); - LOAD_FUNCPTR_EGL(eglGetCurrentContext); - LOAD_FUNCPTR_EGL(eglGetCurrentSurface); - LOAD_FUNCPTR_EGL(eglGetError); - LOAD_FUNCPTR_EGL(eglGetPlatformDisplay); - LOAD_FUNCPTR_EGL(eglInitialize); - LOAD_FUNCPTR_EGL(eglMakeCurrent); - LOAD_FUNCPTR_EGL(eglSwapBuffers); - LOAD_FUNCPTR_EGL(eglSwapInterval); -#undef LOAD_FUNCPTR_EGL - - egl_display = p_eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, - process_wayland.wl_display, - NULL); + 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 (!p_eglInitialize(egl_display, &egl_version[0], &egl_version[1])) + if (!funcs->p_eglInitialize(egl_display, &egl_version[0], &egl_version[1])) { - ERR("Failed to initialized EGLDisplay with error %d\n", p_eglGetError()); + 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 = p_eglQueryString(egl_display, EGL_EXTENSIONS); + egl_exts = funcs->p_eglQueryString(egl_display, EGL_EXTENSIONS); #define REQUIRE_EXT(ext) \ do { \ if (!has_extension(egl_exts, #ext)) \ @@ -993,8 +928,6 @@ UINT WAYLAND_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, c return STATUS_SUCCESS;
err: - dlclose(egl_handle); - egl_handle = NULL; return STATUS_NOT_SUPPORTED; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/wineandroid.drv/opengl.c | 117 ++++++++++++---------------------- 1 file changed, 40 insertions(+), 77 deletions(-)
diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index aacb0c6a1fc..e4939267584 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -49,22 +49,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(android);
-#define DECL_FUNCPTR(f) typeof(f) * p_##f = NULL -DECL_FUNCPTR( eglCreateContext ); -DECL_FUNCPTR( eglCreateWindowSurface ); -DECL_FUNCPTR( eglCreatePbufferSurface ); -DECL_FUNCPTR( eglDestroyContext ); -DECL_FUNCPTR( eglDestroySurface ); -DECL_FUNCPTR( eglGetConfigAttrib ); -DECL_FUNCPTR( eglGetConfigs ); -DECL_FUNCPTR( eglGetDisplay ); -DECL_FUNCPTR( eglGetProcAddress ); -DECL_FUNCPTR( eglInitialize ); -DECL_FUNCPTR( eglMakeCurrent ); -DECL_FUNCPTR( eglSwapBuffers ); -DECL_FUNCPTR( eglSwapInterval ); -#undef DECL_FUNCPTR - +static const struct opengl_funcs *funcs; static const int egl_client_version = 2;
struct egl_pixel_format @@ -94,7 +79,6 @@ struct gl_drawable int swap_interval; };
-static void *egl_handle; static void *opengl_handle; static struct egl_pixel_format *pixel_formats; static int nb_pixel_formats, nb_onscreen_formats; @@ -116,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 = p_eglCreatePbufferSurface( display, pixel_formats[gl->format - 1].config, attribs ); + gl->pbuffer = funcs->p_eglCreatePbufferSurface( display, pixel_formats[gl->format - 1].config, attribs ); pthread_mutex_lock( &drawable_mutex ); list_add_head( &gl_drawables, &gl->entry ); return gl; @@ -150,8 +134,8 @@ void destroy_gl_drawable( HWND hwnd ) { if (gl->hwnd != hwnd) continue; list_remove( &gl->entry ); - if (gl->surface) p_eglDestroySurface( display, gl->surface ); - if (gl->pbuffer) p_eglDestroySurface( display, gl->pbuffer ); + if (gl->surface) funcs->p_eglDestroySurface( display, gl->surface ); + if (gl->pbuffer) funcs->p_eglDestroySurface( display, gl->pbuffer ); release_ioctl_window( gl->window ); free( gl ); break; @@ -166,7 +150,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 ); - p_eglMakeCurrent( display, ctx->surface, ctx->surface, ctx->context ); + funcs->p_eglMakeCurrent( display, ctx->surface, ctx->surface, ctx->context ); NtUserRedrawWindow( ctx->hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE ); } return ret; @@ -180,7 +164,8 @@ void update_gl_drawable( HWND hwnd ) if ((gl = get_gl_drawable( hwnd, 0 ))) { if (!gl->surface && - (gl->surface = p_eglCreateWindowSurface( display, pixel_formats[gl->format - 1].config, gl->window, NULL ))) + (gl->surface = funcs->p_eglCreateWindowSurface( display, pixel_formats[gl->format - 1].config, + gl->window, NULL ))) { LIST_FOR_EACH_ENTRY( ctx, &gl_contexts, struct android_context, entry ) { @@ -188,7 +173,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) - p_eglMakeCurrent( display, ctx->surface, ctx->surface, ctx->context ); + funcs->p_eglMakeCurrent( display, ctx->surface, ctx->surface, ctx->context ); else InterlockedExchange( &ctx->refresh, TRUE ); } @@ -209,7 +194,7 @@ static BOOL android_set_pixel_format( HWND hwnd, int old_format, int new_format, if (internal) { EGLint pf; - p_eglGetConfigAttrib( display, pixel_formats[new_format - 1].config, EGL_NATIVE_VISUAL_ID, &pf ); + funcs->p_eglGetConfigAttrib( 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; } @@ -262,7 +247,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 = p_eglCreateContext( display, ctx->config, shared_ctx ? shared_ctx->context : EGL_NO_CONTEXT, attribs ); + ctx->context = funcs->p_eglCreateContext( 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 );
@@ -286,19 +271,19 @@ static BOOL android_describe_pixel_format( int format, struct wgl_pixel_format * pfd->iPixelType = PFD_TYPE_RGBA; pfd->iLayerType = PFD_MAIN_PLANE;
- p_eglGetConfigAttrib( display, config, EGL_BUFFER_SIZE, &val ); + funcs->p_eglGetConfigAttrib( display, config, EGL_BUFFER_SIZE, &val ); pfd->cColorBits = val; - p_eglGetConfigAttrib( display, config, EGL_RED_SIZE, &val ); + funcs->p_eglGetConfigAttrib( display, config, EGL_RED_SIZE, &val ); pfd->cRedBits = val; - p_eglGetConfigAttrib( display, config, EGL_GREEN_SIZE, &val ); + funcs->p_eglGetConfigAttrib( display, config, EGL_GREEN_SIZE, &val ); pfd->cGreenBits = val; - p_eglGetConfigAttrib( display, config, EGL_BLUE_SIZE, &val ); + funcs->p_eglGetConfigAttrib( display, config, EGL_BLUE_SIZE, &val ); pfd->cBlueBits = val; - p_eglGetConfigAttrib( display, config, EGL_ALPHA_SIZE, &val ); + funcs->p_eglGetConfigAttrib( display, config, EGL_ALPHA_SIZE, &val ); pfd->cAlphaBits = val; - p_eglGetConfigAttrib( display, config, EGL_DEPTH_SIZE, &val ); + funcs->p_eglGetConfigAttrib( display, config, EGL_DEPTH_SIZE, &val ); pfd->cDepthBits = val; - p_eglGetConfigAttrib( display, config, EGL_STENCIL_SIZE, &val ); + funcs->p_eglGetConfigAttrib( display, config, EGL_STENCIL_SIZE, &val ); pfd->cStencilBits = val;
pfd->cAlphaShift = 0; @@ -320,7 +305,7 @@ static BOOL android_context_make_current( HDC draw_hdc, HDC read_hdc, void *priv
if (!private) { - p_eglMakeCurrent( display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); + funcs->p_eglMakeCurrent( display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); NtCurrentTeb()->glReserved2 = NULL; return TRUE; } @@ -333,7 +318,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 = p_eglMakeCurrent( display, draw_surface, read_surface, ctx->context ); + ret = funcs->p_eglMakeCurrent( display, draw_surface, read_surface, ctx->context ); if (ret) { ctx->surface = draw_gl->surface; @@ -369,7 +354,7 @@ static BOOL android_context_destroy( void *private ) pthread_mutex_lock( &drawable_mutex ); list_remove( &ctx->entry ); pthread_mutex_unlock( &drawable_mutex ); - p_eglDestroyContext( display, ctx->context ); + funcs->p_eglDestroyContext( display, ctx->context ); free( ctx ); return TRUE; } @@ -378,7 +363,7 @@ static void *android_get_proc_address( const char *name ) { void *ptr; if ((ptr = dlsym( opengl_handle, name ))) return ptr; - return p_eglGetProcAddress( name ); + return funcs->p_eglGetProcAddress( name ); }
static BOOL android_context_share( void *org, void *dest ) @@ -391,7 +376,7 @@ static void set_swap_interval( struct gl_drawable *gl, int interval ) { if (interval < 0) interval = -interval; if (gl->swap_interval == interval) return; - p_eglSwapInterval( display, interval ); + funcs->p_eglSwapInterval( display, interval ); gl->swap_interval = interval; }
@@ -412,7 +397,7 @@ static BOOL android_swap_buffers( void *private, HWND hwnd, HDC hdc, int interva release_gl_drawable( gl ); }
- if (ctx->surface) p_eglSwapBuffers( display, ctx->surface ); + if (ctx->surface) funcs->p_eglSwapBuffers( display, ctx->surface ); return TRUE; }
@@ -450,10 +435,10 @@ static UINT android_init_pixel_formats( UINT *onscreen_count ) EGLConfig *configs; EGLint count, i, pass;
- p_eglGetConfigs( display, NULL, 0, &count ); + funcs->p_eglGetConfigs( display, NULL, 0, &count ); configs = malloc( count * sizeof(*configs) ); pixel_formats = malloc( count * sizeof(*pixel_formats) ); - p_eglGetConfigs( display, configs, count, &count ); + funcs->p_eglGetConfigs( display, configs, count, &count ); if (!count || !configs || !pixel_formats) { free( configs ); @@ -468,22 +453,22 @@ static UINT android_init_pixel_formats( UINT *onscreen_count ) { EGLint id, type, visual_id, native, render, color, r, g, b, d, s;
- p_eglGetConfigAttrib( display, configs[i], EGL_SURFACE_TYPE, &type ); + funcs->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 ); + funcs->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 ); + 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 ); 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 ); } @@ -522,38 +507,16 @@ UINT ANDROID_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version, WINE_OPENGL_DRIVER_VERSION ); return STATUS_INVALID_PARAMETER; } - if (!(egl_handle = dlopen( SONAME_LIBEGL, RTLD_NOW|RTLD_GLOBAL ))) - { - ERR( "failed to load %s: %s\n", SONAME_LIBEGL, dlerror() ); - return STATUS_NOT_SUPPORTED; - } + if (!opengl_funcs->egl_handle) return STATUS_NOT_SUPPORTED; if (!(opengl_handle = dlopen( SONAME_LIBGLESV2, RTLD_NOW|RTLD_GLOBAL ))) { ERR( "failed to load %s: %s\n", SONAME_LIBGLESV2, dlerror() ); return STATUS_NOT_SUPPORTED; } + funcs = opengl_funcs;
-#define LOAD_FUNCPTR(func) do { \ - if (!(p_##func = dlsym( egl_handle, #func ))) \ - { ERR( "can't find symbol %s\n", #func); return FALSE; } \ - } while(0) - LOAD_FUNCPTR( eglCreateContext ); - LOAD_FUNCPTR( eglCreateWindowSurface ); - LOAD_FUNCPTR( eglCreatePbufferSurface ); - LOAD_FUNCPTR( eglDestroyContext ); - LOAD_FUNCPTR( eglDestroySurface ); - LOAD_FUNCPTR( eglGetConfigAttrib ); - LOAD_FUNCPTR( eglGetConfigs ); - LOAD_FUNCPTR( eglGetDisplay ); - LOAD_FUNCPTR( eglGetProcAddress ); - LOAD_FUNCPTR( eglInitialize ); - LOAD_FUNCPTR( eglMakeCurrent ); - LOAD_FUNCPTR( eglSwapBuffers ); - LOAD_FUNCPTR( eglSwapInterval ); -#undef LOAD_FUNCPTR - - display = p_eglGetDisplay( EGL_DEFAULT_DISPLAY ); - if (!p_eglInitialize( display, &major, &minor )) return 0; + 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;
Will the next step be converting winex11 to use EGL (that's what I think Firefox/OBS already did)?
On Wed May 21 08:31:51 2025 +0000, Aida Jonikienė wrote:
Will the next step be converting winex11 to use EGL (that's what I think Firefox/OBS already did)?
I'm planning to add an opt-in EGL backend for winex11 yes, and ultimately use it by default, but we should keep the GLX code for now.
This merge request was approved by Huw Davies.
Alexandre Julliard (@julliard) commented about include/wine/opengl_driver.h:
- PFNEGLCREATEWINDOWSURFACEPROC p_eglCreateWindowSurface;
- PFNEGLDESTROYCONTEXTPROC p_eglDestroyContext;
- PFNEGLDESTROYSURFACEPROC p_eglDestroySurface;
- PFNEGLGETCONFIGATTRIBPROC p_eglGetConfigAttrib;
- PFNEGLGETCONFIGSPROC p_eglGetConfigs;
- PFNEGLGETCURRENTCONTEXTPROC p_eglGetCurrentContext;
- PFNEGLGETCURRENTSURFACEPROC p_eglGetCurrentSurface;
- PFNEGLGETDISPLAYPROC p_eglGetDisplay;
- PFNEGLGETERRORPROC p_eglGetError;
- PFNEGLGETPLATFORMDISPLAYPROC p_eglGetPlatformDisplay;
- PFNEGLGETPROCADDRESSPROC p_eglGetProcAddress;
- PFNEGLINITIALIZEPROC p_eglInitialize;
- PFNEGLMAKECURRENTPROC p_eglMakeCurrent;
- PFNEGLQUERYSTRINGPROC p_eglQueryString;
- PFNEGLSWAPBUFFERSPROC p_eglSwapBuffers;
- PFNEGLSWAPINTERVALPROC p_eglSwapInterval;
I'd suggest to generate these from the xml spec like we do for the rest of OpenGL, so that the driver interface doesn't depend on configure checks.