nvk: Free the disk cache
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Sat, 14 Oct 2023 05:12:58 +0000 (00:12 -0500)
committerMarge Bot <emma+marge@anholt.net>
Mon, 16 Oct 2023 09:40:59 +0000 (09:40 +0000)
Fixes: a4f8fd9dd53d ("nvk: Hook up the disk cache")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25747>

src/nouveau/vulkan/nvk_physical_device.c

index e7f3909..a6e2ba0 100644 (file)
@@ -665,6 +665,19 @@ nvk_physical_device_init_pipeline_cache(struct nvk_physical_device *pdev)
 #endif
 }
 
+static void
+nvk_physical_device_free_disk_cache(struct nvk_physical_device *pdev)
+{
+#ifdef ENABLE_SHADER_CACHE
+   if (pdev->vk.disk_cache) {
+      disk_cache_destroy(pdev->vk.disk_cache);
+      pdev->vk.disk_cache = NULL;
+   }
+#else
+   assert(pdev->vk.disk_cache == NULL);
+#endif
+}
+
 VkResult
 nvk_create_drm_physical_device(struct vk_instance *_instance,
                                drmDevicePtr drm_device,
@@ -851,6 +864,7 @@ nvk_physical_device_destroy(struct vk_physical_device *vk_pdev)
       container_of(vk_pdev, struct nvk_physical_device, vk);
 
    nvk_finish_wsi(pdev);
+   nvk_physical_device_free_disk_cache(pdev);
    vk_physical_device_finish(&pdev->vk);
    vk_free(&pdev->vk.instance->alloc, pdev);
 }