summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2018-12-13 18:35:07 -0300
committerGravatar ReinUsesLisp2019-01-15 17:54:50 -0300
commit802c23b8a8f1a14100fb9b291482ae197ba53293 (patch)
treee3ed487317466f35aed6f3aebd95611c7894705d /src
parentshader_decode: Implement TEX and TXQ (diff)
downloadyuzu-802c23b8a8f1a14100fb9b291482ae197ba53293.tar.gz
yuzu-802c23b8a8f1a14100fb9b291482ae197ba53293.tar.xz
yuzu-802c23b8a8f1a14100fb9b291482ae197ba53293.zip
shader_decode: Implement TMML
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/decode/memory.cpp48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/video_core/shader/decode/memory.cpp b/src/video_core/shader/decode/memory.cpp
index 220238ce8..d8265d3fd 100644
--- a/src/video_core/shader/decode/memory.cpp
+++ b/src/video_core/shader/decode/memory.cpp
@@ -112,7 +112,7 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
112 "AOFFI is not implemented"); 112 "AOFFI is not implemented");
113 113
114 if (instr.tex.UsesMiscMode(TextureMiscMode::NODEP)) { 114 if (instr.tex.UsesMiscMode(TextureMiscMode::NODEP)) {
115 LOG_WARNING(HW_GPU, "TEX.NODEP is not implemented"); 115 LOG_WARNING(HW_GPU, "TEX.NODEP implementation is incomplete");
116 } 116 }
117 117
118 const Node texture = GetTexCode(instr, texture_type, process_mode, depth_compare, is_array); 118 const Node texture = GetTexCode(instr, texture_type, process_mode, depth_compare, is_array);
@@ -240,7 +240,7 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
240 "AOFFI is not implemented"); 240 "AOFFI is not implemented");
241 241
242 if (instr.tld4s.UsesMiscMode(TextureMiscMode::NODEP)) { 242 if (instr.tld4s.UsesMiscMode(TextureMiscMode::NODEP)) {
243 LOG_WARNING(HW_GPU, "TLD4S.NODEP is not implemented"); 243 LOG_WARNING(HW_GPU, "TLD4S.NODEP implementation is incomplete");
244 } 244 }
245 245
246 const bool depth_compare = instr.tld4s.UsesMiscMode(TextureMiscMode::DC); 246 const bool depth_compare = instr.tld4s.UsesMiscMode(TextureMiscMode::DC);
@@ -273,7 +273,7 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
273 } 273 }
274 case OpCode::Id::TXQ: { 274 case OpCode::Id::TXQ: {
275 if (instr.txq.UsesMiscMode(TextureMiscMode::NODEP)) { 275 if (instr.txq.UsesMiscMode(TextureMiscMode::NODEP)) {
276 LOG_WARNING(HW_GPU, "TXQ.NODEP is not implemented"); 276 LOG_WARNING(HW_GPU, "TXQ.NODEP implementation is incomplete");
277 } 277 }
278 278
279 // TODO: The new commits on the texture refactor, change the way samplers work. 279 // TODO: The new commits on the texture refactor, change the way samplers work.
@@ -304,6 +304,48 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
304 } 304 }
305 break; 305 break;
306 } 306 }
307 case OpCode::Id::TMML: {
308 UNIMPLEMENTED_IF_MSG(instr.tmml.UsesMiscMode(Tegra::Shader::TextureMiscMode::NDV),
309 "NDV is not implemented");
310
311 if (instr.tmml.UsesMiscMode(TextureMiscMode::NODEP)) {
312 LOG_WARNING(HW_GPU, "TMML.NODEP implementation is incomplete");
313 }
314
315 auto texture_type = instr.tmml.texture_type.Value();
316 const bool is_array = instr.tmml.array != 0;
317 const auto& sampler = GetSampler(instr.sampler, texture_type, is_array, false);
318
319 std::vector<Node> coords;
320
321 // TODO: Add coordinates for different samplers once other texture types are implemented.
322 switch (texture_type) {
323 case TextureType::Texture1D:
324 coords.push_back(GetRegister(instr.gpr8));
325 break;
326 case TextureType::Texture2D:
327 coords.push_back(GetRegister(instr.gpr8.Value() + 0));
328 coords.push_back(GetRegister(instr.gpr8.Value() + 1));
329 break;
330 default:
331 UNIMPLEMENTED_MSG("Unhandled texture type {}", static_cast<u32>(texture_type));
332
333 // Fallback to interpreting as a 2D texture for now
334 coords.push_back(GetRegister(instr.gpr8.Value() + 0));
335 coords.push_back(GetRegister(instr.gpr8.Value() + 1));
336 texture_type = TextureType::Texture2D;
337 }
338
339 const MetaTexture meta_texture{sampler, static_cast<u32>(coords.size())};
340 const Node texture =
341 Operation(OperationCode::F4TextureQueryLod, meta_texture, std::move(coords));
342
343 const MetaComponents meta_composite{{0, 1, 2, 3}};
344 bb.push_back(Operation(OperationCode::AssignComposite, meta_composite, texture,
345 GetRegister(instr.gpr0), GetRegister(instr.gpr0.Value() + 1),
346 GetRegister(RZ), GetRegister(RZ)));
347 break;
348 }
307 default: 349 default:
308 UNIMPLEMENTED_MSG("Unhandled memory instruction: {}", opcode->get().GetName()); 350 UNIMPLEMENTED_MSG("Unhandled memory instruction: {}", opcode->get().GetName());
309 } 351 }