Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-02-17 23:57:56 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-02-18 00:26:24 +0300
commitef11be0e77461a7b5d657c365bac2b7746ca47bf (patch)
tree394bc53909f86f43513daec2ec227b01107efb87 /intern/cycles/kernel/kernel_volume.h
parenta9dbaf3755ac1abad109970e0fff190bb7418ac2 (diff)
Cycles: Avoid over-allocation in decouple ray marching
It could have happened with really long rays and small steps. Step size will be adjusted to the clamped number of steps in order to preserve render result compatibility as much as possible. We should probably reformulate this a bit, so it will give the same looking results without step tweaks. But this new behavior should already be much better that it was before.
Diffstat (limited to 'intern/cycles/kernel/kernel_volume.h')
-rw-r--r--intern/cycles/kernel/kernel_volume.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index 9d6c233f5b2..8e67ad5464c 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -623,13 +623,16 @@ ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg, PathState *sta
float step_size, random_jitter_offset;
if(heterogeneous) {
- max_steps = kernel_data.integrator.volume_max_steps;
+ const int global_max_steps = kernel_data.integrator.volume_max_steps;
step_size = kernel_data.integrator.volume_step_size;
- random_jitter_offset = lcg_step_float(&state->rng_congruential) * step_size;
-
/* compute exact steps in advance for malloc */
max_steps = max((int)ceilf(ray->t/step_size), 1);
+ if (max_steps > global_max_steps) {
+ max_steps = global_max_steps;
+ step_size = ray->t / (float)max_steps;
+ }
segment->steps = (VolumeStep*)malloc(sizeof(VolumeStep)*max_steps);
+ random_jitter_offset = lcg_step_float(&state->rng_congruential) * step_size;
}
else {
max_steps = 1;