[PATCH 7/8] glamor: add core profile support to EGL glamor.

Dave Airlie airlied at gmail.com
Mon Jan 18 16:56:55 PST 2016


From: Dave Airlie <airlied at redhat.com>

This breaks ABI unfortunately as we have to pass the core profile
info from the egl part of glamor to the glamor part of glamor.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 glamor/glamor.h                         |  2 +-
 glamor/glamor_egl.c                     | 32 ++++++++++++++++++++++++++------
 hw/xfree86/drivers/modesetting/driver.c |  8 ++++++--
 hw/xfree86/drivers/modesetting/driver.h |  2 ++
 4 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/glamor/glamor.h b/glamor/glamor.h
index 8f34409..0c64a1c 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -260,7 +260,7 @@ extern _X_EXPORT Bool glamor_back_pixmap_from_fd(PixmapPtr pixmap,
  * Should be called from DDX's preInit function.
  * Return TRUE if success, otherwise return FALSE.
  * */
-extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd);
+extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd, Bool *context_is_core);
 
 extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
 
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index ea0443d..1b2e65a 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -727,7 +727,7 @@ glamor_egl_free_screen(ScrnInfoPtr scrn)
 }
 
 Bool
-glamor_egl_init(ScrnInfoPtr scrn, int fd)
+glamor_egl_init(ScrnInfoPtr scrn, int fd, Bool *context_is_core_profile)
 {
     struct glamor_egl_screen_private *glamor_egl;
     const char *version;
@@ -738,6 +738,15 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 #endif
         EGL_NONE
     };
+    static const EGLint config_attribs_core[] = {
+        EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
+        EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
+        EGL_CONTEXT_MAJOR_VERSION_KHR,
+        3,
+        EGL_CONTEXT_MINOR_VERSION_KHR,
+        3,
+        EGL_NONE
+    };
 
     glamor_identify(0);
     glamor_egl = calloc(sizeof(*glamor_egl), 1);
@@ -798,13 +807,24 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
                                 KHR_surfaceless_opengl);
 #endif
 
+    *context_is_core_profile = FALSE;
+#ifndef GLAMOR_GLES2
     glamor_egl->context = eglCreateContext(glamor_egl->display,
                                            NULL, EGL_NO_CONTEXT,
-                                           config_attribs);
-    if (glamor_egl->context == EGL_NO_CONTEXT) {
-        xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL context\n");
-        goto error;
-    }
+                                           config_attribs_core);
+#else
+    glamor_egl->context = NULL;
+#endif
+    if (!glamor_egl->context) {
+        glamor_egl->context = eglCreateContext(glamor_egl->display,
+                                               NULL, EGL_NO_CONTEXT,
+                                               config_attribs);
+        if (glamor_egl->context == EGL_NO_CONTEXT) {
+            xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL context\n");
+            goto error;
+        }
+    } else
+        *context_is_core_profile = TRUE;
 
     if (!eglMakeCurrent(glamor_egl->display,
                         EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 8f60eae..c5d4d02 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -668,7 +668,7 @@ try_enable_glamor(ScrnInfoPtr pScrn)
     }
 
     if (xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME)) {
-        if (glamor_egl_init(pScrn, ms->fd)) {
+        if (glamor_egl_init(pScrn, ms->fd, &ms->glamor_uses_core_profile)) {
             xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n");
             ms->drmmode.glamor = TRUE;
         } else {
@@ -1173,7 +1173,11 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
 
 #ifdef GLAMOR
     if (ms->drmmode.glamor) {
-        if (!glamor_init(pScreen, GLAMOR_USE_EGL_SCREEN)) {
+        int flags = GLAMOR_USE_EGL_SCREEN;
+        if (ms->glamor_uses_core_profile)
+            flags |= GLAMOR_USE_CORE_PROFILE;
+
+        if (!glamor_init(pScreen, flags)) {
             xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                        "Failed to initialize glamor at ScreenInit() time.\n");
             return FALSE;
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index 5e1c5d9..047a765 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -118,6 +118,8 @@ typedef struct _modesettingRec {
     Bool dirty_enabled;
 
     uint32_t cursor_width, cursor_height;
+
+    Bool glamor_uses_core_profile;
 } modesettingRec, *modesettingPtr;
 
 #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
-- 
2.4.3



More information about the xorg-devel mailing list