summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/frontend/maxwell/translate/impl/barrier_operations.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-04-04 08:04:48 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:26 +0200
commitfc93bc2abde0b54a0a495f9b28a76fd34b47f320 (patch)
treefc0b0c022604b3e4adfc28864b8c91b58a9b3c06 /src/shader_recompiler/frontend/maxwell/translate/impl/barrier_operations.cpp
parentshader: Abstract breadth searches and use the abstraction (diff)
downloadyuzu-fc93bc2abde0b54a0a495f9b28a76fd34b47f320.tar
yuzu-fc93bc2abde0b54a0a495f9b28a76fd34b47f320.tar.gz
yuzu-fc93bc2abde0b54a0a495f9b28a76fd34b47f320.tar.bz2
yuzu-fc93bc2abde0b54a0a495f9b28a76fd34b47f320.tar.lz
yuzu-fc93bc2abde0b54a0a495f9b28a76fd34b47f320.tar.xz
yuzu-fc93bc2abde0b54a0a495f9b28a76fd34b47f320.tar.zst
yuzu-fc93bc2abde0b54a0a495f9b28a76fd34b47f320.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/barrier_operations.cpp58
1 files changed, 56 insertions, 2 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/barrier_operations.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/barrier_operations.cpp
index 26d5e276b..2a2a294df 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/barrier_operations.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/barrier_operations.cpp
@@ -38,6 +38,7 @@ void TranslatorVisitor::MEMBAR(u64 inst) {
u64 raw;
BitField<8, 2, LocalScope> scope;
} membar{inst};
+
ir.MemoryBarrier(LocalScopeToMemoryScope(membar.scope));
}
@@ -45,8 +46,61 @@ void TranslatorVisitor::DEPBAR() {
// DEPBAR is a no-op
}
-void TranslatorVisitor::BAR(u64) {
- throw NotImplementedException("Instruction {} is not implemented", Opcode::BAR);
+void TranslatorVisitor::BAR(u64 insn) {
+ enum class Mode {
+ RedPopc,
+ Scan,
+ RedAnd,
+ RedOr,
+ Sync,
+ Arrive,
+ };
+ union {
+ u64 raw;
+ BitField<43, 1, u64> is_a_imm;
+ BitField<44, 1, u64> is_b_imm;
+ BitField<8, 8, u64> imm_a;
+ BitField<20, 12, u64> imm_b;
+ BitField<42, 1, u64> neg_pred;
+ BitField<39, 3, IR::Pred> pred;
+ } const bar{insn};
+
+ const Mode mode{[insn] {
+ switch (insn & 0x0000009B00000000ULL) {
+ case 0x0000000200000000ULL:
+ return Mode::RedPopc;
+ case 0x0000000300000000ULL:
+ return Mode::Scan;
+ case 0x0000000A00000000ULL:
+ return Mode::RedAnd;
+ case 0x0000001200000000ULL:
+ return Mode::RedOr;
+ case 0x0000008000000000ULL:
+ return Mode::Sync;
+ case 0x0000008100000000ULL:
+ return Mode::Arrive;
+ }
+ throw NotImplementedException("Invalid encoding");
+ }()};
+ if (mode != Mode::Sync) {
+ throw NotImplementedException("BAR mode {}", mode);
+ }
+ if (bar.is_a_imm == 0) {
+ throw NotImplementedException("Non-immediate input A");
+ }
+ if (bar.imm_a != 0) {
+ throw NotImplementedException("Non-zero input A");
+ }
+ if (bar.is_b_imm == 0) {
+ throw NotImplementedException("Non-immediate input B");
+ }
+ if (bar.imm_b != 0) {
+ throw NotImplementedException("Non-zero input B");
+ }
+ if (bar.pred != IR::Pred::PT && bar.neg_pred != 0) {
+ throw NotImplementedException("Non-true input predicate");
+ }
+ ir.Barrier();
}
} // namespace Shader::Maxwell