diff options
author | Bas Nieuwenhuizen <[email protected]> | 2019-06-15 18:05:05 +0200 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2019-06-17 10:56:50 +0000 |
commit | 410759091173fa61436ba46baeb20a79d5767849 (patch) | |
tree | e4e52def57c544d1497eae5b2588ef135e138033 /src/amd | |
parent | e9875fc0b648058a995cf16fc380bf8e75330fa6 (diff) |
radv: Decompress DCC when the image format is not allowed for buffers.
Otherwise the buffer loads/stores in the bufimage meta operations fail.
If we decompress DCC then we can use the "canonical" format compatible
with the not-supported format.
CC: <[email protected]>
Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/vulkan/radv_formats.c | 5 | ||||
-rw-r--r-- | src/amd/vulkan/radv_meta_copy.c | 36 | ||||
-rw-r--r-- | src/amd/vulkan/radv_private.h | 1 |
3 files changed, 40 insertions, 2 deletions
diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c index d7b560082f6..e61d793e7f2 100644 --- a/src/amd/vulkan/radv_formats.c +++ b/src/amd/vulkan/radv_formats.c @@ -547,7 +547,7 @@ static bool radv_is_storage_image_format_supported(struct radv_physical_device * } } -static bool radv_is_buffer_format_supported(VkFormat format, bool *scaled) +bool radv_is_buffer_format_supported(VkFormat format, bool *scaled) { const struct vk_format_description *desc = vk_format_description(format); unsigned data_format, num_format; @@ -559,7 +559,8 @@ static bool radv_is_buffer_format_supported(VkFormat format, bool *scaled) num_format = radv_translate_buffer_numformat(desc, vk_format_get_first_non_void_channel(format)); - *scaled = (num_format == V_008F0C_BUF_NUM_FORMAT_SSCALED) || (num_format == V_008F0C_BUF_NUM_FORMAT_USCALED); + if (scaled) + *scaled = (num_format == V_008F0C_BUF_NUM_FORMAT_SSCALED) || (num_format == V_008F0C_BUF_NUM_FORMAT_USCALED); return data_format != V_008F0C_BUF_DATA_FORMAT_INVALID && num_format != ~0; } diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c index 8081057d9df..9b92f64dc89 100644 --- a/src/amd/vulkan/radv_meta_copy.c +++ b/src/amd/vulkan/radv_meta_copy.c @@ -187,6 +187,24 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer, &pRegions[r].imageSubresource, pRegions[r].imageSubresource.aspectMask); + if (!radv_is_buffer_format_supported(img_bsurf.format, NULL)) { + uint32_t queue_mask = radv_image_queue_family_mask(image, + cmd_buffer->queue_family_index, + cmd_buffer->queue_family_index); + MAYBE_UNUSED bool compressed = radv_layout_dcc_compressed(image, layout, queue_mask); + if (compressed) { + radv_decompress_dcc(cmd_buffer, image, &(VkImageSubresourceRange) { + .aspectMask = pRegions[r].imageSubresource.aspectMask, + .baseMipLevel = pRegions[r].imageSubresource.mipLevel, + .levelCount = 1, + .baseArrayLayer = pRegions[r].imageSubresource.baseArrayLayer, + .layerCount = pRegions[r].imageSubresource.layerCount, + }); + } + img_bsurf.format = vk_format_for_size(vk_format_get_blocksize(img_bsurf.format)); + img_bsurf.current_layout = VK_IMAGE_LAYOUT_GENERAL; + } + struct radv_meta_blit2d_buffer buf_bsurf = { .bs = img_bsurf.bs, .format = img_bsurf.format, @@ -313,6 +331,24 @@ meta_copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer, &pRegions[r].imageSubresource, pRegions[r].imageSubresource.aspectMask); + if (!radv_is_buffer_format_supported(img_info.format, NULL)) { + uint32_t queue_mask = radv_image_queue_family_mask(image, + cmd_buffer->queue_family_index, + cmd_buffer->queue_family_index); + MAYBE_UNUSED bool compressed = radv_layout_dcc_compressed(image, layout, queue_mask); + if (compressed) { + radv_decompress_dcc(cmd_buffer, image, &(VkImageSubresourceRange) { + .aspectMask = pRegions[r].imageSubresource.aspectMask, + .baseMipLevel = pRegions[r].imageSubresource.mipLevel, + .levelCount = 1, + .baseArrayLayer = pRegions[r].imageSubresource.baseArrayLayer, + .layerCount = pRegions[r].imageSubresource.layerCount, + }); + } + img_info.format = vk_format_for_size(vk_format_get_blocksize(img_info.format)); + img_info.current_layout = VK_IMAGE_LAYOUT_GENERAL; + } + struct radv_meta_blit2d_buffer buf_info = { .bs = img_info.bs, .format = img_info.format, diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index d6f396f0056..37e56f04450 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -1487,6 +1487,7 @@ uint32_t radv_translate_buffer_dataformat(const struct vk_format_description *de int first_non_void); uint32_t radv_translate_buffer_numformat(const struct vk_format_description *desc, int first_non_void); +bool radv_is_buffer_format_supported(VkFormat format, bool *scaled); uint32_t radv_translate_colorformat(VkFormat format); uint32_t radv_translate_color_numformat(VkFormat format, const struct vk_format_description *desc, |