The open source OpenXR runtime

c/client: improve EGL attributes array filling for context creation

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2004>

+14 -10
+1
doc/changes/compositor/mr.2004.md
···
··· 1 + client: improve EGL context creation and use and match reset notification strategy when creating a shared context.
+13 -10
src/xrt/compositor/client/comp_egl_client.c
··· 208 209 eglBindAPI(api_type); 210 211 - // clang-format off 212 - EGLint attrs[] = { 213 - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, 214 - EGL_CONTEXT_MINOR_VERSION_KHR, 1, // Panfrost only supports 3.1 215 - EGL_NONE, EGL_NONE, 216 - EGL_NONE, 217 - }; 218 - // clang-format on 219 220 if (api_type == EGL_OPENGL_API) { 221 - attrs[4] = EGL_CONTEXT_OPENGL_PROFILE_MASK; 222 - attrs[5] = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT; 223 } 224 225 EGLContext our_context = eglCreateContext(display, config, app_context, attrs); 226
··· 208 209 eglBindAPI(api_type); 210 211 + size_t attrc = 0; 212 + EGLint attrs[7] = {0}; 213 + 214 + attrs[attrc++] = EGL_CONTEXT_MAJOR_VERSION; 215 + attrs[attrc++] = 3; 216 + // Panfrost only supports 3.1 217 + attrs[attrc++] = EGL_CONTEXT_MINOR_VERSION; 218 + attrs[attrc++] = 1; 219 220 if (api_type == EGL_OPENGL_API) { 221 + attrs[attrc++] = EGL_CONTEXT_OPENGL_PROFILE_MASK; 222 + attrs[attrc++] = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT; 223 } 224 + 225 + attrs[attrc++] = EGL_NONE; 226 + assert(attrc <= ARRAY_SIZE(attrs)); 227 228 EGLContext our_context = eglCreateContext(display, config, app_context, attrs); 229