summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader/decode/memory.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2018-12-23 05:18:33 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-01-15 21:54:52 +0100
commit55e6786254d33e3501002bf7fbdd52552a0df32a (patch)
treec4d516419aff5dfa35c1de13efa77294afc50e16 /src/video_core/shader/decode/memory.cpp
parentshader_decode: Update TLD4 reflecting #1862 changes (diff)
downloadyuzu-55e6786254d33e3501002bf7fbdd52552a0df32a.tar
yuzu-55e6786254d33e3501002bf7fbdd52552a0df32a.tar.gz
yuzu-55e6786254d33e3501002bf7fbdd52552a0df32a.tar.bz2
yuzu-55e6786254d33e3501002bf7fbdd52552a0df32a.tar.lz
yuzu-55e6786254d33e3501002bf7fbdd52552a0df32a.tar.xz
yuzu-55e6786254d33e3501002bf7fbdd52552a0df32a.tar.zst
yuzu-55e6786254d33e3501002bf7fbdd52552a0df32a.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/shader/decode/memory.cpp69
1 files changed, 61 insertions, 8 deletions
diff --git a/src/video_core/shader/decode/memory.cpp b/src/video_core/shader/decode/memory.cpp
index cfdb92807..ce3445512 100644
--- a/src/video_core/shader/decode/memory.cpp
+++ b/src/video_core/shader/decode/memory.cpp
@@ -204,7 +204,7 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
break;
}
case OpCode::Id::TEXS: {
- Tegra::Shader::TextureType texture_type{instr.texs.GetTextureType()};
+ const TextureType texture_type{instr.texs.GetTextureType()};
const bool is_array{instr.texs.IsArrayTexture()};
const bool depth_compare = instr.texs.UsesMiscMode(TextureMiscMode::DC);
const auto process_mode = instr.texs.GetTextureProcessMode();
@@ -373,6 +373,22 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
GetRegister(RZ), GetRegister(RZ)));
break;
}
+ case OpCode::Id::TLDS: {
+ const Tegra::Shader::TextureType texture_type{instr.tlds.GetTextureType()};
+ const bool is_array{instr.tlds.IsArrayTexture()};
+
+ UNIMPLEMENTED_IF_MSG(instr.tlds.UsesMiscMode(TextureMiscMode::AOFFI),
+ "AOFFI is not implemented");
+ UNIMPLEMENTED_IF_MSG(instr.tlds.UsesMiscMode(TextureMiscMode::MZ), "MZ is not implemented");
+
+ if (instr.tlds.UsesMiscMode(TextureMiscMode::NODEP)) {
+ LOG_WARNING(HW_GPU, "TMML.NODEP implementation is incomplete");
+ }
+
+ const Node texture = GetTldsCode(instr, texture_type, is_array);
+ WriteTexsInstructionFloat(bb, instr, texture);
+ break;
+ }
default:
UNIMPLEMENTED_MSG("Unhandled memory instruction: {}", opcode->get().GetName());
}
@@ -576,22 +592,59 @@ Node ShaderIR::GetTld4Code(Instruction instr, TextureType texture_type, bool dep
for (size_t i = 0; i < coord_count; ++i) {
params.push_back(GetRegister(coord_register + i));
}
- std::size_t array_offset{};
+ std::optional<u32> array_offset;
if (is_array) {
- array_offset = params.size();
+ array_offset = static_cast<u32>(params.size());
params.push_back(GetRegister(array_register));
}
const auto& sampler = GetSampler(instr.sampler, texture_type, is_array, depth_compare);
-
- std::optional<u32> array_offset_value;
- if (is_array)
- array_offset_value = static_cast<u32>(array_offset);
- MetaTexture meta{sampler, static_cast<u32>(params.size()), array_offset_value};
+ MetaTexture meta{sampler, static_cast<u32>(params.size()), array_offset};
return Operation(OperationCode::F4TextureGather, std::move(meta), std::move(params));
}
+Node ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is_array) {
+ const std::size_t type_coord_count = GetCoordCount(texture_type);
+ const std::size_t total_coord_count = type_coord_count + (is_array ? 1 : 0);
+ const bool lod_enabled = instr.tlds.GetTextureProcessMode() == TextureProcessMode::LL;
+
+ // If enabled arrays index is always stored in the gpr8 field
+ const u64 array_register = instr.gpr8.Value();
+ // if is array gpr20 is used
+ const u64 coord_register = is_array ? instr.gpr20.Value() : instr.gpr8.Value();
+
+ const u64 last_coord_register =
+ ((type_coord_count > 2) || (type_coord_count == 2 && !lod_enabled)) && !is_array
+ ? static_cast<u64>(instr.gpr20.Value())
+ : coord_register + 1;
+
+ std::vector<Node> params;
+
+ for (std::size_t i = 0; i < type_coord_count; ++i) {
+ const bool last = (i == (type_coord_count - 1)) && (type_coord_count > 1);
+ params.push_back(GetRegister(last ? last_coord_register : coord_register + i));
+ }
+ std::optional<u32> array_offset;
+ if (is_array) {
+ array_offset = static_cast<u32>(params.size());
+ params.push_back(GetRegister(array_register));
+ }
+ const auto coords_count = static_cast<u32>(params.size());
+
+ if (lod_enabled) {
+ // When lod is used always is in grp20
+ params.push_back(GetRegister(instr.gpr20));
+ } else {
+ params.push_back(Immediate(0));
+ }
+
+ const auto& sampler = GetSampler(instr.sampler, texture_type, is_array, false);
+ MetaTexture meta{sampler, coords_count, array_offset};
+
+ return Operation(OperationCode::F4TexelFetch, std::move(meta), std::move(params));
+}
+
std::tuple<std::size_t, std::size_t> ShaderIR::ValidateAndGetCoordinateElement(
TextureType texture_type, bool depth_compare, bool is_array, bool lod_bias_enabled,
std::size_t max_coords, std::size_t max_inputs) {