mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 12:40:09 +01:00
tnl: Respect start when converting indices to GLuint
Prior to commite99e7aa4c1(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: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>
This commit is contained in:
parent
bd6120f562
commit
376c8f750b
1 changed files with 10 additions and 6 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue