zink: break out implicit feedback loop detection into separate function

no functional changes

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20674>
This commit is contained in:
Mike Blumenkrantz 2023-01-12 10:13:56 -05:00 committed by Marge Bot
parent 6f91a5ab07
commit 9a9c17cd49

View file

@ -280,6 +280,31 @@ draw(struct zink_context *ctx,
}
}
static void
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))) {
/* new feedback loop detected */
if (res->aspect == VK_IMAGE_ASPECT_COLOR_BIT) {
if (!ctx->gfx_pipeline_state.feedback_loop)
ctx->gfx_pipeline_state.dirty = true;
ctx->gfx_pipeline_state.feedback_loop = true;
} else {
if (!ctx->gfx_pipeline_state.feedback_loop_zs)
ctx->gfx_pipeline_state.dirty = true;
ctx->gfx_pipeline_state.feedback_loop_zs = true;
}
ctx->rp_layout_changed = true;
ctx->feedback_loops |= res->fb_binds;
u_foreach_bit(idx, res->fb_binds) {
if (zink_screen(ctx->base.screen)->info.have_EXT_attachment_feedback_loop_layout)
ctx->dynamic_fb.attachments[idx].imageLayout = VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT;
else
ctx->dynamic_fb.attachments[idx].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
}
}
}
static void
update_barriers(struct zink_context *ctx, bool is_compute,
struct pipe_resource *index, struct pipe_resource *indirect, struct pipe_resource *indirect_draw_count)
@ -297,28 +322,8 @@ update_barriers(struct zink_context *ctx, bool is_compute,
zink_screen(ctx->base.screen)->buffer_barrier(ctx, res, res->barrier_access[is_compute], pipeline);
else {
VkImageLayout layout = zink_descriptor_util_image_layout_eval(ctx, res, is_compute);
if (!is_compute) {
if (res->fb_bind_count && res->sampler_bind_count[0] && (!(ctx->feedback_loops & res->fb_binds))) {
/* new feedback loop detected */
if (res->aspect == VK_IMAGE_ASPECT_COLOR_BIT) {
if (!ctx->gfx_pipeline_state.feedback_loop)
ctx->gfx_pipeline_state.dirty = true;
ctx->gfx_pipeline_state.feedback_loop = true;
} else {
if (!ctx->gfx_pipeline_state.feedback_loop_zs)
ctx->gfx_pipeline_state.dirty = true;
ctx->gfx_pipeline_state.feedback_loop_zs = true;
}
ctx->rp_layout_changed = true;
ctx->feedback_loops |= res->fb_binds;
u_foreach_bit(idx, res->fb_binds) {
if (zink_screen(ctx->base.screen)->info.have_EXT_attachment_feedback_loop_layout)
ctx->dynamic_fb.attachments[idx].imageLayout = VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT;
else
ctx->dynamic_fb.attachments[idx].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
}
}
}
if (!is_compute)
add_implicit_color_feedback_loop(ctx, res);
if (layout != res->layout)
zink_screen(ctx->base.screen)->image_barrier(ctx, res, layout, res->barrier_access[is_compute], pipeline);
}