summaryrefslogtreecommitdiff
path: root/src/video_core/shader/decode
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2018-12-26 01:33:56 -0300
committerGravatar ReinUsesLisp2019-01-15 17:54:53 -0300
commit5af82a8ed4e2e0b7abc9c7da9f7bb5fa1c83de29 (patch)
tree2982046f3f11a2177905e731bd264d21635e3010 /src/video_core/shader/decode
parentshader_decode: Fixup R2P (diff)
downloadyuzu-5af82a8ed4e2e0b7abc9c7da9f7bb5fa1c83de29.tar.gz
yuzu-5af82a8ed4e2e0b7abc9c7da9f7bb5fa1c83de29.tar.xz
yuzu-5af82a8ed4e2e0b7abc9c7da9f7bb5fa1c83de29.zip
shader_decode: Implement TEXS.F16
Diffstat (limited to 'src/video_core/shader/decode')
-rw-r--r--src/video_core/shader/decode/memory.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/video_core/shader/decode/memory.cpp b/src/video_core/shader/decode/memory.cpp
index ce3445512..679e7f01b 100644
--- a/src/video_core/shader/decode/memory.cpp
+++ b/src/video_core/shader/decode/memory.cpp
@@ -219,8 +219,7 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
219 if (instr.texs.fp32_flag) { 219 if (instr.texs.fp32_flag) {
220 WriteTexsInstructionFloat(bb, instr, texture); 220 WriteTexsInstructionFloat(bb, instr, texture);
221 } else { 221 } else {
222 UNIMPLEMENTED(); 222 WriteTexsInstructionHalfFloat(bb, instr, texture);
223 // WriteTexsInstructionHalfFloat(bb, instr, texture);
224 } 223 }
225 break; 224 break;
226 } 225 }
@@ -416,39 +415,52 @@ const Sampler& ShaderIR::GetSampler(const Tegra::Shader::Sampler& sampler, Textu
416 return *used_samplers.emplace(entry).first; 415 return *used_samplers.emplace(entry).first;
417} 416}
418 417
419void ShaderIR::WriteTexsInstructionFloat(BasicBlock& bb, Tegra::Shader::Instruction instr, 418void ShaderIR::WriteTexsInstructionFloat(BasicBlock& bb, Instruction instr, Node texture) {
420 Node texture) {
421 // TEXS has two destination registers and a swizzle. The first two elements in the swizzle 419 // TEXS has two destination registers and a swizzle. The first two elements in the swizzle
422 // go into gpr0+0 and gpr0+1, and the rest goes into gpr28+0 and gpr28+1 420 // go into gpr0+0 and gpr0+1, and the rest goes into gpr28+0 and gpr28+1
423 421
424 MetaComponents meta; 422 MetaComponents meta;
425 std::array<Node, 4> dest; 423 std::array<Node, 4> dest;
426
427 std::size_t written_components = 0;
428 for (u32 component = 0; component < 4; ++component) { 424 for (u32 component = 0; component < 4; ++component) {
429 if (!instr.texs.IsComponentEnabled(component)) { 425 if (!instr.texs.IsComponentEnabled(component)) {
430 continue; 426 continue;
431 } 427 }
432 meta.components_map[written_components] = static_cast<u32>(component); 428 meta.components_map[meta.count] = component;
433 429
434 if (written_components < 2) { 430 if (meta.count < 2) {
435 // Write the first two swizzle components to gpr0 and gpr0+1 431 // Write the first two swizzle components to gpr0 and gpr0+1
436 dest[written_components] = GetRegister(instr.gpr0.Value() + written_components % 2); 432 dest[meta.count] = GetRegister(instr.gpr0.Value() + meta.count % 2);
437 } else { 433 } else {
438 ASSERT(instr.texs.HasTwoDestinations()); 434 ASSERT(instr.texs.HasTwoDestinations());
439 // Write the rest of the swizzle components to gpr28 and gpr28+1 435 // Write the rest of the swizzle components to gpr28 and gpr28+1
440 dest[written_components] = GetRegister(instr.gpr28.Value() + written_components % 2); 436 dest[meta.count] = GetRegister(instr.gpr28.Value() + meta.count % 2);
441 } 437 }
442 438 ++meta.count;
443 ++written_components;
444 } 439 }
445 440
446 std::generate(dest.begin() + written_components, dest.end(), [&]() { return GetRegister(RZ); }); 441 std::generate(dest.begin() + meta.count, dest.end(), [&]() { return GetRegister(RZ); });
447 442
448 bb.push_back(Operation(OperationCode::AssignComposite, meta, texture, dest[0], dest[1], dest[2], 443 bb.push_back(Operation(OperationCode::AssignComposite, meta, texture, dest[0], dest[1], dest[2],
449 dest[3])); 444 dest[3]));
450} 445}
451 446
447void ShaderIR::WriteTexsInstructionHalfFloat(BasicBlock& bb, Instruction instr, Node texture) {
448 // TEXS.F16 destionation registers are packed in two registers in pairs (just like any half
449 // float instruction).
450
451 MetaComponents meta;
452 for (u32 component = 0; component < 4; ++component) {
453 if (!instr.texs.IsComponentEnabled(component))
454 continue;
455 meta.components_map[meta.count++] = component;
456 }
457 if (meta.count == 0)
458 return;
459
460 bb.push_back(Operation(OperationCode::AssignCompositeHalf, meta, texture,
461 GetRegister(instr.gpr0), GetRegister(instr.gpr28)));
462}
463
452Node ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type, 464Node ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type,
453 TextureProcessMode process_mode, bool depth_compare, bool is_array, 465 TextureProcessMode process_mode, bool depth_compare, bool is_array,
454 std::size_t array_offset, std::size_t bias_offset, 466 std::size_t array_offset, std::size_t bias_offset,