From 9a9c17cd492c98ba3862ca47a20268209ca9026a Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 12 Jan 2023 10:13:56 -0500 Subject: [PATCH] zink: break out implicit feedback loop detection into separate function no functional changes Part-of: --- src/gallium/drivers/zink/zink_draw.cpp | 49 ++++++++++++++------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp index 7d5eac10e99..73e1a702610 100644 --- a/src/gallium/drivers/zink/zink_draw.cpp +++ b/src/gallium/drivers/zink/zink_draw.cpp @@ -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); }