diff options
Diffstat (limited to 'src/shader_recompiler/frontend')
5 files changed, 79 insertions, 4 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index 432dd29a5..ff2970125 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -1444,4 +1444,20 @@ F32 IREmitter::ImageSampleDrefExplicitLod(const Value& handle, const Value& coor | |||
| 1444 | return Inst<F32>(op, Flags{info}, handle, coords, dref, lod_lc, offset); | 1444 | return Inst<F32>(op, Flags{info}, handle, coords, dref, lod_lc, offset); |
| 1445 | } | 1445 | } |
| 1446 | 1446 | ||
| 1447 | U1 IREmitter::VoteAll(const U1& value) { | ||
| 1448 | return Inst<U1>(Opcode::VoteAll, value); | ||
| 1449 | } | ||
| 1450 | |||
| 1451 | U1 IREmitter::VoteAny(const U1& value) { | ||
| 1452 | return Inst<U1>(Opcode::VoteAny, value); | ||
| 1453 | } | ||
| 1454 | |||
| 1455 | U1 IREmitter::VoteEqual(const U1& value) { | ||
| 1456 | return Inst<U1>(Opcode::VoteEqual, value); | ||
| 1457 | } | ||
| 1458 | |||
| 1459 | U32 IREmitter::SubgroupBallot(const U1& value) { | ||
| 1460 | return Inst<U32>(Opcode::SubgroupBallot, value); | ||
| 1461 | } | ||
| 1462 | |||
| 1447 | } // namespace Shader::IR | 1463 | } // namespace Shader::IR |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 346cef3ab..1708be3ef 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -234,6 +234,11 @@ public: | |||
| 234 | const Value& offset, const F32& lod_clamp, | 234 | const Value& offset, const F32& lod_clamp, |
| 235 | TextureInstInfo info); | 235 | TextureInstInfo info); |
| 236 | 236 | ||
| 237 | [[nodiscard]] U1 VoteAll(const U1& value); | ||
| 238 | [[nodiscard]] U1 VoteAny(const U1& value); | ||
| 239 | [[nodiscard]] U1 VoteEqual(const U1& value); | ||
| 240 | [[nodiscard]] U32 SubgroupBallot(const U1& value); | ||
| 241 | |||
| 237 | private: | 242 | private: |
| 238 | IR::Block::iterator insertion_point; | 243 | IR::Block::iterator insertion_point; |
| 239 | 244 | ||
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc index bdc07b9a7..fe888b8b2 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.inc +++ b/src/shader_recompiler/frontend/ir/opcodes.inc | |||
| @@ -355,3 +355,9 @@ OPCODE(ImageSampleImplicitLod, F32x4, U32, | |||
| 355 | OPCODE(ImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) | 355 | OPCODE(ImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) |
| 356 | OPCODE(ImageSampleDrefImplicitLod, F32, U32, Opaque, F32, Opaque, Opaque, ) | 356 | OPCODE(ImageSampleDrefImplicitLod, F32, U32, Opaque, F32, Opaque, Opaque, ) |
| 357 | OPCODE(ImageSampleDrefExplicitLod, F32, U32, Opaque, F32, Opaque, Opaque, ) | 357 | OPCODE(ImageSampleDrefExplicitLod, F32, U32, Opaque, F32, Opaque, Opaque, ) |
| 358 | |||
| 359 | // Vote operations | ||
| 360 | OPCODE(VoteAll, U1, U1, ) | ||
| 361 | OPCODE(VoteAny, U1, U1, ) | ||
| 362 | OPCODE(VoteEqual, U1, U1, ) | ||
| 363 | OPCODE(SubgroupBallot, U32, U1, ) | ||
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp index 27b12ff3c..c0e36a7e2 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp | |||
| @@ -417,10 +417,6 @@ void TranslatorVisitor::VMNMX(u64) { | |||
| 417 | ThrowNotImplemented(Opcode::VMNMX); | 417 | ThrowNotImplemented(Opcode::VMNMX); |
| 418 | } | 418 | } |
| 419 | 419 | ||
| 420 | void TranslatorVisitor::VOTE(u64) { | ||
| 421 | ThrowNotImplemented(Opcode::VOTE); | ||
| 422 | } | ||
| 423 | |||
| 424 | void TranslatorVisitor::VOTE_vtg(u64) { | 420 | void TranslatorVisitor::VOTE_vtg(u64) { |
| 425 | ThrowNotImplemented(Opcode::VOTE_vtg); | 421 | ThrowNotImplemented(Opcode::VOTE_vtg); |
| 426 | } | 422 | } |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/vote.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/vote.cpp new file mode 100644 index 000000000..a88894a7e --- /dev/null +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/vote.cpp | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <optional> | ||
| 6 | |||
| 7 | #include "common/bit_field.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | #include "shader_recompiler/frontend/maxwell/translate/impl/impl.h" | ||
| 10 | |||
| 11 | namespace Shader::Maxwell { | ||
| 12 | namespace { | ||
| 13 | enum class VoteOp : u64 { | ||
| 14 | ALL, | ||
| 15 | ANY, | ||
| 16 | EQ, | ||
| 17 | }; | ||
| 18 | |||
| 19 | [[nodiscard]] IR::U1 VoteOperation(IR::IREmitter& ir, const IR::U1& pred, VoteOp vote_op) { | ||
| 20 | switch (vote_op) { | ||
| 21 | case VoteOp::ALL: | ||
| 22 | return ir.VoteAll(pred); | ||
| 23 | case VoteOp::ANY: | ||
| 24 | return ir.VoteAny(pred); | ||
| 25 | case VoteOp::EQ: | ||
| 26 | return ir.VoteEqual(pred); | ||
| 27 | default: | ||
| 28 | throw NotImplementedException("Invalid VOTE op {}", vote_op); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | void Vote(TranslatorVisitor& v, u64 insn) { | ||
| 33 | union { | ||
| 34 | u64 insn; | ||
| 35 | BitField<0, 8, IR::Reg> dest_reg; | ||
| 36 | BitField<39, 3, IR::Pred> pred_a; | ||
| 37 | BitField<42, 1, u64> neg_pred_a; | ||
| 38 | BitField<45, 3, IR::Pred> pred_b; | ||
| 39 | BitField<48, 2, VoteOp> vote_op; | ||
| 40 | } const vote{insn}; | ||
| 41 | |||
| 42 | const IR::U1 vote_pred{v.ir.GetPred(vote.pred_a, vote.neg_pred_a != 0)}; | ||
| 43 | v.ir.SetPred(vote.pred_b, VoteOperation(v.ir, vote_pred, vote.vote_op)); | ||
| 44 | v.X(vote.dest_reg, v.ir.SubgroupBallot(vote_pred)); | ||
| 45 | } | ||
| 46 | } // Anonymous namespace | ||
| 47 | |||
| 48 | void TranslatorVisitor::VOTE(u64 insn) { | ||
| 49 | Vote(*this, insn); | ||
| 50 | } | ||
| 51 | |||
| 52 | } // namespace Shader::Maxwell | ||