Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/sample/lcg.h
| Show All 13 Lines | |||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #pragma once | #pragma once | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Linear Congruential Generator */ | /* Linear Congruential Generator */ | ||||
| ccl_device uint lcg_step_uint(uint *rng) | /* This is templated to handle multiple address spaces on Metal. */ | ||||
| template<class T> ccl_device uint lcg_step_uint(T rng) | |||||
| { | { | ||||
| /* implicit mod 2^32 */ | /* implicit mod 2^32 */ | ||||
| *rng = (1103515245 * (*rng) + 12345); | *rng = (1103515245 * (*rng) + 12345); | ||||
| return *rng; | return *rng; | ||||
| } | } | ||||
| ccl_device float lcg_step_float(uint *rng) | /* This is templated to handle multiple address spaces on Metal. */ | ||||
| template<class T> ccl_device float lcg_step_float(T rng) | |||||
| { | { | ||||
| /* implicit mod 2^32 */ | /* implicit mod 2^32 */ | ||||
| *rng = (1103515245 * (*rng) + 12345); | *rng = (1103515245 * (*rng) + 12345); | ||||
| return (float)*rng * (1.0f / (float)0xFFFFFFFF); | return (float)*rng * (1.0f / (float)0xFFFFFFFF); | ||||
| } | } | ||||
| ccl_device uint lcg_init(uint seed) | ccl_device uint lcg_init(uint seed) | ||||
| { | { | ||||
| Show All 14 Lines | |||||