summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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));