From fac1d00c89ce3d52a70d4b3f599c45dacd1ab09d Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 17 Dec 2020 20:31:04 +0100 Subject: [PATCH] app/internal/egl: support EGL_KHR_no_config_context The mesa surfaceless renderer doesn't support configs, but does support EGL_KHR_no_config_context so no config is required. Don't fail context creation in this setup. With this change, the headless tests work on a headless linux with the EGL_PLATFORM environment variable set to "surfaceless". Signed-off-by: Elias Naur --- app/internal/egl/egl.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/internal/egl/egl.go b/app/internal/egl/egl.go index 9ff407f3..a96863e6 100644 --- a/app/internal/egl/egl.go +++ b/app/internal/egl/egl.go @@ -230,11 +230,18 @@ func createContext(disp _EGLDisplay) (*eglContext, error) { return nil, fmt.Errorf("eglChooseConfig failed: 0x%x", eglGetError()) } if eglCfg == nilEGLConfig { - return nil, errors.New("eglChooseConfig returned 0 configs") + supportsNoCfg := hasExtension(exts, "EGL_KHR_no_config_context") + if !supportsNoCfg { + return nil, errors.New("eglChooseConfig returned no configs") + } } - visID, ret := eglGetConfigAttrib(disp, eglCfg, _EGL_NATIVE_VISUAL_ID) - if !ret { - return nil, errors.New("newContext: eglGetConfigAttrib for _EGL_NATIVE_VISUAL_ID failed") + var visID _EGLint + if eglCfg != nilEGLConfig { + var ok bool + visID, ok = eglGetConfigAttrib(disp, eglCfg, _EGL_NATIVE_VISUAL_ID) + if !ok { + return nil, errors.New("newContext: eglGetConfigAttrib for _EGL_NATIVE_VISUAL_ID failed") + } } ctxAttribs := []_EGLint{ _EGL_CONTEXT_CLIENT_VERSION, 3,