Mesa (main): glx: Fix and simplify the share context compatibility check

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 18 23:07:10 UTC 2021


Module: Mesa
Branch: main
Commit: 145992890caeb24c02bd358f7a96dc1d8b730626
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=145992890caeb24c02bd358f7a96dc1d8b730626

Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Aug  6 17:10:45 2021 -0400

glx: Fix and simplify the share context compatibility check

We only end up with one DRI provider per screen, so the only way the
context vtable can differ is if they're not the same directness. Rewrite
the test in those terms to help us unify some of this code away in the
future. Also apply the same logic to the indirect context creation path.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12456>

---

 src/glx/dri2_glx.c     | 9 +++------
 src/glx/dri3_glx.c     | 9 +++------
 src/glx/drisw_glx.c    | 9 +++------
 src/glx/indirect_glx.c | 8 ++++----
 4 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index e681042bdc5..4247cb7b32c 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -221,12 +221,9 @@ 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;
-      }
+      /* We can't share with an indirect context */
+      if (!shareList->isDirect)
+         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 db1b079663f..e73cba6028c 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -268,12 +268,9 @@ 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;
-      }
+      /* We can't share with an indirect context */
+      if (!shareList->isDirect)
+         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 122c35221ab..02fd2d5aad7 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -548,12 +548,9 @@ 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;
-      }
+      /* We can't share with an indirect context */
+      if (!shareList->isDirect)
+         return NULL;
 
       pcp_shared = (struct drisw_context *) shareList;
       shared = pcp_shared->driContext;
diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c
index db26605b8b2..4fb4ddecc0d 100644
--- a/src/glx/indirect_glx.c
+++ b/src/glx/indirect_glx.c
@@ -253,10 +253,6 @@ indirect_create_context(struct glx_screen *psc,
  * \todo Eliminate \c __glXInitVertexArrayState.  Replace it with a new
  * function called \c __glXAllocateClientState that allocates the memory and
  * does all the initialization (including the pixel pack / unpack).
- *
- * \note
- * This function is \b not the place to validate the context creation
- * parameters.  It is just the allocator for the \c glx_context.
  */
 _X_HIDDEN struct glx_context *
 indirect_create_context_attribs(struct glx_screen *psc,
@@ -302,6 +298,10 @@ indirect_create_context_attribs(struct glx_screen *psc,
       return NULL;
    }
 
+   /* We can't share with a direct context */
+   if (shareList && shareList->isDirect)
+      return NULL;
+
    /* Allocate our context record */
    gc = calloc(1, sizeof *gc);
    if (!gc) {



More information about the mesa-commit mailing list