Commit 0785f69d by Chris Forbes

Add support for OpAny, OpAll

A step toward being able to run many of dEQP-VK.glsl.* Bug: b/126870789 Change-Id: Id53d5a511d7f0fa10994c46254529027ad773542 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26569Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 65321071
...@@ -332,6 +332,8 @@ namespace sw ...@@ -332,6 +332,8 @@ namespace sw
case spv::OpExtInst: case spv::OpExtInst:
case spv::OpIsInf: case spv::OpIsInf:
case spv::OpIsNan: case spv::OpIsNan:
case spv::OpAny:
case spv::OpAll:
// Instructions that yield an intermediate value // Instructions that yield an intermediate value
{ {
TypeID typeId = insn.word(1); TypeID typeId = insn.word(1);
...@@ -1104,6 +1106,14 @@ namespace sw ...@@ -1104,6 +1106,14 @@ namespace sw
EmitExtendedInstruction(insn, routine); EmitExtendedInstruction(insn, routine);
break; break;
case spv::OpAny:
EmitAny(insn, routine);
break;
case spv::OpAll:
EmitAll(insn, routine);
break;
default: default:
UNIMPLEMENTED(OpcodeName(insn.opcode()).c_str()); UNIMPLEMENTED(OpcodeName(insn.opcode()).c_str());
break; break;
...@@ -1685,6 +1695,42 @@ namespace sw ...@@ -1685,6 +1695,42 @@ namespace sw
} }
} }
void SpirvShader::EmitAny(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 &srcType = getType(getObject(insn.word(3)).type);
auto src = GenericValue(this, routine, insn.word(3));
SIMD::UInt result = As<SIMD::UInt>(src[0]);
for (auto i = 1u; i < srcType.sizeInComponents; i++)
{
result |= As<SIMD::UInt>(src[i]);
}
dst.emplace(0, As<SIMD::Float>(result));
}
void SpirvShader::EmitAll(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 &srcType = getType(getObject(insn.word(3)).type);
auto src = GenericValue(this, routine, insn.word(3));
SIMD::UInt result = As<SIMD::UInt>(src[0]);
for (auto i = 1u; i < srcType.sizeInComponents; i++)
{
result &= As<SIMD::UInt>(src[i]);
}
dst.emplace(0, As<SIMD::Float>(result));
}
void SpirvShader::emitEpilog(SpirvRoutine *routine) const void SpirvShader::emitEpilog(SpirvRoutine *routine) const
{ {
for (auto insn : *this) for (auto insn : *this)
......
...@@ -449,6 +449,8 @@ namespace sw ...@@ -449,6 +449,8 @@ namespace sw
void EmitDot(InsnIterator insn, SpirvRoutine *routine) const; void EmitDot(InsnIterator insn, SpirvRoutine *routine) const;
void EmitSelect(InsnIterator insn, SpirvRoutine *routine) const; void EmitSelect(InsnIterator insn, SpirvRoutine *routine) const;
void EmitExtendedInstruction(InsnIterator insn, SpirvRoutine *routine) const; void EmitExtendedInstruction(InsnIterator insn, SpirvRoutine *routine) const;
void EmitAny(InsnIterator insn, SpirvRoutine *routine) const;
void EmitAll(InsnIterator insn, SpirvRoutine *routine) const;
// OpcodeName returns the name of the opcode op. // OpcodeName returns the name of the opcode op.
// If NDEBUG is defined, then OpcodeName will only return the numerical code. // 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