From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 46 ++++++++++++++++++++++++++++++++++++ include/wine/opengl_driver.h | 6 ++++- 2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index f0cca3b06b4..f60e3db7244 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -231,6 +231,47 @@ failed: return FALSE; }
+static void init_egl_platform( struct opengl_funcs *funcs, const struct opengl_driver_funcs *driver_funcs ) +{ + void *platform_display; + const char *extensions; + EGLint major, minor; + EGLenum platform; + + if (!funcs->egl_handle || !driver_funcs->p_get_egl_platform) return; + + platform = driver_funcs->p_get_egl_platform( &platform_display ); + if (!platform) funcs->egl_display = funcs->p_eglGetDisplay( EGL_DEFAULT_DISPLAY ); + else funcs->egl_display = funcs->p_eglGetPlatformDisplay( platform, platform_display, NULL ); + + if (!funcs->egl_display) + { + ERR( "Failed to open EGL display\n" ); + return; + } + + if (!funcs->p_eglInitialize( funcs->egl_display, &major, &minor )) return; + TRACE( "Initialized EGL display %p, version %d.%d\n", funcs->egl_display, major, minor ); + + if (!(extensions = funcs->p_eglQueryString( funcs->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 + + funcs->has_EGL_EXT_present_opaque = has_extension( extensions, "EGL_EXT_present_opaque" ); + funcs->has_EGL_EXT_pixel_format_float = has_extension( extensions, "EGL_EXT_pixel_format_float" ); +} + #else /* SONAME_LIBEGL */
static BOOL egl_init(void) @@ -239,6 +280,10 @@ static BOOL egl_init(void) return FALSE; }
+static void init_egl_platform( struct opengl_funcs *funcs, const struct opengl_driver_funcs *driver_funcs ) +{ +} + #endif /* SONAME_LIBEGL */
#ifdef SONAME_LIBOSMESA @@ -1422,6 +1467,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_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..60edc2edff3 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; @@ -111,11 +111,15 @@ struct opengl_funcs #undef USE_GL_FUNC
void *egl_handle; + EGLDisplay egl_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_get_egl_platform)(void**); void *(*p_get_proc_address)(const char *); UINT (*p_init_pixel_formats)(UINT*); BOOL (*p_describe_pixel_format)(int,struct wgl_pixel_format*);