From bf09a5881b7d4fb7b11a7cc92513807ab00a7a47 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 1 Sep 2022 14:30:20 +0200 Subject: [PATCH] tu/lrz: Fix multiple subpass case with secondaries In dEQP-VK.renderpass.dedicated_allocation.attachment_allocation.input_output.94 we have the following: - There is more than one subpass, but only one depth attachment. - The first subpass doesn't use depth. - The subpass that does use depth has a draw call in a secondary. We wouldn't hit the case where there's more than one depth attachment, but because tu_begin_resumed_renderpass() only looked at the first subpass it wouldn't find the depth attachment and would leave LRZ invalid and thus a NULL LRZ fast-clear base. Then tu_begin_secondary_cmdbuf() would leave LRZ enabled and the draw would have LRZ enabled, leading to a hang. Fix this by making tu_begin_resumed_renderpass() match tu_begin_renderpass() with how it finds the depth attachment. Fixes: 4b5f0d98 ("tu: Overhaul LRZ, implement on-GPU dir tracking and LRZ fast-clear") Part-of: --- src/freedreno/vulkan/tu_lrz.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/freedreno/vulkan/tu_lrz.c b/src/freedreno/vulkan/tu_lrz.c index 215a6777bb8..a60be23ab93 100644 --- a/src/freedreno/vulkan/tu_lrz.c +++ b/src/freedreno/vulkan/tu_lrz.c @@ -271,8 +271,14 @@ tu_lrz_begin_resumed_renderpass(struct tu_cmd_buffer *cmd, { /* Track LRZ valid state */ memset(&cmd->state.lrz, 0, sizeof(cmd->state.lrz)); - uint32_t a = cmd->state.subpass->depth_stencil_attachment.attachment; - if (a != VK_ATTACHMENT_UNUSED) { + + uint32_t a; + for (a = 0; a < cmd->state.pass->attachment_count; a++) { + if (cmd->state.attachments[a]->image->lrz_height) + break; + } + + if (a != cmd->state.pass->attachment_count) { const struct tu_render_pass_attachment *att = &cmd->state.pass->attachments[a]; tu_lrz_init_state(cmd, att, cmd->state.attachments[a]); if (att->clear_mask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT)) {