Mesa (master): i965: Fix reference counting in new basevertex upload code.

Ian Romanick idr at kemper.freedesktop.org
Fri Sep 12 23:43:09 UTC 2014


Module: Mesa
Branch: master
Commit: e980fe607155c79ccba56ef78854093b7730bef6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e980fe607155c79ccba56ef78854093b7730bef6

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Sep 10 15:41:39 2014 -0700

i965: Fix reference counting in new basevertex upload code.

In the non-indirect draw case, we call intel_upload_data to upload
gl_BaseVertex.  It makes brw->draw.draw_params_bo point to the upload
buffer, and increments the upload BO reference count.

So, we need to unreference it when making brw->draw.draw_params_bo point
at something else, or else we'll retain a reference to stale upload
buffers and hold on to them forever.

This also means that the indirect case should increment the reference
count on the indirect draw buffer when making brw->draw.draw_params_bo
point at it.  That way, both paths increment the reference count, so
we can safely unreference it every time.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Cc: "10.3" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Tested-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/drivers/dri/i965/brw_draw.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index efa85de..b28eaf2 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -434,10 +434,13 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
       brw->draw.start_vertex_location = prims[i].start;
       brw->draw.base_vertex_location = prims[i].basevertex;
 
+      drm_intel_bo_unreference(brw->draw.draw_params_bo);
+
       if (prims[i].is_indirect) {
          /* Point draw_params_bo at the indirect buffer. */
          brw->draw.draw_params_bo =
             intel_buffer_object(ctx->DrawIndirectBuffer)->buffer;
+         drm_intel_bo_reference(brw->draw.draw_params_bo);
          brw->draw.draw_params_offset =
             prims[i].indirect_offset + (prims[i].indexed ? 12 : 8);
       } else {




More information about the mesa-commit mailing list