From e8ced90aab366077b3bd82d9cde4bfc09ca9b039 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 16 Mar 2026 12:33:47 -0400 Subject: [PATCH] gallium: add a pipe_context param to pipe_surface_reference() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this shouldn't be used anymore, but for anyone still using it there needs to be a context passed Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_inlines.h | 3 ++- src/gallium/drivers/d3d12/d3d12_batch.cpp | 12 ++++-------- src/gallium/drivers/r300/r300_blit.c | 4 ++-- src/gallium/drivers/r300/r300_context.c | 2 +- src/gallium/drivers/r300/r300_state.c | 4 ++-- src/gallium/drivers/svga/svga_state_framebuffer.c | 12 ++++++------ src/gallium/drivers/svga/svga_surface.h | 5 +++-- 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index c8951626702..992fb53623e 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -140,6 +140,7 @@ typedef void (*pipe_surface_destroy_func)(struct pipe_context*, struct pipe_surf static inline void pipe_surface_reference(struct pipe_surface **dst, struct pipe_surface *src, + struct pipe_context *pipe, pipe_surface_destroy_func surface_destroy) { struct pipe_surface *old_dst = *dst; @@ -148,7 +149,7 @@ pipe_surface_reference(struct pipe_surface **dst, struct pipe_surface *src, src ? &src->reference : NULL, (debug_reference_descriptor) debug_describe_surface)) - surface_destroy(old_dst->context, old_dst); + surface_destroy(pipe, old_dst); *dst = src; } diff --git a/src/gallium/drivers/d3d12/d3d12_batch.cpp b/src/gallium/drivers/d3d12/d3d12_batch.cpp index d1d0a5d195d..4eee68c13ef 100644 --- a/src/gallium/drivers/d3d12/d3d12_batch.cpp +++ b/src/gallium/drivers/d3d12/d3d12_batch.cpp @@ -135,13 +135,6 @@ delete_sampler_view(set_entry *entry) pipe_sampler_view_reference(&pres, NULL); } -static void -delete_surface(set_entry *entry) -{ - struct pipe_surface *surf = (struct pipe_surface *)entry->key; - pipe_surface_reference(&surf, NULL, (pipe_surface_destroy_func)d3d12_surface_destroy); -} - static void delete_object(set_entry *entry) { @@ -173,7 +166,10 @@ d3d12_reset_batch(struct d3d12_context *ctx, struct d3d12_batch *batch, uint64_t } _mesa_hash_table_clear(batch->bos, delete_bo_entry); - _mesa_set_clear(batch->surfaces, delete_surface); + set_foreach_remove(batch->surfaces, entry) { + struct pipe_surface *surf = (struct pipe_surface *)entry->key; + pipe_surface_reference(&surf, NULL, &ctx->base, (pipe_surface_destroy_func)d3d12_surface_destroy); + } _mesa_set_clear(batch->objects, delete_object); util_dynarray_foreach(&batch->local_bos, d3d12_bo*, bo) { diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index e04b394eb3e..c233f3ab300 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -528,7 +528,7 @@ void r300_decompress_zmask_locked(struct r300_context *r300) r300->context.set_framebuffer_state(&r300->context, &saved_fb); util_unreference_framebuffer_state(&saved_fb); - pipe_surface_reference(&r300->locked_zbuffer, NULL, r300_surface_destroy); + pipe_surface_reference(&r300->locked_zbuffer, NULL, &r300->context, r300_surface_destroy); } bool r300_is_blit_supported(enum pipe_format format) @@ -691,7 +691,7 @@ static void r300_resource_copy_region(struct pipe_context *pipe, false, false, 0, NULL); r300_blitter_end(r300); - pipe_surface_reference(&dst_view, NULL, r300_surface_destroy); + pipe_surface_reference(&dst_view, NULL, &r300->context, r300_surface_destroy); pipe_sampler_view_reference(&src_view, NULL); } diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 4cea7108ef6..a96c6238e37 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -48,7 +48,7 @@ static void r300_release_referenced_objects(struct r300_context *r300) /* Manually-created vertex buffers. */ pipe_vertex_buffer_unreference(&r300->dummy_vb); - pipe_surface_reference(&r300->locked_zbuffer, NULL, r300_surface_destroy); + pipe_surface_reference(&r300->locked_zbuffer, NULL, &r300->context, r300_surface_destroy); radeon_bo_reference(r300->rws, &r300->vbo, NULL); r300->context.delete_depth_stencil_alpha_state(&r300->context, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index ed7e1eae479..799767e20d1 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1079,7 +1079,7 @@ r300_set_framebuffer_state(struct pipe_context* pipe, } } else { /* We don't bind another zbuffer, so lock the current one. */ - pipe_surface_reference(&r300->locked_zbuffer, r300->fb_zsbuf, r300_surface_destroy); + pipe_surface_reference(&r300->locked_zbuffer, r300->fb_zsbuf, pipe, r300_surface_destroy); } } else if (r300->locked_zbuffer) { /* We have a locked zbuffer now, what are we gonna do? */ @@ -1146,7 +1146,7 @@ r300_set_framebuffer_state(struct pipe_context* pipe, r300_set_blend_color(pipe, &((struct r300_blend_color_state*)r300->blend_color_state.state)->state); if (unlock_zbuffer) { - pipe_surface_reference(&r300->locked_zbuffer, NULL, r300_surface_destroy); + pipe_surface_reference(&r300->locked_zbuffer, NULL, pipe, r300_surface_destroy); } r300_mark_fb_state_dirty(r300, R300_CHANGED_FB_STATE); diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c index 1368a641cde..7a51d2cdbfc 100644 --- a/src/gallium/drivers/svga/svga_state_framebuffer.c +++ b/src/gallium/drivers/svga/svga_state_framebuffer.c @@ -63,7 +63,7 @@ emit_fb_vgpu9(struct svga_context *svga) return ret; svga_surface_reference(&svga->state.hw_clear.framebuffer.cbufs[i], - svga->curr.framebuffer.cbufs[i]); + svga->curr.framebuffer.cbufs[i], &svga->pipe); } /* Set the rendered-to flag */ @@ -98,7 +98,7 @@ emit_fb_vgpu9(struct svga_context *svga) } svga_surface_reference(&svga->state.hw_clear.framebuffer.zsbuf, - svga->curr.framebuffer.zsbuf); + svga->curr.framebuffer.zsbuf, &svga->pipe); /* Set the rendered-to flag */ struct svga_surface *s = currfb->zsbuf; @@ -245,12 +245,12 @@ emit_fb_vgpu10(struct svga_context *svga) /* Free the alternate surface view when it is unbound. */ pipe_surface_unref(&svga->pipe, &svga->state.hw_clear.rtv[i], svga_surface_destroy); } - svga_surface_reference(&hwfb->cbufs[i], currfb->cbufs[i]); + svga_surface_reference(&hwfb->cbufs[i], currfb->cbufs[i], &svga->pipe); } } svga->state.hw_clear.num_rendertargets = last_rtv + 1; for (unsigned i = 0; i < num_color; i++) { - pipe_surface_reference(&svga->state.hw_clear.rtv[i], rtv[i], svga_surface_destroy); + pipe_surface_reference(&svga->state.hw_clear.rtv[i], rtv[i], &svga->pipe, svga_surface_destroy); } hwfb->base.nr_cbufs = currfb->base.nr_cbufs; @@ -263,9 +263,9 @@ emit_fb_vgpu10(struct svga_context *svga) /* Free the alternate surface view when it is unbound. */ pipe_surface_unref(&svga->pipe, &svga->state.hw_clear.dsv, svga_surface_destroy); } - svga_surface_reference(&hwfb->zsbuf, currfb->zsbuf); + svga_surface_reference(&hwfb->zsbuf, currfb->zsbuf, &svga->pipe); } - pipe_surface_reference(&svga->state.hw_clear.dsv, dsv, svga_surface_destroy); + pipe_surface_reference(&svga->state.hw_clear.dsv, dsv, &svga->pipe, svga_surface_destroy); } return PIPE_OK; diff --git a/src/gallium/drivers/svga/svga_surface.h b/src/gallium/drivers/svga/svga_surface.h index 6b1455d7560..6d22ac42906 100644 --- a/src/gallium/drivers/svga/svga_surface.h +++ b/src/gallium/drivers/svga/svga_surface.h @@ -171,11 +171,12 @@ svga_resource_type(enum pipe_texture_target target) static inline void svga_surface_reference(struct svga_surface **dst, - struct svga_surface *src) + struct svga_surface *src, + struct pipe_context *pipe) { pipe_surface_reference((struct pipe_surface **) dst, (struct pipe_surface *) src, - svga_surface_destroy); + pipe, svga_surface_destroy); }