radv: fix potential crash in the compute resolve path
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 4 Jul 2019 06:54:48 +0000 (08:54 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 4 Jul 2019 10:22:43 +0000 (12:22 +0200)
If the destination attachment is UNUSED.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_meta_resolve_cs.c

index 7d3cc166e0d79496dda507e62e195a48fd66b60d..13c61509b21d1502cb36d99fc4cfa3abd7990bf2 100644 (file)
@@ -917,12 +917,13 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer)
        for (uint32_t i = 0; i < subpass->color_count; ++i) {
                struct radv_subpass_attachment src_att = subpass->color_attachments[i];
                struct radv_subpass_attachment dst_att = subpass->resolve_attachments[i];
-               struct radv_image_view *src_iview = fb->attachments[src_att.attachment].attachment;
-               struct radv_image_view *dst_iview = fb->attachments[dst_att.attachment].attachment;
 
                if (dst_att.attachment == VK_ATTACHMENT_UNUSED)
                        continue;
 
+               struct radv_image_view *src_iview = fb->attachments[src_att.attachment].attachment;
+               struct radv_image_view *dst_iview = fb->attachments[dst_att.attachment].attachment;
+
                VkImageResolve region = {
                        .extent = (VkExtent3D){ fb->width, fb->height, 0 },
                        .srcSubresource = (VkImageSubresourceLayers) {