Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh.cc
| Show All 35 Lines | |||||
| #include "BLI_task.h" | #include "BLI_task.h" | ||||
| #include "BLI_vector.hh" | #include "BLI_vector.hh" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "GPU_capabilities.h" | #include "GPU_capabilities.h" | ||||
| #include "draw_cache_extract.h" | #include "draw_cache_extract.h" | ||||
| #include "draw_cache_extract_mesh_private.h" | |||||
| #include "draw_cache_inline.h" | #include "draw_cache_inline.h" | ||||
| #include "mesh_extractors/extract_mesh.h" | |||||
| // #define DEBUG_TIME | // #define DEBUG_TIME | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| # include "PIL_time_utildefines.h" | # include "PIL_time_utildefines.h" | ||||
| #endif | #endif | ||||
| namespace blender::draw { | namespace blender::draw { | ||||
| Show All 16 Lines | |||||
| #ifdef WITH_CXX_GUARDEDALLOC | #ifdef WITH_CXX_GUARDEDALLOC | ||||
| MEM_CXX_CLASS_ALLOC_FUNCS("DRAW:ExtractorRunData") | MEM_CXX_CLASS_ALLOC_FUNCS("DRAW:ExtractorRunData") | ||||
| #endif | #endif | ||||
| }; | }; | ||||
| class ExtractorRunDatas : public Vector<ExtractorRunData> { | class ExtractorRunDatas : public Vector<ExtractorRunData> { | ||||
| public: | public: | ||||
| void filter_into(ExtractorRunDatas &result, eMRIterType iter_type) const | void filter_into(ExtractorRunDatas &result, eMRIterType iter_type, const bool is_mesh) const | ||||
| { | { | ||||
| for (const ExtractorRunData &data : *this) { | for (const ExtractorRunData &data : *this) { | ||||
| const MeshExtract *extractor = data.extractor; | const MeshExtract *extractor = data.extractor; | ||||
| if ((iter_type & MR_ITER_LOOPTRI) && extractor->iter_looptri_bm) { | if ((iter_type & MR_ITER_LOOPTRI) && *(&extractor->iter_looptri_bm + is_mesh)) { | ||||
| BLI_assert(extractor->iter_looptri_mesh); | |||||
| result.append(data); | result.append(data); | ||||
| continue; | continue; | ||||
| } | } | ||||
| if ((iter_type & MR_ITER_POLY) && extractor->iter_poly_bm) { | if ((iter_type & MR_ITER_POLY) && *(&extractor->iter_poly_bm + is_mesh)) { | ||||
| BLI_assert(extractor->iter_poly_mesh); | |||||
| result.append(data); | result.append(data); | ||||
| continue; | continue; | ||||
| } | } | ||||
| if ((iter_type & MR_ITER_LEDGE) && extractor->iter_ledge_bm) { | if ((iter_type & MR_ITER_LEDGE) && *(&extractor->iter_ledge_bm + is_mesh)) { | ||||
| BLI_assert(extractor->iter_ledge_mesh); | |||||
| result.append(data); | result.append(data); | ||||
| continue; | continue; | ||||
| } | } | ||||
| if ((iter_type & MR_ITER_LVERT) && extractor->iter_lvert_bm) { | if ((iter_type & MR_ITER_LVERT) && *(&extractor->iter_lvert_bm + is_mesh)) { | ||||
| BLI_assert(extractor->iter_lvert_mesh); | |||||
| result.append(data); | result.append(data); | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void filter_threaded_extractors_into(ExtractorRunDatas &result) | void filter_threaded_extractors_into(ExtractorRunDatas &result) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | case MR_ITER_LVERT: | ||||
| func = is_mesh ? extract_range_iter_lvert_mesh : extract_range_iter_lvert_bm; | func = is_mesh ? extract_range_iter_lvert_mesh : extract_range_iter_lvert_bm; | ||||
| stop = mr->vert_loose_len; | stop = mr->vert_loose_len; | ||||
| break; | break; | ||||
| default: | default: | ||||
| BLI_assert(false); | BLI_assert(false); | ||||
| return; | return; | ||||
| } | } | ||||
| extractors->filter_into(range_data.extractors, iter_type); | extractors->filter_into(range_data.extractors, iter_type, is_mesh); | ||||
| BLI_task_parallel_range(0, stop, &range_data, func, settings); | BLI_task_parallel_range(0, stop, &range_data, func, settings); | ||||
| } | } | ||||
| static void extract_task_range_run(void *__restrict taskdata) | static void extract_task_range_run(void *__restrict taskdata) | ||||
| { | { | ||||
| ExtractTaskData *data = (ExtractTaskData *)taskdata; | ExtractTaskData *data = (ExtractTaskData *)taskdata; | ||||
| const eMRIterType iter_type = data->iter_type; | const eMRIterType iter_type = data->iter_type; | ||||
| const bool is_mesh = data->mr->extract_type != MR_EXTRACT_BMESH; | const bool is_mesh = data->mr->extract_type != MR_EXTRACT_BMESH; | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | static void mesh_extract_render_data_node_exec(void *__restrict task_data) | ||||
| MeshRenderDataUpdateTaskData *update_task_data = static_cast<MeshRenderDataUpdateTaskData *>( | MeshRenderDataUpdateTaskData *update_task_data = static_cast<MeshRenderDataUpdateTaskData *>( | ||||
| task_data); | task_data); | ||||
| MeshRenderData *mr = update_task_data->mr; | MeshRenderData *mr = update_task_data->mr; | ||||
| const eMRIterType iter_type = update_task_data->iter_type; | const eMRIterType iter_type = update_task_data->iter_type; | ||||
| const eMRDataType data_flag = update_task_data->data_flag; | const eMRDataType data_flag = update_task_data->data_flag; | ||||
| mesh_render_data_update_normals(mr, data_flag); | mesh_render_data_update_normals(mr, data_flag); | ||||
| mesh_render_data_update_looptris(mr, iter_type, data_flag); | mesh_render_data_update_looptris(mr, iter_type, data_flag); | ||||
| mesh_render_data_update_mat_offsets(mr, update_task_data->cache, data_flag); | mesh_render_data_update_loose_geom(mr, update_task_data->cache, iter_type, data_flag); | ||||
| mesh_render_data_update_polys_sorted(mr, update_task_data->cache, data_flag); | |||||
| } | } | ||||
| static struct TaskNode *mesh_extract_render_data_node_create(struct TaskGraph *task_graph, | static struct TaskNode *mesh_extract_render_data_node_create(struct TaskGraph *task_graph, | ||||
| MeshRenderData *mr, | MeshRenderData *mr, | ||||
| MeshBufferExtractionCache *cache, | MeshBufferExtractionCache *cache, | ||||
| const eMRIterType iter_type, | const eMRIterType iter_type, | ||||
| const eMRDataType data_flag) | const eMRDataType data_flag) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | #undef EXTRACT_ADD_REQUESTED | ||||
| if (extractors.is_empty()) { | if (extractors.is_empty()) { | ||||
| return; | return; | ||||
| } | } | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| double rdata_start = PIL_check_seconds_timer(); | double rdata_start = PIL_check_seconds_timer(); | ||||
| #endif | #endif | ||||
| eMRIterType iter_type = extractors.iter_types(); | MeshRenderData *mr = mesh_render_data_create( | ||||
| eMRDataType data_flag = extractors.data_types(); | me, is_editmode, is_paint_mode, is_mode_active, obmat, do_final, do_uvedit, ts); | ||||
| MeshRenderData *mr = mesh_render_data_create(me, | |||||
| extraction_cache, | |||||
| is_editmode, | |||||
| is_paint_mode, | |||||
| is_mode_active, | |||||
| obmat, | |||||
| do_final, | |||||
| do_uvedit, | |||||
| ts, | |||||
| iter_type); | |||||
| mr->use_hide = use_hide; | mr->use_hide = use_hide; | ||||
| mr->use_subsurf_fdots = use_subsurf_fdots; | mr->use_subsurf_fdots = use_subsurf_fdots; | ||||
| mr->use_final_mesh = do_final; | mr->use_final_mesh = do_final; | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| double rdata_end = PIL_check_seconds_timer(); | double rdata_end = PIL_check_seconds_timer(); | ||||
| #endif | #endif | ||||
| eMRIterType iter_type = extractors.iter_types(); | |||||
| eMRDataType data_flag = extractors.data_types(); | |||||
| struct TaskNode *task_node_mesh_render_data = mesh_extract_render_data_node_create( | struct TaskNode *task_node_mesh_render_data = mesh_extract_render_data_node_create( | ||||
| task_graph, mr, extraction_cache, iter_type, data_flag); | task_graph, mr, extraction_cache, iter_type, data_flag); | ||||
| /* Simple heuristic. */ | /* Simple heuristic. */ | ||||
| const bool use_thread = (mr->loop_len + mr->loop_loose_len) > MIN_RANGE_LEN; | const bool use_thread = (mr->loop_len + mr->loop_loose_len) > MIN_RANGE_LEN; | ||||
| if (use_thread) { | if (use_thread) { | ||||
| /* First run the requested extractors that do not support asynchronous ranges. */ | /* First run the requested extractors that do not support asynchronous ranges. */ | ||||
| ▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines | |||||