Don't use bitcast+float path for integer constant values
LLVM takes liberties with NaN float constants, which can arise in integer
constant values.
Bug b/140294254
Test: dEQP-VK.spirv_assembly.type.vec3.u32.constant_composite_frag
Change-Id: Ibfff77b9e0bacf81756bb50801615369dfc51ab6
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/35728
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp
index 4c5c2b5..0cc4373 100644
--- a/src/Pipeline/SpirvShader.hpp
+++ b/src/Pipeline/SpirvShader.hpp
@@ -1101,17 +1101,27 @@
return intermediate->Float(i);
}
auto constantValue = reinterpret_cast<float *>(obj.constantValue.get());
- return RValue<SIMD::Float>(constantValue[i]);
+ return SIMD::Float(constantValue[i]);
}
RValue<SIMD::Int> Int(uint32_t i) const
{
- return As<SIMD::Int>(Float(i));
+ if (intermediate != nullptr)
+ {
+ return intermediate->Int(i);
+ }
+ auto constantValue = reinterpret_cast<int *>(obj.constantValue.get());
+ return SIMD::Int(constantValue[i]);
}
RValue<SIMD::UInt> UInt(uint32_t i) const
{
- return As<SIMD::UInt>(Float(i));
+ if (intermediate != nullptr)
+ {
+ return intermediate->UInt(i);
+ }
+ auto constantValue = reinterpret_cast<uint32_t *>(obj.constantValue.get());
+ return SIMD::UInt(constantValue[i]);
}
SpirvShader::Type::ID const type;