diff options
author | Samuel Pitoiset <[email protected]> | 2018-04-11 14:09:16 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2018-04-12 09:58:44 +0200 |
commit | ab0e625a671d19bb6a736d663bbc6fa5fd9ecd06 (patch) | |
tree | 50b5dc10ab0b81bf5988f4ba63be3d292a935c31 /src/amd/vulkan/radv_meta_resolve.c | |
parent | ed93d90a67d31fc396e64d566e2ac58e2994a4e3 (diff) |
radv: add radv_decompress_resolve_{subpass}_src() helpers
This helper shares common code before resolving using either
a fragment or a compute shader.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/vulkan/radv_meta_resolve.c')
-rw-r--r-- | src/amd/vulkan/radv_meta_resolve.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c index e932976df28..1828eb37f46 100644 --- a/src/amd/vulkan/radv_meta_resolve.c +++ b/src/amd/vulkan/radv_meta_resolve.c @@ -670,3 +670,61 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer) cmd_buffer->state.subpass = subpass; radv_meta_restore(&saved_state, cmd_buffer); } + +/** + * Decompress CMask/FMask before resolving a multisampled source image inside a + * subpass. + */ +void +radv_decompress_resolve_subpass_src(struct radv_cmd_buffer *cmd_buffer) +{ + const struct radv_subpass *subpass = cmd_buffer->state.subpass; + struct radv_framebuffer *fb = cmd_buffer->state.framebuffer; + + for (uint32_t i = 0; i < subpass->color_count; ++i) { + VkAttachmentReference src_att = subpass->color_attachments[i]; + VkAttachmentReference dest_att = subpass->resolve_attachments[i]; + + if (src_att.attachment == VK_ATTACHMENT_UNUSED || + dest_att.attachment == VK_ATTACHMENT_UNUSED) + continue; + + struct radv_image_view *src_iview = + fb->attachments[src_att.attachment].attachment; + + VkImageSubresourceRange range; + range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + range.baseMipLevel = 0; + range.levelCount = 1; + range.baseArrayLayer = 0; + range.layerCount = 1; + + radv_fast_clear_flush_image_inplace(cmd_buffer, + src_iview->image, &range); + } +} + +/** + * Decompress CMask/FMask before resolving a multisampled source image. + */ +void +radv_decompress_resolve_src(struct radv_cmd_buffer *cmd_buffer, + struct radv_image *src_image, + uint32_t region_count, + const VkImageResolve *regions) +{ + for (uint32_t r = 0; r < region_count; ++r) { + const VkImageResolve *region = ®ions[r]; + const uint32_t src_base_layer = + radv_meta_get_iview_layer(src_image, ®ion->srcSubresource, + ®ion->srcOffset); + VkImageSubresourceRange range; + range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + range.baseMipLevel = region->srcSubresource.mipLevel; + range.levelCount = 1; + range.baseArrayLayer = src_base_layer; + range.layerCount = region->srcSubresource.layerCount; + + radv_fast_clear_flush_image_inplace(cmd_buffer, src_image, &range); + } +} |