Mesh Batch Cache: Fix threading issue
I believed the crash I experienced happened because: 1. The `extract_pos_nor_init` function is called. 2. Tasks are added to the task pool for `extract_pos_nor`. 3. The tasks begin to be executed while more tasks are added. 4. In some rare cases, all existing tasks are finished, but not all have been added yet. 5. This let the task-counter go down to zero. 6. This triggered a call to `extract_pos_nor_finish`. 7. Then more tasks are added and in the end `extract_pos_nor_finish` is called again. A solution is to use a task pool that is suspended when created. Unfortunately, there was an outdated comment, that was probably the root cause of the issue. Reviewers: fclem, sergey Differential Revision: https://developer.blender.org/D5680
This commit is contained in:
parent
17baa43e59
commit
05721cd00a
|
@ -732,9 +732,7 @@ static TaskPool *task_pool_create_ex(TaskScheduler *scheduler,
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a normal task pool.
|
||||
* This means that in single-threaded context, it will not be executed at all until you call
|
||||
* \a BLI_task_pool_work_and_wait() on it.
|
||||
* Create a normal task pool. Tasks will be executed as soon as they are added.
|
||||
*/
|
||||
TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata)
|
||||
{
|
||||
|
|
|
@ -4320,7 +4320,7 @@ void mesh_buffer_cache_create_requested(MeshBatchCache *cache,
|
|||
TaskPool *task_pool;
|
||||
|
||||
task_scheduler = BLI_task_scheduler_get();
|
||||
task_pool = BLI_task_pool_create(task_scheduler, NULL);
|
||||
task_pool = BLI_task_pool_create_suspended(task_scheduler, NULL);
|
||||
|
||||
size_t counters_size = (sizeof(mbc) / sizeof(void *)) * sizeof(int32_t);
|
||||
int32_t *task_counters = MEM_callocN(counters_size, __func__);
|
||||
|
|
Loading…
Reference in New Issue