diff options
Diffstat (limited to 'src/shader_recompiler/frontend')
4 files changed, 17 insertions, 22 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index def29143e..94bdbe39c 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -1778,12 +1778,10 @@ Value IREmitter::ImageSampleImplicitLod(const Value& handle, const Value& coords | |||
| 1778 | } | 1778 | } |
| 1779 | 1779 | ||
| 1780 | Value IREmitter::ImageSampleExplicitLod(const Value& handle, const Value& coords, const F32& lod, | 1780 | Value IREmitter::ImageSampleExplicitLod(const Value& handle, const Value& coords, const F32& lod, |
| 1781 | const Value& offset, const F32& lod_clamp, | 1781 | const Value& offset, TextureInstInfo info) { |
| 1782 | TextureInstInfo info) { | ||
| 1783 | const Value lod_lc{MakeLodClampPair(*this, lod, lod_clamp)}; | ||
| 1784 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageSampleExplicitLod | 1782 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageSampleExplicitLod |
| 1785 | : Opcode::BindlessImageSampleExplicitLod}; | 1783 | : Opcode::BindlessImageSampleExplicitLod}; |
| 1786 | return Inst(op, Flags{info}, handle, coords, lod_lc, offset); | 1784 | return Inst(op, Flags{info}, handle, coords, lod, offset); |
| 1787 | } | 1785 | } |
| 1788 | 1786 | ||
| 1789 | F32 IREmitter::ImageSampleDrefImplicitLod(const Value& handle, const Value& coords, const F32& dref, | 1787 | F32 IREmitter::ImageSampleDrefImplicitLod(const Value& handle, const Value& coords, const F32& dref, |
| @@ -1796,12 +1794,11 @@ F32 IREmitter::ImageSampleDrefImplicitLod(const Value& handle, const Value& coor | |||
| 1796 | } | 1794 | } |
| 1797 | 1795 | ||
| 1798 | F32 IREmitter::ImageSampleDrefExplicitLod(const Value& handle, const Value& coords, const F32& dref, | 1796 | F32 IREmitter::ImageSampleDrefExplicitLod(const Value& handle, const Value& coords, const F32& dref, |
| 1799 | const F32& lod, const Value& offset, const F32& lod_clamp, | 1797 | const F32& lod, const Value& offset, |
| 1800 | TextureInstInfo info) { | 1798 | TextureInstInfo info) { |
| 1801 | const Value lod_lc{MakeLodClampPair(*this, lod, lod_clamp)}; | ||
| 1802 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageSampleDrefExplicitLod | 1799 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageSampleDrefExplicitLod |
| 1803 | : Opcode::BindlessImageSampleDrefExplicitLod}; | 1800 | : Opcode::BindlessImageSampleDrefExplicitLod}; |
| 1804 | return Inst<F32>(op, Flags{info}, handle, coords, dref, lod_lc, offset); | 1801 | return Inst<F32>(op, Flags{info}, handle, coords, dref, lod, offset); |
| 1805 | } | 1802 | } |
| 1806 | 1803 | ||
| 1807 | Value IREmitter::ImageGather(const Value& handle, const Value& coords, const Value& offset, | 1804 | Value IREmitter::ImageGather(const Value& handle, const Value& coords, const Value& offset, |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 4f7c820fe..4ae69b788 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -302,15 +302,14 @@ public: | |||
| 302 | const F32& lod_clamp, TextureInstInfo info); | 302 | const F32& lod_clamp, TextureInstInfo info); |
| 303 | [[nodiscard]] Value ImageSampleExplicitLod(const Value& handle, const Value& coords, | 303 | [[nodiscard]] Value ImageSampleExplicitLod(const Value& handle, const Value& coords, |
| 304 | const F32& lod, const Value& offset, | 304 | const F32& lod, const Value& offset, |
| 305 | const F32& lod_clamp, TextureInstInfo info); | 305 | TextureInstInfo info); |
| 306 | [[nodiscard]] F32 ImageSampleDrefImplicitLod(const Value& handle, const Value& coords, | 306 | [[nodiscard]] F32 ImageSampleDrefImplicitLod(const Value& handle, const Value& coords, |
| 307 | const F32& dref, const F32& bias, | 307 | const F32& dref, const F32& bias, |
| 308 | const Value& offset, const F32& lod_clamp, | 308 | const Value& offset, const F32& lod_clamp, |
| 309 | TextureInstInfo info); | 309 | TextureInstInfo info); |
| 310 | [[nodiscard]] F32 ImageSampleDrefExplicitLod(const Value& handle, const Value& coords, | 310 | [[nodiscard]] F32 ImageSampleDrefExplicitLod(const Value& handle, const Value& coords, |
| 311 | const F32& dref, const F32& lod, | 311 | const F32& dref, const F32& lod, |
| 312 | const Value& offset, const F32& lod_clamp, | 312 | const Value& offset, TextureInstInfo info); |
| 313 | TextureInstInfo info); | ||
| 314 | [[nodiscard]] Value ImageQueryDimension(const Value& handle, const IR::U32& lod); | 313 | [[nodiscard]] Value ImageQueryDimension(const Value& handle, const IR::U32& lod); |
| 315 | 314 | ||
| 316 | [[nodiscard]] Value ImageQueryLod(const Value& handle, const Value& coords, | 315 | [[nodiscard]] Value ImageQueryLod(const Value& handle, const Value& coords, |
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 9671d115e..0046b5edd 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch.cpp | |||
| @@ -177,14 +177,13 @@ void Impl(TranslatorVisitor& v, u64 insn, bool aoffi, Blod blod, bool lc, | |||
| 177 | const IR::Value sample{[&]() -> IR::Value { | 177 | const IR::Value sample{[&]() -> IR::Value { |
| 178 | if (tex.dc == 0) { | 178 | if (tex.dc == 0) { |
| 179 | if (HasExplicitLod(blod)) { | 179 | if (HasExplicitLod(blod)) { |
| 180 | return v.ir.ImageSampleExplicitLod(handle, coords, lod, offset, lod_clamp, info); | 180 | return v.ir.ImageSampleExplicitLod(handle, coords, lod, offset, info); |
| 181 | } else { | 181 | } else { |
| 182 | return v.ir.ImageSampleImplicitLod(handle, coords, lod, offset, lod_clamp, info); | 182 | return v.ir.ImageSampleImplicitLod(handle, coords, lod, offset, lod_clamp, info); |
| 183 | } | 183 | } |
| 184 | } | 184 | } |
| 185 | if (HasExplicitLod(blod)) { | 185 | if (HasExplicitLod(blod)) { |
| 186 | return v.ir.ImageSampleDrefExplicitLod(handle, coords, dref, lod, offset, lod_clamp, | 186 | return v.ir.ImageSampleDrefExplicitLod(handle, coords, dref, lod, offset, info); |
| 187 | info); | ||
| 188 | } else { | 187 | } else { |
| 189 | return v.ir.ImageSampleDrefImplicitLod(handle, coords, dref, lod, offset, lod_clamp, | 188 | return v.ir.ImageSampleDrefImplicitLod(handle, coords, dref, lod, offset, lod_clamp, |
| 190 | info); | 189 | info); |
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 3500a4559..154e7f1a1 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 | |||
| @@ -81,18 +81,18 @@ IR::Value Sample(TranslatorVisitor& v, u64 insn) { | |||
| 81 | switch (texs.encoding) { | 81 | switch (texs.encoding) { |
| 82 | case 0: // 1D.LZ | 82 | case 0: // 1D.LZ |
| 83 | info.type.Assign(TextureType::Color1D); | 83 | info.type.Assign(TextureType::Color1D); |
| 84 | return v.ir.ImageSampleExplicitLod(handle, v.F(reg_a), zero, {}, {}, info); | 84 | return v.ir.ImageSampleExplicitLod(handle, v.F(reg_a), zero, {}, info); |
| 85 | case 1: // 2D | 85 | case 1: // 2D |
| 86 | info.type.Assign(TextureType::Color2D); | 86 | info.type.Assign(TextureType::Color2D); |
| 87 | return v.ir.ImageSampleImplicitLod(handle, Composite(v, reg_a, reg_b), {}, {}, {}, info); | 87 | return v.ir.ImageSampleImplicitLod(handle, Composite(v, reg_a, reg_b), {}, {}, {}, info); |
| 88 | case 2: // 2D.LZ | 88 | case 2: // 2D.LZ |
| 89 | info.type.Assign(TextureType::Color2D); | 89 | info.type.Assign(TextureType::Color2D); |
| 90 | return v.ir.ImageSampleExplicitLod(handle, Composite(v, reg_a, reg_b), zero, {}, {}, info); | 90 | return v.ir.ImageSampleExplicitLod(handle, Composite(v, reg_a, reg_b), zero, {}, info); |
| 91 | case 3: // 2D.LL | 91 | case 3: // 2D.LL |
| 92 | CheckAlignment(reg_a, 2); | 92 | CheckAlignment(reg_a, 2); |
| 93 | info.type.Assign(TextureType::Color2D); | 93 | info.type.Assign(TextureType::Color2D); |
| 94 | return v.ir.ImageSampleExplicitLod(handle, Composite(v, reg_a, reg_a + 1), v.F(reg_b), {}, | 94 | return v.ir.ImageSampleExplicitLod(handle, Composite(v, reg_a, reg_a + 1), v.F(reg_b), {}, |
| 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::Color2D); | 98 | info.type.Assign(TextureType::Color2D); |
| @@ -105,13 +105,13 @@ IR::Value Sample(TranslatorVisitor& v, u64 insn) { | |||
| 105 | info.type.Assign(TextureType::Color2D); | 105 | info.type.Assign(TextureType::Color2D); |
| 106 | info.is_depth.Assign(1); | 106 | info.is_depth.Assign(1); |
| 107 | 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), |
| 108 | v.F(reg_b + 1), v.F(reg_b), {}, {}, info); | 108 | v.F(reg_b + 1), v.F(reg_b), {}, info); |
| 109 | case 6: // 2D.LZ.DC | 109 | case 6: // 2D.LZ.DC |
| 110 | CheckAlignment(reg_a, 2); | 110 | CheckAlignment(reg_a, 2); |
| 111 | info.type.Assign(TextureType::Color2D); | 111 | info.type.Assign(TextureType::Color2D); |
| 112 | info.is_depth.Assign(1); | 112 | info.is_depth.Assign(1); |
| 113 | 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), |
| 114 | zero, {}, {}, info); | 114 | zero, {}, info); |
| 115 | case 7: // ARRAY_2D | 115 | case 7: // ARRAY_2D |
| 116 | CheckAlignment(reg_a, 2); | 116 | CheckAlignment(reg_a, 2); |
| 117 | info.type.Assign(TextureType::ColorArray2D); | 117 | info.type.Assign(TextureType::ColorArray2D); |
| @@ -123,7 +123,7 @@ IR::Value Sample(TranslatorVisitor& v, u64 insn) { | |||
| 123 | info.type.Assign(TextureType::ColorArray2D); | 123 | info.type.Assign(TextureType::ColorArray2D); |
| 124 | return v.ir.ImageSampleExplicitLod( | 124 | return v.ir.ImageSampleExplicitLod( |
| 125 | handle, v.ir.CompositeConstruct(v.F(reg_a + 1), v.F(reg_b), ReadArray(v, v.X(reg_a))), | 125 | handle, v.ir.CompositeConstruct(v.F(reg_a + 1), v.F(reg_b), ReadArray(v, v.X(reg_a))), |
| 126 | zero, {}, {}, info); | 126 | zero, {}, info); |
| 127 | case 9: // ARRAY_2D.LZ.DC | 127 | case 9: // ARRAY_2D.LZ.DC |
| 128 | CheckAlignment(reg_a, 2); | 128 | CheckAlignment(reg_a, 2); |
| 129 | CheckAlignment(reg_b, 2); | 129 | CheckAlignment(reg_b, 2); |
| @@ -131,7 +131,7 @@ IR::Value Sample(TranslatorVisitor& v, u64 insn) { | |||
| 131 | info.is_depth.Assign(1); | 131 | info.is_depth.Assign(1); |
| 132 | return v.ir.ImageSampleDrefExplicitLod( | 132 | return v.ir.ImageSampleDrefExplicitLod( |
| 133 | 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))), |
| 134 | v.F(reg_b + 1), zero, {}, {}, info); | 134 | v.F(reg_b + 1), zero, {}, info); |
| 135 | case 10: // 3D | 135 | case 10: // 3D |
| 136 | CheckAlignment(reg_a, 2); | 136 | CheckAlignment(reg_a, 2); |
| 137 | info.type.Assign(TextureType::Color3D); | 137 | info.type.Assign(TextureType::Color3D); |
| @@ -141,7 +141,7 @@ IR::Value Sample(TranslatorVisitor& v, u64 insn) { | |||
| 141 | CheckAlignment(reg_a, 2); | 141 | CheckAlignment(reg_a, 2); |
| 142 | info.type.Assign(TextureType::Color3D); | 142 | info.type.Assign(TextureType::Color3D); |
| 143 | return v.ir.ImageSampleExplicitLod(handle, Composite(v, reg_a, reg_a + 1, reg_b), zero, {}, | 143 | return v.ir.ImageSampleExplicitLod(handle, Composite(v, reg_a, reg_a + 1, reg_b), zero, {}, |
| 144 | {}, info); | 144 | info); |
| 145 | case 12: // CUBE | 145 | case 12: // CUBE |
| 146 | CheckAlignment(reg_a, 2); | 146 | CheckAlignment(reg_a, 2); |
| 147 | info.type.Assign(TextureType::ColorCube); | 147 | info.type.Assign(TextureType::ColorCube); |
| @@ -152,7 +152,7 @@ IR::Value Sample(TranslatorVisitor& v, u64 insn) { | |||
| 152 | CheckAlignment(reg_b, 2); | 152 | CheckAlignment(reg_b, 2); |
| 153 | info.type.Assign(TextureType::ColorCube); | 153 | info.type.Assign(TextureType::ColorCube); |
| 154 | return v.ir.ImageSampleExplicitLod(handle, Composite(v, reg_a, reg_a + 1, reg_b), | 154 | return v.ir.ImageSampleExplicitLod(handle, Composite(v, reg_a, reg_a + 1, reg_b), |
| 155 | v.F(reg_b + 1), {}, {}, info); | 155 | v.F(reg_b + 1), {}, info); |
| 156 | default: | 156 | default: |
| 157 | throw NotImplementedException("Illegal encoding {}", texs.encoding.Value()); | 157 | throw NotImplementedException("Illegal encoding {}", texs.encoding.Value()); |
| 158 | } | 158 | } |