diff options
author | Sv. Lockal <lockalsash@gmail.com> | 2015-05-10 22:04:24 +0300 |
---|---|---|
committer | Sv. Lockal <lockalsash@gmail.com> | 2015-05-10 22:06:43 +0300 |
commit | 3ec168465d31c90cc75b5ea70de492dbeb4ac992 (patch) | |
tree | b906d413b92eef99a20aa7684d168af75fa40707 /intern | |
parent | c20c07f27a5f5497db219e5c0db8c9cc2377e37a (diff) |
Cycles: fix compilation on 32-bit Windows for half-floats
Reported by IRC user HG1.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/util/util_half.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h index 9642f8ed523..f4bac9888a5 100644 --- a/intern/cycles/util/util_half.h +++ b/intern/cycles/util/util_half.h @@ -54,10 +54,12 @@ ccl_device_inline void float4_store_half(half *h, float4 f, float scale) for(int i = 0; i < 4; i++) { /* optimized float to half for pixels: * assumes no negative, no nan, no inf, and sets denormal to 0 */ + union { uint i; float f; } in; float fscale = f[i] * scale; - float x = min(max(fscale, 0.0f), 65504.0f); + in.f = (fscale > 0.0f)? ((fscale < 65504.0f)? fscale: 65504.0f): 0.0f; + int x = in.i; - int absolute = __float_as_uint(in) & 0x7FFFFFFF; + int absolute = x & 0x7FFFFFFF; int Z = absolute + 0xC8000000; int result = (absolute < 0x38800000)? 0: Z; int rshift = (result >> 13); |