From 7e43f51896fa1bc4ddfb2af8fbcdf988593d3b27 Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Mon, 30 Oct 2023 15:07:36 -0400 Subject: [PATCH] c/client: improve EGL attributes array filling for context creation Part-of: --- doc/changes/compositor/mr.2004.md | 1 + src/xrt/compositor/client/comp_egl_client.c | 23 ++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 doc/changes/compositor/mr.2004.md diff --git a/doc/changes/compositor/mr.2004.md b/doc/changes/compositor/mr.2004.md new file mode 100644 index 000000000..1a50c8b8f --- /dev/null +++ b/doc/changes/compositor/mr.2004.md @@ -0,0 +1 @@ +client: improve EGL context creation and use and match reset notification strategy when creating a shared context. diff --git a/src/xrt/compositor/client/comp_egl_client.c b/src/xrt/compositor/client/comp_egl_client.c index 192ae4cf2..ca2e0feec 100644 --- a/src/xrt/compositor/client/comp_egl_client.c +++ b/src/xrt/compositor/client/comp_egl_client.c @@ -208,20 +208,23 @@ create_context( eglBindAPI(api_type); - // clang-format off - EGLint attrs[] = { - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 1, // Panfrost only supports 3.1 - EGL_NONE, EGL_NONE, - EGL_NONE, - }; - // clang-format on + size_t attrc = 0; + EGLint attrs[7] = {0}; + + attrs[attrc++] = EGL_CONTEXT_MAJOR_VERSION; + attrs[attrc++] = 3; + // Panfrost only supports 3.1 + attrs[attrc++] = EGL_CONTEXT_MINOR_VERSION; + attrs[attrc++] = 1; if (api_type == EGL_OPENGL_API) { - attrs[4] = EGL_CONTEXT_OPENGL_PROFILE_MASK; - attrs[5] = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT; + attrs[attrc++] = EGL_CONTEXT_OPENGL_PROFILE_MASK; + attrs[attrc++] = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT; } + attrs[attrc++] = EGL_NONE; + assert(attrc <= ARRAY_SIZE(attrs)); + EGLContext our_context = eglCreateContext(display, config, app_context, attrs); // Restore old API type. -- 2.51.2