Commit 9b62c5ea by Ben Clayton Committed by Ben Clayton

SpirvShader: Replace Intermediate::operator[] with typed getters.

Simplifies things throughout the cpp. Bug: b/128539387 Change-Id: I7abbe4731d82877204976d654859cba88d1a3047 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26531Tested-by: 's avatarBen Clayton <headlessclayton@gmail.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 093be46a
......@@ -98,13 +98,16 @@ namespace sw
void emplace(uint32_t n, const RValue<SIMD::Int>& value) { emplace(n, As<SIMD::Float>(value)); }
void emplace(uint32_t n, const RValue<SIMD::UInt>& value) { emplace(n, As<SIMD::Float>(value)); }
Scalar const & operator[](uint32_t n) const
// Value retrieval functions.
RValue<SIMD::Float> Float(uint32_t i) const
{
ASSERT(n < size);
auto scalar = reinterpret_cast<Scalar const *>(&contents[n]);
ASSERT(i < size);
auto scalar = reinterpret_cast<Scalar const *>(&contents[i]);
ASSERT(scalar->value != nullptr);
return *scalar;
}
RValue<SIMD::Int> Int(uint32_t i) const { return As<SIMD::Int>(Float(i)); }
RValue<SIMD::UInt> UInt(uint32_t i) const { return As<SIMD::UInt>(Float(i)); }
// No copy/move construction or assignment
Intermediate(Intermediate const &) = delete;
......@@ -536,14 +539,25 @@ namespace sw
obj(shader->getObject(objId)),
intermediate(obj.kind == SpirvShader::Object::Kind::Value ? &routine->getIntermediate(objId) : nullptr) {}
RValue<SIMD::Float> operator[](uint32_t i) const
RValue<SIMD::Float> Float(uint32_t i) const
{
if (intermediate)
return (*intermediate)[i];
if (intermediate != nullptr)
{
return intermediate->Float(i);
}
auto constantValue = reinterpret_cast<float *>(obj.constantValue.get());
return RValue<SIMD::Float>(constantValue[i]);
}
RValue<SIMD::Int> Int(uint32_t i) const
{
return As<SIMD::Int>(Float(i));
}
RValue<SIMD::UInt> UInt(uint32_t i) const
{
return As<SIMD::UInt>(Float(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