From 337f2dc11fefba337020e1b8d16e8a62cbdfa8a2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 16 Apr 2020 22:23:56 -0400 Subject: [PATCH 1/6] time_zone_manager: Resolve sign conversion warnings ttis and ats will never exceed the length of INT32_MAX in our case, so this is safe. --- src/core/hle/service/time/time_zone_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/time/time_zone_manager.cpp b/src/core/hle/service/time/time_zone_manager.cpp index c8159bcd5..69152d0ac 100644 --- a/src/core/hle/service/time/time_zone_manager.cpp +++ b/src/core/hle/service/time/time_zone_manager.cpp @@ -518,8 +518,8 @@ static bool ParseTimeZoneBinary(TimeZoneRule& time_zone_rule, FileSys::VirtualFi constexpr s32 time_zone_max_leaps{50}; constexpr s32 time_zone_max_chars{50}; if (!(0 <= header.leap_count && header.leap_count < time_zone_max_leaps && - 0 < header.type_count && header.type_count < time_zone_rule.ttis.size() && - 0 <= header.time_count && header.time_count < time_zone_rule.ats.size() && + 0 < header.type_count && header.type_count < s32(time_zone_rule.ttis.size()) && + 0 <= header.time_count && header.time_count < s32(time_zone_rule.ats.size()) && 0 <= header.char_count && header.char_count < time_zone_max_chars && (header.ttis_std_count == header.type_count || header.ttis_std_count == 0) && (header.ttis_gmt_count == header.type_count || header.ttis_gmt_count == 0))) { From 7e2d60de26748bfd74c3d8983f85f8c82882167e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 16 Apr 2020 22:27:19 -0400 Subject: [PATCH 2/6] decode/texture: Eliminate trivial missing field initializer warnings We can just specify the initializers. --- src/video_core/shader/decode/texture.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 6c4a1358b..cc6491323 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -139,7 +139,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { } const Node component = Immediate(static_cast(instr.tld4s.component)); - const SamplerInfo info{TextureType::Texture2D, false, is_depth_compare}; + const SamplerInfo info{TextureType::Texture2D, false, is_depth_compare, false}; const Sampler& sampler = *GetSampler(instr.sampler, info); Node4 values; @@ -171,8 +171,9 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { const auto coord_count = GetCoordCount(texture_type); Node index_var{}; const Sampler* sampler = - is_bindless ? GetBindlessSampler(base_reg, index_var, {{texture_type, is_array, false}}) - : GetSampler(instr.sampler, {{texture_type, is_array, false}}); + is_bindless + ? GetBindlessSampler(base_reg, index_var, {{texture_type, is_array, false, false}}) + : GetSampler(instr.sampler, {{texture_type, is_array, false, false}}); Node4 values; if (sampler == nullptr) { for (u32 element = 0; element < values.size(); ++element) { From f522abd8abab3ead966cbba6fae0c55ba1215592 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 16 Apr 2020 22:29:05 -0400 Subject: [PATCH 3/6] decode/texture: Collapse loop down into std::generate Same behavior, less code. --- src/video_core/shader/decode/texture.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index cc6491323..0b9817093 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -176,9 +176,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { : GetSampler(instr.sampler, {{texture_type, is_array, false, false}}); Node4 values; if (sampler == nullptr) { - for (u32 element = 0; element < values.size(); ++element) { - values[element] = Immediate(0); - } + std::generate(values.begin(), values.end(), [] { return Immediate(0); }); WriteTexInstructionFloat(bb, instr, values); break; } From d159643fd780cc8a467822ebd008bb48c2deab7a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 16 Apr 2020 22:30:23 -0400 Subject: [PATCH 4/6] decode/texture: Resolve unused variable warnings. Some variables aren't used, so we can remove these. Unfortunately, diagnostics are still reported on structured bindings even when annotated with [[maybe_unused]], so we need to unpack the elements that we want to use manually. --- src/video_core/shader/decode/texture.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 0b9817093..e68f1d305 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -268,7 +268,6 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { "NDV is not implemented"); auto texture_type = instr.tmml.texture_type.Value(); - const bool is_array = instr.tmml.array != 0; Node index_var{}; const Sampler* sampler = is_bindless ? GetBindlessSampler(instr.gpr20, index_var) : GetSampler(instr.sampler); @@ -592,8 +591,9 @@ Node4 ShaderIR::GetTexCode(Instruction instr, TextureType texture_type, ++parameter_register; } - const auto [coord_count, total_coord_count] = ValidateAndGetCoordinateElement( - texture_type, depth_compare, is_array, lod_bias_enabled, 4, 5); + const auto coord_counts = ValidateAndGetCoordinateElement(texture_type, depth_compare, is_array, + lod_bias_enabled, 4, 5); + const auto coord_count = std::get<0>(coord_counts); // If enabled arrays index is always stored in the gpr8 field const u64 array_register = instr.gpr8.Value(); // First coordinate index is the gpr8 or gpr8 + 1 when arrays are used @@ -631,8 +631,10 @@ Node4 ShaderIR::GetTexsCode(Instruction instr, TextureType texture_type, const bool lod_bias_enabled = (process_mode != TextureProcessMode::None && process_mode != TextureProcessMode::LZ); - const auto [coord_count, total_coord_count] = ValidateAndGetCoordinateElement( - texture_type, depth_compare, is_array, lod_bias_enabled, 4, 4); + const auto coord_counts = ValidateAndGetCoordinateElement(texture_type, depth_compare, is_array, + lod_bias_enabled, 4, 4); + const auto coord_count = std::get<0>(coord_counts); + // If enabled arrays index is always stored in the gpr8 field const u64 array_register = instr.gpr8.Value(); // First coordinate index is stored in gpr8 field or (gpr8 + 1) when arrays are used From 678ac54749650a81b5c190dab6c1930de2fd8b49 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 16 Apr 2020 22:36:33 -0400 Subject: [PATCH 5/6] decode/memory: Resolve unused variable warning Only the first element of the returned pair is ever used. --- src/video_core/shader/decode/memory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video_core/shader/decode/memory.cpp b/src/video_core/shader/decode/memory.cpp index 8112ead3e..9392f065b 100644 --- a/src/video_core/shader/decode/memory.cpp +++ b/src/video_core/shader/decode/memory.cpp @@ -479,7 +479,7 @@ std::tuple ShaderIR::TrackGlobalMemory(NodeBlock& bb.push_back(Comment(fmt::format("Base address is c[0x{:x}][0x{:x}]", index, offset))); const GlobalMemoryBase descriptor{index, offset}; - const auto& [entry, is_new] = used_global_memory.try_emplace(descriptor); + const auto& entry = used_global_memory.try_emplace(descriptor).first; auto& usage = entry->second; usage.is_written |= is_write; usage.is_read |= is_read; From 8f9c599c9f7dff8c3c19375e443d7c6427ea11d3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 16 Apr 2020 22:39:58 -0400 Subject: [PATCH 6/6] key_manager: Resolve missing field initializer warning --- src/core/crypto/key_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 87e6a1fd3..8997c7082 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -1202,7 +1202,8 @@ const boost::container::flat_map> KeyManager: {S128KeyType::Source, static_cast(SourceKeyType::KeyAreaKey), static_cast(KeyAreaKeyType::System)}}, {"titlekek_source", {S128KeyType::Source, static_cast(SourceKeyType::Titlekek), 0}}, - {"keyblob_mac_key_source", {S128KeyType::Source, static_cast(SourceKeyType::KeyblobMAC)}}, + {"keyblob_mac_key_source", + {S128KeyType::Source, static_cast(SourceKeyType::KeyblobMAC), 0}}, {"tsec_key", {S128KeyType::TSEC, 0, 0}}, {"secure_boot_key", {S128KeyType::SecureBoot, 0, 0}}, {"sd_seed", {S128KeyType::SDSeed, 0, 0}},