diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 290a7dd9478..c84c1006ce5 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -5651,8 +5651,9 @@ add_implicit_feedback_loop(struct zink_context *ctx, struct zink_resource *res) /* can only feedback loop with fb+sampler bind; image bind must be GENERAL */ if (!res->fb_bind_count || !res->sampler_bind_count[0] || res->image_bind_count[0]) return false; - /* if zsbuf isn't used then it effectively has no fb binds */ - if (!(res->aspect & VK_IMAGE_ASPECT_COLOR_BIT) && !zink_is_zsbuf_used(ctx)) + if (!(res->aspect & VK_IMAGE_ASPECT_COLOR_BIT) && !zink_is_zsbuf_write(ctx)) + /* if zsbuf isn't used then it effectively has no fb binds */ + /* if zsbuf isn't written to then it'll be fine with read-only access */ return false; bool is_feedback = false; /* avoid false positives when a texture is bound but not used */ diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h index a9664bf2532..3fd2de55a2c 100644 --- a/src/gallium/drivers/zink/zink_context.h +++ b/src/gallium/drivers/zink/zink_context.h @@ -80,6 +80,15 @@ zink_is_zsbuf_used(const struct zink_context *ctx) return ctx->blitting || tc_renderpass_info_is_zsbuf_used(&ctx->dynamic_fb.tc_info); } +static inline bool +zink_is_zsbuf_write(const struct zink_context *ctx) +{ + if (!zink_is_zsbuf_used(ctx)) + return false; + return ctx->dynamic_fb.tc_info.zsbuf_write_fs || ctx->dynamic_fb.tc_info.zsbuf_write_dsa || + ctx->dynamic_fb.tc_info.zsbuf_clear || ctx->dynamic_fb.tc_info.zsbuf_clear_partial; +} + void zink_fence_wait(struct pipe_context *ctx); diff --git a/src/gallium/drivers/zink/zink_descriptors.c b/src/gallium/drivers/zink/zink_descriptors.c index a05bf1e7cd5..8920159b407 100644 --- a/src/gallium/drivers/zink/zink_descriptors.c +++ b/src/gallium/drivers/zink/zink_descriptors.c @@ -274,9 +274,11 @@ zink_descriptor_util_image_layout_eval(const struct zink_context *ctx, const str return VK_IMAGE_LAYOUT_GENERAL; if (!is_compute && res->fb_bind_count && res->sampler_bind_count[0]) { /* feedback loop */ - if (zink_screen(ctx->base.screen)->info.have_EXT_attachment_feedback_loop_layout) - return VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT; - return VK_IMAGE_LAYOUT_GENERAL; + if (!(res->obj->vkusage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) || zink_is_zsbuf_write(ctx)) { + if (zink_screen(ctx->base.screen)->info.have_EXT_attachment_feedback_loop_layout) + return VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT; + return VK_IMAGE_LAYOUT_GENERAL; + } } if (res->obj->vkusage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) return VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;