GPU buffers: Use bitflag to whether we want to show diffuse color
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 12 Jan 2018 16:35:26 +0000 (17:35 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 15 Jan 2018 10:43:59 +0000 (11:43 +0100)
Those fine-tuning bits will be extended soon, so makes sense to start using
some more verbose flag names when calling functions.

source/blender/blenkernel/intern/pbvh.c
source/blender/gpu/GPU_buffers.h
source/blender/gpu/intern/gpu_buffers.c

index 46bd310066f3fc05a0fd5ad367b8fd906bfb6c67..3a7bade1ee3e74b719d0bd2c4bf48e6746bfde98 100644 (file)
@@ -1103,6 +1103,13 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag)
        BLI_task_parallel_range(0, totnode, &data, pbvh_update_BB_redraw_task_cb, &settings);
 }
 
+static int pbvh_get_buffers_update_flags(PBVH *bvh)
+{
+       int update_flags = 0;
+       update_flags |= bvh->show_diffuse_color ? GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR : 0;
+       return update_flags;
+}
+
 static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
 {
        /* can't be done in parallel with OpenGL */
@@ -1138,6 +1145,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
                }
 
                if (node->flag & PBVH_UpdateDrawBuffers) {
+                       const int update_flags = pbvh_get_buffers_update_flags(bvh);
                        switch (bvh->type) {
                                case PBVH_GRIDS:
                                        GPU_pbvh_grid_buffers_update(
@@ -1147,7 +1155,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
                                                node->prim_indices,
                                                node->totprim,
                                                &bvh->gridkey,
-                                               bvh->show_diffuse_color);
+                                               update_flags);
                                        break;
                                case PBVH_FACES:
                                        GPU_pbvh_mesh_buffers_update(
@@ -1158,7 +1166,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
                                                node->face_verts,
                                                CustomData_get_layer(bvh->vdata, CD_PAINT_MASK),
                                                node->face_vert_indices,
-                                               bvh->show_diffuse_color);
+                                               update_flags);
                                        break;
                                case PBVH_BMESH:
                                        GPU_pbvh_bmesh_buffers_update(
@@ -1167,7 +1175,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
                                                node->bm_faces,
                                                node->bm_unique_verts,
                                                node->bm_other_verts,
-                                               bvh->show_diffuse_color);
+                                               update_flags);
                                        break;
                        }
 
index e4a837d0a5f3675782dc52baf9975f89168b7ba6..1423361e8cbd4141fdbd5e0607ba3da5db3a7b0e 100644 (file)
@@ -237,10 +237,15 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading);
 
 /* update */
 
+enum {
+       GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR = (1 << 0),
+};
+
 void GPU_pbvh_mesh_buffers_update(
         GPU_PBVH_Buffers *buffers, const struct MVert *mvert,
         const int *vert_indices, int totvert, const float *vmask,
-        const int (*face_vert_indices)[3], bool show_diffuse_color);
+        const int (*face_vert_indices)[3],
+        const int update_flags);
 
 void GPU_pbvh_bmesh_buffers_update(
         GPU_PBVH_Buffers *buffers,
@@ -248,13 +253,13 @@ void GPU_pbvh_bmesh_buffers_update(
         struct GSet *bm_faces,
         struct GSet *bm_unique_verts,
         struct GSet *bm_other_verts,
-        bool show_diffuse_color);
+        const int update_flags);
 
 void GPU_pbvh_grid_buffers_update(
         GPU_PBVH_Buffers *buffers, struct CCGElem **grids,
         const struct DMFlagMat *grid_flag_mats,
         int *grid_indices, int totgrid, const struct CCGKey *key,
-        bool show_diffuse_color);
+        const int update_flags);
 
 /* draw */
 void GPU_pbvh_buffers_draw(
index e288c74fee6319dede7c0967debade1c8cd117d6..09d6f80abb82194af56cf51eae4f257a2fbe9820 100644 (file)
@@ -1033,8 +1033,10 @@ static void gpu_color_from_mask_quad_copy(const CCGKey *key,
 void GPU_pbvh_mesh_buffers_update(
         GPU_PBVH_Buffers *buffers, const MVert *mvert,
         const int *vert_indices, int totvert, const float *vmask,
-        const int (*face_vert_indices)[3], bool show_diffuse_color)
+        const int (*face_vert_indices)[3],
+        const int update_flags)
 {
+       const bool show_diffuse_color = (update_flags & GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR) != 0;
        VertexBufferFormat *vert_data;
        int i;
 
@@ -1239,8 +1241,10 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(
 void GPU_pbvh_grid_buffers_update(
         GPU_PBVH_Buffers *buffers, CCGElem **grids,
         const DMFlagMat *grid_flag_mats, int *grid_indices,
-        int totgrid, const CCGKey *key, bool show_diffuse_color)
+        int totgrid, const CCGKey *key,
+        const int update_flags)
 {
+       const bool show_diffuse_color = (update_flags & GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR) != 0;
        VertexBufferFormat *vert_data;
        int i, j, k, x, y;
 
@@ -1611,8 +1615,9 @@ void GPU_pbvh_bmesh_buffers_update(
         GSet *bm_faces,
         GSet *bm_unique_verts,
         GSet *bm_other_verts,
-        bool show_diffuse_color)
+        const int update_flags)
 {
+       const bool show_diffuse_color = (update_flags & GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR) != 0;
        VertexBufferFormat *vert_data;
        void *tri_data;
        int tottri, totvert, maxvert = 0;