nvk: Require dedicated allocations for external images
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Mon, 17 Jul 2023 21:54:28 +0000 (16:54 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:32:06 +0000 (21:32 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/vulkan/nvk_image.c

index 8cfa435..3f1c8f0 100644 (file)
@@ -512,6 +512,11 @@ nvk_GetImageMemoryRequirements2(VkDevice device,
          nvk_image_plane_add_req(&image->planes[plane], &size_B, &align_B);
    }
 
+   assert(image->vk.external_handle_types == 0 || image->plane_count == 1);
+   bool needs_dedicated =
+      image->vk.external_handle_types != 0 &&
+      image->planes[0].nil.pte_kind != 0;
+
    if (image->stencil_copy_temp.nil.size_B > 0)
       nvk_image_plane_add_req(&image->stencil_copy_temp, &size_B, &align_B);
 
@@ -523,8 +528,8 @@ nvk_GetImageMemoryRequirements2(VkDevice device,
       switch (ext->sType) {
       case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS: {
          VkMemoryDedicatedRequirements *dedicated = (void *)ext;
-         dedicated->prefersDedicatedAllocation = false;
-         dedicated->requiresDedicatedAllocation = false;
+         dedicated->prefersDedicatedAllocation = needs_dedicated;
+         dedicated->requiresDedicatedAllocation = needs_dedicated;
          break;
       }
       default: