[PATCH v2 0/1] MR9052: win32u: Handle errors when creating EGL context
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. -- v2: win32u: Handle errors when creating EGL context https://gitlab.winehq.org/wine/wine/-/merge_requests/9052
From: Vasiliy Stelmachenok <ventureo(a)cachyos.org> Signed-off-by: Vasiliy Stelmachenok <ventureo(a)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..22678abdd88 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; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9052
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9052
participants (3)
-
Rémi Bernon -
Vasiliy Stelmachenok -
Vasiliy Stelmachenok (@ventureoo)