From d7814d6e0cc8ad10b4568e34d06afad95993e936 Mon Sep 17 00:00:00 2001 From: David Stevens Date: Thu, 26 Nov 2020 13:15:55 +0900 Subject: [PATCH] frontend/dri: plumb loader image cleanup callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Stevens Reviewed-by: Tapani Pälli Part-of: --- src/gallium/frontends/dri/dri2.c | 3 +++ src/gallium/frontends/dri/dri_helpers.c | 13 +++++++++++++ src/gallium/frontends/dri/dri_screen.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c index 76a27ff76af..e65fe169daf 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c @@ -849,6 +849,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen, img->layer = 0; img->use = 0; img->loader_private = loaderPrivate; + img->sPriv = _screen; return img; } @@ -1057,6 +1058,7 @@ dri2_create_image_common(__DRIscreen *_screen, img->use = use; img->loader_private = loaderPrivate; + img->sPriv = _screen; return img; } @@ -1309,6 +1311,7 @@ dri2_dup_image(__DRIimage *image, void *loaderPrivate) /* This should be 0 for sub images, but dup is also used for base images. */ img->dri_components = image->dri_components; img->loader_private = loaderPrivate; + img->sPriv = image->sPriv; return img; } diff --git a/src/gallium/frontends/dri/dri_helpers.c b/src/gallium/frontends/dri/dri_helpers.c index 87162736147..aea24208472 100644 --- a/src/gallium/frontends/dri/dri_helpers.c +++ b/src/gallium/frontends/dri/dri_helpers.c @@ -296,6 +296,7 @@ dri2_create_image_from_renderbuffer2(__DRIcontext *context, img->dri_format = driGLFormatToImageFormat(rb->Format); img->loader_private = loaderPrivate; + img->sPriv = context->driScreenPriv; pipe_resource_reference(&img->texture, tex); @@ -315,6 +316,17 @@ dri2_create_image_from_renderbuffer(__DRIcontext *context, void dri2_destroy_image(__DRIimage *img) { + const __DRIimageLoaderExtension *imgLoader = img->sPriv->image.loader; + const __DRIdri2LoaderExtension *dri2Loader = img->sPriv->dri2.loader; + + if (imgLoader && imgLoader->base.version >= 4 && + imgLoader->destroyLoaderImageState) { + imgLoader->destroyLoaderImageState(img->loader_private); + } else if (dri2Loader && dri2Loader->base.version >= 5 && + dri2Loader->destroyLoaderImageState) { + dri2Loader->destroyLoaderImageState(img->loader_private); + } + pipe_resource_reference(&img->texture, NULL); FREE(img); } @@ -373,6 +385,7 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture, img->dri_format = driGLFormatToImageFormat(obj->Image[face][level]->TexFormat); img->loader_private = loaderPrivate; + img->sPriv = context->driScreenPriv; pipe_resource_reference(&img->texture, tex); diff --git a/src/gallium/frontends/dri/dri_screen.h b/src/gallium/frontends/dri/dri_screen.h index e330aa1f2ac..f80a7f22aa0 100644 --- a/src/gallium/frontends/dri/dri_screen.h +++ b/src/gallium/frontends/dri/dri_screen.h @@ -118,6 +118,8 @@ struct __DRIimageRec { enum __DRIChromaSiting horizontal_siting; enum __DRIChromaSiting vertical_siting; + /* DRI loader screen */ + __DRIscreen *sPriv; }; static inline boolean