Mesa (master): glx: Check share ctx compatibility in ::create_context_attribs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 1 19:05:17 UTC 2020


Module: Mesa
Branch: master
Commit: c4ed0e8f3fb63d753e50576d7402c52cb30b0283
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c4ed0e8f3fb63d753e50576d7402c52cb30b0283

Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Nov 17 13:48:46 2020 -0500

glx: Check share ctx compatibility in ::create_context_attribs

Most of the legacy CreateContext paths already did this, this is just
aligning the two so we can implement one in terms of the other.

Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7660>

---

 src/glx/dri2_glx.c  | 7 +++++++
 src/glx/dri3_glx.c  | 7 +++++++
 src/glx/drisw_glx.c | 7 +++++++
 3 files changed, 21 insertions(+)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 724a17443db..efb6f1f1275 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -272,6 +272,13 @@ dri2_create_context_attribs(struct glx_screen *base,
        goto error_exit;
 
    if (shareList) {
+      /* If the shareList context is not a DRI2 context, we cannot possibly
+       * create a DRI2 context that shares it.
+       */
+      if (shareList->vtable->destroy != dri2_destroy_context) {
+	 return NULL;
+      }
+
       pcp_shared = (struct dri2_context *) shareList;
       shared = pcp_shared->driContext;
    }
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index c2685cc693d..47a8e9a5686 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -268,6 +268,13 @@ dri3_create_context_attribs(struct glx_screen *base,
        goto error_exit;
 
    if (shareList) {
+      /* If the shareList context is not a DRI3 context, we cannot possibly
+       * create a DRI3 context that shares it.
+       */
+      if (shareList->vtable->destroy != dri3_destroy_context) {
+	 return NULL;
+      }
+
       pcp_shared = (struct dri3_context *) shareList;
       shared = pcp_shared->driContext;
    }
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index afa335eee81..b45dd784524 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -587,6 +587,13 @@ drisw_create_context_attribs(struct glx_screen *base,
       return NULL;
 
    if (shareList) {
+      /* If the shareList context is not a DRISW context, we cannot possibly
+       * create a DRISW context that shares it.
+       */
+      if (shareList->vtable->destroy != drisw_destroy_context) {
+	 return NULL;
+      }
+
       pcp_shared = (struct drisw_context *) shareList;
       shared = pcp_shared->driContext;
    }



More information about the mesa-commit mailing list