Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2020-04-22 17:27:25 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-04-22 17:40:52 +0300
commitcf5147f69f0e3c650cf4aadd8515371ce61d27be (patch)
tree02e71ceddcf6e38c09afaba2741e69d9729fc8af /intern
parent138b0c970efbfb732ddee0530e073537582b6df8 (diff)
Fix T74423: Cycles rendering artifacts with CUDA 10.2
Work around what appears to be a compiler bug, just changing the code a bit without any functional changes.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/kernel/kernel_jitter.h39
-rw-r--r--intern/cycles/kernel/kernel_random.h4
2 files changed, 23 insertions, 20 deletions
diff --git a/intern/cycles/kernel/kernel_jitter.h b/intern/cycles/kernel/kernel_jitter.h
index 5b6e3bbf501..b9c48b86a5d 100644
--- a/intern/cycles/kernel/kernel_jitter.h
+++ b/intern/cycles/kernel/kernel_jitter.h
@@ -199,32 +199,33 @@ ccl_device float pmj_sample_1D(KernelGlobals *kg, int sample, int rng_hash, int
{
/* Fallback to random */
if (sample >= NUM_PMJ_SAMPLES) {
- int p = rng_hash + dimension;
+ const int p = rng_hash + dimension;
return cmj_randfloat(sample, p);
}
- uint tmp_rng = cmj_hash_simple(dimension, rng_hash);
- int index = ((dimension % NUM_PMJ_PATTERNS) * NUM_PMJ_SAMPLES + sample) * 2;
- return __uint_as_float(kernel_tex_fetch(__sample_pattern_lut, index) ^ (tmp_rng & 0x007fffff)) -
- 1.0f;
+ else {
+ const uint mask = cmj_hash_simple(dimension, rng_hash) & 0x007fffff;
+ const int index = ((dimension % NUM_PMJ_PATTERNS) * NUM_PMJ_SAMPLES + sample) * 2;
+ return __uint_as_float(kernel_tex_fetch(__sample_pattern_lut, index) ^ mask) - 1.0f;
+ }
}
-ccl_device void pmj_sample_2D(
- KernelGlobals *kg, int sample, int rng_hash, int dimension, float *fx, float *fy)
+ccl_device float2 pmj_sample_2D(KernelGlobals *kg, int sample, int rng_hash, int dimension)
{
if (sample >= NUM_PMJ_SAMPLES) {
- int p = rng_hash + dimension;
- *fx = cmj_randfloat(sample, p);
- *fy = cmj_randfloat(sample, p + 1);
- return;
+ const int p = rng_hash + dimension;
+ const float fx = cmj_randfloat(sample, p);
+ const float fy = cmj_randfloat(sample, p + 1);
+ return make_float2(fx, fy);
+ }
+ else {
+ const int index = ((dimension % NUM_PMJ_PATTERNS) * NUM_PMJ_SAMPLES + sample) * 2;
+ const uint maskx = cmj_hash_simple(dimension, rng_hash) & 0x007fffff;
+ const uint masky = cmj_hash_simple(dimension + 1, rng_hash) & 0x007fffff;
+ const float fx = __uint_as_float(kernel_tex_fetch(__sample_pattern_lut, index) ^ maskx) - 1.0f;
+ const float fy = __uint_as_float(kernel_tex_fetch(__sample_pattern_lut, index + 1) ^ masky) -
+ 1.0f;
+ return make_float2(fx, fy);
}
- uint tmp_rng = cmj_hash_simple(dimension, rng_hash);
- int index = ((dimension % NUM_PMJ_PATTERNS) * NUM_PMJ_SAMPLES + sample) * 2;
- *fx = __uint_as_float(kernel_tex_fetch(__sample_pattern_lut, index) ^ (tmp_rng & 0x007fffff)) -
- 1.0f;
- tmp_rng = cmj_hash_simple(dimension + 1, rng_hash);
- *fy = __uint_as_float(kernel_tex_fetch(__sample_pattern_lut, index + 1) ^
- (tmp_rng & 0x007fffff)) -
- 1.0f;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h
index f4c3b36e778..a9b17854f25 100644
--- a/intern/cycles/kernel/kernel_random.h
+++ b/intern/cycles/kernel/kernel_random.h
@@ -102,7 +102,9 @@ ccl_device_forceinline void path_rng_2D(KernelGlobals *kg,
return;
#endif
if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_PMJ) {
- pmj_sample_2D(kg, sample, rng_hash, dimension, fx, fy);
+ const float2 f = pmj_sample_2D(kg, sample, rng_hash, dimension);
+ *fx = f.x;
+ *fy = f.y;
return;
}
#ifdef __CMJ__