nvk: Use meta for CmdClear*Image
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Tue, 31 Jan 2023 02:11:53 +0000 (20:11 -0600)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:57 +0000 (21:31 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/vulkan/nvk_cmd_copy.c
src/nouveau/vulkan/nvk_cmd_meta.c

index 7652c47..f097ef1 100644 (file)
@@ -409,6 +409,7 @@ nvk_CmdCopyImage2(VkCommandBuffer commandBuffer,
    }
 }
 
+#if 0
 VKAPI_ATTR void VKAPI_CALL
 nvk_CmdClearColorImage(VkCommandBuffer commandBuffer,
                        VkImage image,
@@ -528,6 +529,7 @@ nvk_CmdClearColorImage(VkCommandBuffer commandBuffer,
       }
    }
 }
+#endif
 
 VKAPI_ATTR void VKAPI_CALL
 nvk_CmdFillBuffer(VkCommandBuffer commandBuffer,
index af5d455..a8f4aa1 100644 (file)
@@ -1,6 +1,7 @@
 #include "nvk_buffer.h"
 #include "nvk_cmd_buffer.h"
 #include "nvk_device.h"
+#include "nvk_image.h"
 
 static VkResult
 nvk_cmd_bind_map_buffer(struct vk_command_buffer *vk_cmd,
@@ -115,3 +116,53 @@ nvk_CmdClearAttachments(VkCommandBuffer commandBuffer,
 
    nvk_meta_end(cmd, &save);
 }
+
+VKAPI_ATTR void VKAPI_CALL
+nvk_CmdClearColorImage(VkCommandBuffer commandBuffer,
+                       VkImage _image,
+                       VkImageLayout imageLayout,
+                       const VkClearColorValue *pColor,
+                       uint32_t rangeCount,
+                       const VkImageSubresourceRange *pRanges)
+{
+   VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer);
+   VK_FROM_HANDLE(nvk_image, image, _image);
+   struct nvk_device *dev = nvk_cmd_buffer_device(cmd);
+
+   /* Cannot be rendering right now */
+   assert(cmd->state.gfx.render.samples == 0);
+
+   struct nvk_meta_save save;
+   nvk_meta_begin(cmd, &save);
+
+   vk_meta_clear_color_image(&cmd->vk, &dev->meta,
+                             &image->vk, imageLayout, image->vk.format,
+                             pColor, rangeCount, pRanges);
+
+   nvk_meta_end(cmd, &save);
+}
+
+VKAPI_ATTR void VKAPI_CALL
+nvk_CmdClearDepthStencilImage(VkCommandBuffer commandBuffer,
+                              VkImage _image,
+                              VkImageLayout imageLayout,
+                              const VkClearDepthStencilValue *pDepthStencil,
+                              uint32_t rangeCount,
+                              const VkImageSubresourceRange *pRanges)
+{
+   VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer);
+   VK_FROM_HANDLE(nvk_image, image, _image);
+   struct nvk_device *dev = nvk_cmd_buffer_device(cmd);
+
+   /* Cannot be rendering right now */
+   assert(cmd->state.gfx.render.samples == 0);
+
+   struct nvk_meta_save save;
+   nvk_meta_begin(cmd, &save);
+
+   vk_meta_clear_depth_stencil_image(&cmd->vk, &dev->meta,
+                                     &image->vk, imageLayout,
+                                     pDepthStencil, rangeCount, pRanges);
+
+   nvk_meta_end(cmd, &save);
+}