[Bf-blender-cvs] [87dae08dd3f] lineart-bvh: LineAer: benchmark

YimingWu noreply at git.blender.org
Sat Jul 3 11:26:27 CEST 2021


Commit: 87dae08dd3f2a80dd208576b130cabaca21c9912
Author: YimingWu
Date:   Wed Jun 23 21:26:10 2021 +0800
Branches: lineart-bvh
https://developer.blender.org/rB87dae08dd3f2a80dd208576b130cabaca21c9912

LineAer: benchmark

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

M	source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
M	source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c

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

diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index da9d628dbda..18bd524ed2b 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -347,6 +347,8 @@ typedef struct LineartRenderBuffer {
   struct Collection *_source_collection;
   struct Object *_source_object;
 
+  int debug_triangle_isec_test_count;
+
 } LineartRenderBuffer;
 
 typedef struct LineartCache {
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index fe3a202e8ed..9a08a093f37 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -65,7 +65,7 @@
 
 #include "lineart_intern.h"
 
-#define LINEART_WITH_BVH
+//#define LINEART_WITH_BVH
 #define LINEART_WITH_BVH_THREAD
 #define LINEART_BVH_OWN_ISEC
 
@@ -2977,6 +2977,8 @@ static void lineart_triangle_intersect_in_bounding_area(LineartRenderBuffer *rb,
       continue;
     }
 
+    rb->debug_triangle_isec_test_count++;
+
     /* If we do need to compute intersection, then finally do it. */
     lineart_triangle_intersect(rb, tri, testing_triangle);
   }
@@ -4056,6 +4058,7 @@ typedef struct LineartIsecThread {
   LineartIsecSingle *array;
   int current;
   int max;
+  int count_test;
 } LineartIsecThread;
 typedef struct LineartIsecData {
   LineartRenderBuffer *rb;
@@ -4131,6 +4134,8 @@ static bool lineart_bvh_isec_callback(void *userdata, int index_a, int index_b,
     return false;
   }
 
+  d->threads[thread].count_test++;
+
 #ifdef LINEART_BVH_OWN_ISEC
   float e1[3], e2[3];
 
@@ -4227,6 +4232,14 @@ static void lineart_do_intersections(LineartRenderBuffer *rb)
   BVHTreeOverlap *overlap = BLI_bvhtree_overlap(
       rb->bvh_main, rb->bvh_main, &overlap_tot, lineart_bvh_isec_callback, &d);
 
+  if (G.debug_value == 4000) {
+    int total_test_count = 0;
+    for (int i = 0; i < rb->thread_count; i++) {
+      total_test_count += d.threads[i].count_test;
+    }
+    printf("BVH has done %d pairs.\n", total_test_count);
+  }
+
   lineart_create_edges_from_isec_data(&d);
   lineart_destroy_isec_thread(&d);
 #else
@@ -4611,6 +4624,10 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph,
 
 #ifdef LINEART_WITH_BVH
   lineart_do_intersections(rb);
+#else
+  if (G.debug_value == 4000) {
+    printf("Legacy triangle isec pairs: %d\n", rb->debug_triangle_isec_test_count);
+  }
 #endif
 
   /* Link lines to acceleration structure, this can only be done after perspective division, if



More information about the Bf-blender-cvs mailing list