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