diff options
Diffstat (limited to 'src/shader_recompiler/frontend')
14 files changed, 365 insertions, 68 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index a2104bdb3..17be0c639 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -1620,6 +1620,17 @@ Value IREmitter::ImageGradient(const Value& handle, const Value& coords, const V | |||
| 1620 | return Inst(op, Flags{info}, handle, coords, derivates, offset, lod_clamp); | 1620 | return Inst(op, Flags{info}, handle, coords, derivates, offset, lod_clamp); |
| 1621 | } | 1621 | } |
| 1622 | 1622 | ||
| 1623 | Value IREmitter::ImageRead(const Value& handle, const Value& coords, TextureInstInfo info) { | ||
| 1624 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageRead : Opcode::BindlessImageRead}; | ||
| 1625 | return Inst(op, Flags{info}, handle, coords); | ||
| 1626 | } | ||
| 1627 | |||
| 1628 | void IREmitter::ImageWrite(const Value& handle, const Value& coords, const Value& color, | ||
| 1629 | TextureInstInfo info) { | ||
| 1630 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageWrite : Opcode::BindlessImageWrite}; | ||
| 1631 | Inst(op, Flags{info}, handle, coords, color); | ||
| 1632 | } | ||
| 1633 | |||
| 1623 | U1 IREmitter::VoteAll(const U1& value) { | 1634 | U1 IREmitter::VoteAll(const U1& value) { |
| 1624 | return Inst<U1>(Opcode::VoteAll, value); | 1635 | return Inst<U1>(Opcode::VoteAll, value); |
| 1625 | } | 1636 | } |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 2cab1dc5d..ec60070ef 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -265,20 +265,19 @@ public: | |||
| 265 | 265 | ||
| 266 | [[nodiscard]] Value ImageQueryLod(const Value& handle, const Value& coords, | 266 | [[nodiscard]] Value ImageQueryLod(const Value& handle, const Value& coords, |
| 267 | TextureInstInfo info); | 267 | TextureInstInfo info); |
| 268 | |||
| 269 | [[nodiscard]] Value ImageGather(const Value& handle, const Value& coords, const Value& offset, | 268 | [[nodiscard]] Value ImageGather(const Value& handle, const Value& coords, const Value& offset, |
| 270 | const Value& offset2, TextureInstInfo info); | 269 | const Value& offset2, TextureInstInfo info); |
| 271 | |||
| 272 | [[nodiscard]] Value ImageGatherDref(const Value& handle, const Value& coords, | 270 | [[nodiscard]] Value ImageGatherDref(const Value& handle, const Value& coords, |
| 273 | const Value& offset, const Value& offset2, const F32& dref, | 271 | const Value& offset, const Value& offset2, const F32& dref, |
| 274 | TextureInstInfo info); | 272 | TextureInstInfo info); |
| 275 | |||
| 276 | [[nodiscard]] Value ImageFetch(const Value& handle, const Value& coords, const Value& offset, | 273 | [[nodiscard]] Value ImageFetch(const Value& handle, const Value& coords, const Value& offset, |
| 277 | const U32& lod, const U32& multisampling, TextureInstInfo info); | 274 | const U32& lod, const U32& multisampling, TextureInstInfo info); |
| 278 | |||
| 279 | [[nodiscard]] Value ImageGradient(const Value& handle, const Value& coords, | 275 | [[nodiscard]] Value ImageGradient(const Value& handle, const Value& coords, |
| 280 | const Value& derivates, const Value& offset, | 276 | const Value& derivates, const Value& offset, |
| 281 | const F32& lod_clamp, TextureInstInfo info); | 277 | const F32& lod_clamp, TextureInstInfo info); |
| 278 | [[nodiscard]] Value ImageRead(const Value& handle, const Value& coords, TextureInstInfo info); | ||
| 279 | [[nodiscard]] void ImageWrite(const Value& handle, const Value& coords, const Value& color, | ||
| 280 | TextureInstInfo info); | ||
| 282 | 281 | ||
| 283 | [[nodiscard]] U1 VoteAll(const U1& value); | 282 | [[nodiscard]] U1 VoteAll(const U1& value); |
| 284 | [[nodiscard]] U1 VoteAny(const U1& value); | 283 | [[nodiscard]] U1 VoteAny(const U1& value); |
diff --git a/src/shader_recompiler/frontend/ir/modifiers.h b/src/shader_recompiler/frontend/ir/modifiers.h index 461671326..447e9703c 100644 --- a/src/shader_recompiler/frontend/ir/modifiers.h +++ b/src/shader_recompiler/frontend/ir/modifiers.h | |||
| @@ -43,11 +43,13 @@ static_assert(sizeof(FpControl) <= sizeof(u32)); | |||
| 43 | union TextureInstInfo { | 43 | union TextureInstInfo { |
| 44 | u32 raw; | 44 | u32 raw; |
| 45 | BitField<0, 8, TextureType> type; | 45 | BitField<0, 8, TextureType> type; |
| 46 | BitField<8, 1, u32> has_bias; | 46 | BitField<8, 1, u32> is_depth; |
| 47 | BitField<9, 1, u32> has_lod_clamp; | 47 | BitField<9, 1, u32> has_bias; |
| 48 | BitField<10, 1, u32> relaxed_precision; | 48 | BitField<10, 1, u32> has_lod_clamp; |
| 49 | BitField<11, 2, u32> gather_component; | 49 | BitField<11, 1, u32> relaxed_precision; |
| 50 | BitField<13, 2, u32> num_derivates; | 50 | BitField<12, 2, u32> gather_component; |
| 51 | BitField<14, 2, u32> num_derivates; | ||
| 52 | BitField<16, 3, ImageFormat> image_format; | ||
| 51 | }; | 53 | }; |
| 52 | static_assert(sizeof(TextureInstInfo) <= sizeof(u32)); | 54 | static_assert(sizeof(TextureInstInfo) <= sizeof(u32)); |
| 53 | 55 | ||
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc index 1697de965..82c5b37ba 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.inc +++ b/src/shader_recompiler/frontend/ir/opcodes.inc | |||
| @@ -389,6 +389,8 @@ OPCODE(BindlessImageFetch, F32x4, U32, | |||
| 389 | OPCODE(BindlessImageQueryDimensions, U32x4, U32, U32, ) | 389 | OPCODE(BindlessImageQueryDimensions, U32x4, U32, U32, ) |
| 390 | OPCODE(BindlessImageQueryLod, F32x4, U32, Opaque, ) | 390 | OPCODE(BindlessImageQueryLod, F32x4, U32, Opaque, ) |
| 391 | OPCODE(BindlessImageGradient, F32x4, U32, Opaque, Opaque, Opaque, Opaque, ) | 391 | OPCODE(BindlessImageGradient, F32x4, U32, Opaque, Opaque, Opaque, Opaque, ) |
| 392 | OPCODE(BindlessImageRead, U32x4, U32, Opaque, ) | ||
| 393 | OPCODE(BindlessImageWrite, Void, U32, Opaque, U32x4, ) | ||
| 392 | 394 | ||
| 393 | OPCODE(BoundImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) | 395 | OPCODE(BoundImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) |
| 394 | OPCODE(BoundImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) | 396 | OPCODE(BoundImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) |
| @@ -400,6 +402,8 @@ OPCODE(BoundImageFetch, F32x4, U32, | |||
| 400 | OPCODE(BoundImageQueryDimensions, U32x4, U32, U32, ) | 402 | OPCODE(BoundImageQueryDimensions, U32x4, U32, U32, ) |
| 401 | OPCODE(BoundImageQueryLod, F32x4, U32, Opaque, ) | 403 | OPCODE(BoundImageQueryLod, F32x4, U32, Opaque, ) |
| 402 | OPCODE(BoundImageGradient, F32x4, U32, Opaque, Opaque, Opaque, Opaque, ) | 404 | OPCODE(BoundImageGradient, F32x4, U32, Opaque, Opaque, Opaque, Opaque, ) |
| 405 | OPCODE(BoundImageRead, U32x4, U32, Opaque, ) | ||
| 406 | OPCODE(BoundImageWrite, Void, U32, Opaque, U32x4, ) | ||
| 403 | 407 | ||
| 404 | OPCODE(ImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) | 408 | OPCODE(ImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) |
| 405 | OPCODE(ImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) | 409 | OPCODE(ImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) |
| @@ -411,6 +415,8 @@ OPCODE(ImageFetch, F32x4, U32, | |||
| 411 | OPCODE(ImageQueryDimensions, U32x4, U32, U32, ) | 415 | OPCODE(ImageQueryDimensions, U32x4, U32, U32, ) |
| 412 | OPCODE(ImageQueryLod, F32x4, U32, Opaque, ) | 416 | OPCODE(ImageQueryLod, F32x4, U32, Opaque, ) |
| 413 | OPCODE(ImageGradient, F32x4, U32, Opaque, Opaque, Opaque, Opaque, ) | 417 | OPCODE(ImageGradient, F32x4, U32, Opaque, Opaque, Opaque, Opaque, ) |
| 418 | OPCODE(ImageRead, U32x4, U32, Opaque, ) | ||
| 419 | OPCODE(ImageWrite, Void, U32, Opaque, U32x4, ) | ||
| 414 | 420 | ||
| 415 | // Warp operations | 421 | // Warp operations |
| 416 | OPCODE(VoteAll, U1, U1, ) | 422 | OPCODE(VoteAll, U1, U1, ) |
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 | ||
| 284 | void TranslatorVisitor::SULD(u64) { | ||
| 285 | ThrowNotImplemented(Opcode::SULD); | ||
| 286 | } | ||
| 287 | |||
| 288 | void TranslatorVisitor::SURED(u64) { | 284 | void TranslatorVisitor::SURED(u64) { |
| 289 | ThrowNotImplemented(Opcode::SURED); | 285 | ThrowNotImplemented(Opcode::SURED); |
| 290 | } | 286 | } |
| 291 | 287 | ||
| 292 | void TranslatorVisitor::SUST(u64) { | ||
| 293 | ThrowNotImplemented(Opcode::SUST); | ||
| 294 | } | ||
| 295 | |||
| 296 | void TranslatorVisitor::SYNC(u64) { | 288 | void 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 | |||
| 13 | namespace Shader::Maxwell { | ||
| 14 | namespace { | ||
| 15 | enum class Type : u64 { | ||
| 16 | _1D, | ||
| 17 | BUFFER_1D, | ||
| 18 | ARRAY_1D, | ||
| 19 | _2D, | ||
| 20 | ARRAY_2D, | ||
| 21 | _3D, | ||
| 22 | }; | ||
| 23 | |||
| 24 | constexpr unsigned R = 1 << 0; | ||
| 25 | constexpr unsigned G = 1 << 1; | ||
| 26 | constexpr unsigned B = 1 << 2; | ||
| 27 | constexpr unsigned A = 1 << 3; | ||
| 28 | |||
| 29 | constexpr 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 | |||
| 48 | enum class Size : u64 { | ||
| 49 | U8, | ||
| 50 | S8, | ||
| 51 | U16, | ||
| 52 | S16, | ||
| 53 | B32, | ||
| 54 | B64, | ||
| 55 | B128, | ||
| 56 | }; | ||
| 57 | |||
| 58 | enum class Clamp : u64 { | ||
| 59 | IGN, | ||
| 60 | Default, | ||
| 61 | TRAP, | ||
| 62 | }; | ||
| 63 | |||
| 64 | enum class LoadCache : u64 { | ||
| 65 | Default, | ||
| 66 | CG, | ||
| 67 | CI, | ||
| 68 | CV, | ||
| 69 | }; | ||
| 70 | |||
| 71 | enum class StoreCache : u64 { | ||
| 72 | Default, | ||
| 73 | CG, | ||
| 74 | CS, | ||
| 75 | WT, | ||
| 76 | }; | ||
| 77 | |||
| 78 | ImageFormat 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 | |||
| 98 | int 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 | |||
| 114 | TextureType 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 | |||
| 132 | IR::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 | |||
| 152 | unsigned SwizzleMask(u64 swizzle) { | ||
| 153 | if (swizzle == 0 || swizzle >= MASK.size()) { | ||
| 154 | throw NotImplementedException("Invalid swizzle {}", swizzle); | ||
| 155 | } | ||
| 156 | return MASK[swizzle]; | ||
| 157 | } | ||
| 158 | |||
| 159 | IR::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 | |||
| 171 | void 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 | |||
| 231 | void 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 | ||
| 36 | Shader::TextureType GetType(TextureType type, bool dc) { | 36 | Shader::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 | ||
| 40 | Shader::TextureType GetType(TextureType type, bool dc) { | 40 | Shader::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 | ||
| 26 | Shader::TextureType GetType(TextureType type, bool dc) { | 26 | Shader::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 | ||
| 26 | Shader::TextureType GetType(TextureType type, bool dc) { | 26 | Shader::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 | ||
| 26 | Shader::TextureType GetType(TextureType type, bool dc) { | 26 | Shader::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}; |