Module: Mesa
Branch: main
Commit: 23c003b88c54e00436b4e2684e6227e79538cf5a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=23c003b88c54e00436b4e2684e6227e79538cf5a

Author: Patrick Lerda <[email protected]>
Date:   Tue Jun 13 15:23:53 2023 +0200

util/blitter: fix util_blitter_clear_buffer() refcnt imbalance

Indeed, the vertex state was restored using a specific
condition at the util_blitter_restore_vertex_states()
level. This change ensures that the condition is the
same when the vertex state is saved.

The function util_blitter_clear_buffer() is only called
by the r600 driver on pre-evergreen gpus.

This issue is triggered on a rv770 gpu with "piglit/bin/fbo-1d -auto -fbo"
or "piglit/bin/draw_buffers_gles2 -auto -fbo"
while setting GALLIUM_REFCNT_LOG=refcnt.log.

Fixes: 5f566faa4607 ("radeonsi: don't save and restore vertex buffers and 
elements for u_blitter")
Signed-off-by: Patrick Lerda <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23721>

---

 src/gallium/auxiliary/util/u_blitter.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index 458834f0e1e..ec71bf78b48 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -2633,7 +2633,10 @@ void util_blitter_clear_buffer(struct blitter_context 
*blitter,
    blitter_check_saved_vertex_states(ctx);
    blitter_disable_render_cond(ctx);
 
-   pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0, false, &vb);
+   if (ctx->base.saved_vertex_buffer.buffer.resource) {
+      pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0, false, &vb);
+   }
+
    pipe->bind_vertex_elements_state(pipe,
                                     ctx->velem_state_readbuf[num_channels-1]);
    bind_vs_pos_only(ctx, num_channels);

Reply via email to