panvk: Only prepare texture descriptors when the image is sampled
authorBoris Brezillon <boris.brezillon@collabora.com>
Thu, 23 Sep 2021 14:17:32 +0000 (16:17 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 28 Sep 2021 14:03:40 +0000 (14:03 +0000)
Not that input attachments will be lowered to textures, so we need to
create a texture descriptor in that case too.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13077>

src/panfrost/vulkan/panvk_private.h
src/panfrost/vulkan/panvk_vX_descriptor_set.c
src/panfrost/vulkan/panvk_vX_image.c

index 2c4d0fa..7286649 100644 (file)
@@ -933,7 +933,9 @@ struct panvk_image_view {
 
    VkFormat vk_format;
    struct panfrost_bo *bo;
-   uint32_t desc[TEXTURE_DESC_WORDS];
+   struct {
+      uint32_t tex[TEXTURE_DESC_WORDS];
+   } descs;
 };
 
 #define SAMPLER_DESC_WORDS 8
index 18e1b99..4a68e72 100644 (file)
@@ -203,7 +203,7 @@ panvk_per_arch(set_texture_desc)(struct panvk_descriptor_set *set,
 
 #if PAN_ARCH > 5
    memcpy(&((struct mali_bifrost_texture_packed *)set->textures)[idx],
-          view->desc, pan_size(TEXTURE));
+          view->descs.tex, pan_size(TEXTURE));
 #else
    ((mali_ptr *)set->textures)[idx] = view->bo->ptr.gpu;
 #endif
index 232fe27..ae5efec 100644 (file)
@@ -126,23 +126,27 @@ panvk_per_arch(CreateImageView)(VkDevice _device,
    view->vk_format = pCreateInfo->format;
 
    struct panfrost_device *pdev = &device->physical_device->pdev;
-   unsigned bo_size =
-      GENX(panfrost_estimate_texture_payload_size)(&view->pview) +
-      pan_size(TEXTURE);
 
-   unsigned surf_descs_offset = PAN_ARCH <= 5 ? pan_size(TEXTURE) : 0;
+   if (image->usage &
+       (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)) {
+      unsigned bo_size =
+         GENX(panfrost_estimate_texture_payload_size)(&view->pview) +
+         pan_size(TEXTURE);
 
-   view->bo = panfrost_bo_create(pdev, bo_size, 0, "Texture descriptor");
+      unsigned surf_descs_offset = PAN_ARCH <= 5 ? pan_size(TEXTURE) : 0;
 
-   struct panfrost_ptr surf_descs = {
-      .cpu = view->bo->ptr.cpu + surf_descs_offset,
-      .gpu = view->bo->ptr.gpu + surf_descs_offset,
-   };
-   void *tex_desc = PAN_ARCH >= 6 ?
-                    &view->desc : view->bo->ptr.cpu;
+      view->bo = panfrost_bo_create(pdev, bo_size, 0, "Texture descriptor");
 
-   STATIC_ASSERT(sizeof(view->desc) >= pan_size(TEXTURE));
-   GENX(panfrost_new_texture)(pdev, &view->pview, tex_desc, &surf_descs);
+      struct panfrost_ptr surf_descs = {
+         .cpu = view->bo->ptr.cpu + surf_descs_offset,
+         .gpu = view->bo->ptr.gpu + surf_descs_offset,
+      };
+      void *tex_desc = PAN_ARCH >= 6 ?
+                       &view->descs.tex : view->bo->ptr.cpu;
+
+      STATIC_ASSERT(sizeof(view->descs.tex) >= pan_size(TEXTURE));
+      GENX(panfrost_new_texture)(pdev, &view->pview, tex_desc, &surf_descs);
+   }
 
    *pView = panvk_image_view_to_handle(view);
    return VK_SUCCESS;