diff options
139 files changed, 743 insertions, 632 deletions
diff --git a/.ci/scripts/linux/docker.sh b/.ci/scripts/linux/docker.sh index 1af5ded3d..9b451d3ab 100755 --- a/.ci/scripts/linux/docker.sh +++ b/.ci/scripts/linux/docker.sh @@ -30,10 +30,10 @@ make install DESTDIR=AppDir rm -vf AppDir/usr/bin/yuzu-cmd AppDir/usr/bin/yuzu-tester # Download tools needed to build an AppImage -wget -nc https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -wget -nc https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage -wget -nc https://github.com/darealshinji/AppImageKit-checkrt/releases/download/continuous/AppRun-patched-x86_64 -wget -nc https://github.com/darealshinji/AppImageKit-checkrt/releases/download/continuous/exec-x86_64.so +wget -nc https://github.com/yuzu-emu/ext-linux-bin/raw/main/appimage/linuxdeploy-x86_64.AppImage +wget -nc https://github.com/yuzu-emu/ext-linux-bin/raw/main/appimage/linuxdeploy-plugin-qt-x86_64.AppImage +wget -nc https://github.com/yuzu-emu/ext-linux-bin/raw/main/appimage/AppRun-patched-x86_64 +wget -nc https://github.com/yuzu-emu/ext-linux-bin/raw/main/appimage/exec-x86_64.so # Set executable bit chmod 755 \ AppRun-patched-x86_64 \ diff --git a/.ci/scripts/linux/upload.sh b/.ci/scripts/linux/upload.sh index b2ea07388..208cd0d04 100644 --- a/.ci/scripts/linux/upload.sh +++ b/.ci/scripts/linux/upload.sh @@ -21,7 +21,7 @@ cp build/bin/yuzu "$DIR_NAME" # Build an AppImage cd build -wget -nc https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage +wget -nc https://github.com/yuzu-emu/ext-linux-bin/raw/main/appimage/appimagetool-x86_64.AppImage chmod 755 appimagetool-x86_64.AppImage if [ "${RELEASE_NAME}" = "mainline" ]; then diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8bd7e5f72..f30dd49a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,6 +54,7 @@ if (MSVC) /we4547 # 'operator' : operator before comma has no effect; expected operator with side-effect /we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'? /we4555 # Expression has no effect; expected expression with side-effect + /we4715 # 'function': not all control paths return a value /we4834 # Discarding return value of function with 'nodiscard' attribute /we5038 # data member 'member1' will be initialized after data member 'member2' ) diff --git a/src/common/parent_of_member.h b/src/common/parent_of_member.h index e0f8ab5c8..58c70b0e7 100644 --- a/src/common/parent_of_member.h +++ b/src/common/parent_of_member.h @@ -109,7 +109,8 @@ struct OffsetOfCalculator { } } - return (next - start) * sizeof(MemberType) + Offset; + return static_cast<ptrdiff_t>(static_cast<size_t>(next - start) * sizeof(MemberType) + + Offset); } static constexpr std::ptrdiff_t OffsetOf(MemberType ParentType::*member) { diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 702b6598d..e29cbf506 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -42,7 +42,7 @@ void LogSettings() { log_setting("System_RegionIndex", values.region_index.GetValue()); log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue()); log_setting("Core_UseMultiCore", values.use_multi_core.GetValue()); - log_setting("CPU_Accuracy", values.cpu_accuracy); + log_setting("CPU_Accuracy", values.cpu_accuracy.GetValue()); log_setting("Renderer_UseResolutionFactor", values.resolution_factor.GetValue()); log_setting("Renderer_UseFrameLimit", values.use_frame_limit.GetValue()); log_setting("Renderer_FrameLimit", values.frame_limit.GetValue()); @@ -106,6 +106,12 @@ void RestoreGlobalState(bool is_powered_on) { // Core values.use_multi_core.SetGlobal(true); + // CPU + values.cpu_accuracy.SetGlobal(true); + values.cpuopt_unsafe_unfuse_fma.SetGlobal(true); + values.cpuopt_unsafe_reduce_fp_error.SetGlobal(true); + values.cpuopt_unsafe_inaccurate_nan.SetGlobal(true); + // Renderer values.renderer_backend.SetGlobal(true); values.vulkan_device.SetGlobal(true); @@ -130,7 +136,6 @@ void RestoreGlobalState(bool is_powered_on) { values.region_index.SetGlobal(true); values.time_zone_index.SetGlobal(true); values.rng_seed.SetGlobal(true); - values.custom_rtc.SetGlobal(true); values.sound_index.SetGlobal(true); // Controls diff --git a/src/common/settings.h b/src/common/settings.h index d39b4aa45..48085b9a9 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -115,7 +115,7 @@ struct Values { Setting<bool> use_multi_core; // Cpu - CPUAccuracy cpu_accuracy; + Setting<CPUAccuracy> cpu_accuracy; bool cpuopt_page_tables; bool cpuopt_block_linking; @@ -126,9 +126,9 @@ struct Values { bool cpuopt_misc_ir; bool cpuopt_reduce_misalign_checks; - bool cpuopt_unsafe_unfuse_fma; - bool cpuopt_unsafe_reduce_fp_error; - bool cpuopt_unsafe_inaccurate_nan; + Setting<bool> cpuopt_unsafe_unfuse_fma; + Setting<bool> cpuopt_unsafe_reduce_fp_error; + Setting<bool> cpuopt_unsafe_inaccurate_nan; // Renderer Setting<RendererBackend> renderer_backend; @@ -157,7 +157,7 @@ struct Values { // System Setting<std::optional<u32>> rng_seed; // Measured in seconds since epoch - Setting<std::optional<std::chrono::seconds>> custom_rtc; + std::optional<std::chrono::seconds> custom_rtc; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` std::chrono::seconds custom_rtc_differential; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 83da30418..efb851f5a 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -651,20 +651,17 @@ endif() if (MSVC) target_compile_options(core PRIVATE - # 'expression' : signed/unsigned mismatch - /we4018 - # 'argument' : conversion from 'type1' to 'type2', possible loss of data (floating-point) - /we4244 - # 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch - /we4245 - # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data - /we4254 - # 'var' : conversion from 'size_t' to 'type', possible loss of data - /we4267 - # 'context' : truncation from 'type1' to 'type2' - /we4305 - # 'function' : not all control paths return a value - /we4715 + /we4018 # 'expression' : signed/unsigned mismatch + /we4244 # 'argument' : conversion from 'type1' to 'type2', possible loss of data (floating-point) + /we4245 # 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch + /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data + /we4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data + /we4305 # 'context' : truncation from 'type1' to 'type2' + /we4456 # Declaration of 'identifier' hides previous local declaration + /we4457 # Declaration of 'identifier' hides function parameter + /we4458 # Declaration of 'identifier' hides class member + /we4459 # Declaration of 'identifier' hides global declaration + /we4715 # 'function' : not all control paths return a value ) else() target_compile_options(core PRIVATE @@ -672,6 +669,7 @@ else() -Werror=ignored-qualifiers -Werror=implicit-fallthrough -Werror=sign-compare + -Werror=shadow $<$<CXX_COMPILER_ID:GNU>:-Werror=class-memaccess> $<$<CXX_COMPILER_ID:GNU>:-Werror=unused-but-set-parameter> diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 42a37e84f..93d43e22e 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -24,7 +24,7 @@ namespace Core { class DynarmicCallbacks32 : public Dynarmic::A32::UserCallbacks { public: - explicit DynarmicCallbacks32(ARM_Dynarmic_32& parent) : parent(parent) {} + explicit DynarmicCallbacks32(ARM_Dynarmic_32& parent_) : parent{parent_} {} u8 MemoryRead8(u32 vaddr) override { return parent.system.Memory().Read8(vaddr); @@ -142,7 +142,7 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* config.far_code_offset = 256 * 1024 * 1024; // Safe optimizations - if (Settings::values.cpu_accuracy == Settings::CPUAccuracy::DebugMode) { + if (Settings::values.cpu_accuracy.GetValue() == Settings::CPUAccuracy::DebugMode) { if (!Settings::values.cpuopt_page_tables) { config.page_table = nullptr; } @@ -170,15 +170,15 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* } // Unsafe optimizations - if (Settings::values.cpu_accuracy == Settings::CPUAccuracy::Unsafe) { + if (Settings::values.cpu_accuracy.GetValue() == Settings::CPUAccuracy::Unsafe) { config.unsafe_optimizations = true; - if (Settings::values.cpuopt_unsafe_unfuse_fma) { + if (Settings::values.cpuopt_unsafe_unfuse_fma.GetValue()) { config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_UnfuseFMA; } - if (Settings::values.cpuopt_unsafe_reduce_fp_error) { + if (Settings::values.cpuopt_unsafe_reduce_fp_error.GetValue()) { config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_ReducedErrorFP; } - if (Settings::values.cpuopt_unsafe_inaccurate_nan) { + if (Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue()) { config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_InaccurateNaN; } } diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 653bb7a77..08fa85904 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -27,7 +27,7 @@ using Vector = Dynarmic::A64::Vector; class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks { public: - explicit DynarmicCallbacks64(ARM_Dynarmic_64& parent) : parent(parent) {} + explicit DynarmicCallbacks64(ARM_Dynarmic_64& parent_) : parent{parent_} {} u8 MemoryRead8(u64 vaddr) override { return parent.system.Memory().Read8(vaddr); @@ -182,7 +182,7 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* config.far_code_offset = 256 * 1024 * 1024; // Safe optimizations - if (Settings::values.cpu_accuracy == Settings::CPUAccuracy::DebugMode) { + if (Settings::values.cpu_accuracy.GetValue() == Settings::CPUAccuracy::DebugMode) { if (!Settings::values.cpuopt_page_tables) { config.page_table = nullptr; } @@ -210,15 +210,15 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* } // Unsafe optimizations - if (Settings::values.cpu_accuracy == Settings::CPUAccuracy::Unsafe) { + if (Settings::values.cpu_accuracy.GetValue() == Settings::CPUAccuracy::Unsafe) { config.unsafe_optimizations = true; - if (Settings::values.cpuopt_unsafe_unfuse_fma) { + if (Settings::values.cpuopt_unsafe_unfuse_fma.GetValue()) { config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_UnfuseFMA; } - if (Settings::values.cpuopt_unsafe_reduce_fp_error) { + if (Settings::values.cpuopt_unsafe_reduce_fp_error.GetValue()) { config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_ReducedErrorFP; } - if (Settings::values.cpuopt_unsafe_inaccurate_nan) { + if (Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue()) { config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_InaccurateNaN; } } diff --git a/src/core/arm/dynarmic/arm_dynarmic_cp15.h b/src/core/arm/dynarmic/arm_dynarmic_cp15.h index dc6f4af3a..8597beddf 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_cp15.h +++ b/src/core/arm/dynarmic/arm_dynarmic_cp15.h @@ -18,7 +18,7 @@ class DynarmicCP15 final : public Dynarmic::A32::Coprocessor { public: using CoprocReg = Dynarmic::A32::CoprocReg; - explicit DynarmicCP15(ARM_Dynarmic_32& parent) : parent(parent) {} + explicit DynarmicCP15(ARM_Dynarmic_32& parent_) : parent{parent_} {} std::optional<Callback> CompileInternalOperation(bool two, unsigned opc1, CoprocReg CRd, CoprocReg CRn, CoprocReg CRm, diff --git a/src/core/arm/dynarmic/arm_exclusive_monitor.cpp b/src/core/arm/dynarmic/arm_exclusive_monitor.cpp index 4e209f6a5..9426a3edf 100644 --- a/src/core/arm/dynarmic/arm_exclusive_monitor.cpp +++ b/src/core/arm/dynarmic/arm_exclusive_monitor.cpp @@ -9,8 +9,8 @@ namespace Core { -DynarmicExclusiveMonitor::DynarmicExclusiveMonitor(Memory::Memory& memory, std::size_t core_count) - : monitor(core_count), memory{memory} {} +DynarmicExclusiveMonitor::DynarmicExclusiveMonitor(Memory::Memory& memory_, std::size_t core_count_) + : monitor{core_count_}, memory{memory_} {} DynarmicExclusiveMonitor::~DynarmicExclusiveMonitor() = default; diff --git a/src/core/arm/dynarmic/arm_exclusive_monitor.h b/src/core/arm/dynarmic/arm_exclusive_monitor.h index 964f4a55d..f9f056a59 100644 --- a/src/core/arm/dynarmic/arm_exclusive_monitor.h +++ b/src/core/arm/dynarmic/arm_exclusive_monitor.h @@ -22,7 +22,7 @@ namespace Core { class DynarmicExclusiveMonitor final : public ExclusiveMonitor { public: - explicit DynarmicExclusiveMonitor(Memory::Memory& memory, std::size_t core_count); + explicit DynarmicExclusiveMonitor(Memory::Memory& memory_, std::size_t core_count_); ~DynarmicExclusiveMonitor() override; u8 ExclusiveRead8(std::size_t core_index, VAddr addr) override; diff --git a/src/core/core.cpp b/src/core/core.cpp index 434bf3262..826a00ad6 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -173,7 +173,7 @@ struct System::Impl { const auto current_time = std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now().time_since_epoch()); Settings::values.custom_rtc_differential = - Settings::values.custom_rtc.GetValue().value_or(current_time) - current_time; + Settings::values.custom_rtc.value_or(current_time) - current_time; // Create a default fs if one doesn't already exist. if (virtual_filesystem == nullptr) @@ -289,7 +289,8 @@ struct System::Impl { telemetry_session->AddField(performance, "Shutdown_EmulationSpeed", perf_results.emulation_speed * 100.0); - telemetry_session->AddField(performance, "Shutdown_Framerate", perf_results.game_fps); + telemetry_session->AddField(performance, "Shutdown_Framerate", + perf_results.average_game_fps); telemetry_session->AddField(performance, "Shutdown_Frametime", perf_results.frametime * 1000.0); telemetry_session->AddField(performance, "Mean_Frametime_MS", diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index bdb374792..7e195346b 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp @@ -18,7 +18,7 @@ namespace Core { -CpuManager::CpuManager(System& system) : system{system} {} +CpuManager::CpuManager(System& system_) : system{system_} {} CpuManager::~CpuManager() = default; void CpuManager::ThreadStart(CpuManager& cpu_manager, std::size_t core) { diff --git a/src/core/cpu_manager.h b/src/core/cpu_manager.h index 9817017c0..140263b09 100644 --- a/src/core/cpu_manager.h +++ b/src/core/cpu_manager.h @@ -25,7 +25,7 @@ class System; class CpuManager { public: - explicit CpuManager(System& system); + explicit CpuManager(System& system_); CpuManager(const CpuManager&) = delete; CpuManager(CpuManager&&) = delete; diff --git a/src/core/crypto/ctr_encryption_layer.cpp b/src/core/crypto/ctr_encryption_layer.cpp index 5c84bb0a4..1231da8e3 100644 --- a/src/core/crypto/ctr_encryption_layer.cpp +++ b/src/core/crypto/ctr_encryption_layer.cpp @@ -10,8 +10,8 @@ namespace Core::Crypto { CTREncryptionLayer::CTREncryptionLayer(FileSys::VirtualFile base_, Key128 key_, - std::size_t base_offset) - : EncryptionLayer(std::move(base_)), base_offset(base_offset), cipher(key_, Mode::CTR) {} + std::size_t base_offset_) + : EncryptionLayer(std::move(base_)), base_offset(base_offset_), cipher(key_, Mode::CTR) {} std::size_t CTREncryptionLayer::Read(u8* data, std::size_t length, std::size_t offset) const { if (length == 0) diff --git a/src/core/crypto/ctr_encryption_layer.h b/src/core/crypto/ctr_encryption_layer.h index a2429f001..f86f01b6f 100644 --- a/src/core/crypto/ctr_encryption_layer.h +++ b/src/core/crypto/ctr_encryption_layer.h @@ -17,7 +17,7 @@ class CTREncryptionLayer : public EncryptionLayer { public: using IVData = std::array<u8, 16>; - CTREncryptionLayer(FileSys::VirtualFile base, Key128 key, std::size_t base_offset); + CTREncryptionLayer(FileSys::VirtualFile base_, Key128 key_, std::size_t base_offset_); std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override; diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 070ed439e..a4b739c63 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -458,7 +458,7 @@ static std::array<u8, size> operator^(const std::array<u8, size>& lhs, const std::array<u8, size>& rhs) { std::array<u8, size> out; std::transform(lhs.begin(), lhs.end(), rhs.begin(), out.begin(), - [](u8 lhs, u8 rhs) { return u8(lhs ^ rhs); }); + [](u8 lhs_elem, u8 rhs_elem) { return u8(lhs_elem ^ rhs_elem); }); return out; } diff --git a/src/core/file_sys/nca_metadata.cpp b/src/core/file_sys/nca_metadata.cpp index 3596541b2..f5cb4aa8c 100644 --- a/src/core/file_sys/nca_metadata.cpp +++ b/src/core/file_sys/nca_metadata.cpp @@ -39,10 +39,10 @@ CNMT::CNMT(VirtualFile file) { } } -CNMT::CNMT(CNMTHeader header, OptionalHeader opt_header, std::vector<ContentRecord> content_records, - std::vector<MetaRecord> meta_records) - : header(std::move(header)), opt_header(std::move(opt_header)), - content_records(std::move(content_records)), meta_records(std::move(meta_records)) {} +CNMT::CNMT(CNMTHeader header_, OptionalHeader opt_header_, + std::vector<ContentRecord> content_records_, std::vector<MetaRecord> meta_records_) + : header(std::move(header_)), opt_header(std::move(opt_header_)), + content_records(std::move(content_records_)), meta_records(std::move(meta_records_)) {} CNMT::~CNMT() = default; diff --git a/src/core/file_sys/nca_metadata.h b/src/core/file_sys/nca_metadata.h index 53535e5f5..ce1138a17 100644 --- a/src/core/file_sys/nca_metadata.h +++ b/src/core/file_sys/nca_metadata.h @@ -87,8 +87,8 @@ static_assert(sizeof(CNMTHeader) == 0x20, "CNMTHeader has incorrect size."); class CNMT { public: explicit CNMT(VirtualFile file); - CNMT(CNMTHeader header, OptionalHeader opt_header, std::vector<ContentRecord> content_records, - std::vector<MetaRecord> meta_records); + CNMT(CNMTHeader header_, OptionalHeader opt_header_, + std::vector<ContentRecord> content_records_, std::vector<MetaRecord> meta_records_); ~CNMT(); u64 GetTitleID() const; diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 1fb66874e..b0cb65952 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -12,6 +12,7 @@ #include "common/logging/log.h" #include "core/crypto/key_manager.h" #include "core/file_sys/card_image.h" +#include "core/file_sys/common_funcs.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/nca_metadata.h" #include "core/file_sys/registered_cache.h" @@ -592,6 +593,12 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex const CNMT cnmt(cnmt_file); const auto title_id = cnmt.GetTitleID(); + const auto version = cnmt.GetTitleVersion(); + + if (title_id == GetBaseTitleID(title_id) && version == 0) { + return InstallResult::ErrorBaseInstall; + } + const auto result = RemoveExistingEntry(title_id); // Install Metadata File diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index b31630014..d042aef90 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -38,6 +38,7 @@ enum class InstallResult { ErrorAlreadyExists, ErrorCopyFailed, ErrorMetaFailed, + ErrorBaseInstall, }; struct ContentProviderEntry { diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 80e560970..d51d469e3 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp @@ -20,8 +20,8 @@ namespace FileSys { -NSP::NSP(VirtualFile file_, std::size_t program_index) - : file(std::move(file_)), program_index(program_index), status{Loader::ResultStatus::Success}, +NSP::NSP(VirtualFile file_, std::size_t program_index_) + : file(std::move(file_)), program_index(program_index_), status{Loader::ResultStatus::Success}, pfs(std::make_shared<PartitionFilesystem>(file)), keys{Core::Crypto::KeyManager::Instance()} { if (pfs->GetStatus() != Loader::ResultStatus::Success) { status = pfs->GetStatus(); diff --git a/src/core/file_sys/submission_package.h b/src/core/file_sys/submission_package.h index 54581a6f3..ecb3b6f15 100644 --- a/src/core/file_sys/submission_package.h +++ b/src/core/file_sys/submission_package.h @@ -27,7 +27,7 @@ enum class ContentRecordType : u8; class NSP : public ReadOnlyVfsDirectory { public: - explicit NSP(VirtualFile file, std::size_t program_index = 0); + explicit NSP(VirtualFile file_, std::size_t program_index_ = 0); ~NSP() override; Loader::ResultStatus GetStatus() const; diff --git a/src/core/file_sys/vfs_concat.cpp b/src/core/file_sys/vfs_concat.cpp index 619081502..5f8c09124 100644 --- a/src/core/file_sys/vfs_concat.cpp +++ b/src/core/file_sys/vfs_concat.cpp @@ -23,8 +23,8 @@ static bool VerifyConcatenationMapContinuity(const std::multimap<u64, VirtualFil return map.begin()->first == 0; } -ConcatenatedVfsFile::ConcatenatedVfsFile(std::vector<VirtualFile> files_, std::string name) - : name(std::move(name)) { +ConcatenatedVfsFile::ConcatenatedVfsFile(std::vector<VirtualFile> files_, std::string name_) + : name(std::move(name_)) { std::size_t next_offset = 0; for (const auto& file : files_) { files.emplace(next_offset, file); @@ -32,8 +32,8 @@ ConcatenatedVfsFile::ConcatenatedVfsFile(std::vector<VirtualFile> files_, std::s } } -ConcatenatedVfsFile::ConcatenatedVfsFile(std::multimap<u64, VirtualFile> files_, std::string name) - : files(std::move(files_)), name(std::move(name)) { +ConcatenatedVfsFile::ConcatenatedVfsFile(std::multimap<u64, VirtualFile> files_, std::string name_) + : files(std::move(files_)), name(std::move(name_)) { ASSERT(VerifyConcatenationMapContinuity(files)); } diff --git a/src/core/file_sys/vfs_concat.h b/src/core/file_sys/vfs_concat.h index 3397d32cd..cd32960a5 100644 --- a/src/core/file_sys/vfs_concat.h +++ b/src/core/file_sys/vfs_concat.h @@ -14,8 +14,8 @@ namespace FileSys { // Class that wraps multiple vfs files and concatenates them, making reads seamless. Currently // read-only. class ConcatenatedVfsFile : public VfsFile { - ConcatenatedVfsFile(std::vector<VirtualFile> files, std::string name); - ConcatenatedVfsFile(std::multimap<u64, VirtualFile> files, std::string name); + explicit ConcatenatedVfsFile(std::vector<VirtualFile> files, std::string name_); + explicit ConcatenatedVfsFile(std::multimap<u64, VirtualFile> files, std::string name_); public: ~ConcatenatedVfsFile() override; diff --git a/src/core/file_sys/vfs_layered.cpp b/src/core/file_sys/vfs_layered.cpp index 192740058..e093c4db2 100644 --- a/src/core/file_sys/vfs_layered.cpp +++ b/src/core/file_sys/vfs_layered.cpp @@ -8,8 +8,8 @@ namespace FileSys { -LayeredVfsDirectory::LayeredVfsDirectory(std::vector<VirtualDir> dirs, std::string name) - : dirs(std::move(dirs)), name(std::move(name)) {} +LayeredVfsDirectory::LayeredVfsDirectory(std::vector<VirtualDir> dirs_, std::string name_) + : dirs(std::move(dirs_)), name(std::move(name_)) {} LayeredVfsDirectory::~LayeredVfsDirectory() = default; diff --git a/src/core/file_sys/vfs_layered.h b/src/core/file_sys/vfs_layered.h index cb4b32e91..cd6baf28c 100644 --- a/src/core/file_sys/vfs_layered.h +++ b/src/core/file_sys/vfs_layered.h @@ -13,7 +13,7 @@ namespace FileSys { // one and falling back to the one after. The highest priority directory (overwrites all others) // should be element 0 in the dirs vector. class LayeredVfsDirectory : public VfsDirectory { - LayeredVfsDirectory(std::vector<VirtualDir> dirs, std::string name); + explicit LayeredVfsDirectory(std::vector<VirtualDir> dirs_, std::string name_); public: ~LayeredVfsDirectory() override; diff --git a/src/core/file_sys/vfs_libzip.cpp b/src/core/file_sys/vfs_libzip.cpp index 429d7bc8b..618eb658a 100644 --- a/src/core/file_sys/vfs_libzip.cpp +++ b/src/core/file_sys/vfs_libzip.cpp @@ -3,7 +3,16 @@ // Refer to the license.txt file included. #include <string> + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#endif #include <zip.h> +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #include "common/logging/backend.h" #include "core/file_sys/vfs.h" #include "core/file_sys/vfs_libzip.h" diff --git a/src/core/file_sys/vfs_static.h b/src/core/file_sys/vfs_static.h index c840b24b9..f5b66cf71 100644 --- a/src/core/file_sys/vfs_static.h +++ b/src/core/file_sys/vfs_static.h @@ -14,9 +14,9 @@ namespace FileSys { class StaticVfsFile : public VfsFile { public: - explicit StaticVfsFile(u8 value, std::size_t size = 0, std::string name = "", - VirtualDir parent = nullptr) - : value{value}, size{size}, name{std::move(name)}, parent{std::move(parent)} {} + explicit StaticVfsFile(u8 value_, std::size_t size_ = 0, std::string name_ = "", + VirtualDir parent_ = nullptr) + : value{value_}, size{size_}, name{std::move(name_)}, parent{std::move(parent_)} {} std::string GetName() const override { return name; diff --git a/src/core/file_sys/vfs_vector.cpp b/src/core/file_sys/vfs_vector.cpp index 1a3f06227..f64b88639 100644 --- a/src/core/file_sys/vfs_vector.cpp +++ b/src/core/file_sys/vfs_vector.cpp @@ -7,8 +7,8 @@ #include "core/file_sys/vfs_vector.h" namespace FileSys { -VectorVfsFile::VectorVfsFile(std::vector<u8> initial_data, std::string name, VirtualDir parent) - : data(std::move(initial_data)), parent(std::move(parent)), name(std::move(name)) {} +VectorVfsFile::VectorVfsFile(std::vector<u8> initial_data, std::string name_, VirtualDir parent_) + : data(std::move(initial_data)), parent(std::move(parent_)), name(std::move(name_)) {} VectorVfsFile::~VectorVfsFile() = default; diff --git a/src/core/file_sys/vfs_vector.h b/src/core/file_sys/vfs_vector.h index c10c527b6..73f180070 100644 --- a/src/core/file_sys/vfs_vector.h +++ b/src/core/file_sys/vfs_vector.h @@ -75,8 +75,8 @@ std::shared_ptr<ArrayVfsFile<Size>> MakeArrayFile(const std::array<u8, Size>& da // An implementation of VfsFile that is backed by a vector optionally supplied upon construction class VectorVfsFile : public VfsFile { public: - explicit VectorVfsFile(std::vector<u8> initial_data = {}, std::string name = "", - VirtualDir parent = nullptr); + explicit VectorVfsFile(std::vector<u8> initial_data = {}, std::string name_ = "", + VirtualDir parent_ = nullptr); ~VectorVfsFile() override; std::string GetName() const override; diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index cff49899a..e11ec0b0b 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -26,7 +26,7 @@ public: private: class Device : public Input::TouchDevice { public: - explicit Device(std::weak_ptr<TouchState>&& touch_state) : touch_state(touch_state) {} + explicit Device(std::weak_ptr<TouchState>&& touch_state_) : touch_state(touch_state_) {} Input::TouchStatus GetStatus() const override { if (auto state = touch_state.lock()) { std::lock_guard guard{state->mutex}; diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 5fed3dbf5..497f35d23 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -33,8 +33,8 @@ protected: public: explicit RequestHelperBase(u32* command_buffer) : cmdbuf(command_buffer) {} - explicit RequestHelperBase(Kernel::HLERequestContext& context) - : context(&context), cmdbuf(context.CommandBuffer()) {} + explicit RequestHelperBase(Kernel::HLERequestContext& ctx) + : context(&ctx), cmdbuf(ctx.CommandBuffer()) {} void Skip(u32 size_in_words, bool set_to_null) { if (set_to_null) { @@ -71,12 +71,12 @@ public: AlwaysMoveHandles = 1, }; - explicit ResponseBuilder(Kernel::HLERequestContext& ctx, u32 normal_params_size, - u32 num_handles_to_copy = 0, u32 num_objects_to_move = 0, + explicit ResponseBuilder(Kernel::HLERequestContext& ctx, u32 normal_params_size_, + u32 num_handles_to_copy_ = 0, u32 num_objects_to_move_ = 0, Flags flags = Flags::None) - : RequestHelperBase(ctx), normal_params_size(normal_params_size), - num_handles_to_copy(num_handles_to_copy), - num_objects_to_move(num_objects_to_move), kernel{ctx.kernel} { + : RequestHelperBase(ctx), normal_params_size(normal_params_size_), + num_handles_to_copy(num_handles_to_copy_), + num_objects_to_move(num_objects_to_move_), kernel{ctx.kernel} { memset(cmdbuf, 0, sizeof(u32) * IPC::COMMAND_BUFFER_LENGTH); @@ -110,14 +110,14 @@ public: ctx.data_size = static_cast<u32>(raw_data_size); header.data_size.Assign(static_cast<u32>(raw_data_size)); - if (num_handles_to_copy || num_handles_to_move) { + if (num_handles_to_copy != 0 || num_handles_to_move != 0) { header.enable_handle_descriptor.Assign(1); } PushRaw(header); if (header.enable_handle_descriptor) { IPC::HandleDescriptorHeader handle_descriptor_header{}; - handle_descriptor_header.num_handles_to_copy.Assign(num_handles_to_copy); + handle_descriptor_header.num_handles_to_copy.Assign(num_handles_to_copy_); handle_descriptor_header.num_handles_to_move.Assign(num_handles_to_move); PushRaw(handle_descriptor_header); diff --git a/src/core/hle/kernel/global_scheduler_context.cpp b/src/core/hle/kernel/global_scheduler_context.cpp index 7c87cbada..4f4e338e3 100644 --- a/src/core/hle/kernel/global_scheduler_context.cpp +++ b/src/core/hle/kernel/global_scheduler_context.cpp @@ -12,8 +12,8 @@ namespace Kernel { -GlobalSchedulerContext::GlobalSchedulerContext(KernelCore& kernel) - : kernel{kernel}, scheduler_lock{kernel} {} +GlobalSchedulerContext::GlobalSchedulerContext(KernelCore& kernel_) + : kernel{kernel_}, scheduler_lock{kernel_} {} GlobalSchedulerContext::~GlobalSchedulerContext() = default; diff --git a/src/core/hle/kernel/global_scheduler_context.h b/src/core/hle/kernel/global_scheduler_context.h index ba8b67fd1..6f44b534f 100644 --- a/src/core/hle/kernel/global_scheduler_context.h +++ b/src/core/hle/kernel/global_scheduler_context.h @@ -34,7 +34,7 @@ class GlobalSchedulerContext final { public: using LockType = KAbstractSchedulerLock<KScheduler>; - explicit GlobalSchedulerContext(KernelCore& kernel); + explicit GlobalSchedulerContext(KernelCore& kernel_); ~GlobalSchedulerContext(); /// Adds a new thread to the scheduler diff --git a/src/core/hle/kernel/k_light_condition_variable.h b/src/core/hle/kernel/k_light_condition_variable.h index 362d0db28..ca2e539a7 100644 --- a/src/core/hle/kernel/k_light_condition_variable.h +++ b/src/core/hle/kernel/k_light_condition_variable.h @@ -18,7 +18,8 @@ class KernelCore; class KLightConditionVariable { public: - explicit KLightConditionVariable(KernelCore& kernel) : thread_queue(kernel), kernel(kernel) {} + explicit KLightConditionVariable(KernelCore& kernel_) + : thread_queue(kernel_), kernel(kernel_) {} void Wait(KLightLock* lock, s64 timeout = -1) { WaitImpl(lock, timeout); diff --git a/src/core/hle/kernel/k_linked_list.h b/src/core/hle/kernel/k_linked_list.h index 540e518cd..6adfe1e34 100644 --- a/src/core/hle/kernel/k_linked_list.h +++ b/src/core/hle/kernel/k_linked_list.h @@ -201,10 +201,10 @@ public: } iterator insert(const_iterator pos, reference ref) { - KLinkedListNode* node = KLinkedListNode::Allocate(kernel); - ASSERT(node != nullptr); - node->Initialize(std::addressof(ref)); - return iterator(BaseList::insert(pos.m_base_it, *node)); + KLinkedListNode* new_node = KLinkedListNode::Allocate(kernel); + ASSERT(new_node != nullptr); + new_node->Initialize(std::addressof(ref)); + return iterator(BaseList::insert(pos.m_base_it, *new_node)); } void push_back(reference ref) { diff --git a/src/core/hle/kernel/k_memory_block_manager.cpp b/src/core/hle/kernel/k_memory_block_manager.cpp index 44bfeb0d5..fc7033564 100644 --- a/src/core/hle/kernel/k_memory_block_manager.cpp +++ b/src/core/hle/kernel/k_memory_block_manager.cpp @@ -7,8 +7,8 @@ namespace Kernel { -KMemoryBlockManager::KMemoryBlockManager(VAddr start_addr, VAddr end_addr) - : start_addr{start_addr}, end_addr{end_addr} { +KMemoryBlockManager::KMemoryBlockManager(VAddr start_addr_, VAddr end_addr_) + : start_addr{start_addr_}, end_addr{end_addr_} { const u64 num_pages{(end_addr - start_addr) / PageSize}; memory_block_tree.emplace_back(start_addr, num_pages, KMemoryState::Free, KMemoryPermission::None, KMemoryAttribute::None); diff --git a/src/core/hle/kernel/k_memory_block_manager.h b/src/core/hle/kernel/k_memory_block_manager.h index e11cc70c8..d222da919 100644 --- a/src/core/hle/kernel/k_memory_block_manager.h +++ b/src/core/hle/kernel/k_memory_block_manager.h @@ -19,7 +19,7 @@ public: using const_iterator = MemoryBlockTree::const_iterator; public: - KMemoryBlockManager(VAddr start_addr, VAddr end_addr); + KMemoryBlockManager(VAddr start_addr_, VAddr end_addr_); iterator end() { return memory_block_tree.end(); diff --git a/src/core/hle/kernel/k_page_linked_list.h b/src/core/hle/kernel/k_page_linked_list.h index 64024d01f..dfdac5321 100644 --- a/src/core/hle/kernel/k_page_linked_list.h +++ b/src/core/hle/kernel/k_page_linked_list.h @@ -17,7 +17,7 @@ class KPageLinkedList final { public: class Node final { public: - constexpr Node(u64 addr, std::size_t num_pages) : addr{addr}, num_pages{num_pages} {} + constexpr Node(u64 addr_, std::size_t num_pages_) : addr{addr_}, num_pages{num_pages_} {} constexpr u64 GetAddress() const { return addr; diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp index d4ce98ee3..27dbf0ebc 100644 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp @@ -58,7 +58,7 @@ constexpr std::size_t GetSizeInRange(const KMemoryInfo& info, VAddr start, VAddr } // namespace -KPageTable::KPageTable(Core::System& system) : system{system} {} +KPageTable::KPageTable(Core::System& system_) : system{system_} {} ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr, VAddr code_addr, @@ -906,8 +906,8 @@ ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) { block_manager->UpdateLock( addr, size / PageSize, - [](KMemoryBlockManager::iterator block, KMemoryPermission perm) { - block->ShareToDevice(perm); + [](KMemoryBlockManager::iterator block, KMemoryPermission permission) { + block->ShareToDevice(permission); }, perm); @@ -929,8 +929,8 @@ ResultCode KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size) block_manager->UpdateLock( addr, size / PageSize, - [](KMemoryBlockManager::iterator block, KMemoryPermission perm) { - block->UnshareToDevice(perm); + [](KMemoryBlockManager::iterator block, KMemoryPermission permission) { + block->UnshareToDevice(permission); }, perm); diff --git a/src/core/hle/kernel/k_page_table.h b/src/core/hle/kernel/k_page_table.h index 8c2cc03eb..770c4841c 100644 --- a/src/core/hle/kernel/k_page_table.h +++ b/src/core/hle/kernel/k_page_table.h @@ -24,7 +24,7 @@ class KMemoryBlockManager; class KPageTable final : NonCopyable { public: - explicit KPageTable(Core::System& system); + explicit KPageTable(Core::System& system_); ResultCode InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr, VAddr code_addr, std::size_t code_size, diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index e256e9415..2f82fbcd6 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp @@ -607,7 +607,7 @@ void KScheduler::YieldToAnyThread(KernelCore& kernel) { } } -KScheduler::KScheduler(Core::System& system, s32 core_id) : system(system), core_id(core_id) { +KScheduler::KScheduler(Core::System& system_, s32 core_id_) : system{system_}, core_id{core_id_} { switch_fiber = std::make_shared<Common::Fiber>(OnSwitch, this); state.needs_scheduling.store(true); state.interrupt_task_thread_runnable = false; diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index 13a2414e6..12cfae919 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h @@ -30,7 +30,7 @@ class KThread; class KScheduler final { public: - explicit KScheduler(Core::System& system, s32 core_id); + explicit KScheduler(Core::System& system_, s32 core_id_); ~KScheduler(); /// Reschedules to the next available thread (call after current thread is suspended) diff --git a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h index b5d405744..a86af56dd 100644 --- a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h +++ b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h @@ -17,8 +17,8 @@ namespace Kernel { class [[nodiscard]] KScopedSchedulerLockAndSleep { public: - explicit KScopedSchedulerLockAndSleep(KernelCore & kernel, KThread * t, s64 timeout) - : kernel(kernel), thread(t), timeout_tick(timeout) { + explicit KScopedSchedulerLockAndSleep(KernelCore & kernel_, KThread * t, s64 timeout) + : kernel(kernel_), thread(t), timeout_tick(timeout) { // Lock the scheduler. kernel.GlobalSchedulerContext().scheduler_lock.Lock(); } diff --git a/src/core/hle/kernel/k_thread_queue.h b/src/core/hle/kernel/k_thread_queue.h index c52eba249..35d471dc5 100644 --- a/src/core/hle/kernel/k_thread_queue.h +++ b/src/core/hle/kernel/k_thread_queue.h @@ -10,7 +10,7 @@ namespace Kernel { class KThreadQueue { public: - explicit KThreadQueue(KernelCore& kernel) : kernel{kernel} {} + explicit KThreadQueue(KernelCore& kernel_) : kernel{kernel_} {} bool IsEmpty() const { return wait_list.empty(); diff --git a/src/core/hle/kernel/k_transfer_memory.h b/src/core/hle/kernel/k_transfer_memory.h index 838fd2b18..c2d0f1eaf 100644 --- a/src/core/hle/kernel/k_transfer_memory.h +++ b/src/core/hle/kernel/k_transfer_memory.h @@ -52,7 +52,7 @@ public: } size_t GetSize() const { - return is_initialized ? size * PageSize : 0; + return is_initialized ? size : 0; } private: diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 7fea45f96..7f02d9471 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -13,10 +13,10 @@ namespace Kernel { -PhysicalCore::PhysicalCore(std::size_t core_index, Core::System& system, - Kernel::KScheduler& scheduler, Core::CPUInterrupts& interrupts) - : core_index{core_index}, system{system}, scheduler{scheduler}, - interrupts{interrupts}, guard{std::make_unique<Common::SpinLock>()} {} +PhysicalCore::PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_, + Core::CPUInterrupts& interrupts_) + : core_index{core_index_}, system{system_}, scheduler{scheduler_}, + interrupts{interrupts_}, guard{std::make_unique<Common::SpinLock>()} {} PhysicalCore::~PhysicalCore() = default; diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h index f2b0911aa..901f7e3b0 100644 --- a/src/core/hle/kernel/physical_core.h +++ b/src/core/hle/kernel/physical_core.h @@ -28,8 +28,8 @@ namespace Kernel { class PhysicalCore { public: - PhysicalCore(std::size_t core_index, Core::System& system, Kernel::KScheduler& scheduler, - Core::CPUInterrupts& interrupts); + PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_, + Core::CPUInterrupts& interrupts_); ~PhysicalCore(); PhysicalCore(const PhysicalCore&) = delete; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 6b445677e..81e23f700 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -819,10 +819,10 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle return RESULT_SUCCESS; } - Handle handle{}; - R_TRY(handle_table.Add(&handle, resource_limit)); + Handle resource_handle{}; + R_TRY(handle_table.Add(&resource_handle, resource_limit)); - *result = handle; + *result = resource_handle; return RESULT_SUCCESS; } diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 8feda7ad7..43968386f 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -56,7 +56,7 @@ enum class ErrorModule : u32 { PCIe = 120, Friends = 121, BCAT = 122, - SSL = 123, + SSLSrv = 123, Account = 124, News = 125, Mii = 126, diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 408e441dc..234173297 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -833,7 +833,7 @@ IStorageImpl::~IStorageImpl() = default; class StorageDataImpl final : public IStorageImpl { public: - explicit StorageDataImpl(std::vector<u8>&& buffer) : buffer{std::move(buffer)} {} + explicit StorageDataImpl(std::vector<u8>&& buffer_) : buffer{std::move(buffer_)} {} std::vector<u8>& GetData() override { return buffer; @@ -1513,9 +1513,9 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) { const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), system.GetContentProvider()}; - auto res = pm.GetControlMetadata(); - if (res.first != nullptr) { - return res; + auto metadata = pm.GetControlMetadata(); + if (metadata.first != nullptr) { + return metadata; } const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id), @@ -1550,9 +1550,9 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), system.GetContentProvider()}; - auto res = pm.GetControlMetadata(); - if (res.first != nullptr) { - return res; + auto metadata = pm.GetControlMetadata(); + if (metadata.first != nullptr) { + return metadata; } const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id), diff --git a/src/core/hle/service/apm/controller.cpp b/src/core/hle/service/apm/controller.cpp index 00c174bb0..8bfa7c0e4 100644 --- a/src/core/hle/service/apm/controller.cpp +++ b/src/core/hle/service/apm/controller.cpp @@ -15,11 +15,11 @@ namespace Service::APM { constexpr auto DEFAULT_PERFORMANCE_CONFIGURATION = PerformanceConfiguration::Config7; -Controller::Controller(Core::Timing::CoreTiming& core_timing) - : core_timing{core_timing}, configs{ - {PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION}, - {PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION}, - } {} +Controller::Controller(Core::Timing::CoreTiming& core_timing_) + : core_timing{core_timing_}, configs{ + {PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION}, + {PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION}, + } {} Controller::~Controller() = default; diff --git a/src/core/hle/service/apm/controller.h b/src/core/hle/service/apm/controller.h index af0c4cd34..8d48e0104 100644 --- a/src/core/hle/service/apm/controller.h +++ b/src/core/hle/service/apm/controller.h @@ -50,7 +50,7 @@ enum class PerformanceMode : u8 { // system during times of high load -- this simply maps to different PerformanceConfigs to use. class Controller { public: - explicit Controller(Core::Timing::CoreTiming& core_timing); + explicit Controller(Core::Timing::CoreTiming& core_timing_); ~Controller(); void SetPerformanceConfiguration(PerformanceMode mode, PerformanceConfiguration config); diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 65887011f..ae4284adf 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -362,7 +362,7 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) { static constexpr u64 max_perf_detail_entries = 100; // Size of the data structure representing the bulk of the voice-related state. - static constexpr u64 voice_state_size = 0x100; + static constexpr u64 voice_state_size_bytes = 0x100; // Size of the upsampler manager data structure constexpr u64 upsampler_manager_size = 0x48; @@ -449,7 +449,8 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) { size += Common::AlignUp(voice_info_size * params.voice_count, info_field_alignment_size); size += Common::AlignUp(voice_resource_size * params.voice_count, info_field_alignment_size); - size += Common::AlignUp(voice_state_size * params.voice_count, info_field_alignment_size); + size += + Common::AlignUp(voice_state_size_bytes * params.voice_count, info_field_alignment_size); return size; }; diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 19c578b3a..ee5ec8cd6 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp @@ -50,8 +50,8 @@ public: Enabled, }; - explicit OpusDecoderState(OpusDecoderPtr decoder, u32 sample_rate, u32 channel_count) - : decoder{std::move(decoder)}, sample_rate{sample_rate}, channel_count{channel_count} {} + explicit OpusDecoderState(OpusDecoderPtr decoder_, u32 sample_rate_, u32 channel_count_) + : decoder{std::move(decoder_)}, sample_rate{sample_rate_}, channel_count{channel_count_} {} // Decodes interleaved Opus packets. Optionally allows reporting time taken to // perform the decoding, as well as any relevant extra behavior. @@ -160,9 +160,9 @@ private: class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> { public: - explicit IHardwareOpusDecoderManager(Core::System& system_, OpusDecoderState decoder_state) + explicit IHardwareOpusDecoderManager(Core::System& system_, OpusDecoderState decoder_state_) : ServiceFramework{system_, "IHardwareOpusDecoderManager"}, decoder_state{ - std::move(decoder_state)} { + std::move(decoder_state_)} { // clang-format off static const FunctionInfo functions[] = { {0, &IHardwareOpusDecoderManager::DecodeInterleavedOld, "DecodeInterleavedOld"}, diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp index cee1774d1..d6d2f52e5 100644 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ b/src/core/hle/service/bcat/backend/boxcat.cpp @@ -3,9 +3,18 @@ // Refer to the license.txt file included. #include <fmt/ostream.h> + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#endif #include <httplib.h> #include <mbedtls/sha256.h> #include <nlohmann/json.hpp> +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #include "common/hex_util.h" #include "common/logging/backend.h" #include "common/logging/log.h" @@ -178,8 +187,8 @@ bool VfsRawCopyDProgress(FileSys::VirtualDir src, FileSys::VirtualDir dest, class Boxcat::Client { public: - Client(std::string path, u64 title_id, u64 build_id) - : path(std::move(path)), title_id(title_id), build_id(build_id) {} + Client(std::string path_, u64 title_id_, u64 build_id_) + : path(std::move(path_)), title_id(title_id_), build_id(build_id_) {} DownloadResult DownloadDataZip() { return DownloadInternal(fmt::format(BOXCAT_PATHNAME_DATA, title_id), TIMEOUT_SECONDS, diff --git a/src/core/hle/service/hid/controllers/controller_base.cpp b/src/core/hle/service/hid/controllers/controller_base.cpp index 8091db9d7..9d1e6db6a 100644 --- a/src/core/hle/service/hid/controllers/controller_base.cpp +++ b/src/core/hle/service/hid/controllers/controller_base.cpp @@ -6,7 +6,7 @@ namespace Service::HID { -ControllerBase::ControllerBase(Core::System& system) : system(system) {} +ControllerBase::ControllerBase(Core::System& system_) : system(system_) {} ControllerBase::~ControllerBase() = default; void ControllerBase::ActivateController() { diff --git a/src/core/hle/service/hid/controllers/controller_base.h b/src/core/hle/service/hid/controllers/controller_base.h index f47a9e61c..1556fb08e 100644 --- a/src/core/hle/service/hid/controllers/controller_base.h +++ b/src/core/hle/service/hid/controllers/controller_base.h @@ -18,7 +18,7 @@ class System; namespace Service::HID { class ControllerBase { public: - explicit ControllerBase(Core::System& system); + explicit ControllerBase(Core::System& system_); virtual ~ControllerBase(); // Called when the controller is initialized diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index 9e5df3bb7..d311f754b 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp @@ -23,7 +23,7 @@ constexpr f32 Square(s32 num) { return static_cast<f32>(num * num); } -Controller_Gesture::Controller_Gesture(Core::System& system) : ControllerBase(system) {} +Controller_Gesture::Controller_Gesture(Core::System& system_) : ControllerBase(system_) {} Controller_Gesture::~Controller_Gesture() = default; void Controller_Gesture::OnInit() { @@ -211,15 +211,16 @@ void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, Touch } } -void Controller_Gesture::EndGesture(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, Attribute& attributes, f32 time_difference) { +void Controller_Gesture::EndGesture(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type, + Attribute& attributes, f32 time_difference) { const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; - if (last_gesture.active_points != 0) { + if (last_gesture_props.active_points != 0) { switch (last_entry.type) { case TouchType::Touch: if (enable_press_and_tap) { - SetTapEvent(gesture, last_gesture, type, attributes); + SetTapEvent(gesture, last_gesture_props, type, attributes); return; } type = TouchType::Cancel; @@ -234,7 +235,7 @@ void Controller_Gesture::EndGesture(GestureProperties& gesture, GesturePropertie force_update = true; break; case TouchType::Pan: - EndPanEvent(gesture, last_gesture, type, time_difference); + EndPanEvent(gesture, last_gesture_props, type, time_difference); break; default: break; @@ -246,10 +247,11 @@ void Controller_Gesture::EndGesture(GestureProperties& gesture, GesturePropertie } } -void Controller_Gesture::SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, Attribute& attributes) { +void Controller_Gesture::SetTapEvent(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type, + Attribute& attributes) { type = TouchType::Tap; - gesture = last_gesture; + gesture = last_gesture_props; force_update = true; f32 tap_time_difference = static_cast<f32>(last_update_timestamp - last_tap_timestamp) / (1000 * 1000 * 1000); @@ -259,8 +261,9 @@ void Controller_Gesture::SetTapEvent(GestureProperties& gesture, GestureProperti } } -void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, f32 time_difference) { +void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type, + f32 time_difference) { auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; @@ -272,13 +275,14 @@ void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GesturePrope last_pan_time_difference = time_difference; // Promote to pinch type - if (std::abs(gesture.average_distance - last_gesture.average_distance) > pinch_threshold) { + if (std::abs(gesture.average_distance - last_gesture_props.average_distance) > + pinch_threshold) { type = TouchType::Pinch; - cur_entry.scale = gesture.average_distance / last_gesture.average_distance; + cur_entry.scale = gesture.average_distance / last_gesture_props.average_distance; } - const f32 angle_between_two_lines = std::atan((gesture.angle - last_gesture.angle) / - (1 + (gesture.angle * last_gesture.angle))); + const f32 angle_between_two_lines = std::atan((gesture.angle - last_gesture_props.angle) / + (1 + (gesture.angle * last_gesture_props.angle))); // Promote to rotate type if (std::abs(angle_between_two_lines) > angle_threshold) { type = TouchType::Rotate; @@ -287,8 +291,9 @@ void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GesturePrope } } -void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, f32 time_difference) { +void Controller_Gesture::EndPanEvent(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type, + f32 time_difference) { auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; @@ -301,7 +306,7 @@ void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperti // Set swipe event with parameters if (curr_vel > swipe_threshold) { - SetSwipeEvent(gesture, last_gesture, type); + SetSwipeEvent(gesture, last_gesture_props, type); return; } @@ -312,13 +317,13 @@ void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperti force_update = true; } -void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type) { +void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type) { auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; type = TouchType::Swipe; - gesture = last_gesture; + gesture = last_gesture_props; force_update = true; cur_entry.delta_x = last_entry.delta_x; cur_entry.delta_y = last_entry.delta_y; diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h index 18110a6ad..f46e29411 100644 --- a/src/core/hle/service/hid/controllers/gesture.h +++ b/src/core/hle/service/hid/controllers/gesture.h @@ -128,32 +128,34 @@ private: void UpdateExistingGesture(GestureProperties& gesture, TouchType& type, f32 time_difference); // Terminates exiting gesture - void EndGesture(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, - Attribute& attributes, f32 time_difference); + void EndGesture(GestureProperties& gesture, GestureProperties& last_gesture_props, + TouchType& type, Attribute& attributes, f32 time_difference); // Set current event to a tap event - void SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, - Attribute& attributes); + void SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture_props, + TouchType& type, Attribute& attributes); // Calculates and set the extra parameters related to a pan event - void UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture, + void UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props, TouchType& type, f32 time_difference); // Terminates the pan event - void EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, - f32 time_difference); + void EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props, + TouchType& type, f32 time_difference); // Set current event to a swipe event - void SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture, + void SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture_props, TouchType& type); - // Returns an unused finger id, if there is no fingers avaliable MAX_FINGERS will be returned + // Returns an unused finger id, if there is no fingers available std::nullopt is returned. std::optional<size_t> GetUnusedFingerID() const; - /** If the touch is new it tries to assing a new finger id, if there is no fingers avaliable no + /** + * If the touch is new it tries to assign a new finger id, if there is no fingers available no * changes will be made. Updates the coordinates if the finger id it's already set. If the touch * ends delays the output by one frame to set the end_touch flag before finally freeing the - * finger id */ + * finger id + */ size_t UpdateTouchInputEvent(const std::tuple<float, float, bool>& touch_input, size_t finger_id); diff --git a/src/core/hle/service/mii/manager.h b/src/core/hle/service/mii/manager.h index 2106a528a..ec7efa5f7 100644 --- a/src/core/hle/service/mii/manager.h +++ b/src/core/hle/service/mii/manager.h @@ -89,7 +89,7 @@ static_assert(std::has_unique_object_representations_v<MiiInfo>, #pragma pack(push, 4) struct MiiInfoElement { - MiiInfoElement(const MiiInfo& info, Source source) : info{info}, source{source} {} + MiiInfoElement(const MiiInfo& info_, Source source_) : info{info_}, source{source_} {} MiiInfo info{}; Source source{}; diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 26be9e45b..81f150a88 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -253,8 +253,8 @@ private: class MiiDBModule final : public ServiceFramework<MiiDBModule> { public: - explicit MiiDBModule(Core::System& system_, const char* name) - : ServiceFramework{system_, name} { + explicit MiiDBModule(Core::System& system_, const char* name_) + : ServiceFramework{system_, name_} { // clang-format off static const FunctionInfo functions[] = { {0, &MiiDBModule::GetDatabaseService, "GetDatabaseService"}, diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 94ef3983a..76e3832df 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -368,7 +368,7 @@ private: }, }; - IPC::ResponseBuilder rb{ctx, 2 + sizeof(IpConfigInfo) / sizeof(u32)}; + IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)}; rb.Push(RESULT_SUCCESS); rb.PushRaw<IpConfigInfo>(ip_config_info); } diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h index b37f023df..5b73a5a34 100644 --- a/src/core/hle/service/nvdrv/devices/nvdevice.h +++ b/src/core/hle/service/nvdrv/devices/nvdevice.h @@ -21,7 +21,7 @@ namespace Service::Nvidia::Devices { /// implement the ioctl interface. class nvdevice { public: - explicit nvdevice(Core::System& system) : system{system} {} + explicit nvdevice(Core::System& system_) : system{system_} {} virtual ~nvdevice() = default; /** diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index bbef04a29..2cc0da124 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp @@ -52,7 +52,6 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3 addr, offset, width, height, stride, static_cast<PixelFormat>(format), transform, crop_rect}; - system.GetPerfStats().EndGameFrame(); system.GetPerfStats().EndSystemFrame(); system.GPU().SwapBuffers(&framebuffer); system.FrameLimiter().DoFrameLimiting(system.CoreTiming().GetGlobalTimeUs()); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h index 229bf6350..24e3151cb 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h @@ -48,13 +48,13 @@ private: public: constexpr BufferMap() = default; - constexpr BufferMap(GPUVAddr start_addr, std::size_t size) - : start_addr{start_addr}, end_addr{start_addr + size} {} + constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_) + : start_addr{start_addr_}, end_addr{start_addr_ + size_} {} - constexpr BufferMap(GPUVAddr start_addr, std::size_t size, VAddr cpu_addr, - bool is_allocated) - : start_addr{start_addr}, end_addr{start_addr + size}, cpu_addr{cpu_addr}, - is_allocated{is_allocated} {} + constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_, VAddr cpu_addr_, + bool is_allocated_) + : start_addr{start_addr_}, end_addr{start_addr_ + size_}, cpu_addr{cpu_addr_}, + is_allocated{is_allocated_} {} constexpr VAddr StartAddr() const { return start_addr; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h index 14d0d210a..da10f5f41 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h @@ -27,13 +27,13 @@ protected: public: constexpr BufferMap() = default; - constexpr BufferMap(GPUVAddr start_addr, std::size_t size) - : start_addr{start_addr}, end_addr{start_addr + size} {} + constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_) + : start_addr{start_addr_}, end_addr{start_addr_ + size_} {} - constexpr BufferMap(GPUVAddr start_addr, std::size_t size, VAddr cpu_addr, - bool is_allocated) - : start_addr{start_addr}, end_addr{start_addr + size}, cpu_addr{cpu_addr}, - is_allocated{is_allocated} {} + constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_, VAddr cpu_addr_, + bool is_allocated_) + : start_addr{start_addr_}, end_addr{start_addr_ + size_}, cpu_addr{cpu_addr_}, + is_allocated{is_allocated_} {} constexpr VAddr StartAddr() const { return start_addr; diff --git a/src/core/hle/service/nvdrv/syncpoint_manager.cpp b/src/core/hle/service/nvdrv/syncpoint_manager.cpp index 0151a03b7..3b6f55526 100644 --- a/src/core/hle/service/nvdrv/syncpoint_manager.cpp +++ b/src/core/hle/service/nvdrv/syncpoint_manager.cpp @@ -8,7 +8,7 @@ namespace Service::Nvidia { -SyncpointManager::SyncpointManager(Tegra::GPU& gpu) : gpu{gpu} {} +SyncpointManager::SyncpointManager(Tegra::GPU& gpu_) : gpu{gpu_} {} SyncpointManager::~SyncpointManager() = default; diff --git a/src/core/hle/service/nvdrv/syncpoint_manager.h b/src/core/hle/service/nvdrv/syncpoint_manager.h index d395c5d0b..99f286474 100644 --- a/src/core/hle/service/nvdrv/syncpoint_manager.h +++ b/src/core/hle/service/nvdrv/syncpoint_manager.h @@ -18,7 +18,7 @@ namespace Service::Nvidia { class SyncpointManager final { public: - explicit SyncpointManager(Tegra::GPU& gpu); + explicit SyncpointManager(Tegra::GPU& gpu_); ~SyncpointManager(); /** diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index 0b6e7430b..59ddf6298 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp @@ -13,8 +13,8 @@ namespace Service::NVFlinger { -BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id) - : id(id), layer_id(layer_id), buffer_wait_event{kernel} { +BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id_, u64 layer_id_) + : id(id_), layer_id(layer_id_), buffer_wait_event{kernel} { Kernel::KAutoObject::Create(std::addressof(buffer_wait_event)); buffer_wait_event.Initialize("BufferQueue:WaitEvent"); } diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 4ec0b1506..61e337ac5 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -54,7 +54,7 @@ public: NativeWindowFormat = 2, }; - explicit BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id); + explicit BufferQueue(Kernel::KernelCore& kernel, u32 id_, u64 layer_id_); ~BufferQueue(); enum class BufferTransformFlags : u32 { diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 7fb9133c7..d1dbc659b 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -61,7 +61,7 @@ void NVFlinger::SplitVSync() { } } -NVFlinger::NVFlinger(Core::System& system) : system(system) { +NVFlinger::NVFlinger(Core::System& system_) : system(system_) { displays.emplace_back(0, "Default", system); displays.emplace_back(1, "External", system); displays.emplace_back(2, "Edid", system); @@ -139,11 +139,15 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { } const u64 layer_id = next_layer_id++; + CreateLayerAtId(*display, layer_id); + return layer_id; +} + +void NVFlinger::CreateLayerAtId(VI::Display& display, u64 layer_id) { const u32 buffer_queue_id = next_buffer_queue_id++; buffer_queues.emplace_back( std::make_unique<BufferQueue>(system.Kernel(), buffer_queue_id, layer_id)); - display->CreateLayer(layer_id, *buffer_queues.back()); - return layer_id; + display.CreateLayer(layer_id, *buffer_queues.back()); } void NVFlinger::CloseLayer(u64 layer_id) { @@ -154,9 +158,9 @@ void NVFlinger::CloseLayer(u64 layer_id) { } } -std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { +std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) { const auto lock_guard = Lock(); - const auto* const layer = FindLayer(display_id, layer_id); + const auto* const layer = FindOrCreateLayer(display_id, layer_id); if (layer == nullptr) { return std::nullopt; @@ -232,6 +236,24 @@ const VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const { return display->FindLayer(layer_id); } +VI::Layer* NVFlinger::FindOrCreateLayer(u64 display_id, u64 layer_id) { + auto* const display = FindDisplay(display_id); + + if (display == nullptr) { + return nullptr; + } + + auto* layer = display->FindLayer(layer_id); + + if (layer == nullptr) { + LOG_DEBUG(Service, "Layer at id {} not found. Trying to create it.", layer_id); + CreateLayerAtId(*display, layer_id); + return display->FindLayer(layer_id); + } + + return layer; +} + void NVFlinger::Compose() { for (auto& display : displays) { // Trigger vsync for this display at the end of drawing diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index b0febdaec..d80fd07ef 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -45,7 +45,7 @@ class BufferQueue; class NVFlinger final { public: - explicit NVFlinger(Core::System& system); + explicit NVFlinger(Core::System& system_); ~NVFlinger(); /// Sets the NVDrv module instance to use to send buffers to the GPU. @@ -67,7 +67,7 @@ public: /// Finds the buffer queue ID of the specified layer in the specified display. /// /// If an invalid display ID or layer ID is provided, then an empty optional is returned. - [[nodiscard]] std::optional<u32> FindBufferQueueId(u64 display_id, u64 layer_id) const; + [[nodiscard]] std::optional<u32> FindBufferQueueId(u64 display_id, u64 layer_id); /// Gets the vsync event for the specified display. /// @@ -100,6 +100,14 @@ private: /// Finds the layer identified by the specified ID in the desired display. [[nodiscard]] const VI::Layer* FindLayer(u64 display_id, u64 layer_id) const; + /// Finds the layer identified by the specified ID in the desired display, + /// or creates the layer if it is not found. + /// To be used when the system expects the specified ID to already exist. + [[nodiscard]] VI::Layer* FindOrCreateLayer(u64 display_id, u64 layer_id); + + /// Creates a layer with the specified layer ID in the desired display. + void CreateLayerAtId(VI::Display& display, u64 layer_id); + static void VSyncThread(NVFlinger& nv_flinger); void SplitVSync(); diff --git a/src/core/hle/service/pctl/pctl.cpp b/src/core/hle/service/pctl/pctl.cpp index e4d155c86..908e0a1e3 100644 --- a/src/core/hle/service/pctl/pctl.cpp +++ b/src/core/hle/service/pctl/pctl.cpp @@ -7,8 +7,8 @@ namespace Service::PCTL { PCTL::PCTL(Core::System& system_, std::shared_ptr<Module> module_, const char* name, - Capability capability) - : Interface{system_, std::move(module_), name, capability} { + Capability capability_) + : Interface{system_, std::move(module_), name, capability_} { static const FunctionInfo functions[] = { {0, &PCTL::CreateService, "CreateService"}, {1, &PCTL::CreateServiceWithoutInitialize, "CreateServiceWithoutInitialize"}, diff --git a/src/core/hle/service/pctl/pctl.h b/src/core/hle/service/pctl/pctl.h index fd0a1e486..ea3b97823 100644 --- a/src/core/hle/service/pctl/pctl.h +++ b/src/core/hle/service/pctl/pctl.h @@ -15,7 +15,7 @@ namespace Service::PCTL { class PCTL final : public Module::Interface { public: explicit PCTL(Core::System& system_, std::shared_ptr<Module> module_, const char* name, - Capability capability); + Capability capability_); ~PCTL() override; }; diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index f4715935d..a43185c44 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -31,8 +31,8 @@ std::optional<Kernel::KProcess*> SearchProcessList( void GetApplicationPidGeneric(Kernel::HLERequestContext& ctx, const std::vector<Kernel::KProcess*>& process_list) { - const auto process = SearchProcessList(process_list, [](const auto& process) { - return process->GetProcessID() == Kernel::KProcess::ProcessIDMin; + const auto process = SearchProcessList(process_list, [](const auto& proc) { + return proc->GetProcessID() == Kernel::KProcess::ProcessIDMin; }); IPC::ResponseBuilder rb{ctx, 4}; @@ -100,8 +100,8 @@ private: LOG_DEBUG(Service_PM, "called, title_id={:016X}", title_id); const auto process = - SearchProcessList(kernel.GetProcessList(), [title_id](const auto& process) { - return process->GetTitleID() == title_id; + SearchProcessList(kernel.GetProcessList(), [title_id](const auto& proc) { + return proc->GetTitleID() == title_id; }); if (!process.has_value()) { @@ -140,8 +140,8 @@ private: LOG_DEBUG(Service_PM, "called, process_id={:016X}", process_id); - const auto process = SearchProcessList(process_list, [process_id](const auto& process) { - return process->GetProcessID() == process_id; + const auto process = SearchProcessList(process_list, [process_id](const auto& proc) { + return proc->GetProcessID() == process_id; }); if (!process.has_value()) { diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 3dfb0740a..4c048173b 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -155,17 +155,17 @@ protected: /** * Constructs a FunctionInfo for a function. * - * @param expected_header request header in the command buffer which will trigger dispatch + * @param expected_header_ request header in the command buffer which will trigger dispatch * to this handler - * @param handler_callback member function in this service which will be called to handle + * @param handler_callback_ member function in this service which will be called to handle * the request - * @param name human-friendly name for the request. Used mostly for logging purposes. + * @param name_ human-friendly name for the request. Used mostly for logging purposes. */ - FunctionInfo(u32 expected_header, HandlerFnP<Self> handler_callback, const char* name) + FunctionInfo(u32 expected_header_, HandlerFnP<Self> handler_callback_, const char* name_) : FunctionInfoBase{ - expected_header, + expected_header_, // Type-erase member function pointer by casting it down to the base class. - static_cast<HandlerFnP<ServiceFrameworkBase>>(handler_callback), name} {} + static_cast<HandlerFnP<ServiceFrameworkBase>>(handler_callback_), name_} {} }; /** diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 2c8899ae0..3b072f6bc 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -128,7 +128,7 @@ private: LOG_WARNING(Service_SSL, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; + IPC::ResponseBuilder rb{ctx, 4}; rb.Push(RESULT_SUCCESS); rb.Push(client_id); } diff --git a/src/core/hle/service/time/ephemeral_network_system_clock_core.h b/src/core/hle/service/time/ephemeral_network_system_clock_core.h index 4c6cdef86..d12cb5335 100644 --- a/src/core/hle/service/time/ephemeral_network_system_clock_core.h +++ b/src/core/hle/service/time/ephemeral_network_system_clock_core.h @@ -10,8 +10,8 @@ namespace Service::Time::Clock { class EphemeralNetworkSystemClockCore final : public SystemClockCore { public: - explicit EphemeralNetworkSystemClockCore(SteadyClockCore& steady_clock_core) - : SystemClockCore{steady_clock_core} {} + explicit EphemeralNetworkSystemClockCore(SteadyClockCore& steady_clock_core_) + : SystemClockCore{steady_clock_core_} {} }; } // namespace Service::Time::Clock diff --git a/src/core/hle/service/time/local_system_clock_context_writer.h b/src/core/hle/service/time/local_system_clock_context_writer.h index 7050844c6..490d0ef3e 100644 --- a/src/core/hle/service/time/local_system_clock_context_writer.h +++ b/src/core/hle/service/time/local_system_clock_context_writer.h @@ -12,8 +12,8 @@ namespace Service::Time::Clock { class LocalSystemClockContextWriter final : public SystemClockContextUpdateCallback { public: - explicit LocalSystemClockContextWriter(SharedMemory& shared_memory) - : SystemClockContextUpdateCallback{}, shared_memory{shared_memory} {} + explicit LocalSystemClockContextWriter(SharedMemory& shared_memory_) + : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {} protected: ResultCode Update() override { diff --git a/src/core/hle/service/time/network_system_clock_context_writer.h b/src/core/hle/service/time/network_system_clock_context_writer.h index 94d8788ff..e2920b8eb 100644 --- a/src/core/hle/service/time/network_system_clock_context_writer.h +++ b/src/core/hle/service/time/network_system_clock_context_writer.h @@ -12,8 +12,8 @@ namespace Service::Time::Clock { class NetworkSystemClockContextWriter final : public SystemClockContextUpdateCallback { public: - explicit NetworkSystemClockContextWriter(SharedMemory& shared_memory) - : SystemClockContextUpdateCallback{}, shared_memory{shared_memory} {} + explicit NetworkSystemClockContextWriter(SharedMemory& shared_memory_) + : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {} protected: ResultCode Update() override { diff --git a/src/core/hle/service/time/standard_local_system_clock_core.h b/src/core/hle/service/time/standard_local_system_clock_core.h index 8c1882eb1..6320c7af1 100644 --- a/src/core/hle/service/time/standard_local_system_clock_core.h +++ b/src/core/hle/service/time/standard_local_system_clock_core.h @@ -10,8 +10,8 @@ namespace Service::Time::Clock { class StandardLocalSystemClockCore final : public SystemClockCore { public: - explicit StandardLocalSystemClockCore(SteadyClockCore& steady_clock_core) - : SystemClockCore{steady_clock_core} {} + explicit StandardLocalSystemClockCore(SteadyClockCore& steady_clock_core_) + : SystemClockCore{steady_clock_core_} {} }; } // namespace Service::Time::Clock diff --git a/src/core/hle/service/time/standard_network_system_clock_core.h b/src/core/hle/service/time/standard_network_system_clock_core.h index c993bdf79..9d0aeaedb 100644 --- a/src/core/hle/service/time/standard_network_system_clock_core.h +++ b/src/core/hle/service/time/standard_network_system_clock_core.h @@ -16,21 +16,21 @@ namespace Service::Time::Clock { class StandardNetworkSystemClockCore final : public SystemClockCore { public: - explicit StandardNetworkSystemClockCore(SteadyClockCore& steady_clock_core) - : SystemClockCore{steady_clock_core} {} + explicit StandardNetworkSystemClockCore(SteadyClockCore& steady_clock_core_) + : SystemClockCore{steady_clock_core_} {} void SetStandardNetworkClockSufficientAccuracy(TimeSpanType value) { standard_network_clock_sufficient_accuracy = value; } bool IsStandardNetworkSystemClockAccuracySufficient(Core::System& system) const { - SystemClockContext context{}; - if (GetClockContext(system, context) != RESULT_SUCCESS) { + SystemClockContext clock_ctx{}; + if (GetClockContext(system, clock_ctx) != RESULT_SUCCESS) { return {}; } s64 span{}; - if (context.steady_time_point.GetSpanBetween( + if (clock_ctx.steady_time_point.GetSpanBetween( GetSteadyClockCore().GetCurrentTimePoint(system), span) != RESULT_SUCCESS) { return {}; } diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp index 7f47b12b8..41bc01abd 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp @@ -11,13 +11,13 @@ namespace Service::Time::Clock { StandardUserSystemClockCore::StandardUserSystemClockCore( - StandardLocalSystemClockCore& local_system_clock_core, - StandardNetworkSystemClockCore& network_system_clock_core, Core::System& system) - : SystemClockCore(local_system_clock_core.GetSteadyClockCore()), - local_system_clock_core{local_system_clock_core}, - network_system_clock_core{network_system_clock_core}, auto_correction_enabled{}, + StandardLocalSystemClockCore& local_system_clock_core_, + StandardNetworkSystemClockCore& network_system_clock_core_, Core::System& system_) + : SystemClockCore(local_system_clock_core_.GetSteadyClockCore()), + local_system_clock_core{local_system_clock_core_}, + network_system_clock_core{network_system_clock_core_}, auto_correction_time{SteadyClockTimePoint::GetRandom()}, auto_correction_event{ - system.Kernel()} { + system_.Kernel()} { Kernel::KAutoObject::Create(std::addressof(auto_correction_event)); auto_correction_event.Initialize("StandardUserSystemClockCore:AutoCorrectionEvent"); } @@ -35,13 +35,13 @@ ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::Syst } ResultCode StandardUserSystemClockCore::GetClockContext(Core::System& system, - SystemClockContext& context) const { + SystemClockContext& ctx) const { if (const ResultCode result{ApplyAutomaticCorrection(system, false)}; result != RESULT_SUCCESS) { return result; } - return local_system_clock_core.GetClockContext(system, context); + return local_system_clock_core.GetClockContext(system, ctx); } ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext&) { @@ -64,13 +64,13 @@ ResultCode StandardUserSystemClockCore::ApplyAutomaticCorrection(Core::System& s return ERROR_UNINITIALIZED_CLOCK; } - SystemClockContext context{}; - if (const ResultCode result{network_system_clock_core.GetClockContext(system, context)}; + SystemClockContext ctx{}; + if (const ResultCode result{network_system_clock_core.GetClockContext(system, ctx)}; result != RESULT_SUCCESS) { return result; } - local_system_clock_core.SetClockContext(context); + local_system_clock_core.SetClockContext(ctx); return RESULT_SUCCESS; } diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h index 1bff8a5af..bf9ec5e42 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.h +++ b/src/core/hle/service/time/standard_user_system_clock_core.h @@ -23,13 +23,13 @@ class StandardNetworkSystemClockCore; class StandardUserSystemClockCore final : public SystemClockCore { public: - StandardUserSystemClockCore(StandardLocalSystemClockCore& local_system_clock_core, - StandardNetworkSystemClockCore& network_system_clock_core, - Core::System& system); + StandardUserSystemClockCore(StandardLocalSystemClockCore& local_system_clock_core_, + StandardNetworkSystemClockCore& network_system_clock_core_, + Core::System& system_); ResultCode SetAutomaticCorrectionEnabled(Core::System& system, bool value); - ResultCode GetClockContext(Core::System& system, SystemClockContext& context) const override; + ResultCode GetClockContext(Core::System& system, SystemClockContext& ctx) const override; bool IsAutomaticCorrectionEnabled() const { return auto_correction_enabled; diff --git a/src/core/hle/service/time/system_clock_core.cpp b/src/core/hle/service/time/system_clock_core.cpp index 46fc8c6c3..2ef442b56 100644 --- a/src/core/hle/service/time/system_clock_core.cpp +++ b/src/core/hle/service/time/system_clock_core.cpp @@ -8,8 +8,8 @@ namespace Service::Time::Clock { -SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core) - : steady_clock_core{steady_clock_core} { +SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core_) + : steady_clock_core{steady_clock_core_} { context.steady_time_point.clock_source_id = steady_clock_core.GetClockSourceId(); } diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h index 82a8b79ff..b8e6122bf 100644 --- a/src/core/hle/service/time/system_clock_core.h +++ b/src/core/hle/service/time/system_clock_core.h @@ -21,7 +21,7 @@ class SystemClockContextUpdateCallback; class SystemClockCore { public: - explicit SystemClockCore(SteadyClockCore& steady_clock_core); + explicit SystemClockCore(SteadyClockCore& steady_clock_core_); virtual ~SystemClockCore(); SteadyClockCore& GetSteadyClockCore() const { diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index fe01a3739..4f9684de8 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp @@ -223,7 +223,7 @@ struct TimeManager::Impl final { TimeZone::TimeZoneContentManager time_zone_content_manager; }; -TimeManager::TimeManager(Core::System& system) : system{system} {} +TimeManager::TimeManager(Core::System& system_) : system{system_} {} TimeManager::~TimeManager() = default; diff --git a/src/core/hle/service/time/time_manager.h b/src/core/hle/service/time/time_manager.h index 4db8cc0e1..3af868d87 100644 --- a/src/core/hle/service/time/time_manager.h +++ b/src/core/hle/service/time/time_manager.h @@ -30,7 +30,7 @@ class NetworkSystemClockContextWriter; class TimeManager final { public: - explicit TimeManager(Core::System& system); + explicit TimeManager(Core::System& system_); ~TimeManager(); void Initialize(); diff --git a/src/core/hle/service/time/time_sharedmemory.cpp b/src/core/hle/service/time/time_sharedmemory.cpp index eb57899f6..176ad0eee 100644 --- a/src/core/hle/service/time/time_sharedmemory.cpp +++ b/src/core/hle/service/time/time_sharedmemory.cpp @@ -15,7 +15,7 @@ namespace Service::Time { static constexpr std::size_t SHARED_MEMORY_SIZE{0x1000}; -SharedMemory::SharedMemory(Core::System& system) : system(system) { +SharedMemory::SharedMemory(Core::System& system_) : system(system_) { std::memset(system.Kernel().GetTimeSharedMem().GetPointer(), 0, SHARED_MEMORY_SIZE); } diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h index 1ad9a286d..d471b5d18 100644 --- a/src/core/hle/service/time/time_sharedmemory.h +++ b/src/core/hle/service/time/time_sharedmemory.h @@ -14,7 +14,7 @@ namespace Service::Time { class SharedMemory final { public: - explicit SharedMemory(Core::System& system); + explicit SharedMemory(Core::System& system_); ~SharedMemory(); // TODO(ogniK): We have to properly simulate memory barriers, how are we going to do this? diff --git a/src/core/hle/service/time/time_zone_content_manager.cpp b/src/core/hle/service/time/time_zone_content_manager.cpp index 3c8e71a3c..57f71e6f0 100644 --- a/src/core/hle/service/time/time_zone_content_manager.cpp +++ b/src/core/hle/service/time/time_zone_content_manager.cpp @@ -68,8 +68,8 @@ static std::vector<std::string> BuildLocationNameCache(Core::System& system) { return location_name_cache; } -TimeZoneContentManager::TimeZoneContentManager(Core::System& system) - : system{system}, location_name_cache{BuildLocationNameCache(system)} {} +TimeZoneContentManager::TimeZoneContentManager(Core::System& system_) + : system{system_}, location_name_cache{BuildLocationNameCache(system)} {} void TimeZoneContentManager::Initialize(TimeManager& time_manager) { std::string location_name; diff --git a/src/core/hle/service/time/time_zone_content_manager.h b/src/core/hle/service/time/time_zone_content_manager.h index 52dd1a020..cfa601084 100644 --- a/src/core/hle/service/time/time_zone_content_manager.h +++ b/src/core/hle/service/time/time_zone_content_manager.h @@ -21,7 +21,7 @@ namespace Service::Time::TimeZone { class TimeZoneContentManager final { public: - explicit TimeZoneContentManager(Core::System& system); + explicit TimeZoneContentManager(Core::System& system_); void Initialize(TimeManager& time_manager); diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index becbd36c1..0dd342dbf 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -17,8 +17,8 @@ namespace Service::VI { -Display::Display(u64 id, std::string name, Core::System& system) - : id{id}, name{std::move(name)}, vsync_event{system.Kernel()} { +Display::Display(u64 id, std::string name_, Core::System& system) + : display_id{id}, name{std::move(name_)}, vsync_event{system.Kernel()} { Kernel::KAutoObject::Create(std::addressof(vsync_event)); vsync_event.Initialize(fmt::format("Display VSync Event {}", id)); } diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 388ce6083..166f2a4cc 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -32,14 +32,14 @@ public: /// Constructs a display with a given unique ID and name. /// /// @param id The unique ID for this display. - /// @param name The name for this display. + /// @param name_ The name for this display. /// - Display(u64 id, std::string name, Core::System& system); + Display(u64 id, std::string name_, Core::System& system); ~Display(); /// Gets the unique ID assigned to this display. u64 GetID() const { - return id; + return display_id; } /// Gets the name of this display @@ -96,7 +96,7 @@ public: const Layer* FindLayer(u64 layer_id) const; private: - u64 id; + u64 display_id; std::string name; std::vector<std::shared_ptr<Layer>> layers; diff --git a/src/core/hle/service/vi/layer/vi_layer.cpp b/src/core/hle/service/vi/layer/vi_layer.cpp index 954225c26..9bc382587 100644 --- a/src/core/hle/service/vi/layer/vi_layer.cpp +++ b/src/core/hle/service/vi/layer/vi_layer.cpp @@ -6,7 +6,7 @@ namespace Service::VI { -Layer::Layer(u64 id, NVFlinger::BufferQueue& queue) : id{id}, buffer_queue{queue} {} +Layer::Layer(u64 id, NVFlinger::BufferQueue& queue) : layer_id{id}, buffer_queue{queue} {} Layer::~Layer() = default; diff --git a/src/core/hle/service/vi/layer/vi_layer.h b/src/core/hle/service/vi/layer/vi_layer.h index c6bfd01f6..ebdd85505 100644 --- a/src/core/hle/service/vi/layer/vi_layer.h +++ b/src/core/hle/service/vi/layer/vi_layer.h @@ -31,7 +31,7 @@ public: /// Gets the ID for this layer. u64 GetID() const { - return id; + return layer_id; } /// Gets a reference to the buffer queue this layer is using. @@ -45,7 +45,7 @@ public: } private: - u64 id; + u64 layer_id; NVFlinger::BufferQueue& buffer_queue; }; diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 32e47a43e..fdd2b4b4f 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -212,7 +212,7 @@ private: class IGBPConnectRequestParcel : public Parcel { public: - explicit IGBPConnectRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPConnectRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -274,8 +274,8 @@ private: class IGBPSetPreallocatedBufferRequestParcel : public Parcel { public: - explicit IGBPSetPreallocatedBufferRequestParcel(std::vector<u8> buffer) - : Parcel(std::move(buffer)) { + explicit IGBPSetPreallocatedBufferRequestParcel(std::vector<u8> buffer_) + : Parcel(std::move(buffer_)) { Deserialize(); } @@ -312,7 +312,7 @@ protected: class IGBPCancelBufferRequestParcel : public Parcel { public: - explicit IGBPCancelBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPCancelBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -338,7 +338,7 @@ protected: class IGBPDequeueBufferRequestParcel : public Parcel { public: - explicit IGBPDequeueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPDequeueBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -360,8 +360,8 @@ public: class IGBPDequeueBufferResponseParcel : public Parcel { public: - explicit IGBPDequeueBufferResponseParcel(u32 slot, Service::Nvidia::MultiFence& multi_fence) - : slot(slot), multi_fence(multi_fence) {} + explicit IGBPDequeueBufferResponseParcel(u32 slot_, Nvidia::MultiFence& multi_fence_) + : slot(slot_), multi_fence(multi_fence_) {} protected: void SerializeData() override { @@ -377,7 +377,7 @@ protected: class IGBPRequestBufferRequestParcel : public Parcel { public: - explicit IGBPRequestBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPRequestBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -391,7 +391,7 @@ public: class IGBPRequestBufferResponseParcel : public Parcel { public: - explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer) : buffer(buffer) {} + explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer_) : buffer(buffer_) {} ~IGBPRequestBufferResponseParcel() override = default; protected: @@ -408,7 +408,7 @@ protected: class IGBPQueueBufferRequestParcel : public Parcel { public: - explicit IGBPQueueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPQueueBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -470,7 +470,7 @@ private: class IGBPQueryRequestParcel : public Parcel { public: - explicit IGBPQueryRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPQueryRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -484,7 +484,7 @@ public: class IGBPQueryResponseParcel : public Parcel { public: - explicit IGBPQueryResponseParcel(u32 value) : value(value) {} + explicit IGBPQueryResponseParcel(u32 value_) : value{value_} {} ~IGBPQueryResponseParcel() override = default; protected: diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 42f023258..022885c1b 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp @@ -22,8 +22,8 @@ namespace Loader { AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_, - bool override_update) - : AppLoader(std::move(file_)), override_update(override_update) { + bool override_update_) + : AppLoader(std::move(file_)), override_update(override_update_) { const auto file_dir = file->GetContainingDirectory(); // Title ID @@ -48,9 +48,9 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys // Any png, jpeg, or bmp file const auto& files = file_dir->GetFiles(); const auto icon_iter = - std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) { - return file->GetExtension() == "png" || file->GetExtension() == "jpg" || - file->GetExtension() == "bmp" || file->GetExtension() == "jpeg"; + std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& f) { + return f->GetExtension() == "png" || f->GetExtension() == "jpg" || + f->GetExtension() == "bmp" || f->GetExtension() == "jpeg"; }); if (icon_iter != files.end()) icon_data = (*icon_iter)->ReadAllBytes(); @@ -61,9 +61,8 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys if (nacp_file == nullptr) { const auto& files = file_dir->GetFiles(); const auto nacp_iter = - std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) { - return file->GetExtension() == "nacp"; - }); + std::find_if(files.begin(), files.end(), + [](const FileSys::VirtualFile& f) { return f->GetExtension() == "nacp"; }); if (nacp_iter != files.end()) nacp_file = *nacp_iter; } @@ -75,9 +74,9 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys } AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory( - FileSys::VirtualDir directory, bool override_update) + FileSys::VirtualDir directory, bool override_update_) : AppLoader(directory->GetFile("main")), dir(std::move(directory)), - override_update(override_update) {} + override_update(override_update_) {} FileType AppLoader_DeconstructedRomDirectory::IdentifyType(const FileSys::VirtualFile& dir_file) { if (FileSys::IsDirectoryExeFS(dir_file->GetContainingDirectory())) { @@ -184,8 +183,8 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect // Find the RomFS by searching for a ".romfs" file in this directory const auto& files = dir->GetFiles(); const auto romfs_iter = - std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) { - return file->GetName().find(".romfs") != std::string::npos; + std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& f) { + return f->GetName().find(".romfs") != std::string::npos; }); // Register the RomFS if a ".romfs" file was found diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.h index a49a8b001..79a4d4db5 100644 --- a/src/core/loader/deconstructed_rom_directory.h +++ b/src/core/loader/deconstructed_rom_directory.h @@ -24,11 +24,11 @@ namespace Loader { class AppLoader_DeconstructedRomDirectory final : public AppLoader { public: explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file, - bool override_update = false); + bool override_update_ = false); // Overload to accept exefs directory. Must contain 'main' and 'main.npdm' explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory, - bool override_update = false); + bool override_update_ = false); /** * Identifies whether or not the given file is a deconstructed ROM directory. diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 11b2d0837..d4808fb5b 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -194,7 +194,7 @@ std::ostream& operator<<(std::ostream& os, ResultStatus status) { return os; } -AppLoader::AppLoader(FileSys::VirtualFile file) : file(std::move(file)) {} +AppLoader::AppLoader(FileSys::VirtualFile file_) : file(std::move(file_)) {} AppLoader::~AppLoader() = default; /** diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 9eac11dec..edc8bb257 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -147,7 +147,7 @@ public: }; using LoadResult = std::pair<ResultStatus, std::optional<LoadParameters>>; - explicit AppLoader(FileSys::VirtualFile file); + explicit AppLoader(FileSys::VirtualFile file_); virtual ~AppLoader(); /** diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp index 0f5ef7954..46a7e09b4 100644 --- a/src/core/memory/cheat_engine.cpp +++ b/src/core/memory/cheat_engine.cpp @@ -37,8 +37,8 @@ std::string_view ExtractName(std::string_view data, std::size_t start_index, cha } } // Anonymous namespace -StandardVmCallbacks::StandardVmCallbacks(Core::System& system, const CheatProcessMetadata& metadata) - : metadata(metadata), system(system) {} +StandardVmCallbacks::StandardVmCallbacks(System& system_, const CheatProcessMetadata& metadata_) + : metadata{metadata_}, system{system_} {} StandardVmCallbacks::~StandardVmCallbacks() = default; @@ -174,11 +174,11 @@ std::vector<CheatEntry> TextCheatParser::Parse(std::string_view data) const { return out; } -CheatEngine::CheatEngine(Core::System& system, std::vector<CheatEntry> cheats, - const std::array<u8, 0x20>& build_id) - : vm{std::make_unique<StandardVmCallbacks>(system, metadata)}, - cheats(std::move(cheats)), core_timing{system.CoreTiming()}, system{system} { - metadata.main_nso_build_id = build_id; +CheatEngine::CheatEngine(System& system_, std::vector<CheatEntry> cheats_, + const std::array<u8, 0x20>& build_id_) + : vm{std::make_unique<StandardVmCallbacks>(system_, metadata)}, + cheats(std::move(cheats_)), core_timing{system_.CoreTiming()}, system{system_} { + metadata.main_nso_build_id = build_id_; } CheatEngine::~CheatEngine() { diff --git a/src/core/memory/cheat_engine.h b/src/core/memory/cheat_engine.h index 5e6f901ec..a8e041d9d 100644 --- a/src/core/memory/cheat_engine.h +++ b/src/core/memory/cheat_engine.h @@ -25,7 +25,7 @@ namespace Core::Memory { class StandardVmCallbacks : public DmntCheatVm::Callbacks { public: - StandardVmCallbacks(Core::System& system, const CheatProcessMetadata& metadata); + StandardVmCallbacks(System& system_, const CheatProcessMetadata& metadata_); ~StandardVmCallbacks() override; void MemoryRead(VAddr address, void* data, u64 size) override; @@ -38,7 +38,7 @@ private: VAddr SanitizeAddress(VAddr address) const; const CheatProcessMetadata& metadata; - Core::System& system; + System& system; }; // Intermediary class that parses a text file or other disk format for storing cheats into a @@ -61,8 +61,8 @@ public: // Class that encapsulates a CheatList and manages its interaction with memory and CoreTiming class CheatEngine final { public: - CheatEngine(Core::System& system_, std::vector<CheatEntry> cheats_, - const std::array<u8, 0x20>& build_id); + CheatEngine(System& system_, std::vector<CheatEntry> cheats_, + const std::array<u8, 0x20>& build_id_); ~CheatEngine(); void Initialize(); diff --git a/src/core/memory/dmnt_cheat_vm.cpp b/src/core/memory/dmnt_cheat_vm.cpp index 48be80c12..dc04e37d2 100644 --- a/src/core/memory/dmnt_cheat_vm.cpp +++ b/src/core/memory/dmnt_cheat_vm.cpp @@ -29,7 +29,8 @@ namespace Core::Memory { -DmntCheatVm::DmntCheatVm(std::unique_ptr<Callbacks> callbacks) : callbacks(std::move(callbacks)) {} +DmntCheatVm::DmntCheatVm(std::unique_ptr<Callbacks> callbacks_) + : callbacks(std::move(callbacks_)) {} DmntCheatVm::~DmntCheatVm() = default; diff --git a/src/core/memory/dmnt_cheat_vm.h b/src/core/memory/dmnt_cheat_vm.h index 21b86b72c..707bee82b 100644 --- a/src/core/memory/dmnt_cheat_vm.h +++ b/src/core/memory/dmnt_cheat_vm.h @@ -293,7 +293,7 @@ public: static constexpr std::size_t NumStaticRegisters = NumReadableStaticRegisters + NumWritableStaticRegisters; - explicit DmntCheatVm(std::unique_ptr<Callbacks> callbacks); + explicit DmntCheatVm(std::unique_ptr<Callbacks> callbacks_); ~DmntCheatVm(); std::size_t GetProgramSize() const { diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index c92337079..c42c437b7 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp @@ -27,7 +27,7 @@ constexpr std::size_t IgnoreFrames = 5; namespace Core { -PerfStats::PerfStats(u64 title_id) : title_id(title_id) {} +PerfStats::PerfStats(u64 title_id_) : title_id(title_id_) {} PerfStats::~PerfStats() { if (!Settings::values.record_frame_times || title_id == 0) { @@ -69,9 +69,7 @@ void PerfStats::EndSystemFrame() { } void PerfStats::EndGameFrame() { - std::lock_guard lock{object_mutex}; - - game_frames += 1; + game_frames.fetch_add(1, std::memory_order_relaxed); } double PerfStats::GetMeanFrametime() const { @@ -94,10 +92,11 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us const auto interval = duration_cast<DoubleSecs>(now - reset_point).count(); const auto system_us_per_second = (current_system_time_us - reset_point_system_us) / interval; - + const auto current_frames = static_cast<double>(game_frames.load(std::memory_order_relaxed)); + const auto current_fps = current_frames / interval; const PerfStatsResults results{ .system_fps = static_cast<double>(system_frames) / interval, - .game_fps = static_cast<double>(game_frames) / interval, + .average_game_fps = (current_fps + previous_fps) / 2.0, .frametime = duration_cast<DoubleSecs>(accumulated_frametime).count() / static_cast<double>(system_frames), .emulation_speed = system_us_per_second.count() / 1'000'000.0, @@ -108,7 +107,8 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us reset_point_system_us = current_system_time_us; accumulated_frametime = Clock::duration::zero(); system_frames = 0; - game_frames = 0; + game_frames.store(0, std::memory_order_relaxed); + previous_fps = current_fps; return results; } diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index 69256b960..e5d603717 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -5,6 +5,7 @@ #pragma once #include <array> +#include <atomic> #include <chrono> #include <cstddef> #include <mutex> @@ -15,8 +16,8 @@ namespace Core { struct PerfStatsResults { /// System FPS (LCD VBlanks) in Hz double system_fps; - /// Game FPS (GSP frame submissions) in Hz - double game_fps; + /// Average game FPS (GPU frame renders) in Hz + double average_game_fps; /// Walltime per system frame, in seconds, excluding any waits double frametime; /// Ratio of walltime / emulated time elapsed @@ -29,7 +30,7 @@ struct PerfStatsResults { */ class PerfStats { public: - explicit PerfStats(u64 title_id); + explicit PerfStats(u64 title_id_); ~PerfStats(); using Clock = std::chrono::high_resolution_clock; @@ -72,7 +73,7 @@ private: /// Cumulative number of system frames (LCD VBlanks) presented since last reset u32 system_frames = 0; /// Cumulative number of game frames (GSP frame submissions) since last reset - u32 game_frames = 0; + std::atomic<u32> game_frames = 0; /// Point when the previous system frame ended Clock::time_point previous_frame_end = reset_point; @@ -80,6 +81,8 @@ private: Clock::time_point frame_begin = reset_point; /// Total visible duration (including frame-limiting, etc.) of the previous system frame Clock::duration previous_frame_length = Clock::duration::zero(); + /// Previously computed fps + double previous_fps = 0; }; class FrameLimiter { diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index 896add892..d1e807dd4 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp @@ -192,7 +192,7 @@ json GetHLERequestContextData(Kernel::HLERequestContext& ctx, Core::Memory::Memo namespace Core { -Reporter::Reporter(System& system) : system(system) {} +Reporter::Reporter(System& system_) : system(system_) {} Reporter::~Reporter() = default; diff --git a/src/core/reporter.h b/src/core/reporter.h index b2c2d9a2e..6fb6ebffa 100644 --- a/src/core/reporter.h +++ b/src/core/reporter.h @@ -30,7 +30,7 @@ class System; class Reporter { public: - explicit Reporter(System& system); + explicit Reporter(System& system_); ~Reporter(); // Used by fatal services diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index 8a38a380d..bc1dfab3d 100644 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp @@ -86,6 +86,7 @@ private: case Type::PadData: { Response::PadData pad_data; std::memcpy(&pad_data, &receive_buffer[sizeof(Header)], sizeof(Response::PadData)); + SanitizeMotion(pad_data); callback.pad_data(std::move(pad_data)); break; } @@ -114,6 +115,28 @@ private: StartSend(timer.expiry()); } + void SanitizeMotion(Response::PadData& data) { + // Zero out any non number value + if (!std::isnormal(data.gyro.pitch)) { + data.gyro.pitch = 0; + } + if (!std::isnormal(data.gyro.roll)) { + data.gyro.roll = 0; + } + if (!std::isnormal(data.gyro.yaw)) { + data.gyro.yaw = 0; + } + if (!std::isnormal(data.accel.x)) { + data.accel.x = 0; + } + if (!std::isnormal(data.accel.y)) { + data.accel.y = 0; + } + if (!std::isnormal(data.accel.z)) { + data.accel.z = 0; + } + } + SocketCallback callback; boost::asio::io_service io_service; boost::asio::basic_waitable_timer<clock> timer; diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 32dcbd693..de971041f 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -690,7 +690,10 @@ void BufferCache<P>::BindHostGraphicsUniformBuffer(size_t stage, u32 index, u32 const VAddr cpu_addr = binding.cpu_addr; const u32 size = binding.size; Buffer& buffer = slot_buffers[binding.buffer_id]; - if (size <= uniform_buffer_skip_cache_size && !buffer.IsRegionGpuModified(cpu_addr, size)) { + const bool use_fast_buffer = binding.buffer_id != NULL_BUFFER_ID && + size <= uniform_buffer_skip_cache_size && + !buffer.IsRegionGpuModified(cpu_addr, size); + if (use_fast_buffer) { if constexpr (IS_OPENGL) { if (runtime.HasFastBufferSubData()) { // Fast path for Nvidia diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index a38024242..37f7b24e1 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -13,6 +13,7 @@ #include "core/frontend/emu_window.h" #include "core/hardware_interrupt_manager.h" #include "core/memory.h" +#include "core/perf_stats.h" #include "video_core/engines/fermi_2d.h" #include "video_core/engines/kepler_compute.h" #include "video_core/engines/kepler_memory.h" @@ -191,6 +192,10 @@ u64 GPU::GetTicks() const { return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den; } +void GPU::RendererFrameEndNotify() { + system.GetPerfStats().EndGameFrame(); +} + void GPU::FlushCommands() { rasterizer->FlushCommands(); } diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 8669e9940..29a867863 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -247,6 +247,8 @@ public: return use_nvdec; } + void RendererFrameEndNotify(); + enum class FenceOperation : u32 { Acquire = 0, Increment = 1, diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index cc2e499f9..a718bff7a 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -155,6 +155,7 @@ void RendererOpenGL::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { ++m_current_frame; + gpu.RendererFrameEndNotify(); rasterizer.TickFrame(); context->SwapBuffers(); diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index 2e0cf4232..3986eb172 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -154,6 +154,7 @@ void RendererVulkan::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { if (swapchain.Present(render_semaphore)) { blit_screen.Recreate(); } + gpu.RendererFrameEndNotify(); rasterizer.TickFrame(); } diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp index 695b2ef5f..a2e0e6962 100644 --- a/src/yuzu/about_dialog.cpp +++ b/src/yuzu/about_dialog.cpp @@ -9,17 +9,19 @@ #include "yuzu/about_dialog.h" AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) { + const auto branch_name = std::string(Common::g_scm_branch); + const auto description = std::string(Common::g_scm_desc); const auto build_id = std::string(Common::g_build_id); - const auto fmt = std::string(Common::g_title_bar_format_idle); - const auto yuzu_build_version = - fmt::format(fmt.empty() ? "yuzu Development Build" : fmt, std::string{}, std::string{}, - std::string{}, std::string{}, std::string{}, build_id); + + const auto yuzu_build = fmt::format("yuzu Development Build | {}-{}", branch_name, description); + const auto override_build = fmt::format(std::string(Common::g_title_bar_format_idle), build_id); + const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; ui->setupUi(this); ui->labelLogo->setPixmap(QIcon::fromTheme(QStringLiteral("yuzu")).pixmap(200)); - ui->labelBuildInfo->setText(ui->labelBuildInfo->text().arg( - QString::fromStdString(yuzu_build_version), QString::fromUtf8(Common::g_scm_branch), - QString::fromUtf8(Common::g_scm_desc), QString::fromUtf8(Common::g_build_date).left(10))); + ui->labelBuildInfo->setText( + ui->labelBuildInfo->text().arg(QString::fromStdString(yuzu_build_version), + QString::fromUtf8(Common::g_build_date).left(10))); } AboutDialog::~AboutDialog() = default; diff --git a/src/yuzu/aboutdialog.ui b/src/yuzu/aboutdialog.ui index 1b320630c..27d81cd13 100644 --- a/src/yuzu/aboutdialog.ui +++ b/src/yuzu/aboutdialog.ui @@ -70,7 +70,7 @@ </sizepolicy> </property> <property name="text"> - <string><html><head/><body><p>%1 | %2-%3 (%4)</p></body></html></string> + <string><html><head/><body><p>%1 (%2)</p></body></html></string> </property> </widget> </item> diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index e80a3df77..125feb86b 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -736,10 +736,16 @@ void Config::ReadPathValues() { void Config::ReadCpuValues() { qt_config->beginGroup(QStringLiteral("Cpu")); - if (global) { - Settings::values.cpu_accuracy = static_cast<Settings::CPUAccuracy>( - ReadSetting(QStringLiteral("cpu_accuracy"), 0).toInt()); + ReadSettingGlobal(Settings::values.cpu_accuracy, QStringLiteral("cpu_accuracy"), 0); + + ReadSettingGlobal(Settings::values.cpuopt_unsafe_unfuse_fma, + QStringLiteral("cpuopt_unsafe_unfuse_fma"), true); + ReadSettingGlobal(Settings::values.cpuopt_unsafe_reduce_fp_error, + QStringLiteral("cpuopt_unsafe_reduce_fp_error"), true); + ReadSettingGlobal(Settings::values.cpuopt_unsafe_inaccurate_nan, + QStringLiteral("cpuopt_unsafe_inaccurate_nan"), true); + if (global) { Settings::values.cpuopt_page_tables = ReadSetting(QStringLiteral("cpuopt_page_tables"), true).toBool(); Settings::values.cpuopt_block_linking = @@ -756,13 +762,6 @@ void Config::ReadCpuValues() { ReadSetting(QStringLiteral("cpuopt_misc_ir"), true).toBool(); Settings::values.cpuopt_reduce_misalign_checks = ReadSetting(QStringLiteral("cpuopt_reduce_misalign_checks"), true).toBool(); - - Settings::values.cpuopt_unsafe_unfuse_fma = - ReadSetting(QStringLiteral("cpuopt_unsafe_unfuse_fma"), true).toBool(); - Settings::values.cpuopt_unsafe_reduce_fp_error = - ReadSetting(QStringLiteral("cpuopt_unsafe_reduce_fp_error"), true).toBool(); - Settings::values.cpuopt_unsafe_inaccurate_nan = - ReadSetting(QStringLiteral("cpuopt_unsafe_inaccurate_nan"), true).toBool(); } qt_config->endGroup(); @@ -869,17 +868,14 @@ void Config::ReadSystemValues() { } } - bool custom_rtc_enabled; - ReadSettingGlobal(custom_rtc_enabled, QStringLiteral("custom_rtc_enabled"), false); - bool custom_rtc_global = - global || qt_config->value(QStringLiteral("custom_rtc/use_global"), true).toBool(); - Settings::values.custom_rtc.SetGlobal(custom_rtc_global); - if (global || !custom_rtc_global) { + if (global) { + const auto custom_rtc_enabled = + ReadSetting(QStringLiteral("custom_rtc_enabled"), false).toBool(); if (custom_rtc_enabled) { - Settings::values.custom_rtc.SetValue( - std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong())); + Settings::values.custom_rtc = + std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong()); } else { - Settings::values.custom_rtc.SetValue(std::nullopt); + Settings::values.custom_rtc = std::nullopt; } } @@ -1313,10 +1309,19 @@ void Config::SavePathValues() { void Config::SaveCpuValues() { qt_config->beginGroup(QStringLiteral("Cpu")); - if (global) { - WriteSetting(QStringLiteral("cpu_accuracy"), - static_cast<int>(Settings::values.cpu_accuracy), 0); + WriteSettingGlobal(QStringLiteral("cpu_accuracy"), + static_cast<u32>(Settings::values.cpu_accuracy.GetValue(global)), + Settings::values.cpu_accuracy.UsingGlobal(), + static_cast<u32>(Settings::CPUAccuracy::Accurate)); + WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_unfuse_fma"), + Settings::values.cpuopt_unsafe_unfuse_fma, true); + WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_reduce_fp_error"), + Settings::values.cpuopt_unsafe_reduce_fp_error, true); + WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_inaccurate_nan"), + Settings::values.cpuopt_unsafe_inaccurate_nan, true); + + if (global) { WriteSetting(QStringLiteral("cpuopt_page_tables"), Settings::values.cpuopt_page_tables, true); WriteSetting(QStringLiteral("cpuopt_block_linking"), Settings::values.cpuopt_block_linking, @@ -1331,13 +1336,6 @@ void Config::SaveCpuValues() { WriteSetting(QStringLiteral("cpuopt_misc_ir"), Settings::values.cpuopt_misc_ir, true); WriteSetting(QStringLiteral("cpuopt_reduce_misalign_checks"), Settings::values.cpuopt_reduce_misalign_checks, true); - - WriteSetting(QStringLiteral("cpuopt_unsafe_unfuse_fma"), - Settings::values.cpuopt_unsafe_unfuse_fma, true); - WriteSetting(QStringLiteral("cpuopt_unsafe_reduce_fp_error"), - Settings::values.cpuopt_unsafe_reduce_fp_error, true); - WriteSetting(QStringLiteral("cpuopt_unsafe_inaccurate_nan"), - Settings::values.cpuopt_unsafe_inaccurate_nan, true); } qt_config->endGroup(); @@ -1432,14 +1430,14 @@ void Config::SaveSystemValues() { Settings::values.rng_seed.GetValue(global).value_or(0), Settings::values.rng_seed.UsingGlobal(), 0); - WriteSettingGlobal(QStringLiteral("custom_rtc_enabled"), - Settings::values.custom_rtc.GetValue(global).has_value(), - Settings::values.custom_rtc.UsingGlobal(), false); - WriteSettingGlobal( - QStringLiteral("custom_rtc"), - QVariant::fromValue<long long>( - Settings::values.custom_rtc.GetValue(global).value_or(std::chrono::seconds{}).count()), - Settings::values.custom_rtc.UsingGlobal(), 0); + if (global) { + WriteSetting(QStringLiteral("custom_rtc_enabled"), Settings::values.custom_rtc.has_value(), + false); + WriteSetting(QStringLiteral("custom_rtc"), + QVariant::fromValue<long long>( + Settings::values.custom_rtc.value_or(std::chrono::seconds{}).count()), + 0); + } WriteSettingGlobal(QStringLiteral("sound_index"), Settings::values.sound_index, 1); diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 5a2c026b3..ce3355588 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -132,5 +132,6 @@ private: }; // These metatype declarations cannot be in common/settings.h because core is devoid of QT +Q_DECLARE_METATYPE(Settings::CPUAccuracy); Q_DECLARE_METATYPE(Settings::RendererBackend); Q_DECLARE_METATYPE(Settings::GPUAccuracy); diff --git a/src/yuzu/configuration/configuration_shared.cpp b/src/yuzu/configuration/configuration_shared.cpp index 89be4a62d..096e42e94 100644 --- a/src/yuzu/configuration/configuration_shared.cpp +++ b/src/yuzu/configuration/configuration_shared.cpp @@ -13,32 +13,29 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox, const CheckState& tracker) { - if (tracker == CheckState::Global) { - setting->SetGlobal(true); - } else { - setting->SetGlobal(false); + if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) { setting->SetValue(checkbox->checkState()); + } else if (!Settings::IsConfiguringGlobal()) { + if (tracker == CheckState::Global) { + setting->SetGlobal(true); + } else { + setting->SetGlobal(false); + setting->SetValue(checkbox->checkState()); + } } } void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<int>* setting, const QComboBox* combobox) { - if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { - setting->SetGlobal(true); - } else { - setting->SetGlobal(false); - setting->SetValue(combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET); - } -} - -void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<Settings::RendererBackend>* setting, - const QComboBox* combobox) { - if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { - setting->SetGlobal(true); - } else { - setting->SetGlobal(false); - setting->SetValue(static_cast<Settings::RendererBackend>( - combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET)); + if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) { + setting->SetValue(combobox->currentIndex()); + } else if (!Settings::IsConfiguringGlobal()) { + if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { + setting->SetGlobal(true); + } else { + setting->SetGlobal(false); + setting->SetValue(combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET); + } } } @@ -51,27 +48,6 @@ void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox, } } -void ConfigurationShared::SetPerGameSetting(QComboBox* combobox, - const Settings::Setting<int>* setting) { - combobox->setCurrentIndex(setting->UsingGlobal() - ? ConfigurationShared::USE_GLOBAL_INDEX - : setting->GetValue() + ConfigurationShared::USE_GLOBAL_OFFSET); -} - -void ConfigurationShared::SetPerGameSetting( - QComboBox* combobox, const Settings::Setting<Settings::RendererBackend>* setting) { - combobox->setCurrentIndex(setting->UsingGlobal() ? ConfigurationShared::USE_GLOBAL_INDEX - : static_cast<int>(setting->GetValue()) + - ConfigurationShared::USE_GLOBAL_OFFSET); -} - -void ConfigurationShared::SetPerGameSetting( - QComboBox* combobox, const Settings::Setting<Settings::GPUAccuracy>* setting) { - combobox->setCurrentIndex(setting->UsingGlobal() ? ConfigurationShared::USE_GLOBAL_INDEX - : static_cast<int>(setting->GetValue()) + - ConfigurationShared::USE_GLOBAL_OFFSET); -} - void ConfigurationShared::SetHighlight(QWidget* widget, bool highlighted) { if (highlighted) { widget->setStyleSheet(QStringLiteral("QWidget#%1 { background-color:rgba(0,203,255,0.5) }") diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h index 5b344cdbd..1e0ef01ca 100644 --- a/src/yuzu/configuration/configuration_shared.h +++ b/src/yuzu/configuration/configuration_shared.h @@ -15,37 +15,45 @@ constexpr int USE_GLOBAL_INDEX = 0; constexpr int USE_GLOBAL_SEPARATOR_INDEX = 1; constexpr int USE_GLOBAL_OFFSET = 2; +// CheckBoxes require a tracker for their state since we emulate a tristate CheckBox enum class CheckState { - Off, - On, - Global, - Count, + Off, // Checkbox overrides to off/false + On, // Checkbox overrides to on/true + Global, // Checkbox defers to the global state + Count, // Simply the number of states, not a valid checkbox state }; // Global-aware apply and set functions +// ApplyPerGameSetting, given a Settings::Setting and a Qt UI element, properly applies a Setting void ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox, const CheckState& tracker); void ApplyPerGameSetting(Settings::Setting<int>* setting, const QComboBox* combobox); -void ApplyPerGameSetting(Settings::Setting<Settings::RendererBackend>* setting, - const QComboBox* combobox); -void ApplyPerGameSetting(Settings::Setting<Settings::GPUAccuracy>* setting, - const QComboBox* combobox); +// Sets a Qt UI element given a Settings::Setting void SetPerGameSetting(QCheckBox* checkbox, const Settings::Setting<bool>* setting); -void SetPerGameSetting(QComboBox* combobox, const Settings::Setting<int>* setting); -void SetPerGameSetting(QComboBox* combobox, - const Settings::Setting<Settings::RendererBackend>* setting); -void SetPerGameSetting(QComboBox* combobox, - const Settings::Setting<Settings::GPUAccuracy>* setting); +template <typename Type> +void SetPerGameSetting(QComboBox* combobox, const Settings::Setting<Type>* setting) { + combobox->setCurrentIndex(setting->UsingGlobal() ? ConfigurationShared::USE_GLOBAL_INDEX + : static_cast<int>(setting->GetValue()) + + ConfigurationShared::USE_GLOBAL_OFFSET); +} + +// (Un)highlights a Qt UI element void SetHighlight(QWidget* widget, bool highlighted); + +// Sets up a QCheckBox like a tristate one, given a Setting void SetColoredTristate(QCheckBox* checkbox, const Settings::Setting<bool>& setting, CheckState& tracker); void SetColoredTristate(QCheckBox* checkbox, bool global, bool state, bool global_state, CheckState& tracker); + +// Sets up coloring of a QWidget `target` based on the state of a QComboBox, and calls +// InsertGlobalItem void SetColoredComboBox(QComboBox* combobox, QWidget* target, int global); +// Adds the "Use Global Configuration" selection and separator to the beginning of a QComboBox void InsertGlobalItem(QComboBox* combobox, int global_index); } // namespace ConfigurationShared diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index f9507e228..fc0191432 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -99,6 +99,9 @@ void ConfigureAudio::SetVolumeIndicatorText(int percentage) { } void ConfigureAudio::ApplyConfiguration() { + ConfigurationShared::ApplyPerGameSetting(&Settings::values.enable_audio_stretching, + ui->toggle_audio_stretching, enable_audio_stretching); + if (Settings::IsConfiguringGlobal()) { Settings::values.sink_id = ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex()) @@ -108,19 +111,12 @@ void ConfigureAudio::ApplyConfiguration() { .toStdString(); // Guard if during game and set to game-specific value - if (Settings::values.enable_audio_stretching.UsingGlobal()) { - Settings::values.enable_audio_stretching.SetValue( - ui->toggle_audio_stretching->isChecked()); - } if (Settings::values.volume.UsingGlobal()) { Settings::values.volume.SetValue( static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum()); } } else { - ConfigurationShared::ApplyPerGameSetting(&Settings::values.enable_audio_stretching, - ui->toggle_audio_stretching, - enable_audio_stretching); if (ui->volume_combo_box->currentIndex() == 0) { Settings::values.volume.SetGlobal(true); } else { diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index 4f99bc80f..525c42ff0 100644 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp @@ -10,11 +10,14 @@ #include "common/settings.h" #include "core/core.h" #include "ui_configure_cpu.h" +#include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_cpu.h" ConfigureCpu::ConfigureCpu(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureCpu) { ui->setupUi(this); + SetupPerGameUI(); + SetConfiguration(); connect(ui->accuracy, qOverload<int>(&QComboBox::activated), this, @@ -29,19 +32,29 @@ void ConfigureCpu::SetConfiguration() { const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn(); ui->accuracy->setEnabled(runtime_lock); - ui->accuracy->setCurrentIndex(static_cast<int>(Settings::values.cpu_accuracy)); - UpdateGroup(static_cast<int>(Settings::values.cpu_accuracy)); - ui->cpuopt_unsafe_unfuse_fma->setEnabled(runtime_lock); - ui->cpuopt_unsafe_unfuse_fma->setChecked(Settings::values.cpuopt_unsafe_unfuse_fma); ui->cpuopt_unsafe_reduce_fp_error->setEnabled(runtime_lock); - ui->cpuopt_unsafe_reduce_fp_error->setChecked(Settings::values.cpuopt_unsafe_reduce_fp_error); ui->cpuopt_unsafe_inaccurate_nan->setEnabled(runtime_lock); - ui->cpuopt_unsafe_inaccurate_nan->setChecked(Settings::values.cpuopt_unsafe_inaccurate_nan); + + ui->cpuopt_unsafe_unfuse_fma->setChecked(Settings::values.cpuopt_unsafe_unfuse_fma.GetValue()); + ui->cpuopt_unsafe_reduce_fp_error->setChecked( + Settings::values.cpuopt_unsafe_reduce_fp_error.GetValue()); + ui->cpuopt_unsafe_inaccurate_nan->setChecked( + Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue()); + + if (Settings::IsConfiguringGlobal()) { + ui->accuracy->setCurrentIndex(static_cast<int>(Settings::values.cpu_accuracy.GetValue())); + } else { + ConfigurationShared::SetPerGameSetting(ui->accuracy, &Settings::values.cpu_accuracy); + ConfigurationShared::SetHighlight(ui->widget_accuracy, + !Settings::values.cpu_accuracy.UsingGlobal()); + } + UpdateGroup(ui->accuracy->currentIndex()); } void ConfigureCpu::AccuracyUpdated(int index) { - if (static_cast<Settings::CPUAccuracy>(index) == Settings::CPUAccuracy::DebugMode) { + if (Settings::IsConfiguringGlobal() && + static_cast<Settings::CPUAccuracy>(index) == Settings::CPUAccuracy::DebugMode) { const auto result = QMessageBox::warning(this, tr("Setting CPU to Debug Mode"), tr("CPU Debug Mode is only intended for developer " "use. Are you sure you want to enable this?"), @@ -54,16 +67,39 @@ void ConfigureCpu::AccuracyUpdated(int index) { } void ConfigureCpu::UpdateGroup(int index) { - ui->unsafe_group->setVisible(static_cast<Settings::CPUAccuracy>(index) == - Settings::CPUAccuracy::Unsafe); + if (!Settings::IsConfiguringGlobal()) { + index -= ConfigurationShared::USE_GLOBAL_OFFSET; + } + const auto accuracy = static_cast<Settings::CPUAccuracy>(index); + ui->unsafe_group->setVisible(accuracy == Settings::CPUAccuracy::Unsafe); } void ConfigureCpu::ApplyConfiguration() { - Settings::values.cpu_accuracy = - static_cast<Settings::CPUAccuracy>(ui->accuracy->currentIndex()); - Settings::values.cpuopt_unsafe_unfuse_fma = ui->cpuopt_unsafe_unfuse_fma->isChecked(); - Settings::values.cpuopt_unsafe_reduce_fp_error = ui->cpuopt_unsafe_reduce_fp_error->isChecked(); - Settings::values.cpuopt_unsafe_inaccurate_nan = ui->cpuopt_unsafe_inaccurate_nan->isChecked(); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_unfuse_fma, + ui->cpuopt_unsafe_unfuse_fma, + cpuopt_unsafe_unfuse_fma); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_reduce_fp_error, + ui->cpuopt_unsafe_reduce_fp_error, + cpuopt_unsafe_reduce_fp_error); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_inaccurate_nan, + ui->cpuopt_unsafe_inaccurate_nan, + cpuopt_unsafe_inaccurate_nan); + + if (Settings::IsConfiguringGlobal()) { + // Guard if during game and set to game-specific value + if (Settings::values.cpu_accuracy.UsingGlobal()) { + Settings::values.cpu_accuracy.SetValue( + static_cast<Settings::CPUAccuracy>(ui->accuracy->currentIndex())); + } + } else { + if (ui->accuracy->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { + Settings::values.cpu_accuracy.SetGlobal(true); + } else { + Settings::values.cpu_accuracy.SetGlobal(false); + Settings::values.cpu_accuracy.SetValue(static_cast<Settings::CPUAccuracy>( + ui->accuracy->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET)); + } + } } void ConfigureCpu::changeEvent(QEvent* event) { @@ -77,3 +113,25 @@ void ConfigureCpu::changeEvent(QEvent* event) { void ConfigureCpu::RetranslateUI() { ui->retranslateUi(this); } + +void ConfigureCpu::SetupPerGameUI() { + if (Settings::IsConfiguringGlobal()) { + return; + } + + ConfigurationShared::SetColoredComboBox( + ui->accuracy, ui->widget_accuracy, + static_cast<u32>(Settings::values.cpu_accuracy.GetValue(true))); + ui->accuracy->removeItem(static_cast<u32>(Settings::CPUAccuracy::DebugMode) + + ConfigurationShared::USE_GLOBAL_OFFSET); + + ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_unfuse_fma, + Settings::values.cpuopt_unsafe_unfuse_fma, + cpuopt_unsafe_unfuse_fma); + ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_reduce_fp_error, + Settings::values.cpuopt_unsafe_reduce_fp_error, + cpuopt_unsafe_reduce_fp_error); + ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_inaccurate_nan, + Settings::values.cpuopt_unsafe_inaccurate_nan, + cpuopt_unsafe_inaccurate_nan); +} diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h index ef77b2e7e..8e2eeb7a6 100644 --- a/src/yuzu/configuration/configure_cpu.h +++ b/src/yuzu/configuration/configure_cpu.h @@ -8,6 +8,10 @@ #include <QWidget> #include "common/settings.h" +namespace ConfigurationShared { +enum class CheckState; +} + namespace Ui { class ConfigureCpu; } @@ -30,5 +34,11 @@ private: void SetConfiguration(); + void SetupPerGameUI(); + std::unique_ptr<Ui::ConfigureCpu> ui; + + ConfigurationShared::CheckState cpuopt_unsafe_unfuse_fma; + ConfigurationShared::CheckState cpuopt_unsafe_reduce_fp_error; + ConfigurationShared::CheckState cpuopt_unsafe_inaccurate_nan; }; diff --git a/src/yuzu/configuration/configure_cpu.ui b/src/yuzu/configuration/configure_cpu.ui index bcd0962e9..d0e7e7bfe 100644 --- a/src/yuzu/configuration/configure_cpu.ui +++ b/src/yuzu/configuration/configure_cpu.ui @@ -23,42 +23,44 @@ </property> <layout class="QVBoxLayout"> <item> - <layout class="QHBoxLayout"> - <item> - <widget class="QLabel"> - <property name="text"> - <string>Accuracy:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="accuracy"> - <item> + <widget class="QWidget" name="widget_accuracy" native="true"> + <layout class="QHBoxLayout" name="layout_accuracy"> + <item> + <widget class="QLabel" name="label"> <property name="text"> - <string>Accurate</string> + <string>Accuracy:</string> </property> - </item> - <item> - <property name="text"> - <string>Unsafe</string> - </property> - </item> - <item> - <property name="text"> - <string>Enable Debug Mode</string> - </property> - </item> - </widget> - </item> - </layout> + </widget> + </item> + <item> + <widget class="QComboBox" name="accuracy"> + <item> + <property name="text"> + <string>Accurate</string> + </property> + </item> + <item> + <property name="text"> + <string>Unsafe</string> + </property> + </item> + <item> + <property name="text"> + <string>Enable Debug Mode</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> </item> <item> - <widget class="QLabel"> - <property name="wordWrap"> - <bool>1</bool> - </property> + <widget class="QLabel" name="label"> <property name="text"> - <string>We recommend setting accuracy to "Accurate".</string> + <string>We recommend setting accuracy to "Accurate".</string> + </property> + <property name="wordWrap"> + <bool>false</bool> </property> </widget> </item> @@ -76,49 +78,49 @@ </property> <layout class="QVBoxLayout"> <item> - <widget class="QLabel"> - <property name="wordWrap"> - <bool>1</bool> - </property> + <widget class="QLabel" name="label"> <property name="text"> <string>These settings reduce accuracy for speed.</string> </property> + <property name="wordWrap"> + <bool>false</bool> + </property> </widget> </item> <item> <widget class="QCheckBox" name="cpuopt_unsafe_unfuse_fma"> - <property name="text"> - <string>Unfuse FMA (improve performance on CPUs without FMA)</string> - </property> <property name="toolTip"> <string> <div>This option improves speed by reducing accuracy of fused-multiply-add instructions on CPUs without native FMA support.</div> </string> </property> + <property name="text"> + <string>Unfuse FMA (improve performance on CPUs without FMA)</string> + </property> </widget> </item> <item> <widget class="QCheckBox" name="cpuopt_unsafe_reduce_fp_error"> - <property name="text"> - <string>Faster FRSQRTE and FRECPE</string> - </property> <property name="toolTip"> <string> <div>This option improves the speed of some approximate floating-point functions by using less accurate native approximations.</div> </string> </property> + <property name="text"> + <string>Faster FRSQRTE and FRECPE</string> + </property> </widget> </item> <item> <widget class="QCheckBox" name="cpuopt_unsafe_inaccurate_nan"> - <property name="text"> - <string>Inaccurate NaN handling</string> - </property> <property name="toolTip"> <string> <div>This option improves speed by removing NaN checking. Please note this also reduces accuracy of certain floating-point instructions.</div> </string> </property> + <property name="text"> + <string>Inaccurate NaN handling</string> + </property> </widget> </item> </layout> diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index d812858b6..c9e60ee08 100644 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui @@ -23,7 +23,7 @@ <item> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> - <widget class="QLabel" name="label_2"> + <widget class="QLabel" name="label_1"> <property name="text"> <string>Global Log Filter</string> </property> @@ -66,7 +66,7 @@ </widget> </item> <item> - <widget class="QLabel" name="label_3"> + <widget class="QLabel" name="label_2"> <property name="font"> <font> <italic>true</italic> @@ -92,7 +92,7 @@ <item> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> - <widget class="QLabel" name="label_4"> + <widget class="QLabel" name="label_3"> <property name="text"> <string>Arguments String</string> </property> @@ -155,7 +155,7 @@ </widget> </item> <item> - <widget class="QLabel" name="label_5"> + <widget class="QLabel" name="label_4"> <property name="font"> <font> <italic>true</italic> @@ -200,7 +200,7 @@ </widget> </item> <item> - <widget class="QLabel" name="label_3"> + <widget class="QLabel" name="label_5"> <property name="font"> <font> <italic>true</italic> diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 2fa88dcec..55a6a37bd 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -50,6 +50,9 @@ void ConfigureGeneral::SetConfiguration() { } void ConfigureGeneral::ApplyConfiguration() { + ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core, ui->use_multi_core, + use_multi_core); + if (Settings::IsConfiguringGlobal()) { UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); @@ -62,13 +65,7 @@ void ConfigureGeneral::ApplyConfiguration() { Qt::Checked); Settings::values.frame_limit.SetValue(ui->frame_limit->value()); } - if (Settings::values.use_multi_core.UsingGlobal()) { - Settings::values.use_multi_core.SetValue(ui->use_multi_core->isChecked()); - } } else { - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core, - ui->use_multi_core, use_multi_core); - bool global_frame_limit = use_frame_limit == ConfigurationShared::CheckState::Global; Settings::values.use_frame_limit.SetGlobal(global_frame_limit); Settings::values.frame_limit.SetGlobal(global_frame_limit); @@ -94,6 +91,9 @@ void ConfigureGeneral::RetranslateUI() { void ConfigureGeneral::SetupPerGameUI() { if (Settings::IsConfiguringGlobal()) { + // Disables each setting if: + // - A game is running (thus settings in use), and + // - A non-global setting is applied. ui->toggle_frame_limit->setEnabled(Settings::values.use_frame_limit.UsingGlobal()); ui->frame_limit->setEnabled(Settings::values.frame_limit.UsingGlobal()); diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 0a7536617..fb9ec093c 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -106,6 +106,19 @@ void ConfigureGraphics::SetConfiguration() { } void ConfigureGraphics::ApplyConfiguration() { + ConfigurationShared::ApplyPerGameSetting(&Settings::values.fullscreen_mode, + ui->fullscreen_mode_combobox); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.aspect_ratio, + ui->aspect_ratio_combobox); + + ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_disk_shader_cache, + ui->use_disk_shader_cache, use_disk_shader_cache); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_gpu_emulation, + ui->use_asynchronous_gpu_emulation, + use_asynchronous_gpu_emulation); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_nvdec_emulation, + ui->use_nvdec_emulation, use_nvdec_emulation); + if (Settings::IsConfiguringGlobal()) { // Guard if during game and set to game-specific value if (Settings::values.renderer_backend.UsingGlobal()) { @@ -114,22 +127,6 @@ void ConfigureGraphics::ApplyConfiguration() { if (Settings::values.vulkan_device.UsingGlobal()) { Settings::values.vulkan_device.SetValue(vulkan_device); } - if (Settings::values.fullscreen_mode.UsingGlobal()) { - Settings::values.fullscreen_mode.SetValue(ui->fullscreen_mode_combobox->currentIndex()); - } - if (Settings::values.aspect_ratio.UsingGlobal()) { - Settings::values.aspect_ratio.SetValue(ui->aspect_ratio_combobox->currentIndex()); - } - if (Settings::values.use_disk_shader_cache.UsingGlobal()) { - Settings::values.use_disk_shader_cache.SetValue(ui->use_disk_shader_cache->isChecked()); - } - if (Settings::values.use_asynchronous_gpu_emulation.UsingGlobal()) { - Settings::values.use_asynchronous_gpu_emulation.SetValue( - ui->use_asynchronous_gpu_emulation->isChecked()); - } - if (Settings::values.use_nvdec_emulation.UsingGlobal()) { - Settings::values.use_nvdec_emulation.SetValue(ui->use_nvdec_emulation->isChecked()); - } if (Settings::values.bg_red.UsingGlobal()) { Settings::values.bg_red.SetValue(static_cast<float>(bg_color.redF())); Settings::values.bg_green.SetValue(static_cast<float>(bg_color.greenF())); @@ -150,19 +147,6 @@ void ConfigureGraphics::ApplyConfiguration() { } } - ConfigurationShared::ApplyPerGameSetting(&Settings::values.fullscreen_mode, - ui->fullscreen_mode_combobox); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.aspect_ratio, - ui->aspect_ratio_combobox); - - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_disk_shader_cache, - ui->use_disk_shader_cache, use_disk_shader_cache); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_gpu_emulation, - ui->use_asynchronous_gpu_emulation, - use_asynchronous_gpu_emulation); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_nvdec_emulation, - ui->use_nvdec_emulation, use_nvdec_emulation); - if (ui->bg_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { Settings::values.bg_red.SetGlobal(true); Settings::values.bg_green.SetGlobal(true); diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index c67609b0e..35bf9c6be 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -54,47 +54,23 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() { ui->gpu_accuracy->currentIndex() - ((Settings::IsConfiguringGlobal()) ? 0 : ConfigurationShared::USE_GLOBAL_OFFSET)); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy, + ui->anisotropic_filtering_combobox); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_assembly_shaders, + ui->use_assembly_shaders, use_assembly_shaders); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders, + ui->use_asynchronous_shaders, + use_asynchronous_shaders); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time, + ui->use_fast_gpu_time, use_fast_gpu_time); + if (Settings::IsConfiguringGlobal()) { // Must guard in case of a during-game configuration when set to be game-specific. if (Settings::values.gpu_accuracy.UsingGlobal()) { Settings::values.gpu_accuracy.SetValue(gpu_accuracy); } - if (Settings::values.use_vsync.UsingGlobal()) { - Settings::values.use_vsync.SetValue(ui->use_vsync->isChecked()); - } - if (Settings::values.use_assembly_shaders.UsingGlobal()) { - Settings::values.use_assembly_shaders.SetValue(ui->use_assembly_shaders->isChecked()); - } - if (Settings::values.use_asynchronous_shaders.UsingGlobal()) { - Settings::values.use_asynchronous_shaders.SetValue( - ui->use_asynchronous_shaders->isChecked()); - } - if (Settings::values.use_asynchronous_shaders.UsingGlobal()) { - Settings::values.use_asynchronous_shaders.SetValue( - ui->use_asynchronous_shaders->isChecked()); - } - if (Settings::values.use_fast_gpu_time.UsingGlobal()) { - Settings::values.use_fast_gpu_time.SetValue(ui->use_fast_gpu_time->isChecked()); - } - if (Settings::values.max_anisotropy.UsingGlobal()) { - Settings::values.max_anisotropy.SetValue( - ui->anisotropic_filtering_combobox->currentIndex()); - } } else { - ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy, - ui->anisotropic_filtering_combobox); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, - use_vsync); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_assembly_shaders, - ui->use_assembly_shaders, use_assembly_shaders); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders, - ui->use_asynchronous_shaders, - use_asynchronous_shaders); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time, - ui->use_fast_gpu_time, use_fast_gpu_time); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy, - ui->anisotropic_filtering_combobox); - if (ui->gpu_accuracy->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { Settings::values.gpu_accuracy.SetGlobal(true); } else { diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index bd91ebc42..f550567e2 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -52,6 +52,7 @@ ConfigurePerGame::~ConfigurePerGame() = default; void ConfigurePerGame::ApplyConfiguration() { ui->addonsTab->ApplyConfiguration(); ui->generalTab->ApplyConfiguration(); + ui->cpuTab->ApplyConfiguration(); ui->systemTab->ApplyConfiguration(); ui->graphicsTab->ApplyConfiguration(); ui->graphicsAdvancedTab->ApplyConfiguration(); diff --git a/src/yuzu/configuration/configure_per_game.ui b/src/yuzu/configuration/configure_per_game.ui index 25975b3b9..adf6d0b39 100644 --- a/src/yuzu/configuration/configure_per_game.ui +++ b/src/yuzu/configuration/configure_per_game.ui @@ -235,6 +235,11 @@ <string>System</string> </attribute> </widget> + <widget class="ConfigureCpu" name="cpuTab"> + <attribute name="title"> + <string>CPU</string> + </attribute> + </widget> <widget class="ConfigureGraphics" name="graphicsTab"> <attribute name="title"> <string>Graphics</string> @@ -311,6 +316,12 @@ <header>configuration/configure_per_game_addons.h</header> <container>1</container> </customwidget> + <customwidget> + <class>ConfigureCpu</class> + <extends>QWidget</extends> + <header>configuration/configure_cpu.h</header> + <container>1</container> + </customwidget> </customwidgets> <resources/> <connections> diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 268ed44c3..85418f969 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -65,7 +65,7 @@ void ConfigureSystem::SetConfiguration() { QStringLiteral("%1") .arg(Settings::values.rng_seed.GetValue().value_or(0), 8, 16, QLatin1Char{'0'}) .toUpper(); - const auto rtc_time = Settings::values.custom_rtc.GetValue().value_or( + const auto rtc_time = Settings::values.custom_rtc.value_or( std::chrono::seconds(QDateTime::currentSecsSinceEpoch())); ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value()); @@ -73,9 +73,8 @@ void ConfigureSystem::SetConfiguration() { Settings::values.rng_seed.UsingGlobal()); ui->rng_seed_edit->setText(rng_seed); - ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.GetValue().has_value()); - ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.GetValue().has_value() && - Settings::values.rng_seed.UsingGlobal()); + ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value()); + ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.has_value()); ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count())); if (Settings::IsConfiguringGlobal()) { @@ -109,17 +108,17 @@ void ConfigureSystem::ApplyConfiguration() { // Allow setting custom RTC even if system is powered on, // to allow in-game time to be fast forwarded - if (Settings::values.custom_rtc.UsingGlobal()) { + if (Settings::IsConfiguringGlobal()) { if (ui->custom_rtc_checkbox->isChecked()) { - Settings::values.custom_rtc.SetValue( - std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch())); + Settings::values.custom_rtc = + std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch()); if (system.IsPoweredOn()) { - const s64 posix_time{Settings::values.custom_rtc.GetValue()->count() + + const s64 posix_time{Settings::values.custom_rtc->count() + Service::Time::TimeManager::GetExternalTimeZoneOffset()}; system.GetTimeManager().UpdateLocalSystemClockTime(posix_time); } } else { - Settings::values.custom_rtc.SetValue(std::nullopt); + Settings::values.custom_rtc = std::nullopt; } } @@ -127,21 +126,14 @@ void ConfigureSystem::ApplyConfiguration() { return; } + ConfigurationShared::ApplyPerGameSetting(&Settings::values.language_index, ui->combo_language); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.region_index, ui->combo_region); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.time_zone_index, + ui->combo_time_zone); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.sound_index, ui->combo_sound); + if (Settings::IsConfiguringGlobal()) { // Guard if during game and set to game-specific value - if (Settings::values.language_index.UsingGlobal()) { - Settings::values.language_index.SetValue(ui->combo_language->currentIndex()); - } - if (Settings::values.region_index.UsingGlobal()) { - Settings::values.region_index.SetValue(ui->combo_region->currentIndex()); - } - if (Settings::values.time_zone_index.UsingGlobal()) { - Settings::values.time_zone_index.SetValue(ui->combo_time_zone->currentIndex()); - } - if (Settings::values.sound_index.UsingGlobal()) { - Settings::values.sound_index.SetValue(ui->combo_sound->currentIndex()); - } - if (Settings::values.rng_seed.UsingGlobal()) { if (ui->rng_seed_checkbox->isChecked()) { Settings::values.rng_seed.SetValue( @@ -151,13 +143,6 @@ void ConfigureSystem::ApplyConfiguration() { } } } else { - ConfigurationShared::ApplyPerGameSetting(&Settings::values.language_index, - ui->combo_language); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.region_index, ui->combo_region); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.time_zone_index, - ui->combo_time_zone); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.sound_index, ui->combo_sound); - switch (use_rng_seed) { case ConfigurationShared::CheckState::On: case ConfigurationShared::CheckState::Off: @@ -177,26 +162,6 @@ void ConfigureSystem::ApplyConfiguration() { case ConfigurationShared::CheckState::Count: break; } - - switch (use_custom_rtc) { - case ConfigurationShared::CheckState::On: - case ConfigurationShared::CheckState::Off: - Settings::values.custom_rtc.SetGlobal(false); - if (ui->custom_rtc_checkbox->isChecked()) { - Settings::values.custom_rtc.SetValue( - std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch())); - } else { - Settings::values.custom_rtc.SetValue(std::nullopt); - } - break; - case ConfigurationShared::CheckState::Global: - Settings::values.custom_rtc.SetGlobal(false); - Settings::values.custom_rtc.SetValue(std::nullopt); - Settings::values.custom_rtc.SetGlobal(true); - break; - case ConfigurationShared::CheckState::Count: - break; - } } system.ApplySettings(); @@ -227,8 +192,6 @@ void ConfigureSystem::SetupPerGameUI() { ui->combo_sound->setEnabled(Settings::values.sound_index.UsingGlobal()); ui->rng_seed_checkbox->setEnabled(Settings::values.rng_seed.UsingGlobal()); ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.UsingGlobal()); - ui->custom_rtc_checkbox->setEnabled(Settings::values.custom_rtc.UsingGlobal()); - ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.UsingGlobal()); return; } @@ -246,8 +209,7 @@ void ConfigureSystem::SetupPerGameUI() { ui->rng_seed_checkbox, Settings::values.rng_seed.UsingGlobal(), Settings::values.rng_seed.GetValue().has_value(), Settings::values.rng_seed.GetValue(true).has_value(), use_rng_seed); - ConfigurationShared::SetColoredTristate( - ui->custom_rtc_checkbox, Settings::values.custom_rtc.UsingGlobal(), - Settings::values.custom_rtc.GetValue().has_value(), - Settings::values.custom_rtc.GetValue(true).has_value(), use_custom_rtc); + + ui->custom_rtc_checkbox->setVisible(false); + ui->custom_rtc_edit->setVisible(false); } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 30bb1aac7..9275cba53 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -241,14 +241,15 @@ GMainWindow::GMainWindow() ConnectMenuEvents(); ConnectWidgetEvents(); + const auto branch_name = std::string(Common::g_scm_branch); + const auto description = std::string(Common::g_scm_desc); const auto build_id = std::string(Common::g_build_id); - const auto fmt = std::string(Common::g_title_bar_format_idle); - const auto yuzu_build_version = - fmt::format(fmt.empty() ? "yuzu Development Build" : fmt, std::string{}, std::string{}, - std::string{}, std::string{}, std::string{}, build_id); - LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", yuzu_build_version, Common::g_scm_branch, - Common::g_scm_desc); + const auto yuzu_build = fmt::format("yuzu Development Build | {}-{}", branch_name, description); + const auto override_build = fmt::format(std::string(Common::g_title_bar_format_idle), build_id); + const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; + + LOG_INFO(Frontend, "yuzu Version: {}", yuzu_build_version); #ifdef ARCHITECTURE_x86_64 const auto& caps = Common::GetCPUCaps(); std::string cpu_string = caps.cpu_string; @@ -1377,7 +1378,7 @@ void GMainWindow::BootGame(const QString& filename, std::size_t program_index) { game_list->hide(); game_list_placeholder->hide(); } - status_bar_update_timer.start(2000); + status_bar_update_timer.start(500); async_status_button->setDisabled(true); multicore_status_button->setDisabled(true); renderer_status_button->setDisabled(true); @@ -2101,6 +2102,7 @@ void GMainWindow::OnMenuInstallToNAND() { QStringList new_files{}; // Newly installed files that do not yet exist in the NAND QStringList overwritten_files{}; // Files that overwrote those existing in the NAND QStringList failed_files{}; // Files that failed to install due to errors + bool detected_base_install{}; // Whether a base game was attempted to be installed ui.action_Install_File_NAND->setEnabled(false); @@ -2126,6 +2128,7 @@ void GMainWindow::OnMenuInstallToNAND() { while (!future.isFinished()) { QCoreApplication::processEvents(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } result = future.result(); @@ -2146,6 +2149,10 @@ void GMainWindow::OnMenuInstallToNAND() { case InstallResult::Failure: failed_files.append(QFileInfo(file).fileName()); break; + case InstallResult::BaseInstallAttempted: + failed_files.append(QFileInfo(file).fileName()); + detected_base_install = true; + break; } --remaining; @@ -2153,6 +2160,13 @@ void GMainWindow::OnMenuInstallToNAND() { install_progress->close(); + if (detected_base_install) { + QMessageBox::warning( + this, tr("Install Results"), + tr("To avoid possible conflicts, we discourage users from installing base games to the " + "NAND.\nPlease, only use this feature to install updates and DLC.")); + } + const QString install_results = (new_files.isEmpty() ? QString{} : tr("%n file(s) were newly installed\n", "", new_files.size())) + @@ -2214,11 +2228,14 @@ InstallResult GMainWindow::InstallNSPXCI(const QString& filename) { const auto res = Core::System::GetInstance().GetFileSystemController().GetUserNANDContents()->InstallEntry( *nsp, true, qt_raw_copy); - if (res == FileSys::InstallResult::Success) { + switch (res) { + case FileSys::InstallResult::Success: return InstallResult::Success; - } else if (res == FileSys::InstallResult::OverwriteExisting) { + case FileSys::InstallResult::OverwriteExisting: return InstallResult::Overwrite; - } else { + case FileSys::InstallResult::ErrorBaseInstall: + return InstallResult::BaseInstallAttempted; + default: return InstallResult::Failure; } } @@ -2792,7 +2809,7 @@ void GMainWindow::UpdateStatusBar() { } else { emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0)); } - game_fps_label->setText(tr("Game: %1 FPS").arg(results.game_fps, 0, 'f', 0)); + game_fps_label->setText(tr("Game: %1 FPS").arg(results.average_game_fps, 0, 'f', 0)); emu_frametime_label->setText(tr("Frame: %1 ms").arg(results.frametime * 1000.0, 0, 'f', 2)); emu_speed_label->setVisible(!Settings::values.use_multi_core.GetValue()); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 98a608fce..b3a5033ce 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -76,6 +76,7 @@ enum class InstallResult { Success, Overwrite, Failure, + BaseInstallAttempted, }; enum class ReinitializeKeyBehavior { diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 7e1d5f379..38d896d65 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -361,10 +361,10 @@ void Config::ReadValues() { const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false); if (custom_rtc_enabled) { - Settings::values.custom_rtc.SetValue( - std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0))); + Settings::values.custom_rtc = + std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0)); } else { - Settings::values.custom_rtc.SetValue(std::nullopt); + Settings::values.custom_rtc = std::nullopt; } Settings::values.language_index.SetValue( diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index d64f81106..06b20c975 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -215,7 +215,7 @@ void EmuWindow_SDL2::WaitEvent() { const auto results = Core::System::GetInstance().GetAndResetPerfStats(); const auto title = fmt::format("yuzu {} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname, - Common::g_scm_branch, Common::g_scm_desc, results.game_fps, + Common::g_scm_branch, Common::g_scm_desc, results.average_game_fps, results.emulation_speed * 100.0); SDL_SetWindowTitle(render_window, title.c_str()); last_time = current_time; |