From: Rémi Bernon rbernon@codeweavers.com
GLX_RENDERER_ID_MESA has been removed from GLX_MESA_query_renderer v9. --- dlls/opengl32/winegl.xml | 2 -- dlls/winemac.drv/opengl.c | 45 --------------------------------------- dlls/winex11.drv/opengl.c | 5 ----- include/wine/wgl.h | 1 - 4 files changed, 53 deletions(-)
diff --git a/dlls/opengl32/winegl.xml b/dlls/opengl32/winegl.xml index 7918c3ff894..37152805ace 100644 --- a/dlls/opengl32/winegl.xml +++ b/dlls/opengl32/winegl.xml @@ -354,7 +354,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA <enum value="0x818B" name="WGL_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_WINE"/> <enum value="0x818C" name="WGL_RENDERER_OPENGL_ES_PROFILE_VERSION_WINE"/> <enum value="0x818D" name="WGL_RENDERER_OPENGL_ES2_PROFILE_VERSION_WINE"/> - <enum value="0x818E" name="WGL_RENDERER_ID_WINE"/> </enums>
<extensions> @@ -422,7 +421,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA <require> <enum name="WGL_RENDERER_ACCELERATED_WINE"/> <enum name="WGL_RENDERER_DEVICE_ID_WINE"/> - <enum name="WGL_RENDERER_ID_WINE"/> <enum name="WGL_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_WINE"/> <enum name="WGL_RENDERER_OPENGL_CORE_PROFILE_VERSION_WINE"/> <enum name="WGL_RENDERER_OPENGL_ES2_PROFILE_VERSION_WINE"/> diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 7f145b73711..e60fc04a82e 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -270,7 +270,6 @@ static const char* debugstr_attrib(int attrib, int value) ATTRIB(WGL_PIXEL_TYPE_ARB), ATTRIB(WGL_RED_BITS_ARB), ATTRIB(WGL_RED_SHIFT_ARB), - ATTRIB(WGL_RENDERER_ID_WINE), ATTRIB(WGL_SAMPLE_BUFFERS_ARB), ATTRIB(WGL_SAMPLES_ARB), ATTRIB(WGL_SHARE_ACCUM_ARB), @@ -2151,50 +2150,6 @@ static BOOL macdrv_context_create(int format, void *shared, const int *attrib_li profile = value; break;
- case WGL_RENDERER_ID_WINE: - { - CGLError err; - CGLRendererInfoObj renderer_info; - GLint renderer_count, temp; - - err = CGLQueryRendererInfo(active_displays_mask(), &renderer_info, &renderer_count); - if (err != kCGLNoError) - { - WARN("CGLQueryRendererInfo failed: %d %s\n", err, CGLErrorString(err)); - RtlSetLastWin32Error(ERROR_GEN_FAILURE); - return FALSE; - } - - value = map_renderer_index(renderer_info, renderer_count, value); - - if (value >= renderer_count) - { - WARN("WGL_RENDERER_ID_WINE renderer %d exceeds count (%d)\n", value, renderer_count); - CGLDestroyRendererInfo(renderer_info); - RtlSetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; - } - - if (!get_renderer_property(renderer_info, value, kCGLRPRendererID, &temp)) - { - WARN("WGL_RENDERER_ID_WINE failed to get ID of renderer %d\n", value); - CGLDestroyRendererInfo(renderer_info); - RtlSetLastWin32Error(ERROR_GEN_FAILURE); - return FALSE; - } - - CGLDestroyRendererInfo(renderer_info); - - if (renderer_id && temp != renderer_id) - { - WARN("WGL_RENDERER_ID_WINE requested two different renderers (0x%08x vs. 0x%08x)\n", renderer_id, temp); - RtlSetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; - } - renderer_id = temp; - break; - } - default: WARN("Unknown attribute %s.\n", debugstr_attrib(attr, value)); RtlSetLastWin32Error(ERROR_INVALID_PARAMETER); diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index b810689ff3d..c221adfdfae 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1238,11 +1238,6 @@ static BOOL x11drv_context_create( int format, void *share, const int *attribLis pContextAttribList[1] = attribList[1]; pContextAttribList += 2; break; - case WGL_RENDERER_ID_WINE: - pContextAttribList[0] = GLX_RENDERER_ID_MESA; - pContextAttribList[1] = attribList[1]; - pContextAttribList += 2; - break; default: ERR("Unhandled attribList pair: %#x %#x\n", attribList[0], attribList[1]); } diff --git a/include/wine/wgl.h b/include/wine/wgl.h index d7bc3664b73..b2e4eff9997 100644 --- a/include/wine/wgl.h +++ b/include/wine/wgl.h @@ -5434,7 +5434,6 @@ typedef unsigned int GLhandleARB; #define WGL_RED_SHIFT_ARB 0x2016 #define WGL_RENDERER_ACCELERATED_WINE 0x8186 #define WGL_RENDERER_DEVICE_ID_WINE 0x8184 -#define WGL_RENDERER_ID_WINE 0x818E #define WGL_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_WINE 0x818B #define WGL_RENDERER_OPENGL_CORE_PROFILE_VERSION_WINE 0x818A #define WGL_RENDERER_OPENGL_ES2_PROFILE_VERSION_WINE 0x818D
From: Vasiliy Stelmachenok ventureo@cachyos.org
Signed-off-by: Vasiliy Stelmachenok ventureo@cachyos.org --- dlls/opengl32/make_opengl | 3 +++ dlls/opengl32/unix_thunks.c | 4 ++-- include/wine/opengl_driver.h | 1 + include/wine/wgl.h | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 25862cd7ee9..a2ae4e514a6 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -890,7 +890,10 @@ my %supported_wgl_extensions = ); my %supported_egl_extensions = ( + "EGL_EXT_device_base" => 1, + "EGL_EXT_device_drm" => 1, "EGL_EXT_pixel_format_float" => 1, + "EGL_EXT_platform_device" => 1, "EGL_EXT_present_opaque" => 1, "EGL_KHR_create_context" => 1, "EGL_KHR_create_context_no_error" => 1, diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 7ecf7514afa..5f0c20baedd 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -97533,8 +97533,8 @@ struct opengl_funcs null_opengl_funcs = .p_wglSwapIntervalEXT = null_wglSwapIntervalEXT, };
-const int extension_registry_size = 2694; -const struct registry_entry extension_registry[2694] = +const int extension_registry_size = 2698; +const struct registry_entry extension_registry[2698] = { { "glAccumxOES", "GL_OES_fixed_point", offsetof(struct opengl_funcs, p_glAccumxOES) }, { "glAcquireKeyedMutexWin32EXT", "GL_EXT_win32_keyed_mutex", offsetof(struct opengl_funcs, p_glAcquireKeyedMutexWin32EXT) }, diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 296b030021d..dae81ef0c87 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -121,6 +121,7 @@ struct opengl_funcs BOOL (*p_wglSwapIntervalEXT)( int interval ); #define USE_GL_FUNC(x) PFN_##x p_##x; ALL_EGL_FUNCS + ALL_EGL_EXT_FUNCS ALL_GL_FUNCS ALL_GL_EXT_FUNCS #undef USE_GL_FUNC diff --git a/include/wine/wgl.h b/include/wine/wgl.h index b2e4eff9997..23338b16826 100644 --- a/include/wine/wgl.h +++ b/include/wine/wgl.h @@ -145,6 +145,7 @@ typedef unsigned int GLhandleARB; #define EGL_BAD_CONFIG 0x3005 #define EGL_BAD_CONTEXT 0x3006 #define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DEVICE_EXT 0x322B #define EGL_BAD_DISPLAY 0x3008 #define EGL_BAD_MATCH 0x3009 #define EGL_BAD_NATIVE_PIXMAP 0x300A @@ -196,9 +197,12 @@ typedef unsigned int GLhandleARB; #define EGL_CORE_NATIVE_ENGINE 0x305B #define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0) #define EGL_DEPTH_SIZE 0x3025 +#define EGL_DEVICE_EXT 0x322C #define EGL_DISPLAY_SCALING 10000 #define EGL_DONT_CARE EGL_CAST(EGLint,-1) #define EGL_DRAW 0x3059 +#define EGL_DRM_DEVICE_FILE_EXT 0x3233 +#define EGL_DRM_MASTER_FD_EXT 0x333C #define EGL_EXTENSIONS 0x3055 #define EGL_FALSE 0 #define EGL_FOREVER 0xFFFFFFFFFFFFFFFF @@ -246,6 +250,7 @@ typedef unsigned int GLhandleARB; #define EGL_NOT_INITIALIZED 0x3001 #define EGL_NO_CONFIG_KHR EGL_CAST(EGLConfig,0) #define EGL_NO_CONTEXT EGL_CAST(EGLContext,0) +#define EGL_NO_DEVICE_EXT EGL_CAST(EGLDeviceEXT,0) #define EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0) #define EGL_NO_IMAGE EGL_CAST(EGLImage,0) #define EGL_NO_RESET_NOTIFICATION 0x31BE @@ -267,6 +272,7 @@ typedef unsigned int GLhandleARB; #define EGL_PIXEL_ASPECT_RATIO 0x3092 #define EGL_PIXMAP_BIT 0x0002 #define EGL_PLATFORM_ANDROID_KHR 0x3141 +#define EGL_PLATFORM_DEVICE_EXT 0x313F #define EGL_PLATFORM_SURFACELESS_MESA 0x31DD #define EGL_PLATFORM_WAYLAND_KHR 0x31D8 #define EGL_PLATFORM_X11_KHR 0x31D5 @@ -6233,6 +6239,10 @@ typedef void (GLAPIENTRY *PFN_glVertex4s)( GLshort x, GLshort y, GLshort z typedef void (GLAPIENTRY *PFN_glVertex4sv)( const GLshort *v ); typedef void (GLAPIENTRY *PFN_glVertexPointer)( GLint size, GLenum type, GLsizei stride, const void *pointer ); typedef void (GLAPIENTRY *PFN_glViewport)( GLint x, GLint y, GLsizei width, GLsizei height ); +typedef EGLBoolean (GLAPIENTRY *PFN_eglQueryDeviceAttribEXT)( EGLDeviceEXT device, EGLint attribute, EGLAttrib *value ); +typedef const char * (GLAPIENTRY *PFN_eglQueryDeviceStringEXT)( EGLDeviceEXT device, EGLint name ); +typedef EGLBoolean (GLAPIENTRY *PFN_eglQueryDevicesEXT)( EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices ); +typedef EGLBoolean (GLAPIENTRY *PFN_eglQueryDisplayAttribEXT)( EGLDisplay dpy, EGLint attribute, EGLAttrib *value ); typedef void (GLAPIENTRY *PFN_glAccumxOES)( GLenum op, GLfixed value ); typedef GLboolean (GLAPIENTRY *PFN_glAcquireKeyedMutexWin32EXT)( GLuint memory, GLuint64 key, GLuint timeout ); typedef void (GLAPIENTRY *PFN_glActiveProgramEXT)( GLuint program ); @@ -9027,7 +9037,11 @@ typedef BOOL (GLAPIENTRY *PFN_wglSwapIntervalEXT)( int interval ); USE_GL_FUNC(eglWaitNative) \ USE_GL_FUNC(eglWaitSync)
-#define ALL_EGL_EXT_FUNCS +#define ALL_EGL_EXT_FUNCS \ + USE_GL_FUNC(eglQueryDeviceAttribEXT) \ + USE_GL_FUNC(eglQueryDeviceStringEXT) \ + USE_GL_FUNC(eglQueryDevicesEXT) \ + USE_GL_FUNC(eglQueryDisplayAttribEXT)
#define ALL_GL_FUNCS \ USE_GL_FUNC(glAccum) \
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 86 ++++++++++++++++++++++++++++-------- include/wine/opengl_driver.h | 11 ++--- 2 files changed, 73 insertions(+), 24 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 2454daf7e11..958aea324df 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -54,11 +54,11 @@ struct wgl_pbuffer
static const struct opengl_driver_funcs nulldrv_funcs, *driver_funcs = &nulldrv_funcs; static const struct opengl_funcs *default_funcs; /* default GL function table from opengl32 */ -static struct egl_platform display_egl; +static struct egl_platform display_egl, *devices_egl; static struct opengl_funcs display_funcs;
static struct wgl_pixel_format *pixel_formats; -static UINT formats_count, onscreen_count; +static UINT formats_count, onscreen_count, devices_count; static char wgl_extensions[4096];
static BOOL has_extension( const char *list, const char *ext ) @@ -902,36 +902,30 @@ failed: return FALSE; }
-static void init_egl_platform( struct egl_platform *egl, struct opengl_funcs *funcs, - const struct opengl_driver_funcs *driver_funcs ) +static BOOL init_egl_platform( struct egl_platform *egl, const struct opengl_funcs *funcs ) { const char *extensions; EGLint major, minor;
- if (!funcs->egl_handle || !driver_funcs->p_init_egl_platform) return; - - driver_funcs->p_init_egl_platform( egl ); - if (!egl->type) egl->display = funcs->p_eglGetDisplay( EGL_DEFAULT_DISPLAY ); - else egl->display = funcs->p_eglGetPlatformDisplay( egl->type, egl->native_display, NULL ); - + if (!egl->display) egl->display = funcs->p_eglGetPlatformDisplay( egl->type, egl->native_display, NULL ); if (!egl->display) { - ERR( "Failed to open EGL display\n" ); - return; + WARN( "Failed to open EGL display for type %#x, native display %p\n", egl->type, egl->native_display ); + return FALSE; }
- if (!funcs->p_eglInitialize( egl->display, &major, &minor )) return; + if (!funcs->p_eglInitialize( egl->display, &major, &minor )) return FALSE; TRACE( "Initialized EGL display %p, version %d.%d\n", egl->display, major, minor );
- if (!(extensions = funcs->p_eglQueryString( egl->display, EGL_EXTENSIONS ))) return; + if (!(extensions = funcs->p_eglQueryString( egl->display, EGL_EXTENSIONS ))) return FALSE; 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; \ + WARN( "Failed to find required extension %s\n", #ext ); \ + return FALSE; \ } CHECK_EXTENSION( EGL_KHR_create_context ); CHECK_EXTENSION( EGL_KHR_create_context_no_error ); @@ -940,6 +934,61 @@ static void init_egl_platform( struct egl_platform *egl, struct opengl_funcs *fu
egl->has_EGL_EXT_present_opaque = has_extension( extensions, "EGL_EXT_present_opaque" ); egl->has_EGL_EXT_pixel_format_float = has_extension( extensions, "EGL_EXT_pixel_format_float" ); + return TRUE; +} + +static void init_egl_devices( struct opengl_funcs *funcs ) +{ + EGLDeviceEXT *devices = NULL; + struct egl_platform *egl; + const char *extensions; + EGLint i, count; + + if (!(extensions = funcs->p_eglQueryString( EGL_NO_DISPLAY, EGL_EXTENSIONS ))) return; + if (!has_extension( extensions, "EGL_EXT_device_base" ) || !has_extension( extensions, "EGL_EXT_platform_device" )) return; + +#define LOAD_FUNCPTR( func ) \ + if (!funcs->p_##func && !(funcs->p_##func = (void *)funcs->p_eglGetProcAddress( #func ))) return + LOAD_FUNCPTR( eglQueryDevicesEXT ); + LOAD_FUNCPTR( eglQueryDeviceStringEXT ); + LOAD_FUNCPTR( eglQueryDisplayAttribEXT ); +#undef LOAD_FUNCPTR + + if (!funcs->p_eglQueryDisplayAttribEXT( display_egl.display, EGL_DEVICE_EXT, (EGLAttrib *)&display_egl.device )) + { + WARN( "Failed to query EGL display device (error %#x).\n", funcs->p_eglGetError() ); + display_egl.device = EGL_NO_DEVICE_EXT; + } + TRACE( "Found display platform device %p\n", display_egl.device ); + + funcs->p_eglQueryDevicesEXT( 0, NULL, &count ); + if (!count || !(devices = calloc( count, sizeof(EGLDeviceEXT *) )) || !(devices_egl = calloc( count, sizeof(*devices_egl) ))) goto done; + funcs->p_eglQueryDevicesEXT( count, devices, &count ); + + for (i = 0, egl = devices_egl; i < count; i++) + { + TRACE( "Initializing EGL device %p\n", devices[i] ); + egl->type = EGL_PLATFORM_DEVICE_EXT; + egl->native_display = devices[i]; + egl->device = devices[i]; + if (init_egl_platform( egl, funcs )) egl++; + } + devices_count = egl - devices_egl; + +done: + TRACE( "Initialized %u EGL devices\n", devices_count ); + free( devices ); +} + +static void init_egl_platforms( struct opengl_funcs *funcs, const struct opengl_driver_funcs *driver_funcs ) +{ + if (!funcs->egl_handle || !driver_funcs->p_init_egl_platform) return; + + driver_funcs->p_init_egl_platform( &display_egl ); + if (!display_egl.type) display_egl.display = funcs->p_eglGetDisplay( EGL_DEFAULT_DISPLAY ); + + init_egl_platform( &display_egl, funcs ); + init_egl_devices( funcs ); }
#else /* SONAME_LIBEGL */ @@ -950,8 +999,7 @@ static BOOL egl_init( const struct opengl_driver_funcs **driver_funcs ) return FALSE; }
-static void init_egl_platform( struct egl_platform *egl, struct opengl_funcs *funcs, - const struct opengl_driver_funcs *driver_funcs ) +static void init_egl_platforms( struct opengl_funcs *funcs, const struct opengl_driver_funcs *driver_funcs ) { }
@@ -2102,7 +2150,7 @@ static void display_funcs_init(void)
if ((status = user_driver->pOpenGLInit( WINE_OPENGL_DRIVER_VERSION, &display_funcs, &driver_funcs ))) WARN( "Failed to initialize the driver OpenGL functions, status %#x\n", status ); - init_egl_platform( &display_egl, &display_funcs, driver_funcs ); + init_egl_platforms( &display_funcs, driver_funcs );
formats_count = driver_funcs->p_init_pixel_formats( &onscreen_count ); if (!(pixel_formats = malloc( formats_count * sizeof(*pixel_formats) ))) ERR( "Failed to allocate memory for pixel formats\n" ); diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index dae81ef0c87..d665b93912e 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -136,11 +136,12 @@ struct egl_platform BOOL force_pbuffer_formats;
/* filled by win32u after init_egl_platform */ - EGLDisplay display; - UINT config_count; - EGLConfig *configs; - BOOL has_EGL_EXT_present_opaque; - BOOL has_EGL_EXT_pixel_format_float; + EGLDeviceEXT device; + EGLDisplay display; + UINT config_count; + EGLConfig *configs; + BOOL has_EGL_EXT_present_opaque; + BOOL has_EGL_EXT_pixel_format_float; };
struct opengl_drawable_funcs
From: Vasiliy Stelmachenok ventureo@cachyos.org
--- dlls/win32u/opengl.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 958aea324df..5f4c6702cc1 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -2142,6 +2142,30 @@ static int win32u_wglGetSwapIntervalEXT(void) return interval; }
+static BOOL win32u_wglQueryRendererIntegerWINE( HDC hdc, GLint renderer, GLenum attribute, GLuint *value ) +{ + FIXME( "hdc %p, renderer %u, attribute %#x, value %p stub!\n", hdc, renderer, attribute, value ); + return FALSE; +} + +static const char *win32u_wglQueryRendererStringWINE( HDC hdc, GLint renderer, GLenum attribute ) +{ + FIXME( "hdc %p, renderer %u, attribute %#x stub!\n", hdc, renderer, attribute ); + return NULL; +} + +static BOOL win32u_wglQueryCurrentRendererIntegerWINE( GLenum attribute, GLuint *value ) +{ + FIXME( "attribute %#x, value %p stub!\n", attribute, value ); + return FALSE; +} + +static const char *win32u_wglQueryCurrentRendererStringWINE( GLenum attribute ) +{ + FIXME( "attribute %#x stub!\n", attribute ); + return NULL; +} + static void display_funcs_init(void) { UINT status; @@ -2241,6 +2265,15 @@ static void display_funcs_init(void) 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; + + if (display_egl.device && devices_count) + { + register_extension( wgl_extensions, ARRAY_SIZE(wgl_extensions), "WGL_WINE_query_renderer" ); + display_funcs.p_wglQueryCurrentRendererIntegerWINE = win32u_wglQueryCurrentRendererIntegerWINE; + display_funcs.p_wglQueryCurrentRendererStringWINE = win32u_wglQueryCurrentRendererStringWINE; + display_funcs.p_wglQueryRendererIntegerWINE = win32u_wglQueryRendererIntegerWINE; + display_funcs.p_wglQueryRendererStringWINE = win32u_wglQueryRendererStringWINE; + } }
/***********************************************************************
From: Vasiliy Stelmachenok ventureo@cachyos.org
--- dlls/win32u/opengl.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 5f4c6702cc1..d336a70ecef 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -2156,13 +2156,27 @@ static const char *win32u_wglQueryRendererStringWINE( HDC hdc, GLint renderer, G
static BOOL win32u_wglQueryCurrentRendererIntegerWINE( GLenum attribute, GLuint *value ) { - FIXME( "attribute %#x, value %p stub!\n", attribute, value ); + int i; + + TRACE( "attribute %#x, value %p\n", attribute, value ); + + for (i = 0; i < devices_count; i++) if (devices_egl[i].device == display_egl.device) break; + if (i < devices_count) return win32u_wglQueryRendererIntegerWINE( 0, i, attribute, value ); + + WARN( "Cannot find current renderer device\n" ); return FALSE; }
static const char *win32u_wglQueryCurrentRendererStringWINE( GLenum attribute ) { - FIXME( "attribute %#x stub!\n", attribute ); + int i; + + TRACE( "attribute %#x\n", attribute ); + + for (i = 0; i < devices_count; i++) if (devices_egl[i].device == display_egl.device) break; + if (i < devices_count) return win32u_wglQueryRendererStringWINE( 0, i, attribute ); + + WARN( "Cannot find current renderer device\n" ); return NULL; }
From: Rémi Bernon rbernon@codeweavers.com
Based on a patch from Vasiliy Stelmachenok. --- dlls/win32u/opengl.c | 59 +++++++++++++++++++++++++++++++++++- include/wine/opengl_driver.h | 5 +++ 2 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index d336a70ecef..0c5a211a785 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1005,6 +1005,48 @@ static void init_egl_platforms( struct opengl_funcs *funcs, const struct opengl_
#endif /* SONAME_LIBEGL */
+static UINT read_drm_device_prop( const char *name, const char *prop ) +{ + UINT value = -1; + char *path; + FILE *file; + + if (!(path = malloc( strlen( name ) + strlen( prop ) + 23 ))) return value; + sprintf( path, "/sys/class/drm%s/device/%s", name, prop ); + + if ((file = fopen( path, "r" ))) + { + fscanf( file, "%x", &value ); + fclose( file ); + } + + free( path ); + return value; +} + +static void init_device_info( struct egl_platform *egl, const struct opengl_funcs *funcs ) +{ + const char *extensions, *str; + + TRACE( "Initializing device %zu (%p)\n", egl - devices_egl, egl->device); + + extensions = funcs->p_eglQueryDeviceStringEXT( egl->device, EGL_EXTENSIONS ); + /* Assume that all devices without EGL_MESA_device_software are accelerated. */ + egl->accelerated = !has_extension( extensions, "EGL_MESA_device_software" ); + TRACE( " - accelerated: %u\n", egl->accelerated ); + + /* EGL does not provide a convenient way to get device / vendor ID, so we have to do it + * manually through DRM. Otherwise fallback to value as for SoC devices in GLX */ + if (!has_extension( extensions, "EGL_EXT_device_drm" )) egl->vendor_id = egl->device_id = 0xffffffff; + else if ((str = funcs->p_eglQueryDeviceStringEXT( egl->device, EGL_DRM_DEVICE_FILE_EXT )) && (str = strrchr( str, '/' ))) + { + egl->vendor_id = read_drm_device_prop( str, "vendor" ); + egl->device_id = read_drm_device_prop( str, "device" ); + } + TRACE( " - device_id: %#x\n", egl->device_id ); + TRACE( " - vendor_id: %#x\n", egl->vendor_id ); +} + static const struct { BYTE color_bits; @@ -2144,7 +2186,21 @@ static int win32u_wglGetSwapIntervalEXT(void)
static BOOL win32u_wglQueryRendererIntegerWINE( HDC hdc, GLint renderer, GLenum attribute, GLuint *value ) { - FIXME( "hdc %p, renderer %u, attribute %#x, value %p stub!\n", hdc, renderer, attribute, value ); + struct egl_platform *egl = devices_egl + renderer; + + TRACE( "hdc %p, renderer %u, attribute %#x, value %p\n", hdc, renderer, attribute, value ); + + if (renderer >= devices_count) return FALSE; + + switch (attribute) + { + case WGL_RENDERER_ACCELERATED_WINE: *value = egl->accelerated; return TRUE; + case WGL_RENDERER_DEVICE_ID_WINE: *value = egl->device_id; return TRUE; + case WGL_RENDERER_VENDOR_ID_WINE: *value = egl->vendor_id; return TRUE; + case WGL_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_WINE: *value = 0; return TRUE; + default: FIXME( "Unsupported attribute %#x\n", attribute ); break; + } + return FALSE; }
@@ -2287,6 +2343,7 @@ static void display_funcs_init(void) display_funcs.p_wglQueryCurrentRendererStringWINE = win32u_wglQueryCurrentRendererStringWINE; display_funcs.p_wglQueryRendererIntegerWINE = win32u_wglQueryRendererIntegerWINE; display_funcs.p_wglQueryRendererStringWINE = win32u_wglQueryRendererStringWINE; + for (int i = 0; i < devices_count; i++) init_device_info( devices_egl + i, &display_funcs ); } }
diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index d665b93912e..6aef60ae449 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -142,6 +142,11 @@ struct egl_platform EGLConfig *configs; BOOL has_EGL_EXT_present_opaque; BOOL has_EGL_EXT_pixel_format_float; + + /* WGL_WINE_query_renderer info */ + UINT device_id; + UINT vendor_id; + BOOL accelerated; };
struct opengl_drawable_funcs
From: Rémi Bernon rbernon@codeweavers.com
Based on a patch from Vasiliy Stelmachenok. --- dlls/win32u/opengl.c | 48 ++++++++++++++++++++++++++++++++++++ include/wine/opengl_driver.h | 2 ++ 2 files changed, 50 insertions(+)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 0c5a211a785..e343ed5e8a5 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1026,7 +1026,11 @@ static UINT read_drm_device_prop( const char *name, const char *prop )
static void init_device_info( struct egl_platform *egl, const struct opengl_funcs *funcs ) { + static const UINT versions[] = {46, 45, 44, 43, 42, 41, 40, 33, 32, 31, 30, 21, 20, 15, 14, 13, 12, 11, 10, 0}; + EGLContext core_context = EGL_NO_CONTEXT, compat_context = EGL_NO_CONTEXT; const char *extensions, *str; + EGLConfig config; + int i, count;
TRACE( "Initializing device %zu (%p)\n", egl - devices_egl, egl->device);
@@ -1045,6 +1049,39 @@ static void init_device_info( struct egl_platform *egl, const struct opengl_func } TRACE( " - device_id: %#x\n", egl->device_id ); TRACE( " - vendor_id: %#x\n", egl->vendor_id ); + + funcs->p_eglBindAPI( EGL_OPENGL_API ); + funcs->p_eglGetConfigs( egl->display, &config, 1, &count ); + if (!count) config = EGL_NO_CONFIG_KHR; + + for (i = 0; i < ARRAY_SIZE(versions) && (!egl->core_version || !egl->compat_version); i++) + { + int context_attribs[] = + { + EGL_CONTEXT_MAJOR_VERSION, versions[i] / 10, + EGL_CONTEXT_MINOR_VERSION, versions[i] % 10, + EGL_CONTEXT_OPENGL_PROFILE_MASK, 0, + EGL_NONE, + }; + + if (!egl->compat_version && versions[i] >= 30) + { + context_attribs[5] = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT; + compat_context = funcs->p_eglCreateContext( egl->display, config, EGL_NO_CONTEXT, context_attribs ); + if (compat_context) egl->compat_version = versions[i]; + } + if (!egl->core_version) + { + context_attribs[5] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT; + core_context = funcs->p_eglCreateContext( egl->display, config, EGL_NO_CONTEXT, context_attribs ); + if (core_context) egl->core_version = versions[i]; + } + } + TRACE( " - core_version: %u\n", egl->core_version ); + TRACE( " - compat_version: %u\n", egl->compat_version ); + + if (compat_context) funcs->p_eglDestroyContext( egl->display, compat_context ); + if (core_context) funcs->p_eglDestroyContext( egl->display, core_context ); }
static const struct @@ -2198,6 +2235,17 @@ static BOOL win32u_wglQueryRendererIntegerWINE( HDC hdc, GLint renderer, GLenum case WGL_RENDERER_DEVICE_ID_WINE: *value = egl->device_id; return TRUE; case WGL_RENDERER_VENDOR_ID_WINE: *value = egl->vendor_id; return TRUE; case WGL_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_WINE: *value = 0; return TRUE; + case WGL_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_WINE: + value[0] = egl->compat_version / 10; + value[1] = egl->compat_version % 10; + return TRUE; + case WGL_RENDERER_OPENGL_CORE_PROFILE_VERSION_WINE: + value[0] = egl->core_version / 10; + value[1] = egl->core_version % 10; + return TRUE; + case WGL_RENDERER_PREFERRED_PROFILE_WINE: + *value = egl->core_version ? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + return TRUE; default: FIXME( "Unsupported attribute %#x\n", attribute ); break; }
diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 6aef60ae449..647560bf105 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -147,6 +147,8 @@ struct egl_platform UINT device_id; UINT vendor_id; BOOL accelerated; + UINT core_version; + UINT compat_version; };
struct opengl_drawable_funcs
From: Rémi Bernon rbernon@codeweavers.com
Based on a patch from Vasiliy Stelmachenok. --- dlls/win32u/opengl.c | 28 ++++++++++++++++++++++++++-- include/wine/opengl_driver.h | 2 ++ 2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index e343ed5e8a5..ab7c8042a7f 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1027,10 +1027,10 @@ static UINT read_drm_device_prop( const char *name, const char *prop ) static void init_device_info( struct egl_platform *egl, const struct opengl_funcs *funcs ) { static const UINT versions[] = {46, 45, 44, 43, 42, 41, 40, 33, 32, 31, 30, 21, 20, 15, 14, 13, 12, 11, 10, 0}; - EGLContext core_context = EGL_NO_CONTEXT, compat_context = EGL_NO_CONTEXT; + EGLContext core_context = EGL_NO_CONTEXT, compat_context = EGL_NO_CONTEXT, context = EGL_NO_CONTEXT; + int i, count, values[3] = {0}; const char *extensions, *str; EGLConfig config; - int i, count;
TRACE( "Initializing device %zu (%p)\n", egl - devices_egl, egl->device);
@@ -1069,17 +1069,39 @@ static void init_device_info( struct egl_platform *egl, const struct opengl_func context_attribs[5] = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT; compat_context = funcs->p_eglCreateContext( egl->display, config, EGL_NO_CONTEXT, context_attribs ); if (compat_context) egl->compat_version = versions[i]; + if (!context) context = compat_context; } if (!egl->core_version) { context_attribs[5] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT; core_context = funcs->p_eglCreateContext( egl->display, config, EGL_NO_CONTEXT, context_attribs ); if (core_context) egl->core_version = versions[i]; + if (!context) context = core_context; } } TRACE( " - core_version: %u\n", egl->core_version ); TRACE( " - compat_version: %u\n", egl->compat_version );
+ if (context) + { + funcs->p_eglMakeCurrent( egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, context ); + + if ((str = (const char *)funcs->p_glGetString( GL_VERSION )) && (str = strrchr( str, ' ' )) && + (count = sscanf( str, "%u.%u.%u", &values[0], &values[1], &values[2] )) >= 2) + memcpy( egl->version, values, sizeof(egl->version) ); + TRACE( " - version: %u.%u.%u\n", egl->version[0], egl->version[1], egl->version[2] ); + + extensions = (const char *)funcs->p_glGetString( GL_EXTENSIONS ); + if (has_extension( extensions, "GL_NVX_gpu_memory_info" )) + { + funcs->p_glGetIntegerv( GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, values ); + egl->video_memory = values[0] / 1024; + } + TRACE( " - video_memory: %u MiB\n", egl->video_memory ); + + funcs->p_eglMakeCurrent( egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); + } + if (compat_context) funcs->p_eglDestroyContext( egl->display, compat_context ); if (core_context) funcs->p_eglDestroyContext( egl->display, core_context ); } @@ -2235,6 +2257,7 @@ static BOOL win32u_wglQueryRendererIntegerWINE( HDC hdc, GLint renderer, GLenum case WGL_RENDERER_DEVICE_ID_WINE: *value = egl->device_id; return TRUE; case WGL_RENDERER_VENDOR_ID_WINE: *value = egl->vendor_id; return TRUE; case WGL_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_WINE: *value = 0; return TRUE; + case WGL_RENDERER_VERSION_WINE: memcpy( value, egl->version, 3 ); return TRUE; case WGL_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_WINE: value[0] = egl->compat_version / 10; value[1] = egl->compat_version % 10; @@ -2246,6 +2269,7 @@ static BOOL win32u_wglQueryRendererIntegerWINE( HDC hdc, GLint renderer, GLenum case WGL_RENDERER_PREFERRED_PROFILE_WINE: *value = egl->core_version ? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; return TRUE; + case WGL_RENDERER_VIDEO_MEMORY_WINE: *value = egl->video_memory; return TRUE; default: FIXME( "Unsupported attribute %#x\n", attribute ); break; }
diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 647560bf105..e43522f4570 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -147,8 +147,10 @@ struct egl_platform UINT device_id; UINT vendor_id; BOOL accelerated; + UINT version[3]; UINT core_version; UINT compat_version; + UINT video_memory; };
struct opengl_drawable_funcs
From: Vasiliy Stelmachenok ventureo@cachyos.org
--- dlls/win32u/opengl.c | 19 ++++++++++++++++++- include/wine/opengl_driver.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index ab7c8042a7f..f1cb42e91bd 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1086,6 +1086,11 @@ static void init_device_info( struct egl_platform *egl, const struct opengl_func { funcs->p_eglMakeCurrent( egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, context );
+ egl->device_name = (const char *)funcs->p_glGetString( GL_RENDERER ); + egl->vendor_name = (const char *)funcs->p_glGetString( GL_VENDOR ); + TRACE( " - device_name: %s\n", egl->device_name ); + TRACE( " - vendor_name: %s\n", egl->vendor_name ); + if ((str = (const char *)funcs->p_glGetString( GL_VERSION )) && (str = strrchr( str, ' ' )) && (count = sscanf( str, "%u.%u.%u", &values[0], &values[1], &values[2] )) >= 2) memcpy( egl->version, values, sizeof(egl->version) ); @@ -2278,7 +2283,19 @@ static BOOL win32u_wglQueryRendererIntegerWINE( HDC hdc, GLint renderer, GLenum
static const char *win32u_wglQueryRendererStringWINE( HDC hdc, GLint renderer, GLenum attribute ) { - FIXME( "hdc %p, renderer %u, attribute %#x stub!\n", hdc, renderer, attribute ); + struct egl_platform *egl = devices_egl + renderer; + + TRACE( "hdc %p, renderer %u, attribute %#x\n", hdc, renderer, attribute ); + + if (renderer >= devices_count) return NULL; + + switch (attribute) + { + case WGL_RENDERER_DEVICE_ID_WINE: return egl->device_name; + case WGL_RENDERER_VENDOR_ID_WINE: return egl->vendor_name; + default: FIXME( "Unsupported attribute %#x\n", attribute ); + } + return NULL; }
diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index e43522f4570..ef88c2a00ce 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -151,6 +151,8 @@ struct egl_platform UINT core_version; UINT compat_version; UINT video_memory; + const char *device_name; + const char *vendor_name; };
struct opengl_drawable_funcs
Yes, it looks much better for me, thank you!
Quickly tested on AMD / Intel / NVIDIA, seems to work fine. Although in the case of AMD+NVIDIA, it looks that when using EGL implementation from Mesa information about dGPU cannot be obtained correctly, because NVIDIA device is controlled by a closed driver, which leads to these errors: ``` 0144:trace:wgl:init_egl_devices Initializing EGL device 0x55557d6a6db0 libEGL warning: pci id for fd 46: 10de:25a2, driver (null)
pci id for fd 47: 10de:25a2, driver (null) pci id for fd 48: 10de:25a2, driver (null) libEGL warning: egl: failed to create dri2 screen libEGL warning: pci id for fd 46: 10de:25a2, driver (null)
pci id for fd 47: 10de:25a2, driver (null) pci id for fd 48: 10de:25a2, driver (null) libEGL warning: egl: failed to create dri2 screen libEGL warning: pci id for fd 46: 10de:25a2, driver (null) ```
This is not critical, it just creates some junk in logs and seems to be the same thing happens for eglinfo, so this is probably not our issue.
This merge request was approved by Rémi Bernon.
This merge request was approved by Vasiliy Stelmachenok.
On Thu Oct 9 13:43:03 2025 +0000, Vasiliy Stelmachenok wrote:
Yes, it looks much better for me, thank you! Quickly tested on AMD / Intel / NVIDIA, seems to work fine. Although in the case of AMD+NVIDIA, it looks that when using EGL implementation from Mesa information about dGPU cannot be obtained correctly, because NVIDIA device is controlled by a closed driver, which leads to these errors:
0144:trace:wgl:init_egl_devices Initializing EGL device 0x55557d6a6db0 libEGL warning: pci id for fd 46: 10de:25a2, driver (null) pci id for fd 47: 10de:25a2, driver (null) pci id for fd 48: 10de:25a2, driver (null) libEGL warning: egl: failed to create dri2 screen libEGL warning: pci id for fd 46: 10de:25a2, driver (null) pci id for fd 47: 10de:25a2, driver (null) pci id for fd 48: 10de:25a2, driver (null) libEGL warning: egl: failed to create dri2 screen libEGL warning: pci id for fd 46: 10de:25a2, driver (null)
This is not critical, it just creates some junk in logs and seems to be the same thing happens for eglinfo, so this is probably not our issue.
Fwiw these messages are being printed when both MESA and NVIDIA EGL libraries are being tried. I could see them as well but now anymore after installing the NVIDIA proprietary package (which I suspect possibly broke the MESA libraries, or bypass them).
In any case it's not something we can do anything about.