[waffle] [PATCH v2] egl: Fix creation of compatibility contexts

Chad Versace chad.versace at linux.intel.com
Wed Mar 12 13:07:13 PDT 2014


wegl_context_create() ignored wcore_config_attrs::context_profile and
never set EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR. The default value of
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR is
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR. Therefore, for context versions
>= 3.2,  wegl_context_create() always created a core context.

This patch fixes wegl_context_create() to inspect
wcore_config_attrs::context_profile and set
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR accordingly.

Issue: https://github.com/waffle-gl/waffle/issues/1
Reported-by: Jordan Justen <jordan.l.justen at intel.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 src/waffle/egl/wegl_context.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Jordan, as promised, here is a fix that is more obviously correct in
local context. After you validate, I'll merge it. The patch works for me
on x11_egl and wayland on Ivybridge.

diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index 50b31c6..9ffc4f5 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -94,6 +94,23 @@ create_real_context(struct wegl_config *config,
                 context_flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
             }
 
+            if (attrs->context_full_version >= 32)  {
+                assert(dpy->KHR_create_context);
+                switch (attrs->context_profile) {
+                    case WAFFLE_CONTEXT_CORE_PROFILE:
+                        attrib_list[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
+                        attrib_list[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+                        break;
+                    case WAFFLE_CONTEXT_COMPATIBILITY_PROFILE:
+                        attrib_list[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
+                        attrib_list[i++] = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
+                        break;
+                    default:
+                        wcore_error_internal("attrs->context_profile has bad value %#x",
+                                             attrs->context_profile);
+                        return EGL_NO_CONTEXT;
+                }
+            }
             break;
 
         case WAFFLE_CONTEXT_OPENGL_ES1:
-- 
1.8.5.3



More information about the waffle mailing list