diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/util/u_vbuf.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 26ecb7ab51e..5bd60dc95f0 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -831,18 +831,18 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, { 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] || @@ -872,8 +872,10 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, 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 { @@ -882,19 +884,20 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, 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]; |