Commit faed9d31 by Chris Forbes

Add support for OpVectorInsertDynamic, OpVectorExtractDynamic

Bug: b/126873455 Tests: dEQP-VK.spirv_assembly.* Change-Id: I8b6b6329b37469b9779178488f96fc62c341997b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27308Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 71673c81
...@@ -312,6 +312,9 @@ namespace sw ...@@ -312,6 +312,9 @@ namespace sw
case spv::OpCompositeInsert: case spv::OpCompositeInsert:
case spv::OpCompositeExtract: case spv::OpCompositeExtract:
case spv::OpVectorShuffle: case spv::OpVectorShuffle:
case spv::OpVectorTimesScalar:
case spv::OpVectorExtractDynamic:
case spv::OpVectorInsertDynamic:
case spv::OpNot: // Unary ops case spv::OpNot: // Unary ops
case spv::OpSNegate: case spv::OpSNegate:
case spv::OpFNegate: case spv::OpFNegate:
...@@ -374,7 +377,6 @@ namespace sw ...@@ -374,7 +377,6 @@ namespace sw
case spv::OpIsNan: case spv::OpIsNan:
case spv::OpAny: case spv::OpAny:
case spv::OpAll: case spv::OpAll:
case spv::OpVectorTimesScalar:
// Instructions that yield an intermediate value // Instructions that yield an intermediate value
{ {
Type::ID typeId = insn.word(1); Type::ID typeId = insn.word(1);
...@@ -1100,6 +1102,14 @@ namespace sw ...@@ -1100,6 +1102,14 @@ namespace sw
EmitVectorShuffle(insn, routine); EmitVectorShuffle(insn, routine);
break; break;
case spv::OpVectorExtractDynamic:
EmitVectorExtractDynamic(insn, routine);
break;
case spv::OpVectorInsertDynamic:
EmitVectorInsertDynamic(insn, routine);
break;
case spv::OpVectorTimesScalar: case spv::OpVectorTimesScalar:
EmitVectorTimesScalar(insn, routine); EmitVectorTimesScalar(insn, routine);
break; break;
...@@ -1544,6 +1554,41 @@ namespace sw ...@@ -1544,6 +1554,41 @@ namespace sw
} }
} }
void SpirvShader::EmitVectorExtractDynamic(sw::SpirvShader::InsnIterator insn, sw::SpirvRoutine *routine) const
{
auto &type = getType(insn.word(1));
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto &srcType = getType(getObject(insn.word(3)).type);
GenericValue src(this, routine, insn.word(3));
GenericValue index(this, routine, insn.word(4));
SIMD::UInt v = SIMD::UInt(0);
for (auto i = 0u; i < srcType.sizeInComponents; i++)
{
v |= CmpEQ(index.UInt(0), SIMD::UInt(i)) & src.UInt(i);
}
dst.emplace(0, v);
}
void SpirvShader::EmitVectorInsertDynamic(sw::SpirvShader::InsnIterator insn, sw::SpirvRoutine *routine) const
{
auto &type = getType(insn.word(1));
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
GenericValue src(this, routine, insn.word(3));
GenericValue component(this, routine, insn.word(4));
GenericValue index(this, routine, insn.word(5));
for (auto i = 0u; i < type.sizeInComponents; i++)
{
SIMD::UInt mask = CmpEQ(SIMD::UInt(i), index.UInt(0));
dst.emplace(i, (src.UInt(i) & ~mask) | (component.UInt(0) & mask));
}
}
void SpirvShader::EmitVectorTimesScalar(InsnIterator insn, SpirvRoutine *routine) const void SpirvShader::EmitVectorTimesScalar(InsnIterator insn, SpirvRoutine *routine) const
{ {
auto &type = getType(insn.word(1)); auto &type = getType(insn.word(1));
......
...@@ -484,6 +484,8 @@ namespace sw ...@@ -484,6 +484,8 @@ namespace sw
void EmitCompositeExtract(InsnIterator insn, SpirvRoutine *routine) const; void EmitCompositeExtract(InsnIterator insn, SpirvRoutine *routine) const;
void EmitVectorShuffle(InsnIterator insn, SpirvRoutine *routine) const; void EmitVectorShuffle(InsnIterator insn, SpirvRoutine *routine) const;
void EmitVectorTimesScalar(InsnIterator insn, SpirvRoutine *routine) const; void EmitVectorTimesScalar(InsnIterator insn, SpirvRoutine *routine) const;
void EmitVectorExtractDynamic(InsnIterator insn, SpirvRoutine *routine) const;
void EmitVectorInsertDynamic(InsnIterator insn, SpirvRoutine *routine) const;
void EmitUnaryOp(InsnIterator insn, SpirvRoutine *routine) const; void EmitUnaryOp(InsnIterator insn, SpirvRoutine *routine) const;
void EmitBinaryOp(InsnIterator insn, SpirvRoutine *routine) const; void EmitBinaryOp(InsnIterator insn, SpirvRoutine *routine) const;
void EmitDot(InsnIterator insn, SpirvRoutine *routine) const; void EmitDot(InsnIterator insn, SpirvRoutine *routine) const;
......
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