From 37e7a5e746dbb57bc44ff9da308b7bfc529e40d6 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 29 May 2020 14:46:53 -0400 Subject: [PATCH] zink: unify code for setting resource barriers no functional changes, this code was just duplicated Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/zink/zink_context.c | 46 +++++++++++-------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 83e048216aa..c24334b569a 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -548,6 +548,24 @@ create_framebuffer(struct zink_context *ctx) return zink_create_framebuffer(screen, &state); } +static void +framebuffer_state_buffer_barriers_setup(const struct pipe_framebuffer_state *state, struct zink_batch *batch) +{ + for (int i = 0; i < state->nr_cbufs; i++) { + struct zink_resource *res = zink_resource(state->cbufs[i]->texture); + if (res->layout != VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) + zink_resource_barrier(batch->cmdbuf, res, res->aspect, + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + } + + if (state->zsbuf) { + struct zink_resource *res = zink_resource(state->zsbuf->texture); + if (res->layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) + zink_resource_barrier(batch->cmdbuf, res, res->aspect, + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); + } +} + void zink_begin_render_pass(struct zink_context *ctx, struct zink_batch *batch) { @@ -572,19 +590,7 @@ zink_begin_render_pass(struct zink_context *ctx, struct zink_batch *batch) assert(!batch->rp || batch->rp == ctx->gfx_pipeline_state.render_pass); assert(!batch->fb || batch->fb == ctx->framebuffer); - for (int i = 0; i < fb_state->nr_cbufs; i++) { - struct zink_resource *res = zink_resource(fb_state->cbufs[i]->texture); - if (res->layout != VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) - zink_resource_barrier(batch->cmdbuf, res, res->aspect, - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - } - - if (fb_state->zsbuf) { - struct zink_resource *res = zink_resource(fb_state->zsbuf->texture); - if (res->layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) - zink_resource_barrier(batch->cmdbuf, res, res->aspect, - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); - } + framebuffer_state_buffer_barriers_setup(fb_state, batch); zink_render_pass_reference(screen, &batch->rp, ctx->gfx_pipeline_state.render_pass); zink_framebuffer_reference(screen, &batch->fb, ctx->framebuffer); @@ -654,19 +660,7 @@ zink_set_framebuffer_state(struct pipe_context *pctx, struct zink_batch *batch = zink_batch_no_rp(ctx); - for (int i = 0; i < state->nr_cbufs; i++) { - struct zink_resource *res = zink_resource(state->cbufs[i]->texture); - if (res->layout != VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) - zink_resource_barrier(batch->cmdbuf, res, res->aspect, - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - } - - if (state->zsbuf) { - struct zink_resource *res = zink_resource(state->zsbuf->texture); - if (res->layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) - zink_resource_barrier(batch->cmdbuf, res, res->aspect, - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); - } + framebuffer_state_buffer_barriers_setup(state, batch); } static void -- 2.30.2