The passthrough pipeline needs to check index values (which might be passed
through) as they can be invalid (which causes crashes and various assertion
failures if the clip code runs). Obviously, rendering won't be well-defined,
but those bogus indices might come directly from apps.
There were already debug printfs which reported the out-of-bounds indices but
we really ought to not crash.
While checking at that point doesn't seem like the most efficient solution,
it seems there isn't really another appropriate function to do it.
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
#include "draw/draw_private.h"
#include "draw/draw_pipe.h"
#include "util/u_debug.h"
+#include "util/u_math.h"
do_point( draw, verts + stride * (i0) ); \
} while (0)
-#define GET_ELT(idx) (elts[idx])
+#define GET_ELT(idx) (MIN2(elts[idx], max_index))
#define FUNC pipe_run_elts
#define FUNC_VARS \
struct vertex_header *vertices, \
unsigned stride, \
const ushort *elts, \
- unsigned count
+ unsigned count, \
+ unsigned max_index
#include "draw_pt_decompose.h"
vert_info->verts,
vert_info->stride,
prim_info->elts + start,
- count);
+ count,
+ vert_info->count - 1);
}
draw->pipeline.verts = NULL;
for (i = 0; i < icount; i++) {
ELT_TYPE idx = ib[i];
- if (idx < min_index || idx > max_index) {
+ if (idx < min_index || idx > max_index) {
debug_printf("warning: index out of range\n");
}
}
if (idx < min_index || idx > max_index) {
debug_printf("warning: index out of range\n");
- }
+ }
vsplit->draw_elts[i] = (ushort) idx;
}
}
if (idx < min_index || idx > max_index) {
debug_printf("warning: index out of range\n");
- }
+ }
vsplit->draw_elts[i] = (ushort) (idx - min_index);
}
}