summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2021-03-03 10:56:16 -0500
committerMarge Bot <eric+marge@anholt.net>2021-06-04 15:10:11 +0000
commit9a1c83384102c186af309bdd29f8cac569a7e809 (patch)
tree8b21afd98b5f091fa39a2f719e997c676ce32ebe
parentb786c16365b7ad4f8211b4eb1d6c069686650a44 (diff)
zink: emit fb attachment barriers inline during renderpass start
we don't need a separate function for this Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11130>
-rw-r--r--src/gallium/drivers/zink/zink_context.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index c9406e85db7..3a30737b7ee 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1505,24 +1505,6 @@ get_framebuffer(struct zink_context *ctx)
}
static void
-framebuffer_state_buffer_barriers_setup(struct zink_context *ctx,
- const struct pipe_framebuffer_state *state, struct zink_batch *batch)
-{
- for (int i = 0; i < state->nr_cbufs; i++) {
- struct pipe_surface *surf = state->cbufs[i];
- if (!surf)
- surf = ctx->framebuffer->null_surface;
- struct zink_resource *res = zink_resource(surf->texture);
- zink_resource_image_barrier(ctx, NULL, res, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, 0);
- }
-
- if (state->zsbuf) {
- struct zink_resource *res = zink_resource(state->zsbuf->texture);
- zink_resource_image_barrier(ctx, NULL, res, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, 0);
- }
-}
-
-static void
setup_framebuffer(struct zink_context *ctx)
{
struct zink_screen *screen = zink_screen(ctx->base.screen);
@@ -1611,6 +1593,12 @@ begin_render_pass(struct zink_context *ctx)
struct zink_surface *surf = zink_surface(ctx->framebuffer->surfaces[i]);
zink_batch_reference_resource_rw(batch, zink_resource(surf->base.texture), true);
zink_batch_reference_surface(batch, surf);
+
+ VkImageLayout layout = i == ctx->framebuffer->state.num_attachments - 1 && fb_state->zsbuf ?
+ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL :
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ struct zink_resource *res = zink_resource(surf->base.texture);
+ zink_resource_image_barrier(ctx, NULL, res, layout, 0, 0);
}
}
@@ -1625,7 +1613,6 @@ zink_begin_render_pass(struct zink_context *ctx, struct zink_batch *batch)
{
setup_framebuffer(ctx);
assert(ctx->gfx_pipeline_state.render_pass);
- framebuffer_state_buffer_barriers_setup(ctx, &ctx->fb_state, batch);
unsigned clear_buffers = begin_render_pass(ctx);
if (ctx->render_condition.query)