[Bf-blender-cvs] [3ec1684] master: Cycles: fix compilation on 32-bit Windows for half-floats

Sv. Lockal noreply at git.blender.org
Sun May 10 21:06:55 CEST 2015


Commit: 3ec168465d31c90cc75b5ea70de492dbeb4ac992
Author: Sv. Lockal
Date:   Sun May 10 19:04:24 2015 +0000
Branches: master
https://developer.blender.org/rB3ec168465d31c90cc75b5ea70de492dbeb4ac992

Cycles: fix compilation on 32-bit Windows for half-floats

Reported by IRC user HG1.

===================================================================

M	intern/cycles/util/util_half.h

===================================================================

diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h
index 9642f8e..f4bac98 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);




More information about the Bf-blender-cvs mailing list