Blender
V4.5
intern
cycles
kernel
sample
lcg.h
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2
*
3
* SPDX-License-Identifier: Apache-2.0 */
4
5
#pragma once
6
7
#include "
util/hash.h
"
8
9
CCL_NAMESPACE_BEGIN
10
11
/* Linear Congruential Generator */
12
13
/* This is templated to handle multiple address spaces on Metal. */
14
template
<
class
T>
ccl_device
uint
lcg_step_uint
(
T
rng)
15
{
16
/* implicit mod 2^32 */
17
*rng = (1103515245 * (*rng) + 12345);
18
return
*rng;
19
}
20
21
/* This is templated to handle multiple address spaces on Metal. */
22
template
<
class
T>
ccl_device
float
lcg_step_float
(
T
rng)
23
{
24
/* implicit mod 2^32 */
25
*rng = (1103515245 * (*rng) + 12345);
26
return
(
float
)*rng * (1.0f / (float)0xFFFFFFFF);
27
}
28
29
ccl_device
uint
lcg_init
(
const
uint
seed
)
30
{
31
uint
rng =
seed
;
32
lcg_step_uint
(&rng);
33
return
rng;
34
}
35
36
ccl_device_inline
uint
lcg_state_init
(
const
uint
rng_hash,
37
const
uint
rng_offset,
38
const
uint
sample
,
39
const
uint
scramble)
40
{
41
return
hash_uint3
(rng_hash ^ scramble, rng_offset,
sample
);
42
}
43
44
CCL_NAMESPACE_END
uint
unsigned int uint
Definition
BLI_sys_types.h:64
seed
static unsigned long seed
Definition
btSoftBody.h:39
ccl_device
#define ccl_device
ccl_device_inline
#define ccl_device_inline
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
hash.h
hash_uint3
ccl_device_inline uint hash_uint3(const uint kx, const uint ky, const uint kz)
Definition
hash.h:104
sample
uint sample
Definition
kernel/device/gpu/kernel.h:97
lcg_step_uint
CCL_NAMESPACE_BEGIN ccl_device uint lcg_step_uint(T rng)
Definition
lcg.h:14
lcg_state_init
ccl_device_inline uint lcg_state_init(const uint rng_hash, const uint rng_offset, const uint sample, const uint scramble)
Definition
lcg.h:36
lcg_init
ccl_device uint lcg_init(const uint seed)
Definition
lcg.h:29
lcg_step_float
ccl_device float lcg_step_float(T rng)
Definition
lcg.h:22
T
#define T
Definition
mball_tessellate.cc:274
CCL_NAMESPACE_BEGIN
Definition
python.cpp:37
Generated on
for Blender by
doxygen
1.16.1