Some background: I wanted to test EGL backend on my old laptop with Intel graphics limited with OpenGL 2.1 / GLES 2.0. When trying to run any game this led to a crash with NULL GL_RENDERER, but not with GLX. Tracing has shown that wined3d tries to create a context with high `WGL_CONTEXT_MAJOR_VERSION_ARB`/`WGL_CONTEXT_MINOR_VERSION`, which is not supported by hardware, resulting in the creation of nil context in EGL, but due to lack of error handling it's always assumed to be successful. In GLX this results in an error and creating a context does not lead to success, after which it tries again to create a context with a lower `WGL_CONTEXT_MAJOR_VERSION_ARB` / `WGL_CONTEXT_MINOR_VERSION` until the actual context is created. Proper error handling when creating EGL context as in this patch also allows wined3d to work on such hardware.
I think the real issue is somewhere in wined3d/wgl and passing wrong version of GL for context at first, but I don’t have proper code base knowledge to talk about it exactly. Anyway, I think that error handling when creating a context like with GLX is necessary in case of such errors.
From: Vasiliy Stelmachenok ventureo@cachyos.org
Signed-off-by: Vasiliy Stelmachenok ventureo@cachyos.org --- dlls/win32u/opengl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index fae9a71c988..749982e2e0a 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -725,7 +725,7 @@ static BOOL egldrv_context_create( int format, void *share, const int *attribs, { const struct opengl_funcs *funcs = &display_funcs; const struct egl_platform *egl = &display_egl; - EGLint egl_attribs[16], *attribs_end = egl_attribs; + EGLint err, egl_attribs[16], *attribs_end = egl_attribs;
TRACE( "format %d, share %p, attribs %p\n", format, share, attribs );
@@ -789,6 +789,13 @@ static BOOL egldrv_context_create( int format, void *share, const int *attribs, */ funcs->p_eglBindAPI( EGL_OPENGL_API ); *context = funcs->p_eglCreateContext( egl->display, EGL_NO_CONFIG_KHR, share, attribs ? egl_attribs : NULL ); + + if ((err = funcs->p_eglGetError()) != EGL_SUCCESS || !*context) + { + WARN("Context creation failed (error %#x).\n", err); + return FALSE; + } + TRACE( "Created context %p\n", *context ); return TRUE; }
Rémi Bernon (@rbernon) commented about dlls/win32u/opengl.c:
*/ funcs->p_eglBindAPI( EGL_OPENGL_API ); *context = funcs->p_eglCreateContext( egl->display, EGL_NO_CONFIG_KHR, share, attribs ? egl_attribs : NULL );
- if ((err = funcs->p_eglGetError()) != EGL_SUCCESS || !*context)
- {
WARN("Context creation failed (error %#x).\n", err);
```suggestion:-0+0 WARN( "Context creation failed (error %#x).\n", err ); ```