[Mesa-dev] [PATCH 1/2] gallium/vbuf: add some const qualifiers

Brian Paul brianp at vmware.com
Tue Jun 20 01:50:21 UTC 2017


Helps understandability a bit.
---
 src/gallium/auxiliary/util/u_vbuf.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index 8361e64..b342f34 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -366,8 +366,8 @@ void u_vbuf_destroy(struct u_vbuf *mgr)
 {
    struct pipe_screen *screen = mgr->pipe->screen;
    unsigned i;
-   unsigned num_vb = screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
-                                              PIPE_SHADER_CAP_MAX_INPUTS);
+   const unsigned num_vb = screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
+                                                    PIPE_SHADER_CAP_MAX_INPUTS);
 
    mgr->pipe->set_vertex_buffers(mgr->pipe, 0, num_vb, NULL);
 
@@ -435,7 +435,7 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
    /* Translate. */
    if (unroll_indices) {
       struct pipe_transfer *transfer = NULL;
-      unsigned offset = info->start * info->index_size;
+      const unsigned offset = info->start * info->index_size;
       uint8_t *map;
 
       /* Create and map the output buffer. */
@@ -555,16 +555,16 @@ u_vbuf_translate_begin(struct u_vbuf *mgr,
    struct translate_key key[VB_NUM];
    unsigned elem_index[VB_NUM][PIPE_MAX_ATTRIBS]; /* ... into key.elements */
    unsigned i, type;
-   unsigned incompatible_vb_mask = mgr->incompatible_vb_mask &
-                                   mgr->ve->used_vb_mask;
+   const unsigned incompatible_vb_mask = mgr->incompatible_vb_mask &
+                                         mgr->ve->used_vb_mask;
 
-   int start[VB_NUM] = {
+   const int start[VB_NUM] = {
       start_vertex,           /* VERTEX */
       info->start_instance,   /* INSTANCE */
       0                       /* CONST */
    };
 
-   unsigned num[VB_NUM] = {
+   const unsigned num[VB_NUM] = {
       num_vertices,           /* VERTEX */
       info->instance_count,   /* INSTANCE */
       1                       /* CONST */
@@ -802,7 +802,7 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
    uint32_t incompatible_vb_mask = 0;
    /* which buffers have a non-zero stride */
    uint32_t nonzero_stride_vb_mask = 0;
-   uint32_t mask = ~(((1ull << count) - 1) << start_slot);
+   const uint32_t mask = ~(((1ull << count) - 1) << start_slot);
 
    /* Zero out the bits we are going to rewrite completely. */
    mgr->user_vb_mask &= mask;
@@ -885,7 +885,7 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr,
 {
    unsigned i;
    unsigned nr_velems = mgr->ve->count;
-   struct pipe_vertex_element *velems =
+   const 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];
@@ -893,7 +893,7 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr,
 
    /* Determine how much data needs to be uploaded. */
    for (i = 0; i < nr_velems; i++) {
-      struct pipe_vertex_element *velem = &velems[i];
+      const 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, index_bit;
@@ -1110,9 +1110,10 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
    int start_vertex, min_index;
    unsigned num_vertices;
    boolean unroll_indices = FALSE;
-   uint32_t used_vb_mask = mgr->ve->used_vb_mask;
+   const uint32_t used_vb_mask = mgr->ve->used_vb_mask;
    uint32_t user_vb_mask = mgr->user_vb_mask & used_vb_mask;
-   uint32_t incompatible_vb_mask = mgr->incompatible_vb_mask & used_vb_mask;
+   const uint32_t incompatible_vb_mask =
+      mgr->incompatible_vb_mask & used_vb_mask;
    struct pipe_draw_info new_info;
 
    /* Normal draw. No fallback and no user buffers. */
-- 
1.9.1



More information about the mesa-dev mailing list