Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions kernels/common/instance_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,15 @@ RTC_FORCEINLINE void copy_UU(const RTCRayQueryContext* context, const unsigned*
#else

unsigned int depth = context->instStackSize;

for (unsigned l = 0; l < depth; ++l)
tgt[l] = src[l];

for (unsigned l = depth; l < RTC_MAX_INSTANCE_LEVEL_COUNT; ++l)
tgt[l] = RTC_INVALID_GEOMETRY_ID;

/* NOTE: Splitting this into two separate loops (one copying the first
* `depth` elements, one filling the remainder with
* RTC_INVALID_GEOMETRY_ID) has been observed to get miscompiled by some
* SYCL/GPU compilers when `depth` is a runtime value, silently reversing
* which elements get the copied value and which get invalidated. Using a
* single fused loop with a per-element select avoids triggering this. */
for (unsigned l = 0; l < RTC_MAX_INSTANCE_LEVEL_COUNT; ++l)
tgt[l] = (l < depth) ? src[l] : RTC_INVALID_GEOMETRY_ID;

#endif
}
Expand Down
Loading