[Bf-blender-cvs] [14a49950ff1] master: Cleanup: style, use braces for gpu

Campbell Barton noreply at git.blender.org
Mon Apr 22 13:15:37 CEST 2019


Commit: 14a49950ff11f43b7a5a73da545339b969de97f0
Author: Campbell Barton
Date:   Mon Apr 22 09:32:37 2019 +1000
Branches: master
https://developer.blender.org/rB14a49950ff11f43b7a5a73da545339b969de97f0

Cleanup: style, use braces for gpu

===================================================================

M	source/blender/gpu/intern/gpu_batch.c
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/gpu/intern/gpu_codegen.c
M	source/blender/gpu/intern/gpu_debug.c
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_element.c
M	source/blender/gpu/intern/gpu_extensions.c
M	source/blender/gpu/intern/gpu_framebuffer.c
M	source/blender/gpu/intern/gpu_immediate.c
M	source/blender/gpu/intern/gpu_init_exit.c
M	source/blender/gpu/intern/gpu_material.c
M	source/blender/gpu/intern/gpu_select.c
M	source/blender/gpu/intern/gpu_shader.c
M	source/blender/gpu/intern/gpu_texture.c
M	source/blender/gpu/intern/gpu_viewport.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 4f5215ce9e6..f179f9ef22c 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -194,8 +194,9 @@ int GPU_batch_vertbuf_add_ex(GPUBatch *batch, GPUVertBuf *verts, bool own_vbo)
 #endif
       batch->verts[v] = verts;
       /* TODO: mark dirty so we can keep attribute bindings up-to-date */
-      if (own_vbo)
+      if (own_vbo) {
         batch->owns_flag |= (1 << v);
+      }
       return v;
     }
   }
@@ -211,14 +212,18 @@ static GLuint batch_vao_get(GPUBatch *batch)
 {
   /* Search through cache */
   if (batch->is_dynamic_vao_count) {
-    for (int i = 0; i < batch->dynamic_vaos.count; ++i)
-      if (batch->dynamic_vaos.interfaces[i] == batch->interface)
+    for (int i = 0; i < batch->dynamic_vaos.count; ++i) {
+      if (batch->dynamic_vaos.interfaces[i] == batch->interface) {
         return batch->dynamic_vaos.vao_ids[i];
+      }
+    }
   }
   else {
-    for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i)
-      if (batch->static_vaos.interfaces[i] == batch->interface)
+    for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) {
+      if (batch->static_vaos.interfaces[i] == batch->interface) {
         return batch->static_vaos.vao_ids[i];
+      }
+    }
   }
 
   /* Set context of this batch.
@@ -239,9 +244,11 @@ static GLuint batch_vao_get(GPUBatch *batch)
   GLuint new_vao = 0;
   if (!batch->is_dynamic_vao_count) {
     int i; /* find first unused slot */
-    for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i)
-      if (batch->static_vaos.vao_ids[i] == 0)
+    for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) {
+      if (batch->static_vaos.vao_ids[i] == 0) {
         break;
+      }
+    }
 
     if (i < GPU_BATCH_VAO_STATIC_LEN) {
       batch->static_vaos.interfaces[i] = batch->interface;
@@ -267,9 +274,11 @@ static GLuint batch_vao_get(GPUBatch *batch)
 
   if (batch->is_dynamic_vao_count) {
     int i; /* find first unused slot */
-    for (i = 0; i < batch->dynamic_vaos.count; ++i)
-      if (batch->dynamic_vaos.vao_ids[i] == 0)
+    for (i = 0; i < batch->dynamic_vaos.count; ++i) {
+      if (batch->dynamic_vaos.vao_ids[i] == 0) {
         break;
+      }
+    }
 
     if (i == batch->dynamic_vaos.count) {
       /* Not enough place, realloc the array. */
@@ -362,8 +371,9 @@ static void create_bindings(GPUVertBuf *verts,
     for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) {
       const GPUShaderInput *input = GPU_shaderinterface_attr(interface, a->name[n_idx]);
 
-      if (input == NULL)
+      if (input == NULL) {
         continue;
+      }
 
       if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) {
 #if TRUST_NO_ONE
@@ -540,10 +550,12 @@ static void primitive_restart_enable(const GPUIndexBuf *el)
   GLuint restart_index = (GLuint)0xFFFFFFFF;
 
 #if GPU_TRACK_INDEX_RANGE
-  if (el->index_type == GPU_INDEX_U8)
+  if (el->index_type == GPU_INDEX_U8) {
     restart_index = (GLuint)0xFF;
-  else if (el->index_type == GPU_INDEX_U16)
+  }
+  else if (el->index_type == GPU_INDEX_U16) {
     restart_index = (GLuint)0xFFFF;
+  }
 #endif
 
   glPrimitiveRestartIndex(restart_index);
@@ -557,13 +569,16 @@ static void primitive_restart_disable(void)
 static void *elem_offset(const GPUIndexBuf *el, int v_first)
 {
 #if GPU_TRACK_INDEX_RANGE
-  if (el->index_type == GPU_INDEX_U8)
+  if (el->index_type == GPU_INDEX_U8) {
     return (GLubyte *)0 + v_first;
-  else if (el->index_type == GPU_INDEX_U16)
+  }
+  else if (el->index_type == GPU_INDEX_U16) {
     return (GLushort *)0 + v_first;
-  else
+  }
+  else {
 #endif
     return (GLuint *)0 + v_first;
+  }
 }
 
 void GPU_batch_draw(GPUBatch *batch)
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 2b678876cde..9b89fc3a4a2 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -231,8 +231,9 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
               buffers->mloop[lt->tri[2]].v,
           };
 
-          if (paint_is_face_hidden(lt, mvert, buffers->mloop))
+          if (paint_is_face_hidden(lt, mvert, buffers->mloop)) {
             continue;
+          }
 
           /* Face normal and mask */
           if (lt->poly != mpoly_prev) {
@@ -291,8 +292,9 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
   /* Count the number of visible triangles */
   for (i = 0, tottri = 0; i < face_indices_len; ++i) {
     const MLoopTri *lt = &looptri[face_indices[i]];
-    if (!paint_is_face_hidden(lt, mvert, mloop))
+    if (!paint_is_face_hidden(lt, mvert, mloop)) {
       tottri++;
+    }
   }
 
   if (tottri == 0) {
@@ -325,8 +327,9 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
       const MLoopTri *lt = &looptri[face_indices[i]];
 
       /* Skip hidden faces */
-      if (paint_is_face_hidden(lt, mvert, mloop))
+      if (paint_is_face_hidden(lt, mvert, mloop)) {
         continue;
+      }
 
       GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i]));
 
@@ -347,8 +350,9 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
       const MLoopTri *lt = &looptri[face_indices[i]];
 
       /* Skip hidden faces */
-      if (paint_is_face_hidden(lt, mvert, mloop))
+      if (paint_is_face_hidden(lt, mvert, mloop)) {
         continue;
+      }
 
       /* TODO skip "non-real" edges. */
       GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 0, i * 3 + 1);
@@ -706,13 +710,15 @@ static int gpu_bmesh_vert_visible_count(GSet *bm_unique_verts, GSet *bm_other_ve
 
   GSET_ITER (gs_iter, bm_unique_verts) {
     BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
-    if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN))
+    if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
       totvert++;
+    }
   }
   GSET_ITER (gs_iter, bm_other_verts) {
     BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
-    if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN))
+    if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
       totvert++;
+    }
   }
 
   return totvert;
@@ -727,8 +733,9 @@ static int gpu_bmesh_face_visible_count(GSet *bm_faces)
   GSET_ITER (gh_iter, bm_faces) {
     BMFace *f = BLI_gsetIterator_getKey(&gh_iter);
 
-    if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN))
+    if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
       totface++;
+    }
   }
 
   return totface;
@@ -966,10 +973,12 @@ void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers)
 /* debug function, draws the pbvh BB */
 void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, uint pos)
 {
-  if (leaf)
+  if (leaf) {
     immUniformColor4f(0.0, 1.0, 0.0, 0.5);
-  else
+  }
+  else {
     immUniformColor4f(1.0, 0.0, 0.0, 0.5);
+  }
 
   /* TODO(merwin): revisit this after we have mutable VertexBuffers
    * could keep a static batch & index buffer, change the VBO contents per draw
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 43211fe0969..aef68333b6f 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -81,8 +81,9 @@ static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs, GPUVertAtt
       BLI_hash_mm2a_add(&hm2a, (uchar *)name, strlen(name));
     }
   }
-  if (defs)
+  if (defs) {
     BLI_hash_mm2a_add(&hm2a, (uchar *)defs, strlen(defs));
+  }
 
   return BLI_hash_mm2a_end(&hm2a);
 }
@@ -180,8 +181,9 @@ static GPUShader *FUNCTION_LIB = NULL;
 static int gpu_str_prefix(const char *str, const char *prefix)
 {
   while (*str && *prefix) {
-    if (*str != *prefix)
+    if (*str != *prefix) {
       return 0;
+    }
 
     str++;
     prefix++;
@@ -196,8 +198,9 @@ static char *gpu_str_skip_token(char *str, char *token, int max)
 
   /* skip a variable/function name */
   while (*str) {
-    if (ELEM(*str, ' ', '(', ')', ',', ';', '\t', '\n', '\r'))
+    if (ELEM(*str, ' ', '(', ')', ',', ';', '\t', '\n', '\r')) {
       break;
+    }
     else {
       if (token && len < max - 1) {
         *token = *str;
@@ -208,16 +211,19 @@ static char *gpu_str_skip_token(char *str, char *token, int max)
     }
   }
 
-  if (token)
+  if (token) {
     *token = '\0';
+  }
 
   /* skip the next special characters:
    * note the missing ')' */
   while (*str) {
-    if (ELEM(*str, ' ', '(', ',', ';', '\t', '\n', '\r'))
+    if (ELEM(*str, ' ', '(', ',', ';', '\t', '\n', '\r')) {
       str++;
-    else
+    }
+    else {
       break;
+    }
   }
 
   return str;
@@ -240,12 +246,15 @@ static void gpu_parse_functions_string(GHash *hash, char *code)
     while (*code && *code != ')') {
       /* test if it's an input or output */
       qual = FUNCTION_QUAL_IN;
-      if (gpu_str_prefix(code, "out "))
+      if (gpu_str_prefix(code, "out ")) {
         qual = FUNCTION_QUAL_OUT;
-      if (gpu_str_prefix(code, "inout "))
+      }
+      if (gpu_str_prefix(code, "inout ")) {
         qual = FUNCTION_QUAL_INOUT;
-      if ((qual != FUNCTION_QUAL_IN) || gpu_str_prefix(code, "in "))
+      }
+      if ((qual != FUNCTION_QUAL_IN) || gpu_str_prefix(code, "in ")) {
         code = gpu_str_skip_token(code, NULL, 0);
+      }
 
       /* test for type */
       type = GPU_NONE;
@@ -368,8 +377,9 @@ void gpu_codegen_exit(void)
 {
   extern Material defmaterial; /* render module abuse... */
 
-  if (defmaterial.gpumaterial.first)
+  if (defmaterial.gpumaterial.first) {
     GPU_material_free(&defmaterial.gpumaterial);
+  }
 
   if (FUNCTION_HASH) {
     BLI_ghash_free(FUNCTION_HASH, NULL, MEM_freeN);
@@ -407,46 +417,62 @@ static void codegen_convert_datatype(DynStr *ds, int from, int to, const char *t
     BLI_dynstr_append(ds, name);
   }
   else if (to == GPU_FLOAT) {
-    if (from == GPU_VEC4)
+    if (from == GPU_VEC4) {
       BLI_dynstr_appendf(ds, "convert_rgba_to_float(%s)", name);
-    else if (from == GPU_VEC3)
+    }
+    else if (from == GPU_VEC3) {
       BLI_dynstr_appendf(ds, "(%s.r + %s.g + %s.b) / 3.0", name, name, name);
-    else if (from == GPU_VEC2)
+    }
+    else if (from == GPU_VEC2) {
       BLI_dynstr_appendf(ds, "%s.r", name);
+    }
   }
   else if (to == GPU_VEC2) {
-    if (from == G

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list