Mesa (staging/21.0): tnl: Reset nr_bos to 0 between map/unmap cycles.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 20 19:19:49 UTC 2021


Module: Mesa
Branch: staging/21.0
Commit: 3ffa16bee6a3c6f0ff9f3984dfbf7edfc474af4f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ffa16bee6a3c6f0ff9f3984dfbf7edfc474af4f

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Fri Jan 15 01:02:35 2021 -0800

tnl: Reset nr_bos to 0 between map/unmap cycles.

_tnl_draw_prims loops over the prims, and for each one, maps the VBOs,
draws, and unmaps them.  But it failed to reset nr_bos = 0 between each
loop iteration, which meant that when processing prim[n], the BO list
had all BOs for prior primitives too.  Assuming each primitive used the
same VBOs, that means the same VBO would appear in the list multiple
times, and it would try to unmap the same BO multiple times.  This
triggered asserts on the second unmap, as it had already been unmapped.

Fixes Piglit's oes_draw_elements_base_vertex-multidrawelements on i915.

Fixes: e99e7aa4c1d ("mesa: switch Draw(Range)Elements(BaseVertex) calls to DrawGallium")
Acked-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8522>
(cherry picked from commit 9fb5d7acbbab04af3c85f7b6188af16eda824b43)

---

 .pick_status.json     | 2 +-
 src/mesa/tnl/t_draw.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index bda24790307..7bd79ccc86d 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -247,7 +247,7 @@
         "description": "tnl: Reset nr_bos to 0 between map/unmap cycles.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "e99e7aa4c1ddd7b8c2c4388f4f8e4fa1955ca771"
     },
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index bffab548a0f..1370af691c2 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -494,7 +494,7 @@ void _tnl_draw_prims(struct gl_context *ctx,
        * one for the index buffer.
        */
       struct gl_buffer_object *bo[VERT_ATTRIB_MAX + 1];
-      GLuint nr_bo = 0;
+      GLuint nr_bo;
       GLuint inst;
 
       assert(num_instances > 0);
@@ -517,6 +517,7 @@ void _tnl_draw_prims(struct gl_context *ctx,
           * They will need to be unmapped below.
           */
          for (inst = 0; inst < num_instances; inst++) {
+            nr_bo = 0;
 
             bind_prims(ctx, &prim[i], this_nr_prims);
             bind_inputs(ctx, arrays, max_index + prim[i].basevertex + 1,



More information about the mesa-commit mailing list