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

Chad Versace chad at chad-versace.us
Sat Mar 8 09:39:32 PST 2014


From: Chad Versace <chad at kiwitree.net>

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.

(Whoo! Waffle has an issue tracker now, and the 'Fixes' tag below will
automatically close the issue when patch hits master!)

Fixes: 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>
---

Jordan, this patch is untested because I have access to no Linux computer this
weekend.  When you validate the patch, I'll commit it.

The patch lives on my personal branch issues/1/fix-egl-compat-profile [1],
exact commit at https://github.com/chadversary/waffle/commit/ba6e561.

[1] https://github.com/chadversary/waffle/tree/issues/1/fix-egl-compat-profile

 src/waffle/egl/wegl_context.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index 50b31c6..e189ffd 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -70,6 +70,7 @@ create_real_context(struct wegl_config *config,
     int32_t waffle_context_api = attrs->context_api;
     EGLint attrib_list[64];
     EGLint context_flags = 0;
+    EGLint profile_mask = 0;
     int i = 0;
 
     if (attrs->context_debug) {
@@ -118,6 +119,27 @@ create_real_context(struct wegl_config *config,
             return EGL_NO_CONTEXT;
     }
 
+    switch (attrs->context_profile) {
+        case WAFFLE_NONE:
+            profile_mask = 0;
+            break;
+        case WAFFLE_CONTEXT_CORE_PROFILE:
+            profile_mask = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+            break;
+        case WAFFLE_CONTEXT_COMPATIBILITY_PROFILE:
+            profile_mask = 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;
+    }
+
+    if (profile_mask != 0) {
+        attrib_list[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
+        attrib_list[i++] = profile_mask;
+    }
+
     if (context_flags != 0) {
         attrib_list[i++] = EGL_CONTEXT_FLAGS_KHR;
         attrib_list[i++] = context_flags;
-- 
1.8.5.3



More information about the waffle mailing list