vote.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/bit_field.h"
  5. #include "common/common_types.h"
  6. #include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
  7. namespace Shader::Maxwell {
  8. namespace {
  9. enum class VoteOp : u64 {
  10. ALL,
  11. ANY,
  12. EQ,
  13. };
  14. [[nodiscard]] IR::U1 VoteOperation(IR::IREmitter& ir, const IR::U1& pred, VoteOp vote_op) {
  15. switch (vote_op) {
  16. case VoteOp::ALL:
  17. return ir.VoteAll(pred);
  18. case VoteOp::ANY:
  19. return ir.VoteAny(pred);
  20. case VoteOp::EQ:
  21. return ir.VoteEqual(pred);
  22. default:
  23. throw NotImplementedException("Invalid VOTE op {}", vote_op);
  24. }
  25. }
  26. void Vote(TranslatorVisitor& v, u64 insn) {
  27. union {
  28. u64 insn;
  29. BitField<0, 8, IR::Reg> dest_reg;
  30. BitField<39, 3, IR::Pred> pred_a;
  31. BitField<42, 1, u64> neg_pred_a;
  32. BitField<45, 3, IR::Pred> pred_b;
  33. BitField<48, 2, VoteOp> vote_op;
  34. } const vote{insn};
  35. const IR::U1 vote_pred{v.ir.GetPred(vote.pred_a, vote.neg_pred_a != 0)};
  36. v.ir.SetPred(vote.pred_b, VoteOperation(v.ir, vote_pred, vote.vote_op));
  37. v.X(vote.dest_reg, v.ir.SubgroupBallot(vote_pred));
  38. }
  39. } // Anonymous namespace
  40. void TranslatorVisitor::VOTE(u64 insn) {
  41. Vote(*this, insn);
  42. }
  43. void TranslatorVisitor::VOTE_vtg(u64) {
  44. LOG_WARNING(Shader, "(STUBBED) called");
  45. }
  46. } // namespace Shader::Maxwell