{
unsigned i;
unsigned nr_velems = mgr->ve->count;
- unsigned nr_vbufs = util_last_bit(mgr->enabled_vb_mask);
struct pipe_vertex_element *velems =
mgr->using_translate ? mgr->fallback_velems : mgr->ve->ve;
unsigned start_offset[PIPE_MAX_ATTRIBS];
- unsigned end_offset[PIPE_MAX_ATTRIBS] = {0};
+ unsigned end_offset[PIPE_MAX_ATTRIBS];
+ uint32_t buffer_mask = 0;
/* Determine how much data needs to be uploaded. */
for (i = 0; i < nr_velems; i++) {
struct pipe_vertex_element *velem = &velems[i];
unsigned index = velem->vertex_buffer_index;
struct pipe_vertex_buffer *vb = &mgr->vertex_buffer[index];
- unsigned instance_div, first, size;
+ unsigned instance_div, first, size, index_bit;
/* Skip the buffers generated by translate. */
if (index == mgr->fallback_vbs[VB_VERTEX] ||
size = vb->stride * (num_vertices - 1) + mgr->ve->src_format_size[i];
}
+ index_bit = 1 << index;
+
/* Update offsets. */
- if (!end_offset[index]) {
+ if (!(buffer_mask & index_bit)) {
start_offset[index] = first;
end_offset[index] = first + size;
} else {
if (first + size > end_offset[index])
end_offset[index] = first + size;
}
+
+ buffer_mask |= index_bit;
}
/* Upload buffers. */
- for (i = 0; i < nr_vbufs; i++) {
- unsigned start, end = end_offset[i];
+ while (buffer_mask) {
+ unsigned start, end;
struct pipe_vertex_buffer *real_vb;
const uint8_t *ptr;
- if (!end) {
- continue;
- }
+ i = u_bit_scan(&buffer_mask);
start = start_offset[i];
+ end = end_offset[i];
assert(start < end);
real_vb = &mgr->real_vertex_buffer[i];