diff options
author | Marek Olšák <[email protected]> | 2020-06-01 15:49:36 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2020-06-09 00:45:23 -0400 |
commit | 88e8f1a38d838753542461cea56d1c1b1a5cfc5d (patch) | |
tree | 0cd4035d9e0d89bebb9f36bb21300a64f8deb925 /src/gallium/auxiliary | |
parent | a6c747e8e0b982c707b1ff73edd1087a1c5e1db2 (diff) |
gallium/u_vbuf: get rid of some pointer dereferences
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5304>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/util/u_vbuf.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 62b2e0efc3d..999fcb80135 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -798,13 +798,14 @@ u_vbuf_create_vertex_elements(struct u_vbuf *mgr, unsigned count, * supported. */ for (i = 0; i < count; i++) { enum pipe_format format = ve->ve[i].src_format; + unsigned vb_index_bit = 1 << ve->ve[i].vertex_buffer_index; ve->src_format_size[i] = util_format_get_blocksize(format); - used_buffers |= 1 << ve->ve[i].vertex_buffer_index; + used_buffers |= vb_index_bit; if (!ve->ve[i].instance_divisor) { - ve->noninstance_vb_mask_any |= 1 << ve->ve[i].vertex_buffer_index; + ve->noninstance_vb_mask_any |= vb_index_bit; } format = mgr->caps.format_translation[format]; @@ -818,9 +819,9 @@ u_vbuf_create_vertex_elements(struct u_vbuf *mgr, unsigned count, (!mgr->caps.velem_src_offset_unaligned && ve->ve[i].src_offset % 4 != 0)) { ve->incompatible_elem_mask |= 1 << i; - ve->incompatible_vb_mask_any |= 1 << ve->ve[i].vertex_buffer_index; + ve->incompatible_vb_mask_any |= vb_index_bit; } else { - ve->compatible_vb_mask_any |= 1 << ve->ve[i].vertex_buffer_index; + ve->compatible_vb_mask_any |= vb_index_bit; } } @@ -960,9 +961,10 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, int start_instance, unsigned num_instances) { unsigned i; - unsigned nr_velems = mgr->ve->count; + struct u_vbuf_elements *ve = mgr->ve; + unsigned nr_velems = ve->count; const struct pipe_vertex_element *velems = - mgr->using_translate ? mgr->fallback_velems.velems : mgr->ve->ve; + mgr->using_translate ? mgr->fallback_velems.velems : ve->ve; unsigned start_offset[PIPE_MAX_ATTRIBS]; unsigned end_offset[PIPE_MAX_ATTRIBS]; uint32_t buffer_mask = 0; @@ -988,7 +990,7 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, if (!vb->stride) { /* Constant attrib. */ - size = mgr->ve->src_format_size[i]; + size = ve->src_format_size[i]; } else if (instance_div) { /* Per-instance attrib. */ @@ -1002,11 +1004,11 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, count++; first += vb->stride * start_instance; - size = vb->stride * (count - 1) + mgr->ve->src_format_size[i]; + size = vb->stride * (count - 1) + ve->src_format_size[i]; } else { /* Per-vertex attrib. */ first += vb->stride * start_vertex; - size = vb->stride * (num_vertices - 1) + mgr->ve->src_format_size[i]; + size = vb->stride * (num_vertices - 1) + ve->src_format_size[i]; } index_bit = 1 << index; |