summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/maxwell
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-04-09 01:45:39 -0300
committerGravatar ameerj2021-07-22 21:51:26 -0400
commit7cb2ab358517d95ebcd35c94c72b9e91762906c3 (patch)
tree3f75959e255026665a4dde406cb8c4cc34fb45a0 /src/shader_recompiler/frontend/maxwell
parentshader: Fix Windows build issues (diff)
downloadyuzu-7cb2ab358517d95ebcd35c94c72b9e91762906c3.tar.gz
yuzu-7cb2ab358517d95ebcd35c94c72b9e91762906c3.tar.xz
yuzu-7cb2ab358517d95ebcd35c94c72b9e91762906c3.zip
shader: Implement SULD and SUST
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell')
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp8
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/surface_load_store.cpp280
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch.cpp19
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch_swizzled.cpp12
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp19
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather_swizzled.cpp3
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_gradient.cpp18
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_load.cpp18
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_load_swizzled.cpp2
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_mipmap_level.cpp18
10 files changed, 338 insertions, 59 deletions
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 c23901052..327941223 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp
@@ -281,18 +281,10 @@ void TranslatorVisitor::SUATOM_cas(u64) {
281 ThrowNotImplemented(Opcode::SUATOM_cas); 281 ThrowNotImplemented(Opcode::SUATOM_cas);
282} 282}
283 283
284void TranslatorVisitor::SULD(u64) {
285 ThrowNotImplemented(Opcode::SULD);
286}
287
288void TranslatorVisitor::SURED(u64) { 284void TranslatorVisitor::SURED(u64) {
289 ThrowNotImplemented(Opcode::SURED); 285 ThrowNotImplemented(Opcode::SURED);
290} 286}
291 287
292void TranslatorVisitor::SUST(u64) {
293 ThrowNotImplemented(Opcode::SUST);
294}
295
296void TranslatorVisitor::SYNC(u64) { 288void TranslatorVisitor::SYNC(u64) {
297 ThrowNotImplemented(Opcode::SYNC); 289 ThrowNotImplemented(Opcode::SYNC);
298} 290}
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/surface_load_store.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/surface_load_store.cpp
new file mode 100644
index 000000000..9a2d16a6e
--- /dev/null
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/surface_load_store.cpp
@@ -0,0 +1,280 @@
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 <array>
6#include <bit>
7
8#include "common/bit_field.h"
9#include "common/common_types.h"
10#include "shader_recompiler/frontend/ir/modifiers.h"
11#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
12
13namespace Shader::Maxwell {
14namespace {
15enum class Type : u64 {
16 _1D,
17 BUFFER_1D,
18 ARRAY_1D,
19 _2D,
20 ARRAY_2D,
21 _3D,
22};
23
24constexpr unsigned R = 1 << 0;
25constexpr unsigned G = 1 << 1;
26constexpr unsigned B = 1 << 2;
27constexpr unsigned A = 1 << 3;
28
29constexpr std::array MASK{
30 0U, //
31 R, //
32 G, //
33 R | G, //
34 B, //
35 R | B, //
36 G | B, //
37 R | G | B, //
38 A, //
39 R | A, //
40 G | A, //
41 R | G | A, //
42 B | A, //
43 R | B | A, //
44 G | B | A, //
45 R | G | B | A, //
46};
47
48enum class Size : u64 {
49 U8,
50 S8,
51 U16,
52 S16,
53 B32,
54 B64,
55 B128,
56};
57
58enum class Clamp : u64 {
59 IGN,
60 Default,
61 TRAP,
62};
63
64enum class LoadCache : u64 {
65 Default,
66 CG,
67 CI,
68 CV,
69};
70
71enum class StoreCache : u64 {
72 Default,
73 CG,
74 CS,
75 WT,
76};
77
78ImageFormat Format(Size size) {
79 switch (size) {
80 case Size::U8:
81 return ImageFormat::R8_UINT;
82 case Size::S8:
83 return ImageFormat::R8_SINT;
84 case Size::U16:
85 return ImageFormat::R16_UINT;
86 case Size::S16:
87 return ImageFormat::R16_SINT;
88 case Size::B32:
89 return ImageFormat::R32_UINT;
90 case Size::B64:
91 return ImageFormat::R32G32_UINT;
92 case Size::B128:
93 return ImageFormat::R32G32B32A32_UINT;
94 }
95 throw NotImplementedException("Invalid size {}", size);
96}
97
98int SizeInRegs(Size size) {
99 switch (size) {
100 case Size::U8:
101 case Size::S8:
102 case Size::U16:
103 case Size::S16:
104 case Size::B32:
105 return 1;
106 case Size::B64:
107 return 2;
108 case Size::B128:
109 return 4;
110 }
111 throw NotImplementedException("Invalid size {}", size);
112}
113
114TextureType GetType(Type type) {
115 switch (type) {
116 case Type::_1D:
117 return TextureType::Color1D;
118 case Type::BUFFER_1D:
119 return TextureType::Buffer;
120 case Type::ARRAY_1D:
121 return TextureType::ColorArray1D;
122 case Type::_2D:
123 return TextureType::Color2D;
124 case Type::ARRAY_2D:
125 return TextureType::ColorArray2D;
126 case Type::_3D:
127 return TextureType::Color3D;
128 }
129 throw NotImplementedException("Invalid type {}", type);
130}
131
132IR::Value MakeCoords(TranslatorVisitor& v, IR::Reg reg, Type type) {
133 const auto array{[&](int index) {
134 return v.ir.BitFieldExtract(v.X(reg + index), v.ir.Imm32(0), v.ir.Imm32(16));
135 }};
136 switch (type) {
137 case Type::_1D:
138 case Type::BUFFER_1D:
139 return v.X(reg);
140 case Type::ARRAY_1D:
141 return v.ir.CompositeConstruct(v.X(reg), array(1));
142 case Type::_2D:
143 return v.ir.CompositeConstruct(v.X(reg), v.X(reg + 1));
144 case Type::ARRAY_2D:
145 return v.ir.CompositeConstruct(v.X(reg), v.X(reg + 1), array(2));
146 case Type::_3D:
147 return v.ir.CompositeConstruct(v.X(reg), v.X(reg + 1), v.X(reg + 3));
148 }
149 throw NotImplementedException("Invalid type {}", type);
150}
151
152unsigned SwizzleMask(u64 swizzle) {
153 if (swizzle == 0 || swizzle >= MASK.size()) {
154 throw NotImplementedException("Invalid swizzle {}", swizzle);
155 }
156 return MASK[swizzle];
157}
158
159IR::Value MakeColor(IR::IREmitter& ir, IR::Reg reg, int num_regs) {
160 std::array<IR::U32, 4> colors;
161 for (int i = 0; i < num_regs; ++i) {
162 colors[i] = ir.GetReg(reg + i);
163 }
164 for (int i = num_regs; i < 4; ++i) {
165 colors[i] = ir.Imm32(0);
166 }
167 return ir.CompositeConstruct(colors[0], colors[1], colors[2], colors[3]);
168}
169} // Anonymous namespace
170
171void TranslatorVisitor::SULD(u64 insn) {
172 union {
173 u64 raw;
174 BitField<51, 1, u64> is_bound;
175 BitField<52, 1, u64> d;
176 BitField<23, 1, u64> ba;
177 BitField<33, 3, Type> type;
178 BitField<24, 2, LoadCache> cache;
179 BitField<20, 3, Size> size; // .D
180 BitField<20, 4, u64> swizzle; // .P
181 BitField<49, 2, Clamp> clamp;
182 BitField<0, 8, IR::Reg> dest_reg;
183 BitField<8, 8, IR::Reg> coord_reg;
184 BitField<36, 13, u64> bound_offset; // is_bound
185 BitField<39, 8, IR::Reg> bindless_reg; // !is_bound
186 } const suld{insn};
187
188 if (suld.clamp != Clamp::IGN) {
189 throw NotImplementedException("Clamp {}", suld.clamp.Value());
190 }
191 if (suld.cache != LoadCache::Default) {
192 throw NotImplementedException("Cache {}", suld.cache.Value());
193 }
194 const bool is_typed{suld.d != 0};
195 if (is_typed && suld.ba != 0) {
196 throw NotImplementedException("BA");
197 }
198
199 const ImageFormat format{is_typed ? Format(suld.size) : ImageFormat::Typeless};
200 const TextureType type{GetType(suld.type)};
201 const IR::Value coords{MakeCoords(*this, suld.coord_reg, suld.type)};
202 const IR::U32 handle{suld.is_bound != 0 ? ir.Imm32(static_cast<u32>(suld.bound_offset * 4))
203 : X(suld.bindless_reg)};
204 IR::TextureInstInfo info{};
205 info.type.Assign(type);
206 info.image_format.Assign(format);
207
208 const IR::Value result{ir.ImageRead(handle, coords, info)};
209 IR::Reg dest_reg{suld.dest_reg};
210 if (is_typed) {
211 const int num_regs{SizeInRegs(suld.size)};
212 for (int i = 0; i < num_regs; ++i) {
213 X(dest_reg + i, IR::U32{ir.CompositeExtract(result, i)});
214 }
215 } else {
216 const unsigned mask{SwizzleMask(suld.swizzle)};
217 const int bits{std::popcount(mask)};
218 if (!IR::IsAligned(dest_reg, bits == 3 ? 4 : bits)) {
219 throw NotImplementedException("Unaligned destination register");
220 }
221 for (unsigned component = 0; component < 4; ++component) {
222 if (((mask >> component) & 1) == 0) {
223 continue;
224 }
225 X(dest_reg, IR::U32{ir.CompositeExtract(result, component)});
226 ++dest_reg;
227 }
228 }
229}
230
231void TranslatorVisitor::SUST(u64 insn) {
232 union {
233 u64 raw;
234 BitField<51, 1, u64> is_bound;
235 BitField<52, 1, u64> d;
236 BitField<23, 1, u64> ba;
237 BitField<33, 3, Type> type;
238 BitField<24, 2, StoreCache> cache;
239 BitField<20, 3, Size> size; // .D
240 BitField<20, 4, u64> swizzle; // .P
241 BitField<49, 2, Clamp> clamp;
242 BitField<0, 8, IR::Reg> data_reg;
243 BitField<8, 8, IR::Reg> coord_reg;
244 BitField<36, 13, u64> bound_offset; // is_bound
245 BitField<39, 8, IR::Reg> bindless_reg; // !is_bound
246 } const sust{insn};
247
248 if (sust.clamp != Clamp::IGN) {
249 throw NotImplementedException("Clamp {}", sust.clamp.Value());
250 }
251 if (sust.cache != StoreCache::Default) {
252 throw NotImplementedException("Cache {}", sust.cache.Value());
253 }
254 const bool is_typed{sust.d != 0};
255 if (is_typed && sust.ba != 0) {
256 throw NotImplementedException("BA");
257 }
258 const ImageFormat format{is_typed ? Format(sust.size) : ImageFormat::Typeless};
259 const TextureType type{GetType(sust.type)};
260 const IR::Value coords{MakeCoords(*this, sust.coord_reg, sust.type)};
261 const IR::U32 handle{sust.is_bound != 0 ? ir.Imm32(static_cast<u32>(sust.bound_offset * 4))
262 : X(sust.bindless_reg)};
263 IR::TextureInstInfo info{};
264 info.type.Assign(type);
265 info.image_format.Assign(format);
266
267 IR::Value color;
268 if (is_typed) {
269 color = MakeColor(ir, sust.data_reg, SizeInRegs(sust.size));
270 } else {
271 const unsigned mask{SwizzleMask(sust.swizzle)};
272 if (mask != 0xf) {
273 throw NotImplementedException("Non-full mask");
274 }
275 color = MakeColor(ir, sust.data_reg, 4);
276 }
277 ir.ImageWrite(handle, coords, color, info);
278}
279
280} // namespace Shader::Maxwell
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch.cpp
index 95d416586..9671d115e 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch.cpp
@@ -33,24 +33,24 @@ enum class TextureType : u64 {
33 ARRAY_CUBE, 33 ARRAY_CUBE,
34}; 34};
35 35
36Shader::TextureType GetType(TextureType type, bool dc) { 36Shader::TextureType GetType(TextureType type) {
37 switch (type) { 37 switch (type) {
38 case TextureType::_1D: 38 case TextureType::_1D:
39 return dc ? Shader::TextureType::Shadow1D : Shader::TextureType::Color1D; 39 return Shader::TextureType::Color1D;
40 case TextureType::ARRAY_1D: 40 case TextureType::ARRAY_1D:
41 return dc ? Shader::TextureType::ShadowArray1D : Shader::TextureType::ColorArray1D; 41 return Shader::TextureType::ColorArray1D;
42 case TextureType::_2D: 42 case TextureType::_2D:
43 return dc ? Shader::TextureType::Shadow2D : Shader::TextureType::Color2D; 43 return Shader::TextureType::Color2D;
44 case TextureType::ARRAY_2D: 44 case TextureType::ARRAY_2D:
45 return dc ? Shader::TextureType::ShadowArray2D : Shader::TextureType::ColorArray2D; 45 return Shader::TextureType::ColorArray2D;
46 case TextureType::_3D: 46 case TextureType::_3D:
47 return dc ? Shader::TextureType::Shadow3D : Shader::TextureType::Color3D; 47 return Shader::TextureType::Color3D;
48 case TextureType::ARRAY_3D: 48 case TextureType::ARRAY_3D:
49 throw NotImplementedException("3D array texture type"); 49 throw NotImplementedException("3D array texture type");
50 case TextureType::CUBE: 50 case TextureType::CUBE:
51 return dc ? Shader::TextureType::ShadowCube : Shader::TextureType::ColorCube; 51 return Shader::TextureType::ColorCube;
52 case TextureType::ARRAY_CUBE: 52 case TextureType::ARRAY_CUBE:
53 return dc ? Shader::TextureType::ShadowArrayCube : Shader::TextureType::ColorArrayCube; 53 return Shader::TextureType::ColorArrayCube;
54 } 54 }
55 throw NotImplementedException("Invalid texture type {}", type); 55 throw NotImplementedException("Invalid texture type {}", type);
56} 56}
@@ -169,7 +169,8 @@ void Impl(TranslatorVisitor& v, u64 insn, bool aoffi, Blod blod, bool lc,
169 dref = v.F(meta_reg++); 169 dref = v.F(meta_reg++);
170 } 170 }
171 IR::TextureInstInfo info{}; 171 IR::TextureInstInfo info{};
172 info.type.Assign(GetType(tex.type, tex.dc != 0)); 172 info.type.Assign(GetType(tex.type));
173 info.is_depth.Assign(tex.dc != 0 ? 1 : 0);
173 info.has_bias.Assign(blod == Blod::LB || blod == Blod::LBA ? 1 : 0); 174 info.has_bias.Assign(blod == Blod::LB || blod == Blod::LBA ? 1 : 0);
174 info.has_lod_clamp.Assign(lc ? 1 : 0); 175 info.has_lod_clamp.Assign(lc ? 1 : 0);
175 176
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch_swizzled.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch_swizzled.cpp
index fe2c7db85..3500a4559 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch_swizzled.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch_swizzled.cpp
@@ -95,18 +95,21 @@ IR::Value Sample(TranslatorVisitor& v, u64 insn) {
95 {}, info); 95 {}, info);
96 case 4: // 2D.DC 96 case 4: // 2D.DC
97 CheckAlignment(reg_a, 2); 97 CheckAlignment(reg_a, 2);
98 info.type.Assign(TextureType::Shadow2D); 98 info.type.Assign(TextureType::Color2D);
99 info.is_depth.Assign(1);
99 return v.ir.ImageSampleDrefImplicitLod(handle, Composite(v, reg_a, reg_a + 1), v.F(reg_b), 100 return v.ir.ImageSampleDrefImplicitLod(handle, Composite(v, reg_a, reg_a + 1), v.F(reg_b),
100 {}, {}, {}, info); 101 {}, {}, {}, info);
101 case 5: // 2D.LL.DC 102 case 5: // 2D.LL.DC
102 CheckAlignment(reg_a, 2); 103 CheckAlignment(reg_a, 2);
103 CheckAlignment(reg_b, 2); 104 CheckAlignment(reg_b, 2);
104 info.type.Assign(TextureType::Shadow2D); 105 info.type.Assign(TextureType::Color2D);
106 info.is_depth.Assign(1);
105 return v.ir.ImageSampleDrefExplicitLod(handle, Composite(v, reg_a, reg_a + 1), 107 return v.ir.ImageSampleDrefExplicitLod(handle, Composite(v, reg_a, reg_a + 1),
106 v.F(reg_b + 1), v.F(reg_b), {}, {}, info); 108 v.F(reg_b + 1), v.F(reg_b), {}, {}, info);
107 case 6: // 2D.LZ.DC 109 case 6: // 2D.LZ.DC
108 CheckAlignment(reg_a, 2); 110 CheckAlignment(reg_a, 2);
109 info.type.Assign(TextureType::Shadow2D); 111 info.type.Assign(TextureType::Color2D);
112 info.is_depth.Assign(1);
110 return v.ir.ImageSampleDrefExplicitLod(handle, Composite(v, reg_a, reg_a + 1), v.F(reg_b), 113 return v.ir.ImageSampleDrefExplicitLod(handle, Composite(v, reg_a, reg_a + 1), v.F(reg_b),
111 zero, {}, {}, info); 114 zero, {}, {}, info);
112 case 7: // ARRAY_2D 115 case 7: // ARRAY_2D
@@ -124,7 +127,8 @@ IR::Value Sample(TranslatorVisitor& v, u64 insn) {
124 case 9: // ARRAY_2D.LZ.DC 127 case 9: // ARRAY_2D.LZ.DC
125 CheckAlignment(reg_a, 2); 128 CheckAlignment(reg_a, 2);
126 CheckAlignment(reg_b, 2); 129 CheckAlignment(reg_b, 2);
127 info.type.Assign(TextureType::ShadowArray2D); 130 info.type.Assign(TextureType::ColorArray2D);
131 info.is_depth.Assign(1);
128 return v.ir.ImageSampleDrefExplicitLod( 132 return v.ir.ImageSampleDrefExplicitLod(
129 handle, v.ir.CompositeConstruct(v.F(reg_a + 1), v.F(reg_b), ReadArray(v, v.X(reg_a))), 133 handle, v.ir.CompositeConstruct(v.F(reg_a + 1), v.F(reg_b), ReadArray(v, v.X(reg_a))),
130 v.F(reg_b + 1), zero, {}, {}, info); 134 v.F(reg_b + 1), zero, {}, {}, info);
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp
index b2f9cda46..218cbc1a8 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp
@@ -37,24 +37,24 @@ enum class ComponentType : u64 {
37 A = 3, 37 A = 3,
38}; 38};
39 39
40Shader::TextureType GetType(TextureType type, bool dc) { 40Shader::TextureType GetType(TextureType type) {
41 switch (type) { 41 switch (type) {
42 case TextureType::_1D: 42 case TextureType::_1D:
43 return dc ? Shader::TextureType::Shadow1D : Shader::TextureType::Color1D; 43 return Shader::TextureType::Color1D;
44 case TextureType::ARRAY_1D: 44 case TextureType::ARRAY_1D:
45 return dc ? Shader::TextureType::ShadowArray1D : Shader::TextureType::ColorArray1D; 45 return Shader::TextureType::ColorArray1D;
46 case TextureType::_2D: 46 case TextureType::_2D:
47 return dc ? Shader::TextureType::Shadow2D : Shader::TextureType::Color2D; 47 return Shader::TextureType::Color2D;
48 case TextureType::ARRAY_2D: 48 case TextureType::ARRAY_2D:
49 return dc ? Shader::TextureType::ShadowArray2D : Shader::TextureType::ColorArray2D; 49 return Shader::TextureType::ColorArray2D;
50 case TextureType::_3D: 50 case TextureType::_3D:
51 return dc ? Shader::TextureType::Shadow3D : Shader::TextureType::Color3D; 51 return Shader::TextureType::Color3D;
52 case TextureType::ARRAY_3D: 52 case TextureType::ARRAY_3D:
53 throw NotImplementedException("3D array texture type"); 53 throw NotImplementedException("3D array texture type");
54 case TextureType::CUBE: 54 case TextureType::CUBE:
55 return dc ? Shader::TextureType::ShadowCube : Shader::TextureType::ColorCube; 55 return Shader::TextureType::ColorCube;
56 case TextureType::ARRAY_CUBE: 56 case TextureType::ARRAY_CUBE:
57 return dc ? Shader::TextureType::ShadowArrayCube : Shader::TextureType::ColorArrayCube; 57 return Shader::TextureType::ColorArrayCube;
58 } 58 }
59 throw NotImplementedException("Invalid texture type {}", type); 59 throw NotImplementedException("Invalid texture type {}", type);
60} 60}
@@ -163,7 +163,8 @@ void Impl(TranslatorVisitor& v, u64 insn, ComponentType component_type, OffsetTy
163 dref = v.F(meta_reg++); 163 dref = v.F(meta_reg++);
164 } 164 }
165 IR::TextureInstInfo info{}; 165 IR::TextureInstInfo info{};
166 info.type.Assign(GetType(tld4.type, tld4.dc != 0)); 166 info.type.Assign(GetType(tld4.type));
167 info.is_depth.Assign(tld4.dc != 0 ? 1 : 0);
167 info.gather_component.Assign(static_cast<u32>(component_type)); 168 info.gather_component.Assign(static_cast<u32>(component_type));
168 const IR::Value sample{[&] { 169 const IR::Value sample{[&] {
169 if (tld4.dc == 0) { 170 if (tld4.dc == 0) {
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather_swizzled.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather_swizzled.cpp
index 2ba9c1018..34efa2d50 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather_swizzled.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather_swizzled.cpp
@@ -59,7 +59,8 @@ IR::Value Sample(TranslatorVisitor& v, u64 insn) {
59 info.relaxed_precision.Assign(1); 59 info.relaxed_precision.Assign(1);
60 } 60 }
61 info.gather_component.Assign(static_cast<u32>(tld4s.component_type.Value())); 61 info.gather_component.Assign(static_cast<u32>(tld4s.component_type.Value()));
62 info.type.Assign(tld4s.dc != 0 ? Shader::TextureType::Shadow2D : Shader::TextureType::Color2D); 62 info.type.Assign(Shader::TextureType::Color2D);
63 info.is_depth.Assign(tld4s.dc != 0 ? 1 : 0);
63 IR::Value coords; 64 IR::Value coords;
64 if (tld4s.aoffi != 0) { 65 if (tld4s.aoffi != 0) {
65 CheckAlignment(reg_a, 2); 66 CheckAlignment(reg_a, 2);
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gradient.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gradient.cpp
index c66468a48..c3fe3ffda 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gradient.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gradient.cpp
@@ -23,24 +23,24 @@ enum class TextureType : u64 {
23 ARRAY_CUBE, 23 ARRAY_CUBE,
24}; 24};
25 25
26Shader::TextureType GetType(TextureType type, bool dc) { 26Shader::TextureType GetType(TextureType type) {
27 switch (type) { 27 switch (type) {
28 case TextureType::_1D: 28 case TextureType::_1D:
29 return dc ? Shader::TextureType::Shadow1D : Shader::TextureType::Color1D; 29 return Shader::TextureType::Color1D;
30 case TextureType::ARRAY_1D: 30 case TextureType::ARRAY_1D:
31 return dc ? Shader::TextureType::ShadowArray1D : Shader::TextureType::ColorArray1D; 31 return Shader::TextureType::ColorArray1D;
32 case TextureType::_2D: 32 case TextureType::_2D:
33 return dc ? Shader::TextureType::Shadow2D : Shader::TextureType::Color2D; 33 return Shader::TextureType::Color2D;
34 case TextureType::ARRAY_2D: 34 case TextureType::ARRAY_2D:
35 return dc ? Shader::TextureType::ShadowArray2D : Shader::TextureType::ColorArray2D; 35 return Shader::TextureType::ColorArray2D;
36 case TextureType::_3D: 36 case TextureType::_3D:
37 return dc ? Shader::TextureType::Shadow3D : Shader::TextureType::Color3D; 37 return Shader::TextureType::Color3D;
38 case TextureType::ARRAY_3D: 38 case TextureType::ARRAY_3D:
39 throw NotImplementedException("3D array texture type"); 39 throw NotImplementedException("3D array texture type");
40 case TextureType::CUBE: 40 case TextureType::CUBE:
41 return dc ? Shader::TextureType::ShadowCube : Shader::TextureType::ColorCube; 41 return Shader::TextureType::ColorCube;
42 case TextureType::ARRAY_CUBE: 42 case TextureType::ARRAY_CUBE:
43 return dc ? Shader::TextureType::ShadowArrayCube : Shader::TextureType::ColorArrayCube; 43 return Shader::TextureType::ColorArrayCube;
44 } 44 }
45 throw NotImplementedException("Invalid texture type {}", type); 45 throw NotImplementedException("Invalid texture type {}", type);
46} 46}
@@ -152,7 +152,7 @@ void Impl(TranslatorVisitor& v, u64 insn, bool is_bindless) {
152 } 152 }
153 153
154 IR::TextureInstInfo info{}; 154 IR::TextureInstInfo info{};
155 info.type.Assign(GetType(txd.type, false)); 155 info.type.Assign(GetType(txd.type));
156 info.num_derivates.Assign(num_derivates); 156 info.num_derivates.Assign(num_derivates);
157 info.has_lod_clamp.Assign(has_lod_clamp ? 1 : 0); 157 info.has_lod_clamp.Assign(has_lod_clamp ? 1 : 0);
158 const IR::Value sample{v.ir.ImageGradient(handle, coords, derivates, offset, lod_clamp, info)}; 158 const IR::Value sample{v.ir.ImageGradient(handle, coords, derivates, offset, lod_clamp, info)};
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_load.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_load.cpp
index 987b7ec34..983058303 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_load.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_load.cpp
@@ -23,24 +23,24 @@ enum class TextureType : u64 {
23 ARRAY_CUBE, 23 ARRAY_CUBE,
24}; 24};
25 25
26Shader::TextureType GetType(TextureType type, bool dc) { 26Shader::TextureType GetType(TextureType type) {
27 switch (type) { 27 switch (type) {
28 case TextureType::_1D: 28 case TextureType::_1D:
29 return dc ? Shader::TextureType::Shadow1D : Shader::TextureType::Color1D; 29 return Shader::TextureType::Color1D;
30 case TextureType::ARRAY_1D: 30 case TextureType::ARRAY_1D:
31 return dc ? Shader::TextureType::ShadowArray1D : Shader::TextureType::ColorArray1D; 31 return Shader::TextureType::ColorArray1D;
32 case TextureType::_2D: 32 case TextureType::_2D:
33 return dc ? Shader::TextureType::Shadow2D : Shader::TextureType::Color2D; 33 return Shader::TextureType::Color2D;
34 case TextureType::ARRAY_2D: 34 case TextureType::ARRAY_2D:
35 return dc ? Shader::TextureType::ShadowArray2D : Shader::TextureType::ColorArray2D; 35 return Shader::TextureType::ColorArray2D;
36 case TextureType::_3D: 36 case TextureType::_3D:
37 return dc ? Shader::TextureType::Shadow3D : Shader::TextureType::Color3D; 37 return Shader::TextureType::Color3D;
38 case TextureType::ARRAY_3D: 38 case TextureType::ARRAY_3D:
39 throw NotImplementedException("3D array texture type"); 39 throw NotImplementedException("3D array texture type");
40 case TextureType::CUBE: 40 case TextureType::CUBE:
41 return dc ? Shader::TextureType::ShadowCube : Shader::TextureType::ColorCube; 41 return Shader::TextureType::ColorCube;
42 case TextureType::ARRAY_CUBE: 42 case TextureType::ARRAY_CUBE:
43 return dc ? Shader::TextureType::ShadowArrayCube : Shader::TextureType::ColorArrayCube; 43 return Shader::TextureType::ColorArrayCube;
44 } 44 }
45 throw NotImplementedException("Invalid texture type {}", type); 45 throw NotImplementedException("Invalid texture type {}", type);
46} 46}
@@ -137,7 +137,7 @@ void Impl(TranslatorVisitor& v, u64 insn, bool is_bindless) {
137 throw NotImplementedException("TLD.CL - CLAMP is not implmented"); 137 throw NotImplementedException("TLD.CL - CLAMP is not implmented");
138 } 138 }
139 IR::TextureInstInfo info{}; 139 IR::TextureInstInfo info{};
140 info.type.Assign(GetType(tld.type, false)); 140 info.type.Assign(GetType(tld.type));
141 const IR::Value sample{v.ir.ImageFetch(handle, coords, offset, lod, multisample, info)}; 141 const IR::Value sample{v.ir.ImageFetch(handle, coords, offset, lod, multisample, info)};
142 142
143 IR::Reg dest_reg{tld.dest_reg}; 143 IR::Reg dest_reg{tld.dest_reg};
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_load_swizzled.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_load_swizzled.cpp
index 0863bdfcd..5dd7e31b2 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_load_swizzled.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_load_swizzled.cpp
@@ -2,7 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <utility> 5#include <array>
6 6
7#include "common/bit_field.h" 7#include "common/bit_field.h"
8#include "common/common_types.h" 8#include "common/common_types.h"
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_mipmap_level.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_mipmap_level.cpp
index b6efc04f0..2277d24ff 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_mipmap_level.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_mipmap_level.cpp
@@ -23,24 +23,24 @@ enum class TextureType : u64 {
23 ARRAY_CUBE, 23 ARRAY_CUBE,
24}; 24};
25 25
26Shader::TextureType GetType(TextureType type, bool dc) { 26Shader::TextureType GetType(TextureType type) {
27 switch (type) { 27 switch (type) {
28 case TextureType::_1D: 28 case TextureType::_1D:
29 return dc ? Shader::TextureType::Shadow1D : Shader::TextureType::Color1D; 29 return Shader::TextureType::Color1D;
30 case TextureType::ARRAY_1D: 30 case TextureType::ARRAY_1D:
31 return dc ? Shader::TextureType::ShadowArray1D : Shader::TextureType::ColorArray1D; 31 return Shader::TextureType::ColorArray1D;
32 case TextureType::_2D: 32 case TextureType::_2D:
33 return dc ? Shader::TextureType::Shadow2D : Shader::TextureType::Color2D; 33 return Shader::TextureType::Color2D;
34 case TextureType::ARRAY_2D: 34 case TextureType::ARRAY_2D:
35 return dc ? Shader::TextureType::ShadowArray2D : Shader::TextureType::ColorArray2D; 35 return Shader::TextureType::ColorArray2D;
36 case TextureType::_3D: 36 case TextureType::_3D:
37 return dc ? Shader::TextureType::Shadow3D : Shader::TextureType::Color3D; 37 return Shader::TextureType::Color3D;
38 case TextureType::ARRAY_3D: 38 case TextureType::ARRAY_3D:
39 throw NotImplementedException("3D array texture type"); 39 throw NotImplementedException("3D array texture type");
40 case TextureType::CUBE: 40 case TextureType::CUBE:
41 return dc ? Shader::TextureType::ShadowCube : Shader::TextureType::ColorCube; 41 return Shader::TextureType::ColorCube;
42 case TextureType::ARRAY_CUBE: 42 case TextureType::ARRAY_CUBE:
43 return dc ? Shader::TextureType::ShadowArrayCube : Shader::TextureType::ColorArrayCube; 43 return Shader::TextureType::ColorArrayCube;
44 } 44 }
45 throw NotImplementedException("Invalid texture type {}", type); 45 throw NotImplementedException("Invalid texture type {}", type);
46} 46}
@@ -97,7 +97,7 @@ void Impl(TranslatorVisitor& v, u64 insn, bool is_bindless) {
97 handle = v.ir.Imm32(static_cast<u32>(tmml.cbuf_offset.Value() * 4)); 97 handle = v.ir.Imm32(static_cast<u32>(tmml.cbuf_offset.Value() * 4));
98 } 98 }
99 IR::TextureInstInfo info{}; 99 IR::TextureInstInfo info{};
100 info.type.Assign(GetType(tmml.type, false)); 100 info.type.Assign(GetType(tmml.type));
101 const IR::Value sample{v.ir.ImageQueryLod(handle, coords, info)}; 101 const IR::Value sample{v.ir.ImageQueryLod(handle, coords, info)};
102 102
103 IR::Reg dest_reg{tmml.dest_reg}; 103 IR::Reg dest_reg{tmml.dest_reg};