Commit 16ab9e9d by Ben Clayton

SpirvShader: Add type field to GenericValue

It's quite common to want the object and the type. Fix up these cases. Avoids a second Object lookup. Change-Id: Ied1ae0c8d264cfe6c6ff3603d0d096bf9f657b84 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28468 Presubmit-Ready: Ben Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 3ed8ba0c
......@@ -2192,7 +2192,7 @@ namespace sw
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto lhs = GenericValue(this, routine, insn.word(3));
auto rhs = GenericValue(this, routine, insn.word(4));
auto rhsType = getType(getObject(insn.word(4)).type);
auto rhsType = getType(rhs.type);
for (auto i = 0u; i < type.sizeInComponents; i++)
{
......@@ -2214,7 +2214,7 @@ namespace sw
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto lhs = GenericValue(this, routine, insn.word(3));
auto rhs = GenericValue(this, routine, insn.word(4));
auto lhsType = getType(getObject(insn.word(3)).type);
auto lhsType = getType(lhs.type);
for (auto i = 0u; i < type.sizeInComponents; i++)
{
......@@ -3003,7 +3003,7 @@ namespace sw
auto falseBlockId = Block::ID(block.branchInstruction.word(3));
auto cond = GenericValue(this, state->routine, condId);
ASSERT_MSG(getType(getObject(condId).type).sizeInComponents == 1, "Condition must be a Boolean type scalar");
ASSERT_MSG(getType(cond.type).sizeInComponents == 1, "Condition must be a Boolean type scalar");
// TODO: Optimize for case where all lanes take same path.
......@@ -3021,7 +3021,7 @@ namespace sw
auto selId = Object::ID(block.branchInstruction.word(1));
auto sel = GenericValue(this, state->routine, selId);
ASSERT_MSG(getType(getObject(selId).type).sizeInComponents == 1, "Selector must be a scalar");
ASSERT_MSG(getType(sel.type).sizeInComponents == 1, "Selector must be a scalar");
auto numCases = (block.branchInstruction.wordCount() - 3) / 2;
......
......@@ -766,7 +766,8 @@ namespace sw
public:
GenericValue(SpirvShader const *shader, SpirvRoutine const *routine, SpirvShader::Object::ID objId) :
obj(shader->getObject(objId)),
intermediate(obj.kind == SpirvShader::Object::Kind::Intermediate ? &routine->getIntermediate(objId) : nullptr) {}
intermediate(obj.kind == SpirvShader::Object::Kind::Intermediate ? &routine->getIntermediate(objId) : nullptr),
type(obj.type) {}
RValue<SIMD::Float> Float(uint32_t i) const
{
......@@ -787,6 +788,8 @@ namespace sw
{
return As<SIMD::UInt>(Float(i));
}
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