LineArt: Speedup construction of quad trees.

Using multithread for `add_triangles` to speed up quad tree building.
Each thread would lock its respective tile to work on triangle insertion,
intersection calculation, tile splitting and triangle array extension.

Reviewed By: Sebastian Parborg (zeddb), Sergey Sharybin (sergey)

Ref D14953
This commit is contained in:
YimingWu 2022-06-02 20:32:31 +08:00
parent 901791944d
commit 432c4c74eb
Notes: blender-bot 2023-02-14 09:44:56 +01:00
Referenced by issue #100138, LineArt: Missing intersection lines
3 changed files with 566 additions and 365 deletions

View File

@ -236,6 +236,9 @@ typedef struct LineartRenderBuffer {
ListBase line_buffer_pointers;
ListBase triangle_buffer_pointers;
LineartElementLinkNode *isect_scheduled_up_to;
int isect_scheduled_up_to_index;
/** This one's memory is not from main pool and is free()ed after culling stage. */
ListBase triangle_adjacent_pointers;
@ -429,15 +432,18 @@ typedef struct LineartBoundingArea {
/** 1,2,3,4 quadrant */
struct LineartBoundingArea *child;
SpinLock lock;
ListBase lp;
ListBase rp;
ListBase up;
ListBase bp;
uint16_t triangle_count;
uint16_t max_triangle_count;
uint16_t line_count;
uint16_t max_line_count;
uint32_t triangle_count;
uint32_t max_triangle_count;
uint32_t line_count;
uint32_t max_line_count;
uint32_t user_count;
/* Use array for speeding up multiple accesses. */
struct LineartTriangle **linked_triangles;

File diff suppressed because it is too large Load Diff

View File

@ -80,9 +80,9 @@ void lineart_count_and_print_render_buffer_memory(struct LineartRenderBuffer *rb
#define LRT_BOUND_AREA_CROSSES(b1, b2) \
((b1)[0] < (b2)[1] && (b1)[1] > (b2)[0] && (b1)[3] < (b2)[2] && (b1)[2] > (b2)[3])
/* Initial bounding area row/column count, setting 4 is the simplest way algorithm could function
* efficiently. */
#define LRT_BA_ROWS 4
/* Initial bounding area row/column count, setting 10 is tested to be realitvely optimal for the
* performance under current algorithm. */
#define LRT_BA_ROWS 10
#ifdef __cplusplus
extern "C" {