Commit 10a900e5 by Chris Forbes

Add assert in GenericValue constant access

While debugging the 1.2.1 dEQP-VK.graphicsfuzz.* tests, noticed a crash here where a non-constant failed to have its intermediate pointer set. An assert here is clearer than exploding. Bug: b/146653181 Change-Id: I23aae701edce1595cd145930d304c9f6e4b82924 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39808Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
parent 59465799
......@@ -950,6 +950,7 @@ private:
// Constructing a constant SIMD::Float is not guaranteed to preserve the data's exact
// bit pattern, but SPIR-V provides 32-bit words representing "the bit pattern for the constant".
// Thus we must first construct an integer constant, and bitcast to float.
ASSERT(obj.kind == SpirvShader::Object::Kind::Constant);
auto constantValue = reinterpret_cast<uint32_t *>(obj.constantValue.get());
return As<SIMD::Float>(SIMD::UInt(constantValue[i]));
}
......@@ -960,6 +961,7 @@ private:
{
return intermediate->Int(i);
}
ASSERT(obj.kind == SpirvShader::Object::Kind::Constant);
auto constantValue = reinterpret_cast<int *>(obj.constantValue.get());
return SIMD::Int(constantValue[i]);
}
......@@ -970,6 +972,7 @@ private:
{
return intermediate->UInt(i);
}
ASSERT(obj.kind == SpirvShader::Object::Kind::Constant);
auto constantValue = reinterpret_cast<uint32_t *>(obj.constantValue.get());
return SIMD::UInt(constantValue[i]);
}
......
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