[PATCH] glamor: add fallback if NULL EGLConfig is not supported

Jammy Zhou Jammy.Zhou at amd.com
Wed Mar 4 01:29:17 PST 2015


Signed-off-by: Kai Guo <Kai.Guo at amd.com>
Signed-off-by: Jammy Zhou <Jammy.Zhou at amd.com>
---
 glamor/glamor_egl.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 113450c..b230e39 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -800,8 +800,32 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
                                            NULL, EGL_NO_CONTEXT,
                                            config_attribs);
     if (glamor_egl->context == EGL_NO_CONTEXT) {
-        xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL context\n");
-        return FALSE;
+	/* fallback to select a EGLConfig explicitly */
+        EGLint attr[] = {
+            EGL_RENDERABLE_TYPE,
+#ifdef GLAMOR_GLES2
+            EGL_OPENGL_ES2_BIT,
+#else
+            EGL_OPENGL_BIT,
+#endif
+            EGL_NONE
+        };
+
+        EGLConfig config;
+        EGLint n;
+        if (!eglChooseConfig(glamor_egl->display, attr, &config, 1, &n)
+            || (n != 1)) {
+            xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to choose EGL config\n");
+            return FALSE;
+        }
+
+        glamor_egl->context = eglCreateContext(glamor_egl->display,
+                                               config, EGL_NO_CONTEXT,
+                                               config_attribs);
+        if (glamor_egl->context == EGL_NO_CONTEXT) {
+            xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL context\n");
+            return FALSE;
+        }
     }
 
     if (!eglMakeCurrent(glamor_egl->display,
-- 
1.9.1



More information about the xorg-devel mailing list