From c4ed0e8f3fb63d753e50576d7402c52cb30b0283 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 17 Nov 2020 13:48:46 -0500 Subject: 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 Part-of: --- src/glx/dri2_glx.c | 7 +++++++ src/glx/dri3_glx.c | 7 +++++++ src/glx/drisw_glx.c | 7 +++++++ 3 files changed, 21 insertions(+) (limited to 'src/glx') 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; } -- cgit v1.2.3