for (i = 0; i < primcount; i++) {
min_index_ptr = MIN2(min_index_ptr, (uintptr_t) indices[i]);
max_index_ptr = MAX2(max_index_ptr, (uintptr_t) indices[i] +
- ib.index_size * count[i]);
+ (count[i] << ib.index_size_shift));
}
/* Check if we can handle this thing as a bunch of index offsets from the
* Check that the difference between each prim's indexes is a multiple of
* the index/element size.
*/
- if (ib.index_size != 1) {
+ if (ib.index_size_shift) {
for (i = 0; i < primcount; i++) {
- if ((((uintptr_t) indices[i] - min_index_ptr) % ib.index_size) !=
- 0) {
+ if ((((uintptr_t) indices[i] - min_index_ptr) &
+ ((1 << ib.index_size_shift) - 1)) != 0) {
fallback = GL_TRUE;
break;
}
ALLOC_PRIMS(prim, primcount, "glMultiDrawElements");
- ib.count = (max_index_ptr - min_index_ptr) / ib.index_size;
+ ib.count = (max_index_ptr - min_index_ptr) >> ib.index_size_shift;
ib.obj = ctx->Array.VAO->IndexBufferObj;
ib.ptr = (void *) min_index_ptr;
prim[i].end = 1;
prim[i].mode = mode;
prim[i].start =
- ((uintptr_t) indices[i] - min_index_ptr) / ib.index_size;
+ ((uintptr_t) indices[i] - min_index_ptr) >> ib.index_size_shift;
prim[i].count = count[i];
prim[i].draw_id = i;
if (basevertex != NULL)
if (!info.index.resource)
return;
- start = pointer_to_offset(ib->ptr) / info.index_size;
+ start = pointer_to_offset(ib->ptr) >> ib->index_size_shift;
} else {
/* indices are in user space memory */
info.has_user_indices = true;
info.index_size = ib->index_size;
info.index.resource = st_buffer_object(bufobj)->buffer;
- info.start = pointer_to_offset(ib->ptr) / info.index_size;
+ info.start = pointer_to_offset(ib->ptr) >> ib->index_size_shift;
/* Primitive restart is not handled by the VBO module in this case. */
setup_primitive_restart(ctx, &info);
if (bufobj && bufobj->Name) {
struct st_buffer_object *stobj = st_buffer_object(bufobj);
- start = pointer_to_offset(ib->ptr) / index_size;
+ start = pointer_to_offset(ib->ptr) >> ib->index_size_shift;
mapped_indices = pipe_buffer_map(pipe, stobj->buffer,
PIPE_TRANSFER_READ, &ib_transfer);
}
mapped_indices = ib->ptr;
}
- info.index_size = ib->index_size;
+ info.index_size = index_size;
info.min_index = min_index;
info.max_index = max_index;
info.has_user_indices = true;
GLuint i;
GLintptr offset = 0;
- indices = (char *) ib->ptr + prim->start * ib->index_size;
+ indices = (char *) ib->ptr + (prim->start << ib->index_size_shift);
if (_mesa_is_bufferobj(ib->obj)) {
- GLsizeiptr size = MIN2(count * ib->index_size, ib->obj->Size);
+ GLsizeiptr size = MIN2(count << ib->index_size_shift, ib->obj->Size);
if (vbo_get_minmax_cached(ib->obj, ib->index_size, (GLintptr) indices,
count, min_index, max_index))