Refactor: DRW Mesh Extractor: Join the extractors in a same loop
This patch replaces / redoes the entire MeshExtractors system. Although they were useful and facilitated the addition of new buffers, they made it difficult to control the threads and added a lot of threading overhead. Part of the problem was in traversing the same loop type in different threads. The concurrent access of the BMesh Elements slowed the reading. This patch simplifies the use of threads by merging all the old callbacks from the extracts into a single series of iteration functions. The type of extraction can be chosen using flags. This optimized the process by around 34%. Initial idea and implementation By @mano-wii. Fine-tuning, cleanup by @atmind. MASTER: large_mesh_editing: - rdata 9ms iter 50ms (frame 155ms) - Average: 6.462874 FPS PATCH: large_mesh_editing: - rdata 9ms iter 34ms (frame 136ms) - Average: 7.379491 FPS Differential Revision: https://developer.blender.org/D11425
This commit is contained in:
@@ -286,7 +286,7 @@ typedef struct MeshBatchCache {
|
||||
|
||||
void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
|
||||
MeshBatchCache *cache,
|
||||
MeshBufferCache mbc,
|
||||
MeshBufferCache *mbc,
|
||||
MeshBufferExtractionCache *extraction_cache,
|
||||
Mesh *me,
|
||||
const bool is_editmode,
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -843,6 +843,9 @@ static void curve_create_edit_data_and_handles(CurveRenderData *rdata,
|
||||
int edges_len_capacity = curve_render_data_overlay_edges_len_get(rdata) * 2;
|
||||
int vbo_len_used = 0;
|
||||
|
||||
#define DRW_TEST_ASSIGN_VBO(v) (v = (DRW_vbo_requested(v) ? (v) : NULL))
|
||||
#define DRW_TEST_ASSIGN_IBO(v) (v = (DRW_ibo_requested(v) ? (v) : NULL))
|
||||
|
||||
if (DRW_TEST_ASSIGN_VBO(vbo_pos)) {
|
||||
GPU_vertbuf_init_with_format(vbo_pos, &format_pos);
|
||||
GPU_vertbuf_data_alloc(vbo_pos, verts_len_capacity);
|
||||
@@ -863,6 +866,9 @@ static void curve_create_edit_data_and_handles(CurveRenderData *rdata,
|
||||
GPU_indexbuf_init(elbp_lines, GPU_PRIM_LINES, edges_len_capacity, verts_len_capacity);
|
||||
}
|
||||
|
||||
#undef DRW_TEST_ASSIGN_VBO
|
||||
#undef DRW_TEST_ASSIGN_IBO
|
||||
|
||||
int nu_id = 0;
|
||||
for (Nurb *nu = (Nurb *)rdata->nurbs->first; nu; nu = nu->next, nu_id++) {
|
||||
const BezTriple *bezt = nu->bezt;
|
||||
|
@@ -532,6 +532,8 @@ void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(ListBase *lb,
|
||||
GPUVertBufRaw uv_step = {0};
|
||||
GPUVertBufRaw tan_step = {0};
|
||||
|
||||
#define DRW_TEST_ASSIGN_VBO(v) (v = (DRW_vbo_requested(v) ? (v) : NULL))
|
||||
|
||||
if (DRW_TEST_ASSIGN_VBO(vbo_pos_nor)) {
|
||||
GPU_vertbuf_init_with_format(vbo_pos_nor,
|
||||
do_hq_normals ? &format_pos_nor_hq : &format_pos_nor);
|
||||
@@ -550,6 +552,8 @@ void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(ListBase *lb,
|
||||
GPU_vertbuf_attr_get_raw_data(vbo_tan, tan_id, &tan_step);
|
||||
}
|
||||
|
||||
#undef DRW_TEST_ASSIGN_VBO
|
||||
|
||||
BKE_displist_normals_add(lb);
|
||||
|
||||
LISTBASE_FOREACH (const DispList *, dl, lb) {
|
||||
|
@@ -1559,7 +1559,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
|
||||
if (do_uvcage) {
|
||||
mesh_buffer_cache_create_requested(task_graph,
|
||||
cache,
|
||||
cache->uv_cage,
|
||||
&cache->uv_cage,
|
||||
&cache->uv_cage_extraction_cache,
|
||||
me,
|
||||
is_editmode,
|
||||
@@ -1578,7 +1578,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
|
||||
if (do_cage) {
|
||||
mesh_buffer_cache_create_requested(task_graph,
|
||||
cache,
|
||||
cache->cage,
|
||||
&cache->cage,
|
||||
&cache->cage_extraction_cache,
|
||||
me,
|
||||
is_editmode,
|
||||
@@ -1596,7 +1596,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
|
||||
|
||||
mesh_buffer_cache_create_requested(task_graph,
|
||||
cache,
|
||||
cache->final,
|
||||
&cache->final,
|
||||
&cache->final_extraction_cache,
|
||||
me,
|
||||
is_editmode,
|
||||
|
@@ -40,10 +40,6 @@
|
||||
(flag |= DRW_ibo_requested(ibo) ? (value) : 0)
|
||||
#endif
|
||||
|
||||
/* Test and assign NULL if test fails */
|
||||
#define DRW_TEST_ASSIGN_VBO(v) (v = (DRW_vbo_requested(v) ? (v) : NULL))
|
||||
#define DRW_TEST_ASSIGN_IBO(v) (v = (DRW_ibo_requested(v) ? (v) : NULL))
|
||||
|
||||
BLI_INLINE GPUBatch *DRW_batch_request(GPUBatch **batch)
|
||||
{
|
||||
/* XXX TODO(fclem): We are writing to batch cache here. Need to make this thread safe. */
|
||||
|
Reference in New Issue
Block a user