Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/particle_system.c
| Show First 20 Lines • Show All 3,688 Lines • ▼ Show 20 Lines | typedef struct DynamicStepSolverTaskData { | ||||
| float cfra; | float cfra; | ||||
| float timestep; | float timestep; | ||||
| float dtime; | float dtime; | ||||
| SpinLock spin; | SpinLock spin; | ||||
| } DynamicStepSolverTaskData; | } DynamicStepSolverTaskData; | ||||
| static void dynamics_step_sphdata_reduce(const void *__restrict UNUSED(userdata), | static void dynamics_step_sphdata_reduce(const void *__restrict UNUSED(userdata), | ||||
| void *__restrict UNUSED(join_v), | void *__restrict join_v, | ||||
| void *__restrict chunk_v) | void *__restrict chunk_v) | ||||
| { | { | ||||
| SPHData *sphdata = chunk_v; | SPHData *sphdata_to = join_v; | ||||
| SPHData *sphdata_from = chunk_v; | |||||
| psys_sph_flush_springs(sphdata); | if (sphdata_from->new_springs.count > 0) { | ||||
mont29: This only gets called once now at the end of the process (as opposed to after each step in the… | |||||
Done Inline ActionsHow is it 'not at all' when it's called from psys_sph_finalize that cleans up the SPHData structure? Also, it seems that springs are only added by the DDR solver anyway, because the only place they can be added is sph_force_cb, which is only referenced from psys_sph_init for the SPH_SOLVER_DDR case. The original fix was probably being paranoid. Should I remove the extra references to reduce while I'm at it? angavrilov: How is it 'not at all' when it's called `from psys_sph_finalize` that cleans up the SPHData… | |||||
Not Done Inline Actions
Ugh you are right, sorry, I missed one level of indentation here (that's shy I hate that two-spaces indentation...). mont29: > How is it 'not at all' when it's called from `psys_sph_finalize` that cleans up the `SPHData`… | |||||
| BLI_buffer_append_array(&sphdata_to->new_springs, | |||||
| ParticleSpring, | |||||
| &BLI_buffer_at(&sphdata_from->new_springs, ParticleSpring, 0), | |||||
| sphdata_from->new_springs.count); | |||||
| } | |||||
| BLI_buffer_field_free(&sphdata_from->new_springs); | |||||
| } | } | ||||
| static void dynamics_step_sph_ddr_task_cb_ex(void *__restrict userdata, | static void dynamics_step_sph_ddr_task_cb_ex(void *__restrict userdata, | ||||
| const int p, | const int p, | ||||
| const TaskParallelTLS *__restrict tls) | const TaskParallelTLS *__restrict tls) | ||||
| { | { | ||||
| DynamicStepSolverTaskData *data = userdata; | DynamicStepSolverTaskData *data = userdata; | ||||
| ParticleSimulationData *sim = data->sim; | ParticleSimulationData *sim = data->sim; | ||||
| ▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | case PART_PHYS_FLUID: { | ||||
| /* Note that we could avoid copying sphdata for each thread here (it's only read here), | /* Note that we could avoid copying sphdata for each thread here (it's only read here), | ||||
| * but doubt this would gain us anything except confusion... */ | * but doubt this would gain us anything except confusion... */ | ||||
| { | { | ||||
| TaskParallelSettings settings; | TaskParallelSettings settings; | ||||
| BLI_parallel_range_settings_defaults(&settings); | BLI_parallel_range_settings_defaults(&settings); | ||||
| settings.use_threading = (psys->totpart > 100); | settings.use_threading = (psys->totpart > 100); | ||||
| settings.userdata_chunk = &sphdata; | settings.userdata_chunk = &sphdata; | ||||
| settings.userdata_chunk_size = sizeof(sphdata); | settings.userdata_chunk_size = sizeof(sphdata); | ||||
| settings.func_reduce = dynamics_step_sphdata_reduce; | |||||
| BLI_task_parallel_range(0, | BLI_task_parallel_range(0, | ||||
| psys->totpart, | psys->totpart, | ||||
| &task_data, | &task_data, | ||||
| dynamics_step_sph_classical_calc_density_task_cb_ex, | dynamics_step_sph_classical_calc_density_task_cb_ex, | ||||
| &settings); | &settings); | ||||
| } | } | ||||
| /* do global forces & effectors */ | /* do global forces & effectors */ | ||||
| { | { | ||||
| TaskParallelSettings settings; | TaskParallelSettings settings; | ||||
| BLI_parallel_range_settings_defaults(&settings); | BLI_parallel_range_settings_defaults(&settings); | ||||
| settings.use_threading = (psys->totpart > 100); | settings.use_threading = (psys->totpart > 100); | ||||
| settings.userdata_chunk = &sphdata; | settings.userdata_chunk = &sphdata; | ||||
| settings.userdata_chunk_size = sizeof(sphdata); | settings.userdata_chunk_size = sizeof(sphdata); | ||||
| settings.func_reduce = dynamics_step_sphdata_reduce; | |||||
| BLI_task_parallel_range(0, | BLI_task_parallel_range(0, | ||||
| psys->totpart, | psys->totpart, | ||||
| &task_data, | &task_data, | ||||
| dynamics_step_sph_classical_integrate_task_cb_ex, | dynamics_step_sph_classical_integrate_task_cb_ex, | ||||
| &settings); | &settings); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 980 Lines • Show Last 20 Lines | |||||
This only gets called once now at the end of the process (as opposed to after each step in the classical solver case), and not at all even in the DDR solver case.
Not sure whether this is important or not (did not follow enough code to check), but either way this change should be clearly analyzed and explained in commit message imho?