Fix non-float constant creation for ASM

Despite the name, PARAMETER_FLOAT4LITERAL is used for integer and
Boolean constants in the ASM representation of GLSL compiled shaders.
Reactor can turn sNaN values into qNan when constructing Float
constants, and thus integers bitcast from a float which were initialized
from a reinterpreted integer may not preserve its original bit pattern.

Instead construct the Float register values from Reactor Ints which are
bitcast to Float.

Bug: b/140302841
Change-Id: I4d915851c430dee4a752e06be0011c10d89fb79d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/35888
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Shader/PixelProgram.cpp b/src/Shader/PixelProgram.cpp
index 1644c06..46f87c2 100644
--- a/src/Shader/PixelProgram.cpp
+++ b/src/Shader/PixelProgram.cpp
@@ -945,10 +945,13 @@
 		case Shader::PARAMETER_PREDICATE:   return reg; // Dummy
 		case Shader::PARAMETER_VOID:        return reg; // Dummy
 		case Shader::PARAMETER_FLOAT4LITERAL:
-			reg.x = Float4(src.value[0]);
-			reg.y = Float4(src.value[1]);
-			reg.z = Float4(src.value[2]);
-			reg.w = Float4(src.value[3]);
+			// This is used for all literal types, and since Reactor doesn't guarantee
+			// preserving the bit pattern of float constants, we must construct them
+			// as integer constants and bitcast.
+			reg.x = As<Float4>(Int4(src.integer[0]));
+			reg.y = As<Float4>(Int4(src.integer[1]));
+			reg.z = As<Float4>(Int4(src.integer[2]));
+			reg.w = As<Float4>(Int4(src.integer[3]));
 			break;
 		case Shader::PARAMETER_CONSTINT:    return reg; // Dummy
 		case Shader::PARAMETER_CONSTBOOL:   return reg; // Dummy
diff --git a/src/Shader/VertexProgram.cpp b/src/Shader/VertexProgram.cpp
index b3f81a0..ca0a24a 100644
--- a/src/Shader/VertexProgram.cpp
+++ b/src/Shader/VertexProgram.cpp
@@ -725,10 +725,13 @@
 			break;
 		case Shader::PARAMETER_VOID: return r[0];   // Dummy
 		case Shader::PARAMETER_FLOAT4LITERAL:
-			reg.x = Float4(src.value[0]);
-			reg.y = Float4(src.value[1]);
-			reg.z = Float4(src.value[2]);
-			reg.w = Float4(src.value[3]);
+			// This is used for all literal types, and since Reactor doesn't guarantee
+			// preserving the bit pattern of float constants, we must construct them
+			// as integer constants and bitcast.
+			reg.x = As<Float4>(Int4(src.integer[0]));
+			reg.y = As<Float4>(Int4(src.integer[1]));
+			reg.z = As<Float4>(Int4(src.integer[2]));
+			reg.w = As<Float4>(Int4(src.integer[3]));
 			break;
 		case Shader::PARAMETER_ADDR:      reg = a0; break;
 		case Shader::PARAMETER_CONSTBOOL: return r[0];   // Dummy