Commit b1d3bbfc by Nicolas Capens Committed by Nicolas Capens

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: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 5a5ffe52
......@@ -945,10 +945,13 @@ namespace sw
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
......
......@@ -725,10 +725,13 @@ namespace sw
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment