i965: plumb loader image cleanup callback
authorDavid Stevens <stevensd@chromium.org>
Wed, 9 Dec 2020 01:38:25 +0000 (10:38 +0900)
committerMarge Bot <eric+marge@anholt.net>
Tue, 15 Dec 2020 06:05:27 +0000 (06:05 +0000)
Signed-off-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7805>

src/mesa/drivers/dri/i965/intel_image.h
src/mesa/drivers/dri/i965/intel_screen.c

index 961b2712360520549219252963d1ce1379e36b65..c150473db4fb5d9ad863124ea9f72bfc768491a2 100644 (file)
@@ -110,7 +110,9 @@ struct __DRIimageRec {
    enum __DRIChromaSiting vertical_siting;
    /* \} */
 
-   void *data;
+   __DRIscreen *driScrnPriv;
+
+   void *loader_private;
 };
 
 #ifdef __cplusplus
index e5606f8f7d0e2a393fc24a95bd89d931b7077c00..1e34cbbca1ac2498d4d3e0d1d5398d2cd704ef8f 100644 (file)
@@ -477,7 +477,8 @@ intel_allocate_image(struct intel_screen *screen, int dri_format,
     }
 
     image->internal_format = _mesa_get_format_base_format(image->format);
-    image->data = loaderPrivate;
+    image->driScrnPriv = screen->driScrnPriv;
+    image->loader_private = loaderPrivate;
 
     return image;
 }
@@ -568,7 +569,8 @@ intel_create_image_from_renderbuffer(__DRIcontext *context,
    image->modifier = tiling_to_modifier(
                         isl_tiling_to_i915_tiling(irb->mt->surf.tiling));
    image->offset = 0;
-   image->data = loaderPrivate;
+   image->driScrnPriv = context->driScreenPriv;
+   image->loader_private = loaderPrivate;
    brw_bo_unreference(image->bo);
    image->bo = irb->mt->bo;
    brw_bo_reference(irb->mt->bo);
@@ -630,7 +632,8 @@ intel_create_image_from_texture(__DRIcontext *context, int target,
    image->format = obj->Image[face][level]->TexFormat;
    image->modifier = tiling_to_modifier(
                         isl_tiling_to_i915_tiling(iobj->mt->surf.tiling));
-   image->data = loaderPrivate;
+   image->driScrnPriv = context->driScreenPriv;
+   image->loader_private = loaderPrivate;
    intel_setup_image_from_mipmap_tree(brw, image, iobj->mt, level, zoffset);
    image->dri_format = driGLFormatToImageFormat(image->format);
    image->has_depthstencil = iobj->mt->stencil_mt? true : false;
@@ -648,6 +651,18 @@ intel_create_image_from_texture(__DRIcontext *context, int target,
 static void
 intel_destroy_image(__DRIimage *image)
 {
+   const __DRIscreen * driScreen = image->driScrnPriv;
+   const __DRIimageLoaderExtension *imgLoader = driScreen->image.loader;
+   const __DRIdri2LoaderExtension *dri2Loader = driScreen->dri2.loader;
+
+   if (imgLoader && imgLoader->base.version >= 4 &&
+         imgLoader->destroyLoaderImageState) {
+      imgLoader->destroyLoaderImageState(image->loader_private);
+   } else if (dri2Loader && dri2Loader->base.version >= 5 &&
+         dri2Loader->destroyLoaderImageState) {
+      dri2Loader->destroyLoaderImageState(image->loader_private);
+   }
+
    brw_bo_unreference(image->bo);
    free(image);
 }
@@ -1007,7 +1022,8 @@ intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
    image->tile_x          = orig_image->tile_x;
    image->tile_y          = orig_image->tile_y;
    image->has_depthstencil = orig_image->has_depthstencil;
-   image->data            = loaderPrivate;
+   image->driScrnPriv     = orig_image->driScrnPriv;
+   image->loader_private  = loaderPrivate;
    image->aux_offset      = orig_image->aux_offset;
    image->aux_pitch       = orig_image->aux_pitch;