[Bf-blender-cvs] [7d38f503679] blender-v2.83-release: Fix T75908: Sculpt GPU Batches + Render Artifacts

Jeroen Bakker noreply at git.blender.org
Thu May 14 12:00:41 CEST 2020


Commit: 7d38f5036794e7bf2678c8138b940257b152435b
Author: Jeroen Bakker
Date:   Thu May 14 11:56:16 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB7d38f5036794e7bf2678c8138b940257b152435b

Fix T75908: Sculpt GPU Batches + Render Artifacts

When sculpting the GPU batches are constructed with only the required data
for a single viewport. When that viewport changes shading or coloring mode (object
to vertex) batches might not hold all the needed information.

There is also a case when you have two 3d viewport one in object color
mode and the other in vertex color mode that the GPU batches were
updated without any vertex colors.

In order to fix these category of issues this patch would always
construct the full GPU batches for sculpting.

Reviewed By: Clément Foucault, Pablo Dobarro

Maniphest Tasks: T75908

Differential Revision: https://developer.blender.org/D7701

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

M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/draw/engines/basic/basic_engine.c
M	source/blender/draw/engines/eevee/eevee_materials.c
M	source/blender/draw/engines/overlay/overlay_facing.c
M	source/blender/draw/engines/overlay/overlay_sculpt.c
M	source/blender/draw/engines/overlay/overlay_wireframe.c
M	source/blender/draw/engines/workbench/workbench_engine.c
M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_manager_data.c

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

diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 94f0e544a6b..1779385b97b 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -190,7 +190,6 @@ bool BKE_pbvh_node_find_nearest_to_ray(PBVH *bvh,
 /* Drawing */
 
 void BKE_pbvh_draw_cb(PBVH *bvh,
-                      bool show_vcol,
                       bool update_only_visible,
                       PBVHFrustumPlanes *update_frustum,
                       PBVHFrustumPlanes *draw_frustum,
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 5756cb8c706..7d5a0e7fd91 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1009,7 +1009,6 @@ typedef struct PBVHUpdateData {
 
   float (*vnors)[3];
   int flag;
-  bool show_vcol;
   bool show_sculpt_face_sets;
 } PBVHUpdateData;
 
@@ -1250,12 +1249,10 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag)
   BKE_pbvh_parallel_range(0, totnode, &data, pbvh_update_BB_redraw_task_cb, &settings);
 }
 
-static int pbvh_get_buffers_update_flags(PBVH *bvh, bool show_vcol)
+static int pbvh_get_buffers_update_flags(PBVH *UNUSED(bvh))
 {
-  int update_flags = 0;
-  update_flags |= bvh->show_mask ? GPU_PBVH_BUFFERS_SHOW_MASK : 0;
-  update_flags |= show_vcol ? GPU_PBVH_BUFFERS_SHOW_VCOL : 0;
-  update_flags |= bvh->show_face_sets ? GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS : 0;
+  int update_flags = GPU_PBVH_BUFFERS_SHOW_VCOL | GPU_PBVH_BUFFERS_SHOW_MASK |
+                     GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS;
   return update_flags;
 }
 
@@ -1295,7 +1292,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
   }
 
   if (node->flag & PBVH_UpdateDrawBuffers) {
-    const int update_flags = pbvh_get_buffers_update_flags(bvh, data->show_vcol);
+    const int update_flags = pbvh_get_buffers_update_flags(bvh);
     switch (bvh->type) {
       case PBVH_GRIDS:
         GPU_pbvh_grid_buffers_update(node->draw_buffers,
@@ -1335,8 +1332,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
   }
 }
 
-static void pbvh_update_draw_buffers(
-    PBVH *bvh, PBVHNode **nodes, int totnode, bool show_vcol, int update_flag)
+static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode, int update_flag)
 {
   if ((update_flag & PBVH_RebuildDrawBuffers) || ELEM(bvh->type, PBVH_GRIDS, PBVH_BMESH)) {
     /* Free buffers uses OpenGL, so not in parallel. */
@@ -1362,7 +1358,6 @@ static void pbvh_update_draw_buffers(
   PBVHUpdateData data = {
       .bvh = bvh,
       .nodes = nodes,
-      .show_vcol = show_vcol,
   };
 
   PBVHParallelSettings settings;
@@ -2679,7 +2674,6 @@ static bool pbvh_draw_search_cb(PBVHNode *node, void *data_v)
 }
 
 void BKE_pbvh_draw_cb(PBVH *bvh,
-                      bool show_vcol,
                       bool update_only_visible,
                       PBVHFrustumPlanes *update_frustum,
                       PBVHFrustumPlanes *draw_frustum,
@@ -2696,7 +2690,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
     BKE_pbvh_search_gather(bvh, update_search_cb, POINTER_FROM_INT(update_flag), &nodes, &totnode);
 
     if (totnode) {
-      pbvh_update_draw_buffers(bvh, nodes, totnode, show_vcol, update_flag);
+      pbvh_update_draw_buffers(bvh, nodes, totnode, update_flag);
     }
 
     MEM_SAFE_FREE(nodes);
@@ -2708,7 +2702,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
 
   if (update_only_visible && (data.accum_update_flag & update_flag)) {
     /* Update draw buffers in visible nodes. */
-    pbvh_update_draw_buffers(bvh, nodes, totnode, show_vcol, data.accum_update_flag);
+    pbvh_update_draw_buffers(bvh, nodes, totnode, data.accum_update_flag);
   }
 
   /* Draw. */
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index ab53f7025c0..6658fea7825 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -202,7 +202,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
                                        stl->g_data->depth_shgrp[do_in_front];
 
   if (use_sculpt_pbvh) {
-    DRW_shgroup_call_sculpt(shgrp, ob, false, false, false);
+    DRW_shgroup_call_sculpt(shgrp, ob, false, false);
   }
   else {
     struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index f0dbd47e146..03cdb02a48a 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -2073,23 +2073,21 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
       }
 
       if (use_sculpt_pbvh) {
-        /* Vcol is not supported in the modes that require PBVH drawing. */
-        const bool use_vcol = false;
         struct DRWShadingGroup **sculpt_shgrps_array = BLI_array_alloca(sculpt_shgrps_array,
                                                                         materials_len);
         for (int i = 0; i < materials_len; i++) {
           sculpt_shgrps_array[i] = shgrps_array[i].shading_grp;
         }
-        DRW_shgroup_call_sculpt_with_materials(sculpt_shgrps_array, materials_len, ob, use_vcol);
+        DRW_shgroup_call_sculpt_with_materials(sculpt_shgrps_array, materials_len, ob);
 
         for (int i = 0; i < materials_len; i++) {
           sculpt_shgrps_array[i] = shgrps_array[i].depth_grp;
         }
-        DRW_shgroup_call_sculpt_with_materials(sculpt_shgrps_array, materials_len, ob, use_vcol);
+        DRW_shgroup_call_sculpt_with_materials(sculpt_shgrps_array, materials_len, ob);
         for (int i = 0; i < materials_len; i++) {
           sculpt_shgrps_array[i] = shgrps_array[i].depth_clip_grp;
         }
-        DRW_shgroup_call_sculpt_with_materials(sculpt_shgrps_array, materials_len, ob, use_vcol);
+        DRW_shgroup_call_sculpt_with_materials(sculpt_shgrps_array, materials_len, ob);
 
         for (int renderpass_index = 0;
              renderpass_index < stl->g_data->render_passes_material_count;
@@ -2097,7 +2095,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
           for (int i = 0; i < materials_len; i++) {
             sculpt_shgrps_array[i] = shgrps_array[i].material_accum_grp[renderpass_index];
           }
-          DRW_shgroup_call_sculpt_with_materials(sculpt_shgrps_array, materials_len, ob, use_vcol);
+          DRW_shgroup_call_sculpt_with_materials(sculpt_shgrps_array, materials_len, ob);
         }
 
         /* TODO(fclem): Support shadows in sculpt mode. */
diff --git a/source/blender/draw/engines/overlay/overlay_facing.c b/source/blender/draw/engines/overlay/overlay_facing.c
index e98181ea718..9216ae61b3e 100644
--- a/source/blender/draw/engines/overlay/overlay_facing.c
+++ b/source/blender/draw/engines/overlay/overlay_facing.c
@@ -63,7 +63,7 @@ void OVERLAY_facing_cache_populate(OVERLAY_Data *vedata, Object *ob)
   const bool is_xray = (ob->dtx & OB_DRAWXRAY) != 0;
 
   if (use_sculpt_pbvh) {
-    DRW_shgroup_call_sculpt(pd->facing_grp[is_xray], ob, false, false, false);
+    DRW_shgroup_call_sculpt(pd->facing_grp[is_xray], ob, false, false);
   }
   else {
     struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
diff --git a/source/blender/draw/engines/overlay/overlay_sculpt.c b/source/blender/draw/engines/overlay/overlay_sculpt.c
index 391c49e0695..111fa6316ed 100644
--- a/source/blender/draw/engines/overlay/overlay_sculpt.c
+++ b/source/blender/draw/engines/overlay/overlay_sculpt.c
@@ -54,7 +54,7 @@ void OVERLAY_sculpt_cache_populate(OVERLAY_Data *vedata, Object *ob)
 
   if (use_pbvh || !ob->sculpt->deform_modifiers_active || ob->sculpt->shapekey_active) {
     if (!use_pbvh || pbvh_has_mask(pbvh) || pbvh_has_face_sets(pbvh)) {
-      DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true, false);
+      DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true);
     }
   }
 }
diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.c b/source/blender/draw/engines/overlay/overlay_wireframe.c
index 63a1a72c9a6..99ff7f67d49 100644
--- a/source/blender/draw/engines/overlay/overlay_wireframe.c
+++ b/source/blender/draw/engines/overlay/overlay_wireframe.c
@@ -230,7 +230,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata,
         DRW_shgroup_call_no_cull(shgrp, geom, ob);
       }
       else if (use_sculpt_pbvh) {
-        DRW_shgroup_call_sculpt(shgrp, ob, true, false, false);
+        DRW_shgroup_call_sculpt(shgrp, ob, true, false);
       }
       else {
         DRW_shgroup_call(shgrp, geom, ob);
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c
index cb0dfc0a8bf..a88076d5fd7 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.c
+++ b/source/blender/draw/engines/workbench/workbench_engine.c
@@ -118,7 +118,7 @@ static void workbench_cache_sculpt_populate(WORKBENCH_PrivateData *wpd,
 
   if (use_single_drawcall) {
     DRWShadingGroup *grp = workbench_material_setup(wpd, ob, 0, color_type, NULL);
-    DRW_shgroup_call_sculpt(grp, ob, false, false, use_vcol);
+    DRW_shgroup_call_sculpt(grp, ob, false, false);
   }
   else {
     const int materials_len = DRW_cache_object_material_count_get(ob);
@@ -126,7 +126,7 @@ static void workbench_cache_sculpt_populate(WORKBENCH_PrivateData *wpd,
     for (int i = 0; i < materials_len; i++) {
       shgrps[i] = workbench_material_setup(wpd, ob, i + 1, color_type, NULL);
     }
-    DRW_shgroup_call_sculpt_with_materials(shgrps, materials_len, ob, false);
+    DRW_shgroup_call_sculpt_with_materials(shgrps, materials_len, ob);
   }
 }
 
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 663567fd51e..c4d9396307a 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -410,11 +410,8 @@ void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup,
                                            struct GPUBatch *geom,
                                            struct GPUBatch *inst

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list