Cycles: optimize Sobol loop

Ref D5363
This commit is contained in:
Patrick Mours 2019-08-26 15:30:12 +02:00 committed by Brecht Van Lommel
parent 030a023eb2
commit 6055db084d
1 changed files with 3 additions and 4 deletions

View File

@ -41,10 +41,9 @@ ccl_device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
{
uint result = 0;
uint i = index + SOBOL_SKIP;
for (uint j = 0; i; i >>= 1, j++) {
if (i & 1) {
result ^= kernel_tex_fetch(__sobol_directions, 32 * dimension + j);
}
for (int j = 0, x; (x = find_first_set(i)); i >>= x) {
j += x;
result ^= kernel_tex_fetch(__sobol_directions, 32 * dimension + j - 1);
}
return result;
}