From 1d149f6746a00cb49df202b1c49fcff4264dd226 Mon Sep 17 00:00:00 2001 From: Patrick Mours Date: Fri, 10 Jan 2020 15:42:44 +0100 Subject: Fix T72470: OptiX render fails with scene with many translucent planes on Linux. OptiX always uses record-all behavior for transparent shadow rays, but did not check whether the maximum number of hits exceeded the shadow hit stack. This fixes that. --- intern/cycles/kernel/kernel_shadow.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'intern') diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h index b3ae29932da..07043e6a769 100644 --- a/intern/cycles/kernel/kernel_shadow.h +++ b/intern/cycles/kernel/kernel_shadow.h @@ -431,8 +431,13 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, if (state->transparent_bounce >= transparent_max_bounce) { return true; } - const uint max_hits = transparent_max_bounce - state->transparent_bounce - 1; -# if defined(__KERNEL_GPU__) && !defined(__KERNEL_OPTIX__) + uint max_hits = transparent_max_bounce - state->transparent_bounce - 1; +# if defined(__KERNEL_OPTIX__) + /* Always use record-all behavior in OptiX, but ensure there are no out of bounds + * accesses to the hit stack. + */ + max_hits = min(max_hits, SHADOW_STACK_MAX_HITS - 1); +# elif defined(__KERNEL_GPU__) /* On GPU we do tricky with tracing opaque ray first, this avoids speed * regressions in some files. * -- cgit v1.2.3