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 | 30 ++++++++++++- 5 files changed, 128 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..39bc521cb4c 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,28 @@ struct opengl_funcs ALL_GL_FUNCS ALL_GL_EXT_FUNCS #undef USE_GL_FUNC + + 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; };
/* interface between win32u and the user drivers */