summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-05-21 21:42:48 -0300
committerGravatar ameerj2021-07-22 21:51:33 -0400
commitc8414e686f30b3bec7f179ee7ab800f223f8ece0 (patch)
tree73e86260d181d7022eacdc7821b6d41b3b47e13b
parentglasm: Reorder unreachable image atomic insts (diff)
downloadyuzu-c8414e686f30b3bec7f179ee7ab800f223f8ece0.tar.gz
yuzu-c8414e686f30b3bec7f179ee7ab800f223f8ece0.tar.xz
yuzu-c8414e686f30b3bec7f179ee7ab800f223f8ece0.zip
glasm: Implement image atomics
-rw-r--r--src/shader_recompiler/CMakeLists.txt1
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_image.cpp153
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_image_atomic.cpp165
3 files changed, 153 insertions, 166 deletions
diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt
index 0d55924a7..becdb7d54 100644
--- a/src/shader_recompiler/CMakeLists.txt
+++ b/src/shader_recompiler/CMakeLists.txt
@@ -13,7 +13,6 @@ add_library(shader_recompiler STATIC
13 backend/glasm/emit_glasm_convert.cpp 13 backend/glasm/emit_glasm_convert.cpp
14 backend/glasm/emit_glasm_floating_point.cpp 14 backend/glasm/emit_glasm_floating_point.cpp
15 backend/glasm/emit_glasm_image.cpp 15 backend/glasm/emit_glasm_image.cpp
16 backend/glasm/emit_glasm_image_atomic.cpp
17 backend/glasm/emit_glasm_instructions.h 16 backend/glasm/emit_glasm_instructions.h
18 backend/glasm/emit_glasm_integer.cpp 17 backend/glasm/emit_glasm_integer.cpp
19 backend/glasm/emit_glasm_logical.cpp 18 backend/glasm/emit_glasm_logical.cpp
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
index 385ca51ac..a7def0897 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
@@ -205,6 +205,16 @@ std::string_view FormatStorage(ImageFormat format) {
205 } 205 }
206 throw InvalidArgument("Invalid image format {}", format); 206 throw InvalidArgument("Invalid image format {}", format);
207} 207}
208
209template <typename T>
210void ImageAtomic(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, T value,
211 std::string_view op) {
212 const auto info{inst.Flags<IR::TextureInstInfo>()};
213 const std::string_view type{TextureType(info)};
214 const std::string image{Image(ctx, info, index)};
215 const Register ret{ctx.reg_alloc.Define(inst)};
216 ctx.Add("ATOMIM.{} {},{},{},{},{};", op, ret, value, coord, image, type);
217}
208} // Anonymous namespace 218} // Anonymous namespace
209 219
210void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, 220void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
@@ -590,6 +600,61 @@ void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Re
590 ctx.Add("STOREIM.{} {},{},{},{};", format, image, color, coord, type); 600 ctx.Add("STOREIM.{} {},{},{},{};", format, image, color, coord, type);
591} 601}
592 602
603void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
604 ScalarU32 value) {
605 ImageAtomic(ctx, inst, index, coord, value, "ADD.U32");
606}
607
608void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
609 ScalarS32 value) {
610 ImageAtomic(ctx, inst, index, coord, value, "MIN.S32");
611}
612
613void EmitImageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
614 ScalarU32 value) {
615 ImageAtomic(ctx, inst, index, coord, value, "MIN.U32");
616}
617
618void EmitImageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
619 ScalarS32 value) {
620 ImageAtomic(ctx, inst, index, coord, value, "MAX.S32");
621}
622
623void EmitImageAtomicUMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
624 ScalarU32 value) {
625 ImageAtomic(ctx, inst, index, coord, value, "MAX.U32");
626}
627
628void EmitImageAtomicInc32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
629 ScalarU32 value) {
630 ImageAtomic(ctx, inst, index, coord, value, "IWRAP.U32");
631}
632
633void EmitImageAtomicDec32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
634 ScalarU32 value) {
635 ImageAtomic(ctx, inst, index, coord, value, "DWRAP.U32");
636}
637
638void EmitImageAtomicAnd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
639 ScalarU32 value) {
640 ImageAtomic(ctx, inst, index, coord, value, "AND.U32");
641}
642
643void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
644 ScalarU32 value) {
645 ImageAtomic(ctx, inst, index, coord, value, "OR.U32");
646}
647
648void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
649 ScalarU32 value) {
650 ImageAtomic(ctx, inst, index, coord, value, "XOR.U32");
651}
652
653void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
654 Register coord, ScalarU32 value) {
655 ImageAtomic(ctx, inst, index, coord, value, "EXCH.U32");
656}
657
593void EmitBindlessImageSampleImplicitLod(EmitContext&) { 658void EmitBindlessImageSampleImplicitLod(EmitContext&) {
594 throw LogicError("Unreachable instruction"); 659 throw LogicError("Unreachable instruction");
595} 660}
@@ -686,4 +751,92 @@ void EmitBoundImageWrite(EmitContext&) {
686 throw LogicError("Unreachable instruction"); 751 throw LogicError("Unreachable instruction");
687} 752}
688 753
754void EmitBindlessImageAtomicIAdd32(EmitContext&) {
755 throw LogicError("Unreachable instruction");
756}
757
758void EmitBindlessImageAtomicSMin32(EmitContext&) {
759 throw LogicError("Unreachable instruction");
760}
761
762void EmitBindlessImageAtomicUMin32(EmitContext&) {
763 throw LogicError("Unreachable instruction");
764}
765
766void EmitBindlessImageAtomicSMax32(EmitContext&) {
767 throw LogicError("Unreachable instruction");
768}
769
770void EmitBindlessImageAtomicUMax32(EmitContext&) {
771 throw LogicError("Unreachable instruction");
772}
773
774void EmitBindlessImageAtomicInc32(EmitContext&) {
775 throw LogicError("Unreachable instruction");
776}
777
778void EmitBindlessImageAtomicDec32(EmitContext&) {
779 throw LogicError("Unreachable instruction");
780}
781
782void EmitBindlessImageAtomicAnd32(EmitContext&) {
783 throw LogicError("Unreachable instruction");
784}
785
786void EmitBindlessImageAtomicOr32(EmitContext&) {
787 throw LogicError("Unreachable instruction");
788}
789
790void EmitBindlessImageAtomicXor32(EmitContext&) {
791 throw LogicError("Unreachable instruction");
792}
793
794void EmitBindlessImageAtomicExchange32(EmitContext&) {
795 throw LogicError("Unreachable instruction");
796}
797
798void EmitBoundImageAtomicIAdd32(EmitContext&) {
799 throw LogicError("Unreachable instruction");
800}
801
802void EmitBoundImageAtomicSMin32(EmitContext&) {
803 throw LogicError("Unreachable instruction");
804}
805
806void EmitBoundImageAtomicUMin32(EmitContext&) {
807 throw LogicError("Unreachable instruction");
808}
809
810void EmitBoundImageAtomicSMax32(EmitContext&) {
811 throw LogicError("Unreachable instruction");
812}
813
814void EmitBoundImageAtomicUMax32(EmitContext&) {
815 throw LogicError("Unreachable instruction");
816}
817
818void EmitBoundImageAtomicInc32(EmitContext&) {
819 throw LogicError("Unreachable instruction");
820}
821
822void EmitBoundImageAtomicDec32(EmitContext&) {
823 throw LogicError("Unreachable instruction");
824}
825
826void EmitBoundImageAtomicAnd32(EmitContext&) {
827 throw LogicError("Unreachable instruction");
828}
829
830void EmitBoundImageAtomicOr32(EmitContext&) {
831 throw LogicError("Unreachable instruction");
832}
833
834void EmitBoundImageAtomicXor32(EmitContext&) {
835 throw LogicError("Unreachable instruction");
836}
837
838void EmitBoundImageAtomicExchange32(EmitContext&) {
839 throw LogicError("Unreachable instruction");
840}
841
689} // namespace Shader::Backend::GLASM 842} // namespace Shader::Backend::GLASM
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image_atomic.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image_atomic.cpp
deleted file mode 100644
index f82cf9ffc..000000000
--- a/src/shader_recompiler/backend/glasm/emit_glasm_image_atomic.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
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 "shader_recompiler/backend/glasm/emit_context.h"
6#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
7#include "shader_recompiler/frontend/ir/value.h"
8
9namespace Shader::Backend::GLASM {
10
11void EmitImageAtomicIAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
12 [[maybe_unused]] const IR::Value& index,
13 [[maybe_unused]] Register coords, [[maybe_unused]] ScalarU32 value) {
14 throw NotImplementedException("GLASM instruction");
15}
16
17void EmitImageAtomicSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
18 [[maybe_unused]] const IR::Value& index,
19 [[maybe_unused]] Register coords, [[maybe_unused]] ScalarS32 value) {
20 throw NotImplementedException("GLASM instruction");
21}
22
23void EmitImageAtomicUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
24 [[maybe_unused]] const IR::Value& index,
25 [[maybe_unused]] Register coords, [[maybe_unused]] ScalarU32 value) {
26 throw NotImplementedException("GLASM instruction");
27}
28
29void EmitImageAtomicSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
30 [[maybe_unused]] const IR::Value& index,
31 [[maybe_unused]] Register coords, [[maybe_unused]] ScalarS32 value) {
32 throw NotImplementedException("GLASM instruction");
33}
34
35void EmitImageAtomicUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
36 [[maybe_unused]] const IR::Value& index,
37 [[maybe_unused]] Register coords, [[maybe_unused]] ScalarU32 value) {
38 throw NotImplementedException("GLASM instruction");
39}
40
41void EmitImageAtomicInc32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
42 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
43 [[maybe_unused]] ScalarU32 value) {
44 throw NotImplementedException("GLASM instruction");
45}
46
47void EmitImageAtomicDec32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
48 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
49 [[maybe_unused]] ScalarU32 value) {
50 throw NotImplementedException("GLASM instruction");
51}
52
53void EmitImageAtomicAnd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
54 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
55 [[maybe_unused]] ScalarU32 value) {
56 throw NotImplementedException("GLASM instruction");
57}
58
59void EmitImageAtomicOr32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
60 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
61 [[maybe_unused]] ScalarU32 value) {
62 throw NotImplementedException("GLASM instruction");
63}
64
65void EmitImageAtomicXor32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
66 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
67 [[maybe_unused]] ScalarU32 value) {
68 throw NotImplementedException("GLASM instruction");
69}
70
71void EmitImageAtomicExchange32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
72 [[maybe_unused]] const IR::Value& index,
73 [[maybe_unused]] Register coords, [[maybe_unused]] ScalarU32 value) {
74 throw NotImplementedException("GLASM instruction");
75}
76
77void EmitBindlessImageAtomicIAdd32(EmitContext&) {
78 throw LogicError("Unreachable instruction");
79}
80
81void EmitBindlessImageAtomicSMin32(EmitContext&) {
82 throw LogicError("Unreachable instruction");
83}
84
85void EmitBindlessImageAtomicUMin32(EmitContext&) {
86 throw LogicError("Unreachable instruction");
87}
88
89void EmitBindlessImageAtomicSMax32(EmitContext&) {
90 throw LogicError("Unreachable instruction");
91}
92
93void EmitBindlessImageAtomicUMax32(EmitContext&) {
94 throw LogicError("Unreachable instruction");
95}
96
97void EmitBindlessImageAtomicInc32(EmitContext&) {
98 throw LogicError("Unreachable instruction");
99}
100
101void EmitBindlessImageAtomicDec32(EmitContext&) {
102 throw LogicError("Unreachable instruction");
103}
104
105void EmitBindlessImageAtomicAnd32(EmitContext&) {
106 throw LogicError("Unreachable instruction");
107}
108
109void EmitBindlessImageAtomicOr32(EmitContext&) {
110 throw LogicError("Unreachable instruction");
111}
112
113void EmitBindlessImageAtomicXor32(EmitContext&) {
114 throw LogicError("Unreachable instruction");
115}
116
117void EmitBindlessImageAtomicExchange32(EmitContext&) {
118 throw LogicError("Unreachable instruction");
119}
120
121void EmitBoundImageAtomicIAdd32(EmitContext&) {
122 throw LogicError("Unreachable instruction");
123}
124
125void EmitBoundImageAtomicSMin32(EmitContext&) {
126 throw LogicError("Unreachable instruction");
127}
128
129void EmitBoundImageAtomicUMin32(EmitContext&) {
130 throw LogicError("Unreachable instruction");
131}
132
133void EmitBoundImageAtomicSMax32(EmitContext&) {
134 throw LogicError("Unreachable instruction");
135}
136
137void EmitBoundImageAtomicUMax32(EmitContext&) {
138 throw LogicError("Unreachable instruction");
139}
140
141void EmitBoundImageAtomicInc32(EmitContext&) {
142 throw LogicError("Unreachable instruction");
143}
144
145void EmitBoundImageAtomicDec32(EmitContext&) {
146 throw LogicError("Unreachable instruction");
147}
148
149void EmitBoundImageAtomicAnd32(EmitContext&) {
150 throw LogicError("Unreachable instruction");
151}
152
153void EmitBoundImageAtomicOr32(EmitContext&) {
154 throw LogicError("Unreachable instruction");
155}
156
157void EmitBoundImageAtomicXor32(EmitContext&) {
158 throw LogicError("Unreachable instruction");
159}
160
161void EmitBoundImageAtomicExchange32(EmitContext&) {
162 throw LogicError("Unreachable instruction");
163}
164
165} // namespace Shader::Backend::GLASM