tu: Precompute maximum views across all subpasses
authorConnor Abbott <cwabbott0@gmail.com>
Thu, 17 Nov 2022 12:24:30 +0000 (13:24 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 8 May 2023 19:59:25 +0000 (19:59 +0000)
We'll need this to know how many viewports to create.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20304>

src/freedreno/vulkan/tu_pass.cc
src/freedreno/vulkan/tu_pass.h
src/freedreno/vulkan/tu_util.cc

index 3335f33..d3ef312 100644 (file)
@@ -514,6 +514,15 @@ static void update_samples(struct tu_subpass *subpass,
 }
 
 static void
+tu_render_pass_calc_views(struct tu_render_pass *pass)
+{
+   uint32_t view_mask = 0;
+   for (unsigned i = 0; i < pass->subpass_count; i++)
+      view_mask |= pass->subpasses[i].multiview_mask;
+   pass->num_views = util_last_bit(view_mask);
+}
+
+static void
 tu_render_pass_calc_hash(struct tu_render_pass *pass)
 {
    #define HASH(hash, data) XXH64(&(data), sizeof(data), hash)
@@ -952,6 +961,7 @@ tu_CreateRenderPass2(VkDevice _device,
    tu_render_pass_cond_config(pass);
    tu_render_pass_gmem_config(pass, device->physical_device);
    tu_render_pass_bandwidth_config(pass);
+   tu_render_pass_calc_views(pass);
    tu_render_pass_calc_hash(pass);
 
    for (unsigned i = 0; i < pCreateInfo->dependencyCount; ++i) {
@@ -1126,6 +1136,7 @@ tu_setup_dynamic_render_pass(struct tu_cmd_buffer *cmd_buffer,
    tu_render_pass_cond_config(pass);
    tu_render_pass_gmem_config(pass, device->physical_device);
    tu_render_pass_bandwidth_config(pass);
+   tu_render_pass_calc_views(pass);
    tu_render_pass_calc_hash(pass);
 }
 
@@ -1185,6 +1196,8 @@ tu_setup_dynamic_inheritance(struct tu_cmd_buffer *cmd_buffer,
    } else {
       subpass->depth_stencil_attachment.attachment = VK_ATTACHMENT_UNUSED;
    }
+
+   tu_render_pass_calc_views(pass);
 }
 
 VKAPI_ATTR void VKAPI_CALL
index dfdd012..bbe12bf 100644 (file)
@@ -107,6 +107,8 @@ struct tu_render_pass
    uint32_t gmem_bandwidth_per_pixel;
    uint32_t sysmem_bandwidth_per_pixel;
 
+   unsigned num_views;
+
    struct tu_subpass_attachment *subpass_attachments;
 
    struct tu_render_pass_attachment *attachments;
index f7c2435..5688273 100644 (file)
@@ -122,13 +122,7 @@ tu_tiling_config_update_tile_layout(struct tu_framebuffer *fb,
     *   used.
     */
 
-   uint32_t layers = fb->layers;
-   if (pass->subpasses[0].multiview_mask) {
-      uint32_t view_mask = 0;
-      for (unsigned i = 0; i < pass->subpass_count; i++)
-         view_mask |= pass->subpasses[i].multiview_mask;
-      layers = util_logbase2(view_mask) + 1;
-   }
+   uint32_t layers = MAX2(fb->layers, pass->num_views);
 
    /* If there is more than one layer, we need to make sure that the layer
     * stride is expressible as an offset in RB_BLIT_BASE_GMEM which ignores