Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/util/math.h
| Show First 20 Lines • Show All 786 Lines • ▼ Show 20 Lines | |||||
| ccl_device float bits_to_01(uint bits) | ccl_device float bits_to_01(uint bits) | ||||
| { | { | ||||
| return bits * (1.0f / (float)0xFFFFFFFF); | return bits * (1.0f / (float)0xFFFFFFFF); | ||||
| } | } | ||||
| #if !defined(__KERNEL_GPU__) | #if !defined(__KERNEL_GPU__) | ||||
| # if defined(__GNUC__) | # if defined(__GNUC__) | ||||
| # define popcount(x) __builtin_popcount(x) | # define popcount(x) __builtin_popcount(x) | ||||
| # elif defined(_MSC_VER) && defined(__KERNEL_AVX__) | |||||
| # define popcount(x) _mm_popcnt_u32(x) | |||||
| # else | # else | ||||
| ccl_device_inline uint popcount(uint x) | ccl_device_inline uint popcount(uint x) | ||||
| { | { | ||||
| /* TODO(Stefan): pop-count intrinsic for Windows with fallback for older CPUs. */ | |||||
| uint i = x; | uint i = x; | ||||
| i = i - ((i >> 1) & 0x55555555); | i = i - ((i >> 1) & 0x55555555); | ||||
| i = (i & 0x33333333) + ((i >> 2) & 0x33333333); | i = (i & 0x33333333) + ((i >> 2) & 0x33333333); | ||||
| i = (((i + (i >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; | i = (((i + (i >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; | ||||
| return i; | return i; | ||||
| } | } | ||||
| # endif | # endif | ||||
| #elif defined(__KERNEL_ONEAPI__) | #elif defined(__KERNEL_ONEAPI__) | ||||
| ▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines | |||||