radv: determine the first subpass id for every attachments
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 30 May 2019 12:10:42 +0000 (14:10 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 7 Jun 2019 11:11:08 +0000 (13:11 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-By: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_pass.c
src/amd/vulkan/radv_private.h

index 4d1e38a780e89e3092665e0e9b8c433a50bd206a..8fa098eaac8898b9381a340e193d5a36f5945bdf 100644 (file)
@@ -62,6 +62,22 @@ radv_render_pass_add_subpass_dep(struct radv_render_pass *pass,
 static void
 radv_render_pass_compile(struct radv_render_pass *pass)
 {
+       for (uint32_t i = 0; i < pass->subpass_count; i++) {
+               struct radv_subpass *subpass = &pass->subpasses[i];
+
+               for (uint32_t j = 0; j < subpass->attachment_count; j++) {
+                       struct radv_subpass_attachment *subpass_att =
+                               &subpass->attachments[j];
+                       if (subpass_att->attachment == VK_ATTACHMENT_UNUSED)
+                               continue;
+
+                       struct radv_render_pass_attachment *pass_att =
+                               &pass->attachments[subpass_att->attachment];
+
+                       pass_att->first_subpass_idx = UINT32_MAX;
+               }
+       }
+
        for (uint32_t i = 0; i < pass->subpass_count; i++) {
                struct radv_subpass *subpass = &pass->subpasses[i];
                uint32_t color_sample_count = 1, depth_sample_count = 1;
@@ -84,6 +100,8 @@ radv_render_pass_compile(struct radv_render_pass *pass)
                        struct radv_render_pass_attachment *pass_att =
                                &pass->attachments[subpass_att->attachment];
 
+                       if (i < pass_att->first_subpass_idx)
+                               pass_att->first_subpass_idx = i;
                        pass_att->last_subpass_idx = i;
                }
 
index 9af8fb3b6db21129e1b965a98a2710bf5d6acc7b..b8f84c84913e4ab680a594be0cbc8188cf4682d8 100644 (file)
@@ -1921,7 +1921,8 @@ struct radv_render_pass_attachment {
        VkImageLayout                                initial_layout;
        VkImageLayout                                final_layout;
 
-       /* The subpass id in which the attachment will be used last. */
+       /* The subpass id in which the attachment will be used first/last. */
+       uint32_t                                     first_subpass_idx;
        uint32_t                                     last_subpass_idx;
 };