From de1e67b39d7fe78af7b7a0f36b99efb1eef2d9a8 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 3 Jun 2022 13:57:30 -0400 Subject: [PATCH] zink: hook up surface invalidation to LOAD_OP_DONT_CARE this should improve perf for tilers Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_context.c | 9 ++++++--- src/gallium/drivers/zink/zink_render_pass.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 94f04d71d73..a05a6b09c73 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -2034,7 +2034,7 @@ begin_rendering(struct zink_context *ctx) /* dead swapchain */ return 0; ctx->dynamic_fb.attachments[i].imageView = iv; - if (!surf || (surf->is_swapchain && ctx->new_swapchain)) + if (!surf || !zink_resource(surf->base.texture)->valid || (surf->is_swapchain && ctx->new_swapchain)) ctx->dynamic_fb.attachments[i].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; else ctx->dynamic_fb.attachments[i].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; @@ -2056,12 +2056,15 @@ begin_rendering(struct zink_context *ctx) /* depth may or may not be used but init it anyway */ ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].imageView = iv; ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].imageLayout = zink_resource(surf->base.texture)->layout; - ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + if (zink_resource(surf->base.texture)->valid) + ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + else + ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; /* stencil may or may not be used but init it anyway */ ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].imageView = iv; ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].imageLayout = zink_resource(surf->base.texture)->layout; - ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].loadOp = ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].loadOp; if (has_depth) { ctx->dynamic_fb.info.pDepthAttachment = &ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS]; diff --git a/src/gallium/drivers/zink/zink_render_pass.c b/src/gallium/drivers/zink/zink_render_pass.c index 1acbb8c4ee1..4b15bbca7c1 100644 --- a/src/gallium/drivers/zink/zink_render_pass.c +++ b/src/gallium/drivers/zink/zink_render_pass.c @@ -353,7 +353,7 @@ zink_init_color_attachment(struct zink_context *ctx, unsigned i, struct zink_rt_ rt->format = surf->info.format[0]; rt->samples = MAX3(transient ? transient->base.nr_samples : 0, psurf->texture->nr_samples, 1); rt->clear_color = zink_fb_clear_enabled(ctx, i) && !zink_fb_clear_first_needs_explicit(&ctx->fb_clears[i]); - rt->invalid = ctx->new_swapchain && (psurf->texture->bind & PIPE_BIND_DISPLAY_TARGET); + rt->invalid = !zink_resource(psurf->texture)->valid || (ctx->new_swapchain && (psurf->texture->bind & PIPE_BIND_DISPLAY_TARGET)); rt->fbfetch = (ctx->fbfetch_outputs & BITFIELD_BIT(i)) > 0; } else { memset(rt, 0, sizeof(struct zink_rt_attrib));