zink: further eliminate zs implicit feedback loops for read-only access

if all access is read-only then there is no feedback loop

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21988>
This commit is contained in:
Mike Blumenkrantz 2023-03-17 12:22:26 -04:00 committed by Marge Bot
parent a702e5038c
commit 23cd81686c
3 changed files with 17 additions and 5 deletions

View file

@ -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 */

View file

@ -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);

View file

@ -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;