summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_draw.c
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2021-01-15 00:40:18 -0800
committerMarge Bot <eric+marge@anholt.net>2021-01-20 00:29:04 +0000
commit376c8f750b9766d9704ced167dfaf00f521a92f4 (patch)
tree4a9c21067ecfd8e04c30579eeb2f99259edd1a8b /src/mesa/tnl/t_draw.c
parentbd6120f562d57e150aa2071f9108f538858311a6 (diff)
tnl: Respect `start` when converting indices to GLuint
Prior to commit e99e7aa4c1ddd7b8c2c4388f4f8e4fa1955ca771 (mesa: switch Draw(Range)Elements(BaseVertex) calls to DrawGallium), the indices parameter of glDrawElements (an offset into the VBO) was handled by setting ib->ptr. With that commit, it instead began binding the index buffer with offset 0, and adding the offset to draw->start, which eventually becomes prim->start. t_draw.c's bind_indices() was trying to convert the relevant section of the index buffer to GLuints, but was failing to account for start, so it nabbed the wrong portion of the index buffer. Fixes: e99e7aa4c1d ("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>
Diffstat (limited to 'src/mesa/tnl/t_draw.c')
-rw-r--r--src/mesa/tnl/t_draw.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index c28378cb148..bffab548a0f 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -341,6 +341,7 @@ static void bind_inputs(struct gl_context *ctx,
/* Translate indices to GLuints and store in VB->Elts.
*/
static void bind_indices(struct gl_context *ctx,
+ unsigned start,
const struct _mesa_index_buffer *ib,
struct gl_buffer_object **bo,
GLuint *nr_bo)
@@ -376,21 +377,23 @@ static void bind_indices(struct gl_context *ctx,
VB->Elts = (GLuint *) ptr;
}
else {
- GLuint *elts = (GLuint *)get_space(ctx, ib->count * sizeof(GLuint));
+ GLuint *elts = (GLuint *)get_space(ctx, (start + ib->count) * sizeof(GLuint));
VB->Elts = elts;
+ elts += start;
+
if (ib->index_size_shift == 2) {
- const GLuint *in = (GLuint *)ptr;
+ const GLuint *in = (GLuint *)ptr + start;
for (i = 0; i < ib->count; i++)
*elts++ = (GLuint)(*in++) + VB->Primitive[0].basevertex;
}
else if (ib->index_size_shift == 1) {
- const GLushort *in = (GLushort *)ptr;
+ const GLushort *in = (GLushort *)ptr + start;
for (i = 0; i < ib->count; i++)
*elts++ = (GLuint)(*in++) + VB->Primitive[0].basevertex;
}
else {
- const GLubyte *in = (GLubyte *)ptr;
+ const GLubyte *in = (GLubyte *)ptr + start;
for (i = 0; i < ib->count; i++)
*elts++ = (GLuint)(*in++) + VB->Primitive[0].basevertex;
}
@@ -505,7 +508,8 @@ void _tnl_draw_prims(struct gl_context *ctx,
*/
for (this_nr_prims = 1; i + this_nr_prims < nr_prims;
this_nr_prims++) {
- if (prim[i].basevertex != prim[i + this_nr_prims].basevertex)
+ if (prim[i].basevertex != prim[i + this_nr_prims].basevertex ||
+ prim[i].start != prim[i + this_nr_prims].start)
break;
}
@@ -517,7 +521,7 @@ void _tnl_draw_prims(struct gl_context *ctx,
bind_prims(ctx, &prim[i], this_nr_prims);
bind_inputs(ctx, arrays, max_index + prim[i].basevertex + 1,
bo, &nr_bo);
- bind_indices(ctx, ib, bo, &nr_bo);
+ bind_indices(ctx, prim[i].start, ib, bo, &nr_bo);
tnl->CurInstance = inst;
TNL_CONTEXT(ctx)->Driver.RunPipeline(ctx);