From 2930dccecc933d6748772e9f51a5724fe1e6771b Mon Sep 17 00:00:00 2001
From: ReinUsesLisp <reinuseslisp@airmail.cc>
Date: Mon, 8 Feb 2021 02:54:35 -0300
Subject: spirv: Initial SPIR-V support

---
 src/shader_recompiler/frontend/ir/ir_emitter.cpp             | 12 ++++++------
 src/shader_recompiler/frontend/ir/opcodes.inc                | 12 ++++--------
 .../frontend/maxwell/translate/translate.cpp                 | 10 +++++-----
 3 files changed, 15 insertions(+), 19 deletions(-)

(limited to 'src/shader_recompiler/frontend')

diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
index 9d7dc034c9..ada0be8343 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
@@ -130,27 +130,27 @@ void IREmitter::SetAttribute(IR::Attribute attribute, const F32& value) {
 }
 
 U32 IREmitter::WorkgroupIdX() {
-    return Inst<U32>(Opcode::WorkgroupIdX);
+    return U32{CompositeExtract(Inst(Opcode::WorkgroupId), 0)};
 }
 
 U32 IREmitter::WorkgroupIdY() {
-    return Inst<U32>(Opcode::WorkgroupIdY);
+    return U32{CompositeExtract(Inst(Opcode::WorkgroupId), 1)};
 }
 
 U32 IREmitter::WorkgroupIdZ() {
-    return Inst<U32>(Opcode::WorkgroupIdZ);
+    return U32{CompositeExtract(Inst(Opcode::WorkgroupId), 2)};
 }
 
 U32 IREmitter::LocalInvocationIdX() {
-    return Inst<U32>(Opcode::LocalInvocationIdX);
+    return U32{CompositeExtract(Inst(Opcode::LocalInvocationId), 0)};
 }
 
 U32 IREmitter::LocalInvocationIdY() {
-    return Inst<U32>(Opcode::LocalInvocationIdY);
+    return U32{CompositeExtract(Inst(Opcode::LocalInvocationId), 1)};
 }
 
 U32 IREmitter::LocalInvocationIdZ() {
-    return Inst<U32>(Opcode::LocalInvocationIdZ);
+    return U32{CompositeExtract(Inst(Opcode::LocalInvocationId), 2)};
 }
 
 U32 IREmitter::LoadGlobalU8(const U64& address) {
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc
index 82b04f37c6..5dc65f2dfa 100644
--- a/src/shader_recompiler/frontend/ir/opcodes.inc
+++ b/src/shader_recompiler/frontend/ir/opcodes.inc
@@ -21,9 +21,9 @@ OPCODE(GetPred,                                             U1,             Pred
 OPCODE(SetPred,                                             Void,           Pred,           U1,                                             )
 OPCODE(GetCbuf,                                             U32,            U32,            U32,                                            )
 OPCODE(GetAttribute,                                        U32,            Attribute,                                                      )
-OPCODE(SetAttribute,                                        U32,            Attribute,                                                      )
+OPCODE(SetAttribute,                                        Void,           Attribute,      U32,                                            )
 OPCODE(GetAttributeIndexed,                                 U32,            U32,                                                            )
-OPCODE(SetAttributeIndexed,                                 U32,            U32,                                                            )
+OPCODE(SetAttributeIndexed,                                 Void,           U32,            U32,                                            )
 OPCODE(GetZFlag,                                            U1,             Void,                                                           )
 OPCODE(GetSFlag,                                            U1,             Void,                                                           )
 OPCODE(GetCFlag,                                            U1,             Void,                                                           )
@@ -32,12 +32,8 @@ OPCODE(SetZFlag,                                            Void,           U1,
 OPCODE(SetSFlag,                                            Void,           U1,                                                             )
 OPCODE(SetCFlag,                                            Void,           U1,                                                             )
 OPCODE(SetOFlag,                                            Void,           U1,                                                             )
-OPCODE(WorkgroupIdX,                                        U32,                                                                            )
-OPCODE(WorkgroupIdY,                                        U32,                                                                            )
-OPCODE(WorkgroupIdZ,                                        U32,                                                                            )
-OPCODE(LocalInvocationIdX,                                  U32,                                                                            )
-OPCODE(LocalInvocationIdY,                                  U32,                                                                            )
-OPCODE(LocalInvocationIdZ,                                  U32,                                                                            )
+OPCODE(WorkgroupId,                                         U32x3,                                                                          )
+OPCODE(LocalInvocationId,                                   U32x3,                                                                          )
 
 // Undefined
 OPCODE(Undef1,                                              U1,                                                                             )
diff --git a/src/shader_recompiler/frontend/maxwell/translate/translate.cpp b/src/shader_recompiler/frontend/maxwell/translate/translate.cpp
index dcc3f6c0ed..7e6bb07a22 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/translate.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/translate.cpp
@@ -11,15 +11,15 @@
 
 namespace Shader::Maxwell {
 
-template <auto visitor_method>
+template <auto method>
 static void Invoke(TranslatorVisitor& visitor, Location pc, u64 insn) {
-    using MethodType = decltype(visitor_method);
+    using MethodType = decltype(method);
     if constexpr (std::is_invocable_r_v<void, MethodType, TranslatorVisitor&, Location, u64>) {
-        (visitor.*visitor_method)(pc, insn);
+        (visitor.*method)(pc, insn);
     } else if constexpr (std::is_invocable_r_v<void, MethodType, TranslatorVisitor&, u64>) {
-        (visitor.*visitor_method)(insn);
+        (visitor.*method)(insn);
     } else {
-        (visitor.*visitor_method)();
+        (visitor.*method)();
     }
 }
 
-- 
cgit v1.2.3-70-g09d2