diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index c0fc405048d..22c445ccf33 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -4010,19 +4010,8 @@ zink_set_framebuffer_state(struct pipe_context *pctx, zink_resource(psurf->texture)->fb_binds |= BITFIELD_BIT(PIPE_MAX_COLOR_BUFS); } - 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); - /* delete extra ref: the resource controls the surface lifetime, not the other way around */ - struct pipe_resource *pres = ctx->fb_state.resolve; - pipe_resource_reference(&pres, NULL); - } - } + if (ctx->fb_state.resolve) + zink_surface_resolve_init(screen, zink_resource(ctx->fb_state.resolve)); rebind_fb_state(ctx, NULL, true); ctx->fb_state.samples = MAX2(samples, 1); if (ctx->fb_state.width != w || ctx->fb_state.height != h) diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c index c20d1d92c50..33019976116 100644 --- a/src/gallium/drivers/zink/zink_surface.c +++ b/src/gallium/drivers/zink/zink_surface.c @@ -477,3 +477,18 @@ zink_surface_swapchain_update(struct zink_context *ctx, struct zink_surface *sur /* the current swapchain imageview is now the view for the current swapchain image */ surface->image_view = surface->swapchain[res->obj->dt_idx]; } + +void +zink_surface_resolve_init(struct zink_screen *screen, struct zink_resource *res) +{ + if (res->surface) + return; + 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); + /* delete extra ref: the resource controls the surface lifetime, not the other way around */ + struct pipe_resource *pres = &res->base.b; + pipe_resource_reference(&pres, NULL); +} diff --git a/src/gallium/drivers/zink/zink_surface.h b/src/gallium/drivers/zink/zink_surface.h index cfbcc222645..eaff8234807 100644 --- a/src/gallium/drivers/zink/zink_surface.h +++ b/src/gallium/drivers/zink/zink_surface.h @@ -82,4 +82,7 @@ zink_surface_create_null(struct zink_context *ctx, enum pipe_texture_target targ void zink_surface_swapchain_update(struct zink_context *ctx, struct zink_surface *surface); +void +zink_surface_resolve_init(struct zink_screen *screen, struct zink_resource *res); + #endif