Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editmesh_undo.c
| Show First 20 Lines • Show All 391 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| # ifdef USE_ARRAY_STORE_THREAD | # ifdef USE_ARRAY_STORE_THREAD | ||||
| struct UMArrayData { | struct UMArrayData { | ||||
| UndoMesh *um; | UndoMesh *um; | ||||
| const UndoMesh *um_ref; /* can be NULL */ | const UndoMesh *um_ref; /* can be NULL */ | ||||
| }; | }; | ||||
| static void um_arraystore_compact_cb(TaskPool *__restrict UNUSED(pool), | static void um_arraystore_compact_cb(TaskPool *__restrict UNUSED(pool), void *taskdata) | ||||
| void *taskdata, | |||||
| int UNUSED(threadid)) | |||||
| { | { | ||||
| struct UMArrayData *um_data = taskdata; | struct UMArrayData *um_data = taskdata; | ||||
| um_arraystore_compact_with_info(um_data->um, um_data->um_ref); | um_arraystore_compact_with_info(um_data->um, um_data->um_ref); | ||||
| } | } | ||||
| # endif /* USE_ARRAY_STORE_THREAD */ | # endif /* USE_ARRAY_STORE_THREAD */ | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | static void um_arraystore_free(UndoMesh *um) | ||||
| if (um_arraystore.users == 0) { | if (um_arraystore.users == 0) { | ||||
| # ifdef DEBUG_PRINT | # ifdef DEBUG_PRINT | ||||
| printf("mesh undo store: freeing all data!\n"); | printf("mesh undo store: freeing all data!\n"); | ||||
| # endif | # endif | ||||
| BLI_array_store_at_size_clear(&um_arraystore.bs_stride); | BLI_array_store_at_size_clear(&um_arraystore.bs_stride); | ||||
| # ifdef USE_ARRAY_STORE_THREAD | # ifdef USE_ARRAY_STORE_THREAD | ||||
| BLI_task_pool_free(um_arraystore.task_pool); | BLI_task_pool_tbb_free(um_arraystore.task_pool); | ||||
| um_arraystore.task_pool = NULL; | um_arraystore.task_pool = NULL; | ||||
| # endif | # endif | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| #endif /* USE_ARRAY_STORE */ | #endif /* USE_ARRAY_STORE */ | ||||
| /* for callbacks */ | /* for callbacks */ | ||||
| /* undo simply makes copies of a bmesh */ | /* undo simply makes copies of a bmesh */ | ||||
| static void *undomesh_from_editmesh(UndoMesh *um, BMEditMesh *em, Key *key) | static void *undomesh_from_editmesh(UndoMesh *um, BMEditMesh *em, Key *key) | ||||
| { | { | ||||
| BLI_assert(BLI_array_is_zeroed(um, 1)); | BLI_assert(BLI_array_is_zeroed(um, 1)); | ||||
| #ifdef USE_ARRAY_STORE_THREAD | #ifdef USE_ARRAY_STORE_THREAD | ||||
| /* changes this waits is low, but must have finished */ | /* changes this waits is low, but must have finished */ | ||||
| if (um_arraystore.task_pool) { | if (um_arraystore.task_pool) { | ||||
| BLI_task_pool_work_and_wait(um_arraystore.task_pool); | BLI_task_pool_tbb_work_and_wait(um_arraystore.task_pool); | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* make sure shape keys work */ | /* make sure shape keys work */ | ||||
| um->me.key = key ? BKE_key_copy_nolib(key) : NULL; | um->me.key = key ? BKE_key_copy_nolib(key) : NULL; | ||||
| /* BM_mesh_validate(em->bm); */ /* for troubleshooting */ | /* BM_mesh_validate(em->bm); */ /* for troubleshooting */ | ||||
| BM_mesh_bm_to_me( | BM_mesh_bm_to_me( | ||||
| Show All 18 Lines | const UndoMesh *um_ref = um_arraystore.local_links.last ? | ||||
| ((LinkData *)um_arraystore.local_links.last)->data : | ((LinkData *)um_arraystore.local_links.last)->data : | ||||
| NULL; | NULL; | ||||
| /* add oursrlves */ | /* add oursrlves */ | ||||
| BLI_addtail(&um_arraystore.local_links, BLI_genericNodeN(um)); | BLI_addtail(&um_arraystore.local_links, BLI_genericNodeN(um)); | ||||
| # ifdef USE_ARRAY_STORE_THREAD | # ifdef USE_ARRAY_STORE_THREAD | ||||
| if (um_arraystore.task_pool == NULL) { | if (um_arraystore.task_pool == NULL) { | ||||
| TaskScheduler *scheduler = BLI_task_scheduler_get(); | TaskScheduler *scheduler = BLI_task_scheduler_legacy_get(); | ||||
| um_arraystore.task_pool = BLI_task_pool_create_background( | um_arraystore.task_pool = BLI_task_pool_tbb_create_background( | ||||
| scheduler, NULL, TASK_PRIORITY_LOW); | scheduler, NULL, TASK_PRIORITY_LOW); | ||||
| } | } | ||||
| struct UMArrayData *um_data = MEM_mallocN(sizeof(*um_data), __func__); | struct UMArrayData *um_data = MEM_mallocN(sizeof(*um_data), __func__); | ||||
| um_data->um = um; | um_data->um = um; | ||||
| um_data->um_ref = um_ref; | um_data->um_ref = um_ref; | ||||
| BLI_task_pool_push(um_arraystore.task_pool, um_arraystore_compact_cb, um_data, true, NULL); | BLI_task_pool_tbb_push( | ||||
| um_arraystore.task_pool, um_arraystore_compact_cb, um_data, true, NULL); | |||||
| # else | # else | ||||
| um_arraystore_compact_with_info(um, um_ref); | um_arraystore_compact_with_info(um, um_ref); | ||||
| # endif | # endif | ||||
| } | } | ||||
| #endif | #endif | ||||
| return um; | return um; | ||||
| } | } | ||||
| static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em, Key *key) | static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em, Key *key) | ||||
| { | { | ||||
| BMEditMesh *em_tmp; | BMEditMesh *em_tmp; | ||||
| BMesh *bm; | BMesh *bm; | ||||
| #ifdef USE_ARRAY_STORE | #ifdef USE_ARRAY_STORE | ||||
| # ifdef USE_ARRAY_STORE_THREAD | # ifdef USE_ARRAY_STORE_THREAD | ||||
| /* changes this waits is low, but must have finished */ | /* changes this waits is low, but must have finished */ | ||||
| BLI_task_pool_work_and_wait(um_arraystore.task_pool); | BLI_task_pool_tbb_work_and_wait(um_arraystore.task_pool); | ||||
| # endif | # endif | ||||
| # ifdef DEBUG_TIME | # ifdef DEBUG_TIME | ||||
| TIMEIT_START(mesh_undo_expand); | TIMEIT_START(mesh_undo_expand); | ||||
| # endif | # endif | ||||
| um_arraystore_expand(um); | um_arraystore_expand(um); | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| static void undomesh_free_data(UndoMesh *um) | static void undomesh_free_data(UndoMesh *um) | ||||
| { | { | ||||
| Mesh *me = &um->me; | Mesh *me = &um->me; | ||||
| #ifdef USE_ARRAY_STORE | #ifdef USE_ARRAY_STORE | ||||
| # ifdef USE_ARRAY_STORE_THREAD | # ifdef USE_ARRAY_STORE_THREAD | ||||
| /* changes this waits is low, but must have finished */ | /* changes this waits is low, but must have finished */ | ||||
| BLI_task_pool_work_and_wait(um_arraystore.task_pool); | BLI_task_pool_tbb_work_and_wait(um_arraystore.task_pool); | ||||
| # endif | # endif | ||||
| /* we need to expand so any allocations in custom-data are freed with the mesh */ | /* we need to expand so any allocations in custom-data are freed with the mesh */ | ||||
| um_arraystore_expand(um); | um_arraystore_expand(um); | ||||
| { | { | ||||
| LinkData *link = BLI_findptr(&um_arraystore.local_links, um, offsetof(LinkData, data)); | LinkData *link = BLI_findptr(&um_arraystore.local_links, um, offsetof(LinkData, data)); | ||||
| BLI_remlink(&um_arraystore.local_links, link); | BLI_remlink(&um_arraystore.local_links, link); | ||||
| ▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines | |||||