forked from bartvdbraak/blender
Code cleanup: remove unused Cycles random number code.
This commit is contained in:
parent
6919393a51
commit
601f94a3c2
@ -825,8 +825,6 @@ ccl_device void kernel_path_trace(KernelGlobals *kg,
|
|||||||
else {
|
else {
|
||||||
kernel_write_result(kg, buffer, sample, NULL, 0.0f, false);
|
kernel_write_result(kg, buffer, sample, NULL, 0.0f, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
path_rng_end(kg, rng_state, rng);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __SPLIT_KERNEL__ */
|
#endif /* __SPLIT_KERNEL__ */
|
||||||
|
@ -673,8 +673,6 @@ ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
|
|||||||
else {
|
else {
|
||||||
kernel_write_result(kg, buffer, sample, NULL, 0.0f, false);
|
kernel_write_result(kg, buffer, sample, NULL, 0.0f, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
path_rng_end(kg, rng_state, rng);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __SPLIT_KERNEL__ */
|
#endif /* __SPLIT_KERNEL__ */
|
||||||
|
@ -28,42 +28,6 @@ CCL_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
/* High Dimensional Sobol. */
|
/* High Dimensional Sobol. */
|
||||||
|
|
||||||
/* Van der Corput radical inverse. */
|
|
||||||
ccl_device uint van_der_corput(uint bits)
|
|
||||||
{
|
|
||||||
bits = (bits << 16) | (bits >> 16);
|
|
||||||
bits = ((bits & 0x00ff00ff) << 8) | ((bits & 0xff00ff00) >> 8);
|
|
||||||
bits = ((bits & 0x0f0f0f0f) << 4) | ((bits & 0xf0f0f0f0) >> 4);
|
|
||||||
bits = ((bits & 0x33333333) << 2) | ((bits & 0xcccccccc) >> 2);
|
|
||||||
bits = ((bits & 0x55555555) << 1) | ((bits & 0xaaaaaaaa) >> 1);
|
|
||||||
return bits;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sobol radical inverse. */
|
|
||||||
ccl_device uint sobol(uint i)
|
|
||||||
{
|
|
||||||
uint r = 0;
|
|
||||||
for(uint v = 1U << 31; i; i >>= 1, v ^= v >> 1) {
|
|
||||||
if(i & 1) {
|
|
||||||
r ^= v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Inverse of sobol radical inverse. */
|
|
||||||
ccl_device uint sobol_inverse(uint i)
|
|
||||||
{
|
|
||||||
const uint msb = 1U << 31;
|
|
||||||
uint r = 0;
|
|
||||||
for(uint v = 1; i; i <<= 1, v ^= v << 1) {
|
|
||||||
if(i & msb) {
|
|
||||||
r ^= v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Multidimensional sobol with generator matrices
|
/* Multidimensional sobol with generator matrices
|
||||||
* dimension 0 and 1 are equal to van_der_corput() and sobol() respectively.
|
* dimension 0 and 1 are equal to van_der_corput() and sobol() respectively.
|
||||||
*/
|
*/
|
||||||
@ -79,31 +43,6 @@ ccl_device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lookup index and x/y coordinate, assumes m is a power of two. */
|
|
||||||
ccl_device uint sobol_lookup(const uint m,
|
|
||||||
const uint frame,
|
|
||||||
const uint ex,
|
|
||||||
const uint ey,
|
|
||||||
uint *x, uint *y)
|
|
||||||
{
|
|
||||||
/* Shift is constant per frame. */
|
|
||||||
const uint shift = frame << (m << 1);
|
|
||||||
const uint sobol_shift = sobol(shift);
|
|
||||||
/* Van der Corput is its own inverse. */
|
|
||||||
const uint lower = van_der_corput(ex << (32 - m));
|
|
||||||
/* Need to compensate for ey difference and shift. */
|
|
||||||
const uint sobol_lower = sobol(lower);
|
|
||||||
const uint mask = ~-(1 << m) << (32 - m); /* Only m upper bits. */
|
|
||||||
const uint delta = ((ey << (32 - m)) ^ sobol_lower ^ sobol_shift) & mask;
|
|
||||||
/* Only use m upper bits for the index (m is a power of two). */
|
|
||||||
const uint sobol_result = delta | (delta >> m);
|
|
||||||
const uint upper = sobol_inverse(sobol_result);
|
|
||||||
const uint index = shift | upper | lower;
|
|
||||||
*x = van_der_corput(index);
|
|
||||||
*y = sobol_shift ^ sobol_result ^ sobol_lower;
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
|
ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
|
||||||
RNG *rng,
|
RNG *rng,
|
||||||
int sample, int num_samples,
|
int sample, int num_samples,
|
||||||
@ -117,11 +56,6 @@ ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __SOBOL_FULL_SCREEN__
|
|
||||||
uint result = sobol_dimension(kg, *rng, dimension);
|
|
||||||
float r = (float)result * (1.0f/(float)0xFFFFFFFF);
|
|
||||||
return r;
|
|
||||||
#else
|
|
||||||
/* Compute sobol sequence value using direction vectors. */
|
/* Compute sobol sequence value using direction vectors. */
|
||||||
uint result = sobol_dimension(kg, sample + SOBOL_SKIP, dimension);
|
uint result = sobol_dimension(kg, sample + SOBOL_SKIP, dimension);
|
||||||
float r = (float)result * (1.0f/(float)0xFFFFFFFF);
|
float r = (float)result * (1.0f/(float)0xFFFFFFFF);
|
||||||
@ -136,7 +70,6 @@ ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
|
|||||||
shift = tmp_rng * (1.0f/(float)0xFFFFFFFF);
|
shift = tmp_rng * (1.0f/(float)0xFFFFFFFF);
|
||||||
|
|
||||||
return r + shift - floorf(r + shift);
|
return r + shift - floorf(r + shift);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device_forceinline void path_rng_2D(KernelGlobals *kg,
|
ccl_device_forceinline void path_rng_2D(KernelGlobals *kg,
|
||||||
@ -167,25 +100,6 @@ ccl_device_inline void path_rng_init(KernelGlobals *kg,
|
|||||||
int x, int y,
|
int x, int y,
|
||||||
float *fx, float *fy)
|
float *fx, float *fy)
|
||||||
{
|
{
|
||||||
#ifdef __SOBOL_FULL_SCREEN__
|
|
||||||
uint px, py;
|
|
||||||
uint bits = 16; /* limits us to 65536x65536 and 65536 samples */
|
|
||||||
uint size = 1 << bits;
|
|
||||||
uint frame = sample;
|
|
||||||
|
|
||||||
*rng = sobol_lookup(bits, frame, x, y, &px, &py);
|
|
||||||
|
|
||||||
*rng ^= kernel_data.integrator.seed;
|
|
||||||
|
|
||||||
if(sample == 0) {
|
|
||||||
*fx = 0.5f;
|
|
||||||
*fy = 0.5f;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
*fx = size * (float)px * (1.0f/(float)0xFFFFFFFF) - x;
|
|
||||||
*fy = size * (float)py * (1.0f/(float)0xFFFFFFFF) - y;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
*rng = *rng_state;
|
*rng = *rng_state;
|
||||||
|
|
||||||
*rng ^= kernel_data.integrator.seed;
|
*rng ^= kernel_data.integrator.seed;
|
||||||
@ -197,28 +111,19 @@ ccl_device_inline void path_rng_init(KernelGlobals *kg,
|
|||||||
else {
|
else {
|
||||||
path_rng_2D(kg, rng, sample, num_samples, PRNG_FILTER_U, fx, fy);
|
path_rng_2D(kg, rng, sample, num_samples, PRNG_FILTER_U, fx, fy);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
ccl_device void path_rng_end(KernelGlobals *kg,
|
|
||||||
ccl_global uint *rng_state,
|
|
||||||
RNG rng)
|
|
||||||
{
|
|
||||||
/* nothing to do */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* __SOBOL__ */
|
#else /* __SOBOL__ */
|
||||||
|
|
||||||
/* Linear Congruential Generator */
|
/* Pseudo random numbers, use this only on the CPU with a single thread
|
||||||
|
* for debugging correlations. */
|
||||||
|
|
||||||
ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
|
ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
|
||||||
RNG *rng,
|
RNG *rng,
|
||||||
int sample, int num_samples,
|
int sample, int num_samples,
|
||||||
int dimension)
|
int dimension)
|
||||||
{
|
{
|
||||||
/* implicit mod 2^32 */
|
return (float)drand48();
|
||||||
*rng = (1103515245*(*rng) + 12345);
|
|
||||||
return (float)*rng * (1.0f/(float)0xFFFFFFFF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device_inline void path_rng_2D(KernelGlobals *kg,
|
ccl_device_inline void path_rng_2D(KernelGlobals *kg,
|
||||||
@ -227,8 +132,8 @@ ccl_device_inline void path_rng_2D(KernelGlobals *kg,
|
|||||||
int dimension,
|
int dimension,
|
||||||
float *fx, float *fy)
|
float *fx, float *fy)
|
||||||
{
|
{
|
||||||
*fx = path_rng_1D(kg, rng, sample, num_samples, dimension);
|
*fx = (float)drand48();
|
||||||
*fy = path_rng_1D(kg, rng, sample, num_samples, dimension + 1);
|
*fy = (float)drand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device void path_rng_init(KernelGlobals *kg,
|
ccl_device void path_rng_init(KernelGlobals *kg,
|
||||||
@ -240,9 +145,10 @@ ccl_device void path_rng_init(KernelGlobals *kg,
|
|||||||
{
|
{
|
||||||
/* load state */
|
/* load state */
|
||||||
*rng = *rng_state;
|
*rng = *rng_state;
|
||||||
|
|
||||||
*rng ^= kernel_data.integrator.seed;
|
*rng ^= kernel_data.integrator.seed;
|
||||||
|
|
||||||
|
srand48(*rng);
|
||||||
|
|
||||||
if(sample == 0) {
|
if(sample == 0) {
|
||||||
*fx = 0.5f;
|
*fx = 0.5f;
|
||||||
*fy = 0.5f;
|
*fy = 0.5f;
|
||||||
@ -252,14 +158,6 @@ ccl_device void path_rng_init(KernelGlobals *kg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device void path_rng_end(KernelGlobals *kg,
|
|
||||||
ccl_global uint *rng_state,
|
|
||||||
RNG rng)
|
|
||||||
{
|
|
||||||
/* store state for next sample */
|
|
||||||
*rng_state = rng;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __SOBOL__ */
|
#endif /* __SOBOL__ */
|
||||||
|
|
||||||
/* Linear Congruential Generator */
|
/* Linear Congruential Generator */
|
||||||
|
@ -119,8 +119,6 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
|
|||||||
bool is_shadow_catcher = (state->flag & PATH_RAY_SHADOW_CATCHER);
|
bool is_shadow_catcher = (state->flag & PATH_RAY_SHADOW_CATCHER);
|
||||||
kernel_write_result(kg, buffer, sample, L, 1.0f - (*L_transparent), is_shadow_catcher);
|
kernel_write_result(kg, buffer, sample, L, 1.0f - (*L_transparent), is_shadow_catcher);
|
||||||
|
|
||||||
path_rng_end(kg, rng_state, rng);
|
|
||||||
|
|
||||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
|
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +167,6 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
|
|||||||
float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
|
float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
/* Accumulate result in output buffer. */
|
/* Accumulate result in output buffer. */
|
||||||
kernel_write_pass_float4(buffer, sample, L_rad);
|
kernel_write_pass_float4(buffer, sample, L_rad);
|
||||||
path_rng_end(kg, rng_state, rng);
|
|
||||||
|
|
||||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
|
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,6 @@ ccl_device void kernel_path_init(KernelGlobals *kg) {
|
|||||||
float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
|
float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
/* Accumulate result in output buffer. */
|
/* Accumulate result in output buffer. */
|
||||||
kernel_write_pass_float4(buffer, my_sample, L_rad);
|
kernel_write_pass_float4(buffer, my_sample, L_rad);
|
||||||
path_rng_end(kg, rng_state, kernel_split_state.rng[ray_index]);
|
|
||||||
ASSIGN_RAY_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE);
|
ASSIGN_RAY_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE);
|
||||||
}
|
}
|
||||||
kernel_split_state.rng[ray_index] = rng;
|
kernel_split_state.rng[ray_index] = rng;
|
||||||
|
Loading…
Reference in New Issue
Block a user