From ce118a7002bf41def94a5a8ed47f80be83e4d3ed Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 26 May 2022 09:22:40 -0700 Subject: [PATCH] turnip: estimate render pass costs They will be used by autotuner. Part-of: --- src/freedreno/vulkan/tu_pass.c | 22 ++++++++++++++++++++++ src/freedreno/vulkan/tu_private.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/src/freedreno/vulkan/tu_pass.c b/src/freedreno/vulkan/tu_pass.c index c90498436e0..278283249f1 100644 --- a/src/freedreno/vulkan/tu_pass.c +++ b/src/freedreno/vulkan/tu_pass.c @@ -885,6 +885,28 @@ tu_CreateRenderPass2(VkDevice _device, tu_render_pass_gmem_config(pass, device->physical_device); } + for (uint32_t i = 0; i < pass->attachment_count; i++) { + const struct tu_render_pass_attachment *att = &pass->attachments[i]; + + /* approximate tu_load_gmem_attachment */ + if (att->load) + pass->gmem_bandwidth_per_pixel += att->cpp; + + /* approximate tu_store_gmem_attachment */ + if (att->store) + pass->gmem_bandwidth_per_pixel += att->cpp; + + /* approximate tu_clear_sysmem_attachment */ + if (att->clear_mask) + pass->sysmem_bandwidth_per_pixel += att->cpp; + + /* approximate tu6_emit_sysmem_resolves */ + if (att->will_be_resolved) { + pass->sysmem_bandwidth_per_pixel += + att->cpp + att->cpp / att->samples; + } + } + for (unsigned i = 0; i < pCreateInfo->dependencyCount; ++i) { tu_render_pass_add_subpass_dep(pass, &pCreateInfo->pDependencies[i]); } diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index a9fce74ff24..2992d40aeba 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1912,6 +1912,11 @@ struct tu_render_pass uint32_t subpass_count; uint32_t gmem_pixels; uint32_t tile_align_w; + + /* memory bandwidth costs (in bytes) for gmem / sysmem rendering */ + uint32_t gmem_bandwidth_per_pixel; + uint32_t sysmem_bandwidth_per_pixel; + struct tu_subpass_attachment *subpass_attachments; struct tu_render_pass_attachment *attachments; struct tu_subpass_barrier end_barrier;