summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-10-07 23:17:46 -0300
committerGravatar ReinUsesLisp2020-10-07 23:17:46 -0300
commitdffaffaac1eb633d5907202df1ca0dbf338a6095 (patch)
tree29bf9c22b1a0e2092676d7ed14c6091e67f63203
parentMerge pull request #4731 from lat9nq/mingw-zstd-fix (diff)
downloadyuzu-dffaffaac1eb633d5907202df1ca0dbf338a6095.tar.gz
yuzu-dffaffaac1eb633d5907202df1ca0dbf338a6095.tar.xz
yuzu-dffaffaac1eb633d5907202df1ca0dbf338a6095.zip
shader/texture: Implement CUBE texture type for TMML and fix arrays
TMML takes an array argument that has no known meaning, this one appears as the first component in gpr8 followed by s, t and r. Skip this component when arrays are being used. Also implement CUBE texture types. - Used by Pikmin 3: Deluxe Demo.
Diffstat (limited to '')
-rw-r--r--src/video_core/shader/decode/texture.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp
index a03b50e39..4e932a4b6 100644
--- a/src/video_core/shader/decode/texture.cpp
+++ b/src/video_core/shader/decode/texture.cpp
@@ -292,33 +292,36 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
292 break; 292 break;
293 } 293 }
294 294
295 std::vector<Node> coords; 295 const u64 base_index = is_array ? 1 : 0;
296 296 const u64 num_components = [texture_type] {
297 // TODO: Add coordinates for different samplers once other texture types are implemented. 297 switch (texture_type) {
298 switch (texture_type) { 298 case TextureType::Texture1D:
299 case TextureType::Texture1D: 299 return 1;
300 coords.push_back(GetRegister(instr.gpr8)); 300 case TextureType::Texture2D:
301 break; 301 return 2;
302 case TextureType::Texture2D: 302 case TextureType::TextureCube:
303 coords.push_back(GetRegister(instr.gpr8.Value() + 0)); 303 return 3;
304 coords.push_back(GetRegister(instr.gpr8.Value() + 1)); 304 default:
305 break; 305 UNIMPLEMENTED_MSG("Unhandled texture type {}", static_cast<int>(texture_type));
306 default: 306 return 2;
307 UNIMPLEMENTED_MSG("Unhandled texture type {}", static_cast<int>(texture_type)); 307 }
308 }();
309 // TODO: What's the array component used for?
308 310
309 // Fallback to interpreting as a 2D texture for now 311 std::vector<Node> coords;
310 coords.push_back(GetRegister(instr.gpr8.Value() + 0)); 312 coords.reserve(num_components);
311 coords.push_back(GetRegister(instr.gpr8.Value() + 1)); 313 for (u64 component = 0; component < num_components; ++component) {
314 coords.push_back(GetRegister(instr.gpr8.Value() + base_index + component));
312 } 315 }
316
313 u32 indexer = 0; 317 u32 indexer = 0;
314 for (u32 element = 0; element < 2; ++element) { 318 for (u32 element = 0; element < 2; ++element) {
315 if (!instr.tmml.IsComponentEnabled(element)) { 319 if (!instr.tmml.IsComponentEnabled(element)) {
316 continue; 320 continue;
317 } 321 }
318 auto params = coords;
319 MetaTexture meta{*sampler, {}, {}, {}, {}, {}, {}, {}, {}, element, index_var}; 322 MetaTexture meta{*sampler, {}, {}, {}, {}, {}, {}, {}, {}, element, index_var};
320 const Node value = Operation(OperationCode::TextureQueryLod, meta, std::move(params)); 323 Node value = Operation(OperationCode::TextureQueryLod, meta, coords);
321 SetTemporary(bb, indexer++, value); 324 SetTemporary(bb, indexer++, std::move(value));
322 } 325 }
323 for (u32 i = 0; i < indexer; ++i) { 326 for (u32 i = 0; i < indexer; ++i) {
324 SetRegister(bb, instr.gpr0.Value() + i, GetTemporary(i)); 327 SetRegister(bb, instr.gpr0.Value() + i, GetTemporary(i));