diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c index 5f5bfb341a5..1a778c7a927 100644 --- a/src/gallium/drivers/zink/zink_surface.c +++ b/src/gallium/drivers/zink/zink_surface.c @@ -364,9 +364,12 @@ zink_create_surface(struct pipe_context *pctx, csurf->needs_mutable = needs_mutable; if (needs_mutable) { - pipe_resource_reference(&csurf->base.texture, pres); + struct pipe_resource *ref = NULL; + pipe_resource_reference(&ref, pres); init_pipe_surface_info(pctx, &csurf->base, templ, pres); } + /* this may or may not be set previously depending whether templ->texture is set */ + csurf->base.texture = pres; if (templ->nr_samples && !screen->info.have_EXT_multisampled_render_to_single_sampled) { /* transient fb attachment: not cached */