And use it to move wglGetExtensionsString(ARB|EXT) to win32u.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/driver.c | 8 ++++---- dlls/win32u/opengl.c | 12 +++++++++++- dlls/wineandroid.drv/android.h | 2 +- dlls/wineandroid.drv/init.c | 2 +- dlls/wineandroid.drv/opengl.c | 15 +++++++++------ dlls/winemac.drv/gdi.c | 2 +- dlls/winemac.drv/macdrv.h | 2 +- dlls/winemac.drv/opengl.c | 15 ++++++++------- dlls/winewayland.drv/opengl.c | 19 +++++++++++-------- dlls/winewayland.drv/waylanddrv.h | 2 +- dlls/winewayland.drv/waylanddrv_main.c | 2 +- dlls/winex11.drv/init.c | 2 +- dlls/winex11.drv/opengl.c | 21 ++++++++++++--------- dlls/winex11.drv/x11drv.h | 2 +- include/wine/gdi_driver.h | 5 +++-- include/wine/opengl_driver.h | 8 +++++++- 16 files changed, 73 insertions(+), 46 deletions(-)
diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index 5edac6a0c8a..94dc8ceae44 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -911,9 +911,9 @@ static UINT nulldrv_VulkanInit( UINT version, void *vulkan_handle, const struct return STATUS_NOT_IMPLEMENTED; }
-static struct opengl_funcs *nulldrv_wine_get_wgl_driver( UINT version ) +static UINT nulldrv_OpenGLInit( UINT version, struct opengl_funcs **opengl_funcs, const struct opengl_driver_funcs **driver_funcs ) { - return (void *)-1; + return STATUS_NOT_IMPLEMENTED; }
static void nulldrv_ThreadDetach( void ) @@ -1302,7 +1302,7 @@ static const struct user_driver_funcs lazy_load_driver = /* vulkan support */ loaderdrv_VulkanInit, /* opengl support */ - nulldrv_wine_get_wgl_driver, + nulldrv_OpenGLInit, /* thread management */ nulldrv_ThreadDetach, }; @@ -1396,7 +1396,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version SET_USER_FUNC(WindowPosChanged); SET_USER_FUNC(SystemParametersInfo); SET_USER_FUNC(VulkanInit); - SET_USER_FUNC(wine_get_wgl_driver); + SET_USER_FUNC(OpenGLInit); SET_USER_FUNC(ThreadDetach); #undef SET_USER_FUNC
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index a65f6567dc7..ca0023ebe67 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -352,6 +352,9 @@ static struct opengl_funcs *osmesa_get_wgl_driver(void)
#endif /* SONAME_LIBOSMESA */
+static const struct opengl_driver_funcs nulldrv_funcs; +static const struct opengl_driver_funcs *driver_funcs = &nulldrv_funcs; + static struct opengl_funcs *display_funcs; static struct opengl_funcs *memory_funcs;
@@ -362,7 +365,14 @@ static void memory_funcs_init(void)
static void display_funcs_init(void) { - display_funcs = user_driver->pwine_get_wgl_driver( WINE_OPENGL_DRIVER_VERSION ); + UINT status; + + if ((status = user_driver->pOpenGLInit( WINE_OPENGL_DRIVER_VERSION, &display_funcs, &driver_funcs )) && + status != STATUS_NOT_IMPLEMENTED) + { + ERR( "Failed to initialize the driver opengl functions, status %#x\n", status ); + return; + } }
static struct opengl_funcs *get_dc_funcs( HDC hdc, void *null_funcs ) diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index e3b5467ced1..d744202e6c9 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 struct opengl_funcs *ANDROID_wine_get_wgl_driver( UINT version ); +extern UINT ANDROID_OpenGLInit( UINT version, struct opengl_funcs **opengl_funcs, const struct opengl_driver_funcs **driver_funcs );
/************************************************************************** diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index 1211ccd102b..cb640268c34 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -319,7 +319,7 @@ static const struct user_driver_funcs android_drv_funcs = .pWindowPosChanging = ANDROID_WindowPosChanging, .pCreateWindowSurface = ANDROID_CreateWindowSurface, .pWindowPosChanged = ANDROID_WindowPosChanged, - .pwine_get_wgl_driver = ANDROID_wine_get_wgl_driver, + .pOpenGLInit = ANDROID_OpenGLInit, };
diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index fdd4ceddd73..0cfa45c77f1 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -39,6 +39,8 @@ #include <EGL/egl.h> #endif
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "android.h" #include "winternl.h"
@@ -956,9 +958,9 @@ static void init_extensions(void) }
/********************************************************************** - * ANDROID_wine_get_wgl_driver + * ANDROID_OpenGLInit */ -struct opengl_funcs *ANDROID_wine_get_wgl_driver( UINT version ) +UINT ANDROID_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs ) { EGLConfig *configs; EGLint major, minor, count, i, pass; @@ -966,17 +968,17 @@ struct opengl_funcs *ANDROID_wine_get_wgl_driver( UINT version ) if (version != WINE_OPENGL_DRIVER_VERSION) { ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version, WINE_OPENGL_DRIVER_VERSION ); - return NULL; + 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 NULL; + 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 NULL; + return STATUS_NOT_SUPPORTED; }
#define LOAD_FUNCPTR(func) do { \ @@ -1043,7 +1045,8 @@ struct opengl_funcs *ANDROID_wine_get_wgl_driver( UINT version ) }
init_extensions(); - return &egl_funcs; + *funcs = &egl_funcs; + return STATUS_SUCCESS; }
diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c index 4921fc2f170..f74236c7b0c 100644 --- a/dlls/winemac.drv/gdi.c +++ b/dlls/winemac.drv/gdi.c @@ -310,7 +310,7 @@ static const struct user_driver_funcs macdrv_funcs = .pGetWindowStyleMasks = macdrv_GetWindowStyleMasks, .pCreateWindowSurface = macdrv_CreateWindowSurface, .pVulkanInit = macdrv_VulkanInit, - .pwine_get_wgl_driver = macdrv_wine_get_wgl_driver, + .pOpenGLInit = macdrv_OpenGLInit, };
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 4673d69654a..c42c3fd1634 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -241,7 +241,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 struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version); +extern UINT macdrv_OpenGLInit(UINT version, 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 13a64bda372..0c64d459ad9 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -4165,23 +4165,23 @@ static void load_extensions(void)
/********************************************************************** - * macdrv_wine_get_wgl_driver + * macdrv_OpenGLInit */ -struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) +UINT macdrv_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs) { TRACE("()\n");
if (version != WINE_OPENGL_DRIVER_VERSION) { ERR("version mismatch, opengl32 wants %u but macdrv has %u\n", version, WINE_OPENGL_DRIVER_VERSION); - return NULL; + return STATUS_INVALID_PARAMETER; }
dc_pbuffers = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); if (!dc_pbuffers) { WARN("CFDictionaryCreateMutable failed\n"); - return NULL; + return STATUS_NOT_SUPPORTED; }
opengl_handle = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY|RTLD_LOCAL|RTLD_NOLOAD); @@ -4189,7 +4189,7 @@ struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) { ERR("Failed to load OpenGL: %s\n", dlerror()); ERR("OpenGL support is disabled.\n"); - return NULL; + return STATUS_NOT_SUPPORTED; }
#define USE_GL_FUNC(func) \ @@ -4230,12 +4230,13 @@ struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) if (!init_pixel_formats()) goto failed;
- return &opengl_funcs; + *funcs = &opengl_funcs; + return STATUS_SUCCESS;
failed: dlclose(opengl_handle); opengl_handle = NULL; - return NULL; + return STATUS_NOT_SUPPORTED; }
diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index 501b17550d2..fcf13ae81d7 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -29,6 +29,8 @@ #include <stdlib.h> #include <string.h>
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "waylanddrv.h" #include "wine/debug.h"
@@ -1311,9 +1313,9 @@ static BOOL init_egl_configs(void) }
/********************************************************************** - * WAYLAND_wine_get_wgl_driver + * WAYLAND_OpenGLInit */ -struct opengl_funcs *WAYLAND_wine_get_wgl_driver(UINT version) +UINT WAYLAND_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs) { EGLint egl_version[2]; const char *egl_client_exts, *egl_exts; @@ -1322,13 +1324,13 @@ struct opengl_funcs *WAYLAND_wine_get_wgl_driver(UINT version) { ERR("Version mismatch, opengl32 wants %u but driver has %u\n", version, WINE_OPENGL_DRIVER_VERSION); - return NULL; + 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 NULL; + return STATUS_NOT_SUPPORTED; }
#define LOAD_FUNCPTR_DLSYM(func) \ @@ -1404,12 +1406,13 @@ struct opengl_funcs *WAYLAND_wine_get_wgl_driver(UINT version)
if (!init_opengl_funcs()) goto err; if (!init_egl_configs()) goto err; - return &opengl_funcs; + *funcs = &opengl_funcs; + return STATUS_SUCCESS;
err: dlclose(egl_handle); egl_handle = NULL; - return NULL; + return STATUS_NOT_SUPPORTED; }
static struct opengl_funcs opengl_funcs = @@ -1449,9 +1452,9 @@ void wayland_resize_gl_drawable(HWND hwnd)
#else /* No GL */
-struct opengl_funcs *WAYLAND_wine_get_wgl_driver(UINT version) +UINT WAYLAND_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs) { - return NULL; + return STATUS_NOT_IMPLEMENTED; }
void wayland_destroy_gl_drawable(HWND hwnd) diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 065d4d31873..47bf6ea1f21 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -439,6 +439,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); -struct opengl_funcs *WAYLAND_wine_get_wgl_driver(UINT version); +UINT WAYLAND_OpenGLInit(UINT version, struct opengl_funcs **opengl_funcs, const struct opengl_driver_funcs **driver_funcs);
#endif /* __WINE_WAYLANDDRV_H */ diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index dba519b1df1..8e310963ef3 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -52,7 +52,7 @@ static const struct user_driver_funcs waylanddrv_funcs = .pWindowPosChanging = WAYLAND_WindowPosChanging, .pCreateWindowSurface = WAYLAND_CreateWindowSurface, .pVulkanInit = WAYLAND_VulkanInit, - .pwine_get_wgl_driver = WAYLAND_wine_get_wgl_driver, + .pOpenGLInit = WAYLAND_OpenGLInit, };
static void wayland_init_process_name(void) diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index 70da9b8c094..5f13de49d24 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -467,7 +467,7 @@ static const struct user_driver_funcs x11drv_funcs = .pWindowPosChanged = X11DRV_WindowPosChanged, .pSystemParametersInfo = X11DRV_SystemParametersInfo, .pVulkanInit = X11DRV_VulkanInit, - .pwine_get_wgl_driver = X11DRV_wine_get_wgl_driver, + .pOpenGLInit = X11DRV_OpenGLInit, .pThreadDetach = X11DRV_ThreadDetach, };
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 4524e7c46fa..9d5b0ff3504 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -38,6 +38,8 @@ #include <sys/un.h> #endif
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "x11drv.h" #include "xcomposite.h" #include "winternl.h" @@ -536,16 +538,16 @@ done: static void *opengl_handle;
/********************************************************************** - * X11DRV_wine_get_wgl_driver + * X11DRV_OpenglInit */ -struct opengl_funcs *X11DRV_wine_get_wgl_driver(UINT version) +UINT X11DRV_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs ) { int error_base, event_base;
if (version != WINE_OPENGL_DRIVER_VERSION) { ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version, WINE_OPENGL_DRIVER_VERSION ); - return NULL; + return STATUS_INVALID_PARAMETER; }
/* No need to load any other libraries as according to the ABI, libGL should be self-sufficient @@ -555,7 +557,7 @@ struct opengl_funcs *X11DRV_wine_get_wgl_driver(UINT version) { ERR( "Failed to load libGL: %s\n", dlerror() ); ERR( "OpenGL support is disabled.\n"); - return NULL; + return STATUS_NOT_SUPPORTED; }
#define USE_GL_FUNC(func) \ @@ -724,12 +726,13 @@ struct opengl_funcs *X11DRV_wine_get_wgl_driver(UINT version) X11DRV_WineGL_LoadExtensions(); init_pixel_formats( gdi_display );
- return &opengl_funcs; + *funcs = &opengl_funcs; + return STATUS_SUCCESS;
failed: dlclose(opengl_handle); opengl_handle = NULL; - return NULL; + return STATUS_NOT_SUPPORTED; }
static const char *debugstr_fbconfig( GLXFBConfig fbconfig ) @@ -2905,11 +2908,11 @@ static struct opengl_funcs opengl_funcs = #else /* no OpenGL includes */
/********************************************************************** - * X11DRV_wine_get_wgl_driver + * X11DRV_OpenglInit */ -struct opengl_funcs *X11DRV_wine_get_wgl_driver(UINT version) +UINT X11DRV_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct opengl_driver_funcs **driver_funcs ) { - return NULL; + return STATUS_NOT_IMPLEMENTED; }
void sync_gl_drawable( HWND hwnd, BOOL known_child ) diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index b6255c2a880..921008cb211 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 struct opengl_funcs *X11DRV_wine_get_wgl_driver( UINT version ); +extern UINT X11DRV_OpenGLInit( UINT, 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 efee8d1af4d..85f1676623b 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 103 +#define WINE_GDI_DRIVER_VERSION 104
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */ #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */ @@ -320,6 +320,7 @@ struct gdi_device_manager #define WINE_DM_UNSUPPORTED 0x80000000
struct vulkan_driver_funcs; +struct opengl_driver_funcs;
struct user_driver_funcs { @@ -394,7 +395,7 @@ struct user_driver_funcs /* vulkan support */ UINT (*pVulkanInit)(UINT,void *,const struct vulkan_driver_funcs **); /* opengl support */ - struct opengl_funcs * (*pwine_get_wgl_driver)(UINT); + UINT (*pOpenGLInit)(UINT,struct opengl_funcs **,const struct opengl_driver_funcs **); /* thread management */ void (*pThreadDetach)(void); }; diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index c5540e379ad..34c83d6f40f 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -61,11 +61,12 @@ 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 30 +#define WINE_OPENGL_DRIVER_VERSION 31
struct wgl_context; struct wgl_pbuffer;
+/* interface between opengl32 and win32u */ struct opengl_funcs { BOOL (*p_wglCopyContext)( struct wgl_context * hglrcSrc, struct wgl_context * hglrcDst, UINT mask ); @@ -109,6 +110,11 @@ struct opengl_funcs #undef USE_GL_FUNC };
+/* interface between win32u and the user drivers */ +struct opengl_driver_funcs +{ +}; + #endif /* WINE_UNIX_LIB */
#endif /* __WINE_OPENGL_DRIVER_H */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 71 ++++++++++++++++++++++++++++++++++++ include/wine/opengl_driver.h | 1 + 2 files changed, 72 insertions(+)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index ca0023ebe67..d0affa80495 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -23,6 +23,7 @@
#include "config.h"
+#include <assert.h> #include <pthread.h> #include <dlfcn.h>
@@ -38,6 +39,50 @@
WINE_DEFAULT_DEBUG_CHANNEL(wgl);
+static struct opengl_funcs *get_dc_funcs( HDC hdc, void *null_funcs ); + +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 dump_extensions( const char *list ) +{ + const char *start, *end, *ptr; + + for (start = end = ptr = list; ptr; ptr = strchr( ptr + 1, ' ' )) + { + if (ptr - start <= 128) end = ptr; + else + { + TRACE( "%.*s\n", (int)(end - start), start ); + start = end + 1; + } + } + + TRACE( "%s\n", start ); +} + +static void register_extension( char *list, size_t size, const char *name ) +{ + if (!has_extension( list, name )) + { + size_t len = strlen( list ); + assert( size - len >= strlen( name ) + 1 ); + if (*list) strcat( list + len, " " ); + strcat( list + len, name ); + } +} + #ifdef SONAME_LIBOSMESA
#define OSMESA_COLOR_INDEX GL_COLOR_INDEX @@ -355,6 +400,20 @@ static struct opengl_funcs *osmesa_get_wgl_driver(void) static const struct opengl_driver_funcs nulldrv_funcs; static const struct opengl_driver_funcs *driver_funcs = &nulldrv_funcs;
+static char wgl_extensions[4096]; + +static const char *win32u_wglGetExtensionsStringARB( HDC hdc ) +{ + if (TRACE_ON(wgl)) dump_extensions( wgl_extensions ); + return wgl_extensions; +} + +static const char *win32u_wglGetExtensionsStringEXT(void) +{ + if (TRACE_ON(wgl)) dump_extensions( wgl_extensions ); + return wgl_extensions; +} + static struct opengl_funcs *display_funcs; static struct opengl_funcs *memory_funcs;
@@ -373,6 +432,18 @@ static void display_funcs_init(void) ERR( "Failed to initialize the driver opengl functions, status %#x\n", status ); return; } + if (!display_funcs) return; + + if (driver_funcs->p_init_wgl_extensions) + { + strcpy( wgl_extensions, driver_funcs->p_init_wgl_extensions() ); + + register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_extensions_string" ); + display_funcs->p_wglGetExtensionsStringARB = win32u_wglGetExtensionsStringARB; + + register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_EXT_extensions_string" ); + display_funcs->p_wglGetExtensionsStringEXT = win32u_wglGetExtensionsStringEXT; + } }
static struct opengl_funcs *get_dc_funcs( HDC hdc, void *null_funcs ) diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 34c83d6f40f..d8b2336aadd 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -113,6 +113,7 @@ struct opengl_funcs /* interface between win32u and the user drivers */ struct opengl_driver_funcs { + const char *(*p_init_wgl_extensions)(void); };
#endif /* WINE_UNIX_LIB */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/wineandroid.drv/opengl.c | 43 ++++++++++++----------------------- 1 file changed, 15 insertions(+), 28 deletions(-)
diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index 0cfa45c77f1..311fea95f8b 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -305,24 +305,6 @@ static void describe_pixel_format( struct egl_pixel_format *fmt, PIXELFORMATDESC pfd->cRedShift = pfd->cGreenShift + pfd->cGreenBits; }
-/*********************************************************************** - * android_wglGetExtensionsStringARB - */ -static const char *android_wglGetExtensionsStringARB( HDC hdc ) -{ - TRACE( "() returning "%s"\n", wgl_extensions ); - return wgl_extensions; -} - -/*********************************************************************** - * android_wglGetExtensionsStringEXT - */ -static const char *android_wglGetExtensionsStringEXT(void) -{ - TRACE( "() returning "%s"\n", wgl_extensions ); - return wgl_extensions; -} - /*********************************************************************** * android_wglCreateContextAttribsARB */ @@ -636,24 +618,16 @@ static void register_extension( const char *ext ) TRACE( "%s\n", ext ); }
-static void init_extensions(void) +static const char *android_init_wgl_extensions(void) { - void *ptr; - register_extension("WGL_ARB_create_context"); register_extension("WGL_ARB_create_context_profile"); egl_funcs.p_wglCreateContextAttribsARB = android_wglCreateContextAttribsARB;
- register_extension("WGL_ARB_extensions_string"); - egl_funcs.p_wglGetExtensionsStringARB = android_wglGetExtensionsStringARB; - register_extension("WGL_ARB_make_current_read"); egl_funcs.p_wglGetCurrentReadDCARB = (void *)1; /* never called */ egl_funcs.p_wglMakeContextCurrentARB = android_wglMakeContextCurrentARB;
- register_extension("WGL_EXT_extensions_string"); - egl_funcs.p_wglGetExtensionsStringEXT = android_wglGetExtensionsStringEXT; - register_extension("WGL_EXT_swap_control"); egl_funcs.p_wglSwapIntervalEXT = android_wglSwapIntervalEXT; egl_funcs.p_wglGetSwapIntervalEXT = android_wglGetSwapIntervalEXT; @@ -666,6 +640,13 @@ static void init_extensions(void) register_extension("WGL_WINE_pixel_format_passthrough"); egl_funcs.p_wglSetPixelFormatWINE = android_wglSetPixelFormatWINE;
+ return wgl_extensions; +} + +static void init_opengl_funcs(void) +{ + void *ptr; + /* load standard functions and extensions exported from the OpenGL library */
#define USE_GL_FUNC(func) if ((ptr = dlsym( opengl_handle, #func ))) egl_funcs.p_##func = ptr; @@ -957,6 +938,11 @@ static void init_extensions(void) #undef REDIRECT }
+static const struct opengl_driver_funcs android_driver_funcs = +{ + .p_init_wgl_extensions = android_init_wgl_extensions, +}; + /********************************************************************** * ANDROID_OpenGLInit */ @@ -1044,8 +1030,9 @@ UINT ANDROID_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct if (!pass) nb_onscreen_formats = nb_pixel_formats; }
- init_extensions(); + init_opengl_funcs(); *funcs = &egl_funcs; + *driver_funcs = &android_driver_funcs; return STATUS_SUCCESS; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winemac.drv/opengl.c | 45 +++++++++------------------------------ 1 file changed, 10 insertions(+), 35 deletions(-)
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 0c64d459ad9..5d4bcadcdfa 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -98,6 +98,7 @@ 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, GLsizei width); @@ -3032,32 +3033,6 @@ static BOOL macdrv_wglDestroyPbufferARB(struct wgl_pbuffer *pbuffer) }
-/********************************************************************** - * macdrv_wglGetExtensionsStringARB - * - * WGL_ARB_extensions_string: wglGetExtensionsStringARB - */ -static const char *macdrv_wglGetExtensionsStringARB(HDC hdc) -{ - /* FIXME: Since we're given an HDC, this should be device-specific. I.e. - this can be specific to the CGL renderer like we're supposed to do. */ - TRACE("returning "%s"\n", gl_info.wglExtensions); - return gl_info.wglExtensions; -} - - -/********************************************************************** - * macdrv_wglGetExtensionsStringEXT - * - * WGL_EXT_extensions_string: wglGetExtensionsStringEXT - */ -static const char *macdrv_wglGetExtensionsStringEXT(void) -{ - TRACE("returning "%s"\n", gl_info.wglExtensions); - return gl_info.wglExtensions; -} - - /********************************************************************** * macdrv_wglGetPbufferDCARB * @@ -4073,14 +4048,11 @@ static void register_extension(const char *ext) TRACE("'%s'\n", ext); }
-static void load_extensions(void) +static const char *macdrv_init_wgl_extensions(void) { /* * ARB Extensions */ - register_extension("WGL_ARB_extensions_string"); - opengl_funcs.p_wglGetExtensionsStringARB = macdrv_wglGetExtensionsStringARB; - register_extension("WGL_ARB_make_current_read"); opengl_funcs.p_wglGetCurrentReadDCARB = (void *)1; /* never called */ opengl_funcs.p_wglMakeContextCurrentARB = macdrv_wglMakeContextCurrentARB; @@ -4128,9 +4100,6 @@ static void load_extensions(void) /* * EXT Extensions */ - register_extension("WGL_EXT_extensions_string"); - opengl_funcs.p_wglGetExtensionsStringEXT = macdrv_wglGetExtensionsStringEXT; - if (allow_vsync) { register_extension("WGL_EXT_swap_control"); @@ -4161,8 +4130,9 @@ static void load_extensions(void) opengl_funcs.p_wglQueryCurrentRendererStringWINE = macdrv_wglQueryCurrentRendererStringWINE; opengl_funcs.p_wglQueryRendererIntegerWINE = macdrv_wglQueryRendererIntegerWINE; opengl_funcs.p_wglQueryRendererStringWINE = macdrv_wglQueryRendererStringWINE; -}
+ return gl_info.wglExtensions; +}
/********************************************************************** * macdrv_OpenGLInit @@ -4226,11 +4196,11 @@ UINT macdrv_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct o if (gluCheckExtension((GLubyte*)"GL_APPLE_flush_render", (GLubyte*)gl_info.glExtensions)) pglFlushRenderAPPLE = dlsym(opengl_handle, "glFlushRenderAPPLE");
- load_extensions(); if (!init_pixel_formats()) goto failed;
*funcs = &opengl_funcs; + *driver_funcs = &macdrv_driver_funcs; return STATUS_SUCCESS;
failed: @@ -4568,6 +4538,11 @@ static void macdrv_get_pixel_formats(struct wgl_pixel_format *formats, *num_onscreen_formats = nb_displayable_formats; }
+static const struct opengl_driver_funcs macdrv_driver_funcs = +{ + .p_init_wgl_extensions = macdrv_init_wgl_extensions, +}; + static struct opengl_funcs opengl_funcs = { .p_wglCopyContext = macdrv_wglCopyContext,
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/opengl.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index fcf13ae81d7..9a973b983dc 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -594,18 +594,6 @@ static BOOL wayland_wglDeleteContext(struct wgl_context *ctx) return TRUE; }
-static const char *wayland_wglGetExtensionsStringARB(HDC hdc) -{ - TRACE("() returning "%s"\n", wgl_extensions); - return wgl_extensions; -} - -static const char *wayland_wglGetExtensionsStringEXT(void) -{ - TRACE("() returning "%s"\n", wgl_extensions); - return wgl_extensions; -} - static PROC wayland_wglGetProcAddress(LPCSTR name) { if (!strncmp(name, "wgl", 3)) return NULL; @@ -1210,12 +1198,11 @@ static BOOL init_opengl_funcs(void) p_glClear = opengl_funcs.p_glClear; opengl_funcs.p_glClear = wayland_glClear;
- register_extension("WGL_ARB_extensions_string"); - opengl_funcs.p_wglGetExtensionsStringARB = wayland_wglGetExtensionsStringARB; - - register_extension("WGL_EXT_extensions_string"); - opengl_funcs.p_wglGetExtensionsStringEXT = wayland_wglGetExtensionsStringEXT; + return TRUE; +}
+static const char *wayland_init_wgl_extensions(void) +{ register_extension("WGL_WINE_pixel_format_passthrough"); opengl_funcs.p_wglSetPixelFormatWINE = wayland_wglSetPixelFormatWINE;
@@ -1255,7 +1242,7 @@ static BOOL init_opengl_funcs(void) opengl_funcs.p_wglReleaseTexImageARB = wayland_wglReleaseTexImageARB; opengl_funcs.p_wglSetPbufferAttribARB = wayland_wglSetPbufferAttribARB;
- return TRUE; + return wgl_extensions; }
static BOOL init_egl_configs(void) @@ -1312,6 +1299,11 @@ static BOOL init_egl_configs(void) return TRUE; }
+static const struct opengl_driver_funcs wayland_driver_funcs = +{ + .p_init_wgl_extensions = wayland_init_wgl_extensions, +}; + /********************************************************************** * WAYLAND_OpenGLInit */ @@ -1407,6 +1399,7 @@ UINT WAYLAND_OpenGLInit(UINT version, struct opengl_funcs **funcs, const struct if (!init_opengl_funcs()) goto err; if (!init_egl_configs()) goto err; *funcs = &opengl_funcs; + *driver_funcs = &wayland_driver_funcs; return STATUS_SUCCESS;
err:
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/opengl.c | 45 +++++++++------------------------------ 1 file changed, 10 insertions(+), 35 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 9d5b0ff3504..717df3c2501 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -287,7 +287,6 @@ static const BOOL is_win64 = sizeof(void *) > sizeof(int);
static struct opengl_funcs opengl_funcs;
-static void X11DRV_WineGL_LoadExtensions(void); static void init_pixel_formats( Display *display ); static BOOL glxRequireVersion(int requiredVersion);
@@ -536,6 +535,7 @@ done: }
static void *opengl_handle; +static const struct opengl_driver_funcs x11drv_driver_funcs;
/********************************************************************** * X11DRV_OpenglInit @@ -723,10 +723,10 @@ UINT X11DRV_OpenGLInit( UINT version, struct opengl_funcs **funcs, const struct pglXSwapBuffersMscOML = pglXGetProcAddressARB( (const GLubyte *)"glXSwapBuffersMscOML" ); }
- X11DRV_WineGL_LoadExtensions(); init_pixel_formats( gdi_display );
*funcs = &opengl_funcs; + *driver_funcs = &x11drv_driver_funcs; return STATUS_SUCCESS;
failed: @@ -2058,17 +2058,6 @@ static struct wgl_context *X11DRV_wglCreateContextAttribsARB( HDC hdc, struct wg return ret; }
-/** - * X11DRV_wglGetExtensionsStringARB - * - * WGL_ARB_extensions_string: wglGetExtensionsStringARB - */ -static const char *X11DRV_wglGetExtensionsStringARB(HDC hdc) -{ - TRACE("() returning "%s"\n", wglExtensions); - return wglExtensions; -} - /** * X11DRV_wglCreatePbufferARB * @@ -2532,17 +2521,6 @@ static BOOL X11DRV_wglReleaseTexImageARB( struct wgl_pbuffer *object, int iBuffe return ret; }
-/** - * X11DRV_wglGetExtensionsStringEXT - * - * WGL_EXT_extensions_string: wglGetExtensionsStringEXT - */ -static const char *X11DRV_wglGetExtensionsStringEXT(void) -{ - TRACE("() returning "%s"\n", wglExtensions); - return wglExtensions; -} - /** * X11DRV_wglGetSwapIntervalEXT * @@ -2664,10 +2642,7 @@ static void register_extension(const char *ext) TRACE("'%s'\n", ext); }
-/** - * X11DRV_WineGL_LoadExtensions - */ -static void X11DRV_WineGL_LoadExtensions(void) +static const char *x11drv_init_wgl_extensions(void) { wglExtensions[0] = 0;
@@ -2684,10 +2659,6 @@ static void X11DRV_WineGL_LoadExtensions(void) register_extension("WGL_ARB_create_context_profile"); }
- - register_extension( "WGL_ARB_extensions_string" ); - opengl_funcs.p_wglGetExtensionsStringARB = X11DRV_wglGetExtensionsStringARB; - if (glxRequireVersion(3)) { register_extension( "WGL_ARB_make_current_read" ); @@ -2738,9 +2709,6 @@ static void X11DRV_WineGL_LoadExtensions(void)
/* EXT Extensions */
- register_extension( "WGL_EXT_extensions_string" ); - opengl_funcs.p_wglGetExtensionsStringEXT = X11DRV_wglGetExtensionsStringEXT; - /* Load this extension even when it isn't backed by a GLX extension because it is has been around for ages. * Games like Call of Duty and K.O.T.O.R. rely on it. Further our emulation is good enough. */ register_extension( "WGL_EXT_swap_control" ); @@ -2798,6 +2766,8 @@ static void X11DRV_WineGL_LoadExtensions(void) opengl_funcs.p_wglQueryRendererIntegerWINE = X11DRV_wglQueryRendererIntegerWINE; opengl_funcs.p_wglQueryRendererStringWINE = X11DRV_wglQueryRendererStringWINE; } + + return wglExtensions; }
/** @@ -2891,6 +2861,11 @@ static void glxdrv_get_pixel_formats( struct wgl_pixel_format *formats, *num_onscreen_formats = nb_onscreen_formats; }
+static const struct opengl_driver_funcs x11drv_driver_funcs = +{ + .p_init_wgl_extensions = x11drv_init_wgl_extensions, +}; + static struct opengl_funcs opengl_funcs = { .p_wglCopyContext = glxdrv_wglCopyContext,
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index d0affa80495..c3245945446 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -397,7 +397,15 @@ static struct opengl_funcs *osmesa_get_wgl_driver(void)
#endif /* SONAME_LIBOSMESA */
-static const struct opengl_driver_funcs nulldrv_funcs; +static const char *nulldrv_init_wgl_extensions(void) +{ + return ""; +} + +static const struct opengl_driver_funcs nulldrv_funcs = +{ + .p_init_wgl_extensions = nulldrv_init_wgl_extensions, +}; static const struct opengl_driver_funcs *driver_funcs = &nulldrv_funcs;
static char wgl_extensions[4096]; @@ -434,16 +442,13 @@ static void display_funcs_init(void) } if (!display_funcs) return;
- if (driver_funcs->p_init_wgl_extensions) - { - strcpy( wgl_extensions, driver_funcs->p_init_wgl_extensions() ); + strcpy( wgl_extensions, driver_funcs->p_init_wgl_extensions() );
- register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_extensions_string" ); - display_funcs->p_wglGetExtensionsStringARB = win32u_wglGetExtensionsStringARB; + register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_ARB_extensions_string" ); + display_funcs->p_wglGetExtensionsStringARB = win32u_wglGetExtensionsStringARB;
- register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_EXT_extensions_string" ); - display_funcs->p_wglGetExtensionsStringEXT = win32u_wglGetExtensionsStringEXT; - } + register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_EXT_extensions_string" ); + display_funcs->p_wglGetExtensionsStringEXT = win32u_wglGetExtensionsStringEXT; }
static struct opengl_funcs *get_dc_funcs( HDC hdc, void *null_funcs )
This merge request was approved by Huw Davies.