From 2c700bb842faf065820cc89def2f14ff3d967dd7 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 14 Feb 2023 13:09:48 -0500 Subject: [PATCH] zink: create a surface for resolve resources this can be reused since the state tracker doesn't give a surface Part-of: --- src/gallium/drivers/zink/zink_context.c | 11 +++++++++++ src/gallium/drivers/zink/zink_resource.c | 1 + src/gallium/drivers/zink/zink_types.h | 1 + 3 files changed, 13 insertions(+) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index fb6d020d247..d88f0decf13 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -3850,6 +3850,17 @@ zink_set_framebuffer_state(struct pipe_context *pctx, } else { ctx->depth_bias_scale_factor = 0; } + + if (ctx->fb_state.resolve) { + struct zink_resource *res = zink_resource(ctx->fb_state.resolve); + if (!res->surface) { + struct pipe_surface tmpl = {0}; + tmpl.format = res->base.b.format; + zink_screen_lock_context(screen); + res->surface = screen->copy_context->base.create_surface(&screen->copy_context->base, &res->base.b, &tmpl); + zink_screen_unlock_context(screen); + } + } if (depth_bias_scale_factor != ctx->depth_bias_scale_factor && ctx->rast_state && ctx->rast_state->base.offset_units_unscaled) ctx->rast_state_changed = true; diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 8fea8b13721..beaf360d347 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -244,6 +244,7 @@ zink_resource_destroy(struct pipe_screen *pscreen, assert(!_mesa_hash_table_num_entries(&res->surface_cache)); simple_mtx_destroy(&res->surface_mtx); ralloc_free(res->surface_cache.table); + pipe_surface_reference(&res->surface, NULL); } /* no need to do anything for the caches, these objects own the resource lifetimes */ diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 09f9507bf17..7cfe0476fbe 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1288,6 +1288,7 @@ struct zink_resource { enum pipe_format internal_format:16; struct zink_resource_object *obj; + struct pipe_surface *surface; //for swapchain images uint32_t queue; union { struct {