summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2020-11-17 13:48:46 -0500
committerMarge Bot <eric+marge@anholt.net>2020-12-01 18:40:18 +0000
commitc4ed0e8f3fb63d753e50576d7402c52cb30b0283 (patch)
tree65b51db39a468c296bd616f9a7f401cff4ea1ba9
parent731f3c113ee22729e9c98d8e049d824b2c153261 (diff)
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@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7660>
-rw-r--r--src/glx/dri2_glx.c7
-rw-r--r--src/glx/dri3_glx.c7
-rw-r--r--src/glx/drisw_glx.c7
3 files changed, 21 insertions, 0 deletions
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;
}