summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-04-16 17:22:59 -0300
committerGravatar ameerj2021-07-22 21:51:28 -0400
commit95815a3883d708f71db5119f42243e183f32f9a2 (patch)
treeb479ed61fb90f8bc6dbe25983a431e336f5f5ce9 /src/shader_recompiler/frontend
parentspirv: Bitcast non-F32 output attributes to their type before store (diff)
downloadyuzu-95815a3883d708f71db5119f42243e183f32f9a2.tar.gz
yuzu-95815a3883d708f71db5119f42243e183f32f9a2.tar.xz
yuzu-95815a3883d708f71db5119f42243e183f32f9a2.zip
shader: Implement PIXLD.MY_INDEX
Diffstat (limited to 'src/shader_recompiler/frontend')
-rw-r--r--src/shader_recompiler/frontend/ir/ir_emitter.cpp4
-rw-r--r--src/shader_recompiler/frontend/ir/ir_emitter.h1
-rw-r--r--src/shader_recompiler/frontend/ir/opcodes.inc1
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp4
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/pixel_load.cpp46
5 files changed, 52 insertions, 4 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
index b821d9f47..141efd86c 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
@@ -375,6 +375,10 @@ U32 IREmitter::InvocationId() {
375 return Inst<U32>(Opcode::InvocationId); 375 return Inst<U32>(Opcode::InvocationId);
376} 376}
377 377
378U32 IREmitter::SampleId() {
379 return Inst<U32>(Opcode::SampleId);
380}
381
378U1 IREmitter::IsHelperInvocation() { 382U1 IREmitter::IsHelperInvocation() {
379 return Inst<U1>(Opcode::IsHelperInvocation); 383 return Inst<U1>(Opcode::IsHelperInvocation);
380} 384}
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h
index 7f8f1ad42..81833d928 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.h
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.h
@@ -99,6 +99,7 @@ public:
99 [[nodiscard]] U32 LocalInvocationIdZ(); 99 [[nodiscard]] U32 LocalInvocationIdZ();
100 100
101 [[nodiscard]] U32 InvocationId(); 101 [[nodiscard]] U32 InvocationId();
102 [[nodiscard]] U32 SampleId();
102 [[nodiscard]] U1 IsHelperInvocation(); 103 [[nodiscard]] U1 IsHelperInvocation();
103 104
104 [[nodiscard]] U32 LaneId(); 105 [[nodiscard]] U32 LaneId();
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc
index a86542cd8..d5e443673 100644
--- a/src/shader_recompiler/frontend/ir/opcodes.inc
+++ b/src/shader_recompiler/frontend/ir/opcodes.inc
@@ -63,6 +63,7 @@ OPCODE(SetOFlag, Void, U1,
63OPCODE(WorkgroupId, U32x3, ) 63OPCODE(WorkgroupId, U32x3, )
64OPCODE(LocalInvocationId, U32x3, ) 64OPCODE(LocalInvocationId, U32x3, )
65OPCODE(InvocationId, U32, ) 65OPCODE(InvocationId, U32, )
66OPCODE(SampleId, U32, )
66OPCODE(IsHelperInvocation, U1, ) 67OPCODE(IsHelperInvocation, U1, )
67 68
68// Undefined 69// Undefined
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 a45d1e4be..a4f99bbbe 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp
@@ -181,10 +181,6 @@ void TranslatorVisitor::PEXIT(u64) {
181 ThrowNotImplemented(Opcode::PEXIT); 181 ThrowNotImplemented(Opcode::PEXIT);
182} 182}
183 183
184void TranslatorVisitor::PIXLD(u64) {
185 ThrowNotImplemented(Opcode::PIXLD);
186}
187
188void TranslatorVisitor::PLONGJMP(u64) { 184void TranslatorVisitor::PLONGJMP(u64) {
189 ThrowNotImplemented(Opcode::PLONGJMP); 185 ThrowNotImplemented(Opcode::PLONGJMP);
190} 186}
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/pixel_load.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/pixel_load.cpp
new file mode 100644
index 000000000..b4767afb5
--- /dev/null
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/pixel_load.cpp
@@ -0,0 +1,46 @@
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 "common/bit_field.h"
6#include "common/common_types.h"
7#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
8
9namespace Shader::Maxwell {
10namespace {
11enum class Mode : u64 {
12 Default,
13 CovMask,
14 Covered,
15 Offset,
16 CentroidOffset,
17 MyIndex,
18};
19} // Anonymous namespace
20
21void TranslatorVisitor::PIXLD(u64 insn) {
22 union {
23 u64 raw;
24 BitField<31, 3, Mode> mode;
25 BitField<0, 8, IR::Reg> dest_reg;
26 BitField<8, 8, IR::Reg> addr_reg;
27 BitField<20, 8, s64> addr_offset;
28 BitField<45, 3, IR::Pred> dest_pred;
29 } const pixld{insn};
30
31 if (pixld.dest_pred != IR::Pred::PT) {
32 throw NotImplementedException("Destination predicate");
33 }
34 if (pixld.addr_reg != IR::Reg::RZ || pixld.addr_offset != 0) {
35 throw NotImplementedException("Non-zero source register");
36 }
37 switch (pixld.mode) {
38 case Mode::MyIndex:
39 X(pixld.dest_reg, ir.SampleId());
40 break;
41 default:
42 throw NotImplementedException("Mode {}", pixld.mode.Value());
43 }
44}
45
46} // namespace Shader::Maxwell