tnl: Code formatting in t_rebase.c
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 8 Apr 2020 18:15:32 +0000 (11:15 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 13 Apr 2020 17:27:00 +0000 (10:27 -0700)
Many little changes.  Almost everything is indentation or removal of
trailing whitespace.  Some places move a loop variable declaration to
the loop.  Some comments either re-wrapped or converted to single
line.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4512>

src/mesa/tnl/t_rebase.c

index 23395e4b576f902f890e98a3aad55569928cd161..3d5a1a1c4c86b7c70dc6185359f6b71a409e763a 100644 (file)
@@ -39,7 +39,7 @@
  *
  * If we just upload the new data, however, the indices will be
  * incorrect as we tend to upload each set of vertex data to a new
- * region.  
+ * region.
  *
  * This file provides a helper to adjust the arrays, primitives and
  * indices of a draw call so that it can be re-issued with a min_index
 
 
 #define REBASE(TYPE)                                           \
-static void *rebase_##TYPE( const void *ptr,                   \
-                         GLuint count,                         \
-                         TYPE min_index )                      \
+static void *rebase_##TYPE(const void *ptr,                    \
+                           unsigned count,                     \
+                           TYPE min_index)                     \
 {                                                              \
-   GLuint i;                                                   \
    const TYPE *in = (TYPE *)ptr;                               \
    TYPE *tmp_indices = malloc(count * sizeof(TYPE));           \
-                                                               \
+                                                                \
    if (tmp_indices == NULL) {                                   \
       _mesa_error_no_memory(__func__);                          \
       return NULL;                                              \
    }                                                            \
-                                                               \
-   for (i = 0; i < count; i++)                                 \
+                                                                \
+   for (unsigned i = 0; i < count; i++)                         \
       tmp_indices[i] = in[i] - min_index;                      \
-                                                               \
+                                                                \
    return (void *)tmp_indices;                                 \
 }
 
-
 REBASE(GLuint)
 REBASE(GLushort)
 REBASE(GLubyte)
 
 
-
 /* Adjust primitives, indices and vertex definitions so that min_index
  * becomes zero. There are lots of reasons for wanting to do this, eg:
  *
@@ -92,7 +89,7 @@ REBASE(GLubyte)
  *      min_index will be transformed.
  *
  * Hardware tnl:
- *    - if ib != NULL and min_index != 0, otherwise vertices lower than 
+ *    - if ib != NULL and min_index != 0, otherwise vertices lower than
  *      min_index will be uploaded.  Requires adjusting index values.
  *
  *    - if ib == NULL and min_index != 0, just for convenience so this doesn't
@@ -103,16 +100,16 @@ REBASE(GLubyte)
  *    - can't save time by trying to upload half a vbo - typically it is
  *      all or nothing.
  */
-void t_rebase_prims( struct gl_context *ctx,
-                     const struct tnl_vertex_array *arrays,
-                     const struct _mesa_prim *prim,
-                     GLuint nr_prims,
-                     const struct _mesa_index_buffer *ib,
-                     GLuint min_index,
-                     GLuint max_index,
-                     GLuint num_instances,
-                     GLuint base_instance,
-                     tnl_draw_func draw )
+void t_rebase_prims(struct gl_context *ctx,
+                    const struct tnl_vertex_array *arrays,
+                    const struct _mesa_prim *prim,
+                    GLuint nr_prims,
+                    const struct _mesa_index_buffer *ib,
+                    GLuint min_index,
+                    GLuint max_index,
+                    GLuint num_instances,
+                    GLuint base_instance,
+                    tnl_draw_func draw)
 {
    struct gl_array_attributes tmp_attribs[VERT_ATTRIB_MAX];
    struct tnl_vertex_array tmp_arrays[VERT_ATTRIB_MAX];
@@ -127,13 +124,12 @@ void t_rebase_prims( struct gl_context *ctx,
    if (0)
       printf("%s %d..%d\n", __func__, min_index, max_index);
 
-
    /* XXX this path is disabled for now.
     * There's rendering corruption in some apps when it's enabled.
     */
    if (0 && ib && ctx->Extensions.ARB_draw_elements_base_vertex) {
-      /* If we can just tell the hardware or the TNL to interpret our
-       * indices with a different base, do so.
+      /* If we can just tell the hardware or the TNL to interpret our indices
+       * with a different base, do so.
        */
       tmp_prims = malloc(sizeof(*prim) * nr_prims);
 
@@ -143,8 +139,8 @@ void t_rebase_prims( struct gl_context *ctx,
       }
 
       for (i = 0; i < nr_prims; i++) {
-        tmp_prims[i] = prim[i];
-        tmp_prims[i].basevertex -= min_index;
+         tmp_prims[i] = prim[i];
+         tmp_prims[i].basevertex -= min_index;
       }
 
       prim = tmp_prims;
@@ -165,27 +161,26 @@ void t_rebase_prims( struct gl_context *ctx,
       } else
          ptr = ib->ptr;
 
-      /* Some users might prefer it if we translated elements to
-       * GLuints here.  Others wouldn't...
+      /* Some users might prefer it if we translated elements to GLuints here.
+       * Others wouldn't...
        */
       switch (ib->index_size_shift) {
       case 2:
-        tmp_indices = rebase_GLuint( ptr, ib->count, min_index );
-        break;
+         tmp_indices = rebase_GLuint( ptr, ib->count, min_index );
+         break;
       case 1:
-        tmp_indices = rebase_GLushort( ptr, ib->count, min_index );
-        break;
+         tmp_indices = rebase_GLushort( ptr, ib->count, min_index );
+         break;
       case 0:
-        tmp_indices = rebase_GLubyte( ptr, ib->count, min_index );
-        break;
-      }      
+         tmp_indices = rebase_GLubyte( ptr, ib->count, min_index );
+         break;
+      }
 
-      if (map_ib) 
-        ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL);
+      if (map_ib)
+         ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL);
 
-      if (tmp_indices == NULL) {
+      if (tmp_indices == NULL)
          return;
-      }
 
       tmp_ib.obj = NULL;
       tmp_ib.ptr = tmp_indices;
@@ -195,8 +190,7 @@ void t_rebase_prims( struct gl_context *ctx,
       ib = &tmp_ib;
    }
    else {
-      /* Otherwise the primitives need adjustment.
-       */
+      /* Otherwise the primitives need adjustment. */
       tmp_prims = malloc(sizeof(*prim) * nr_prims);
 
       if (tmp_prims == NULL) {
@@ -205,12 +199,11 @@ void t_rebase_prims( struct gl_context *ctx,
       }
 
       for (i = 0; i < nr_prims; i++) {
-        /* If this fails, it could indicate an application error:
-         */
-        assert(prim[i].start >= min_index);
+         /* If this fails, it could indicate an application error: */
+         assert(prim[i].start >= min_index);
 
-        tmp_prims[i] = prim[i];
-        tmp_prims[i].start -= min_index;
+         tmp_prims[i] = prim[i];
+         tmp_prims[i].start -= min_index;
       }
 
       prim = tmp_prims;
@@ -236,21 +229,19 @@ void t_rebase_prims( struct gl_context *ctx,
       else
          tmp_attribs[i].Ptr += min_index * arrays[i].BufferBinding->Stride;
    }
-   
-   /* Re-issue the draw call.
-    */
-   draw( ctx,
-         tmp_arrays,
-        prim,
-        nr_prims, 
-        ib, 
-        GL_TRUE,
-        0, 
-        max_index - min_index,
-         num_instances, base_instance);
+
+   /* Re-issue the draw call. */
+   draw(ctx,
+        tmp_arrays,
+        prim,
+        nr_prims,
+        ib,
+        GL_TRUE,
+        0,
+        max_index - min_index,
+        num_instances, base_instance);
 
    free(tmp_indices);
-   
    free(tmp_prims);
 }