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: e99e7aa4c1 ("mesa: switch Draw(Range)Elements(BaseVertex) calls to DrawGallium")
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8522>
(cherry picked from commit 9fb5d7acbb)
This commit is contained in:
Kenneth Graunke 2021-01-15 01:02:35 -08:00 committed by Dylan Baker
parent 14e0ee3479
commit 3ffa16bee6
2 changed files with 3 additions and 2 deletions

View file

@ -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"
},

View file

@ -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,