From e39bf3e6aa8ad18e2383e1c8d729fef18e312b61 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 12 Jan 2023 10:45:43 -0500 Subject: [PATCH] zink: skip implicit feedback loop layout changes if feedback loop not present if a resource is bound as both a framebuffer attachment and a sampler but isn't actually used as a sampler, it's just a framebuffer attachment, and it should retain its layout as a framebuffer attachment without any barriers Part-of: --- .../drivers/zink/ci/traces-zink-restricted.yml | 1 - src/gallium/drivers/zink/zink_draw.cpp | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/ci/traces-zink-restricted.yml b/src/gallium/drivers/zink/ci/traces-zink-restricted.yml index d2b00f8ccbb..a261b59acdd 100644 --- a/src/gallium/drivers/zink/ci/traces-zink-restricted.yml +++ b/src/gallium/drivers/zink/ci/traces-zink-restricted.yml @@ -44,7 +44,6 @@ traces: label: [skip, flakes] checksum: 826f966a52bc956644bf41562aa9c686 text: |- - 'WARNING: Incorrect rendering will happen because the Vulkan device doesn't support the 'EXT_attachment_feedback_loop_layout' feature.' This trace is flaky on freedreno too. SirYouAreBeingHunted/sir-f750-v2.trace: gl-zink-anv-tgl: diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp index 34a40f732ac..aac34675be8 100644 --- a/src/gallium/drivers/zink/zink_draw.cpp +++ b/src/gallium/drivers/zink/zink_draw.cpp @@ -280,11 +280,11 @@ draw(struct zink_context *ctx, } } -static void +static bool add_implicit_color_feedback_loop(struct zink_context *ctx, struct zink_resource *res) { if (!res->fb_bind_count || !res->sampler_bind_count[0] || ctx->feedback_loops & res->fb_binds) - return; + return false; bool is_feedback = false; /* avoid false positives when a texture is bound but not used */ u_foreach_bit(vkstage, res->gfx_barrier) { @@ -297,7 +297,7 @@ add_implicit_color_feedback_loop(struct zink_context *ctx, struct zink_resource is_feedback = true; } if (!is_feedback) - return; + return false; /* new feedback loop detected */ if (res->aspect == VK_IMAGE_ASPECT_COLOR_BIT) { if (!ctx->gfx_pipeline_state.feedback_loop) @@ -316,6 +316,7 @@ add_implicit_color_feedback_loop(struct zink_context *ctx, struct zink_resource else ctx->dynamic_fb.attachments[idx].imageLayout = VK_IMAGE_LAYOUT_GENERAL; } + return true; } static void @@ -334,10 +335,10 @@ update_barriers(struct zink_context *ctx, bool is_compute, if (res->base.b.target == PIPE_BUFFER) zink_screen(ctx->base.screen)->buffer_barrier(ctx, res, res->barrier_access[is_compute], pipeline); else { + bool is_feedback = is_compute ? false : add_implicit_color_feedback_loop(ctx, res); VkImageLayout layout = zink_descriptor_util_image_layout_eval(ctx, res, is_compute); - if (!is_compute) - add_implicit_color_feedback_loop(ctx, res); - if (layout != res->layout) + /* GENERAL is only used for feedback loops and storage image binds */ + if (is_feedback || layout != VK_IMAGE_LAYOUT_GENERAL || res->image_bind_count[is_compute]) zink_screen(ctx->base.screen)->image_barrier(ctx, res, layout, res->barrier_access[is_compute], pipeline); } if (zink_resource_access_is_write(res->barrier_access[is_compute]))