diff options
| author | 2021-05-17 02:52:01 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:31 -0400 | |
| commit | ec6fc5fe78c9038fc9ad7259b7b3a7be751ecef6 (patch) | |
| tree | 063963b0a197526467902ef9bfceff1be8f5b9ef /src/shader_recompiler/frontend/maxwell | |
| parent | glasm: Add support for non-2D texture samples (diff) | |
| download | yuzu-ec6fc5fe78c9038fc9ad7259b7b3a7be751ecef6.tar.gz yuzu-ec6fc5fe78c9038fc9ad7259b7b3a7be751ecef6.tar.xz yuzu-ec6fc5fe78c9038fc9ad7259b7b3a7be751ecef6.zip | |
glasm: Implement TEX and TEXS instructions
Remove lod clamp from texture instructions with lod, as this is not
needed (nor supported).
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell')
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch.cpp | 5 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/translate/impl/texture_fetch_swizzled.cpp | 18 |
2 files changed, 11 insertions, 12 deletions
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 | } |