From 6c4883bc9dec7310d8ee717541c72e1b8a38d4bb Mon Sep 17 00:00:00 2001 From: Luigi Santivetti Date: Thu, 11 Sep 2025 11:03:34 +0100 Subject: [PATCH] pvr: restrict the scope of copy_{buffer,image}_to_{image,buffer} Do not conflate api and internal driver use of copy commands and make the correct assumptions for the api path, according to the Vulkan spec. Signed-off-by: Luigi Santivetti Acked-by: Erik Faye-Lund Part-of: --- src/imagination/vulkan/pvr_blit.c | 19 ++++++++++++++----- src/imagination/vulkan/pvr_blit.h | 10 ---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/imagination/vulkan/pvr_blit.c b/src/imagination/vulkan/pvr_blit.c index 2ffd4450376..b05ef1c179f 100644 --- a/src/imagination/vulkan/pvr_blit.c +++ b/src/imagination/vulkan/pvr_blit.c @@ -853,7 +853,7 @@ pvr_copy_buffer_to_image_region_format(struct pvr_cmd_buffer *const cmd_buffer, return VK_SUCCESS; } -VkResult +static VkResult pvr_copy_buffer_to_image_region(struct pvr_cmd_buffer *const cmd_buffer, const pvr_dev_addr_t buffer_dev_addr, const struct pvr_image *const image, @@ -864,6 +864,12 @@ pvr_copy_buffer_to_image_region(struct pvr_cmd_buffer *const cmd_buffer, VkFormat dst_format; uint32_t flags = 0; + /* From the Vulkan spec: + * + * dstImage must have a sample count equal to VK_SAMPLE_COUNT_1_BIT + */ + assert(image->vk.samples == VK_SAMPLE_COUNT_1_BIT); + if (vk_format_has_depth(image->vk.format) && vk_format_has_stencil(image->vk.format)) { flags |= PVR_TRANSFER_CMD_FLAGS_DSMERGE; @@ -930,9 +936,6 @@ pvr_copy_image_to_buffer_region_format(struct pvr_cmd_buffer *const cmd_buffer, uint32_t max_depth_slice; VkSubresourceLayout info; - /* Only images with VK_SAMPLE_COUNT_1_BIT can be copied to buffer. */ - assert(image->vk.samples == 1); - if (region->bufferRowLength == 0) buffer_row_length = region->imageExtent.width; else @@ -1042,7 +1045,7 @@ pvr_copy_image_to_buffer_region_format(struct pvr_cmd_buffer *const cmd_buffer, return VK_SUCCESS; } -VkResult +static VkResult pvr_copy_image_to_buffer_region(struct pvr_cmd_buffer *const cmd_buffer, const struct pvr_image *const image, const pvr_dev_addr_t buffer_dev_addr, @@ -1053,6 +1056,12 @@ pvr_copy_image_to_buffer_region(struct pvr_cmd_buffer *const cmd_buffer, VkFormat src_format = pvr_get_copy_format(image->vk.format); VkFormat dst_format; + /* From the Vulkan spec: + * + * srcImage must have a sample count equal to VK_SAMPLE_COUNT_1_BIT + */ + assert(image->vk.samples == VK_SAMPLE_COUNT_1_BIT); + /* Color and depth aspect copies can nearly all be done using an appropriate * raw format. */ diff --git a/src/imagination/vulkan/pvr_blit.h b/src/imagination/vulkan/pvr_blit.h index dece3462a1e..7235a45eec9 100644 --- a/src/imagination/vulkan/pvr_blit.h +++ b/src/imagination/vulkan/pvr_blit.h @@ -43,11 +43,6 @@ pvr_copy_or_resolve_color_image_region(struct pvr_cmd_buffer *cmd_buffer, const struct pvr_image *dst, const VkImageCopy2 *region); -VkResult pvr_copy_buffer_to_image_region(struct pvr_cmd_buffer *cmd_buffer, - pvr_dev_addr_t buffer_dev_addr, - const struct pvr_image *image, - const VkBufferImageCopy2 *region); - VkResult pvr_copy_buffer_to_image_region_format(struct pvr_cmd_buffer *cmd_buffer, pvr_dev_addr_t buffer_dev_addr, @@ -57,11 +52,6 @@ pvr_copy_buffer_to_image_region_format(struct pvr_cmd_buffer *cmd_buffer, VkFormat dst_format, uint32_t flags); -VkResult pvr_copy_image_to_buffer_region(struct pvr_cmd_buffer *cmd_buffer, - const struct pvr_image *image, - pvr_dev_addr_t buffer_dev_addr, - const VkBufferImageCopy2 *region); - VkResult pvr_copy_image_to_buffer_region_format(struct pvr_cmd_buffer *cmd_buffer, const struct pvr_image *image,