Commit 2b287cc1 by Chris Forbes

Add support for OpDot

Bug: b/126873455 Change-Id: Ibe76dc02ab22903f1ad2d00685cd1855aaeb3338 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/25968Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent e86b6dcc
......@@ -235,6 +235,7 @@ namespace sw
case spv::OpLogicalAnd:
case spv::OpUMulExtended:
case spv::OpSMulExtended:
case spv::OpDot:
// Instructions that yield an intermediate value
{
TypeID typeId = insn.word(1);
......@@ -914,6 +915,10 @@ namespace sw
EmitBinaryOp(insn, routine);
break;
case spv::OpDot:
EmitDot(insn, routine);
break;
default:
printf("emit: ignoring opcode %s\n", OpcodeName(insn.opcode()).c_str());
break;
......@@ -1279,6 +1284,25 @@ namespace sw
}
}
void SpirvShader::EmitDot(InsnIterator insn, SpirvRoutine *routine) const
{
auto &type = getType(insn.word(1));
assert(type.sizeInComponents == 1);
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto &lhsType = getType(getObject(insn.word(3)).type);
auto srcLHS = GenericValue(this, routine, insn.word(3));
auto srcRHS = GenericValue(this, routine, insn.word(4));
SIMD::Float result = srcLHS[0] * srcRHS[0];
for (auto i = 1u; i < lhsType.sizeInComponents; i++)
{
result += srcLHS[i] * srcRHS[i];
}
dst.emplace(0, result);
}
void SpirvShader::emitEpilog(SpirvRoutine *routine) const
{
for (auto insn : *this)
......
......@@ -402,6 +402,7 @@ namespace sw
void EmitVectorShuffle(InsnIterator insn, SpirvRoutine *routine) const;
void EmitUnaryOp(InsnIterator insn, SpirvRoutine *routine) const;
void EmitBinaryOp(InsnIterator insn, SpirvRoutine *routine) const;
void EmitDot(InsnIterator insn, SpirvRoutine *routine) const;
// OpcodeName returns the name of the opcode op.
// If NDEBUG is defined, then OpcodeName will only return the numerical code.
......
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