[Mesa-dev] [PATCH shaderdb 2/3] run: fallback to 3.1 core context

Rob Clark robdclark at gmail.com
Mon Jan 29 19:26:33 UTC 2018


If we can't create a 3.2 core context, fall back to a 3.1 context.
---
 run.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/run.c b/run.c
index 79d771e..2056ebd 100644
--- a/run.c
+++ b/run.c
@@ -383,9 +383,22 @@ create_context(EGLDisplay egl_dpy, EGLConfig cfg, enum shader_type type)
         EGL_NONE
     };
     switch (type) {
-    case TYPE_CORE:
+    case TYPE_CORE: {
         eglBindAPI(EGL_OPENGL_API);
-        return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
+        EGLContext core_ctx =
+                eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
+
+        if (core_ctx == EGL_NO_CONTEXT) {
+            static const EGLint attribs_31[] = {
+                EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
+                EGL_CONTEXT_MINOR_VERSION_KHR, 1,
+                EGL_NONE
+            };
+            core_ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs_31);
+        }
+
+        return core_ctx;
+    }
     case TYPE_COMPAT:
         eglBindAPI(EGL_OPENGL_API);
         return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, &attribs[6]);
-- 
2.14.3



More information about the mesa-dev mailing list