Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/sample/pattern.h
| Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| ccl_device_inline bool sample_is_even(int pattern, int sample) | ccl_device_inline bool sample_is_even(int pattern, int sample) | ||||
| { | { | ||||
| if (pattern == SAMPLING_PATTERN_PMJ) { | if (pattern == SAMPLING_PATTERN_PMJ) { | ||||
| /* See Section 10.2.1, "Progressive Multi-Jittered Sample Sequences", Christensen et al. | /* See Section 10.2.1, "Progressive Multi-Jittered Sample Sequences", Christensen et al. | ||||
| * We can use this to get divide sample sequence into two classes for easier variance | * We can use this to get divide sample sequence into two classes for easier variance | ||||
| * estimation. */ | * estimation. */ | ||||
| #if defined(__GNUC__) && !defined(__KERNEL_GPU__) | return popcount(uint(sample) & 0xaaaaaaaa) & 1; | ||||
| return __builtin_popcount(sample & 0xaaaaaaaa) & 1; | |||||
| #elif defined(__NVCC__) | |||||
| return __popc(sample & 0xaaaaaaaa) & 1; | |||||
| #else | |||||
| /* TODO(Stefan): pop-count intrinsic for Windows with fallback for older CPUs. */ | |||||
| int i = sample & 0xaaaaaaaa; | |||||
| i = i - ((i >> 1) & 0x55555555); | |||||
| i = (i & 0x33333333) + ((i >> 2) & 0x33333333); | |||||
| i = (((i + (i >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; | |||||
| return i & 1; | |||||
| #endif | |||||
| } | } | ||||
| else { | else { | ||||
| /* TODO(Stefan): Are there reliable ways of dividing CMJ and Sobol into two classes? */ | /* TODO(Stefan): Are there reliable ways of dividing CMJ and Sobol into two classes? */ | ||||
| return sample & 0x1; | return sample & 0x1; | ||||
| } | } | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||