Commit ac69da70 by Chris Forbes

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: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 6d684b4c
...@@ -1101,17 +1101,27 @@ namespace sw ...@@ -1101,17 +1101,27 @@ namespace sw
return intermediate->Float(i); return intermediate->Float(i);
} }
auto constantValue = reinterpret_cast<float *>(obj.constantValue.get()); 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 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 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; SpirvShader::Type::ID const type;
......
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