From aa8d8c7a23263b9a30d5848df8e3073c1f2d8720 Mon Sep 17 00:00:00 2001 From: chaoticgd <43898262+chaoticgd@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:08:01 +0000 Subject: [PATCH] Misc: Minimise the amount of work done when svnrev.h is updated --- pcsx2-qt/AutoUpdaterDialog.cpp | 90 +++++++++++------------- pcsx2-qt/MainWindow.cpp | 1 - pcsx2-qt/QtHost.cpp | 4 +- pcsx2/Achievements.cpp | 4 +- pcsx2/BuildVersion.cpp | 16 +++++ pcsx2/BuildVersion.h | 18 +++++ pcsx2/CMakeLists.txt | 2 + pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp | 10 +-- pcsx2/Host.cpp | 4 +- pcsx2/ImGui/FullscreenUI.cpp | 4 +- pcsx2/ImGui/ImGuiOverlays.cpp | 4 +- pcsx2/PINE.cpp | 8 +-- pcsx2/Recording/InputRecordingFile.cpp | 7 +- pcsx2/SIO/Memcard/MemoryCardFile.cpp | 4 +- pcsx2/SIO/Memcard/MemoryCardFolder.cpp | 4 +- pcsx2/SaveState.cpp | 65 +++++++++-------- pcsx2/VMManager.cpp | 4 +- pcsx2/pcsx2.vcxproj | 2 + pcsx2/pcsx2.vcxproj.filters | 6 ++ 19 files changed, 145 insertions(+), 112 deletions(-) create mode 100644 pcsx2/BuildVersion.cpp create mode 100644 pcsx2/BuildVersion.h diff --git a/pcsx2-qt/AutoUpdaterDialog.cpp b/pcsx2-qt/AutoUpdaterDialog.cpp index caece04b7b02c..2a4722f82dbd7 100644 --- a/pcsx2-qt/AutoUpdaterDialog.cpp +++ b/pcsx2-qt/AutoUpdaterDialog.cpp @@ -7,8 +7,8 @@ #include "QtProgressCallback.h" #include "QtUtils.h" +#include "pcsx2/BuildVersion.h" #include "pcsx2/Host.h" -#include "svnrev.h" #include "updater/UpdaterExtractor.h" @@ -47,12 +47,6 @@ // Interval at which HTTP requests are polled. static constexpr u32 HTTP_POLL_INTERVAL = 10; -// Logic to detect whether we can use the auto updater. -// We use tagged commit, because this gets set on nightly builds. -#if (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && GIT_TAGGED_COMMIT - -#define AUTO_UPDATER_SUPPORTED 1 - #if defined(_WIN32) #define UPDATE_PLATFORM_STR "Windows" #elif defined(__linux__) @@ -69,10 +63,6 @@ static constexpr u32 HTTP_POLL_INTERVAL = 10; #define UPDATE_ADDITIONAL_TAGS "SSE4" #endif -#endif - -#ifdef AUTO_UPDATER_SUPPORTED - #define LATEST_RELEASE_URL "https://api.pcsx2.net/v1/%1Releases?pageSize=1" #define CHANGES_URL "https://api.github.com/repos/PCSX2/pcsx2/compare/%1...%2" @@ -87,8 +77,6 @@ static const char* UPDATE_TAGS[] = {"stable", "nightly"}; #define DEFAULT_UPDATER_CHANNEL "nightly" #endif -#endif - AutoUpdaterDialog::AutoUpdaterDialog(QWidget* parent /* = nullptr */) : QDialog(parent) { @@ -109,7 +97,12 @@ AutoUpdaterDialog::~AutoUpdaterDialog() = default; bool AutoUpdaterDialog::isSupported() { -#ifdef AUTO_UPDATER_SUPPORTED + // Logic to detect whether we can use the auto updater. + // We use tagged commit, because this gets set on nightly builds. + if (!BuildVersion::GitTaggedCommit) + return false; + +#if (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) #ifdef __linux__ // For Linux, we need to check whether we're running from the appimage. if (!std::getenv("APPIMAGE")) @@ -130,39 +123,36 @@ bool AutoUpdaterDialog::isSupported() QStringList AutoUpdaterDialog::getTagList() { -#ifdef AUTO_UPDATER_SUPPORTED + if (!isSupported()) + return QStringList(); + return QStringList(std::begin(UPDATE_TAGS), std::end(UPDATE_TAGS)); -#else - return QStringList(); -#endif } std::string AutoUpdaterDialog::getDefaultTag() { -#ifdef AUTO_UPDATER_SUPPORTED + if (!isSupported()) + return {}; + return DEFAULT_UPDATER_CHANNEL; -#else - return {}; -#endif } QString AutoUpdaterDialog::getCurrentVersion() { - return QStringLiteral(GIT_TAG); + return QString(BuildVersion::GitTag); } QString AutoUpdaterDialog::getCurrentVersionDate() { - return QStringLiteral(GIT_DATE); + return QString(BuildVersion::GitDate); } QString AutoUpdaterDialog::getCurrentUpdateTag() const { -#ifdef AUTO_UPDATER_SUPPORTED + if (!isSupported()) + return QString(); + return QString::fromStdString(Host::GetBaseStringSettingValue("AutoUpdater", "UpdateTag", DEFAULT_UPDATER_CHANNEL)); -#else - return QString(); -#endif } void AutoUpdaterDialog::reportError(const char* msg, ...) @@ -215,18 +205,21 @@ void AutoUpdaterDialog::queueUpdateCheck(bool display_message) { m_display_messages = display_message; -#ifdef AUTO_UPDATER_SUPPORTED - if (!ensureHttpReady()) + if (isSupported()) + { + if (!ensureHttpReady()) + { + emit updateCheckCompleted(); + return; + } + + m_http->CreateRequest(QStringLiteral(LATEST_RELEASE_URL).arg(getCurrentUpdateTag()).toStdString(), + std::bind(&AutoUpdaterDialog::getLatestReleaseComplete, this, std::placeholders::_1, std::placeholders::_3)); + } + else { emit updateCheckCompleted(); - return; } - - m_http->CreateRequest(QStringLiteral(LATEST_RELEASE_URL).arg(getCurrentUpdateTag()).toStdString(), - std::bind(&AutoUpdaterDialog::getLatestReleaseComplete, this, std::placeholders::_1, std::placeholders::_3)); -#else - emit updateCheckCompleted(); -#endif } void AutoUpdaterDialog::getLatestReleaseComplete(s32 status_code, std::vector data) @@ -236,7 +229,9 @@ void AutoUpdaterDialog::getLatestReleaseComplete(s32 status_code, std::vectorCreateRequest(QStringLiteral(CHANGES_URL).arg(GIT_HASH).arg(m_latest_version).toStdString(), + m_http->CreateRequest(QStringLiteral(CHANGES_URL).arg(BuildVersion::GitHash).arg(m_latest_version).toStdString(), std::bind(&AutoUpdaterDialog::getChangesComplete, this, std::placeholders::_1, std::placeholders::_3)); -#endif } void AutoUpdaterDialog::getChangesComplete(s32 status_code, std::vector data) { -#ifdef AUTO_UPDATER_SUPPORTED + if (!isSupported()) + { + m_ui.downloadAndInstall->setEnabled(true); + return; + } + if (status_code == HTTPDownloader::HTTP_STATUS_OK) { QJsonParseError parse_error; @@ -456,7 +453,6 @@ void AutoUpdaterDialog::getChangesComplete(s32 status_code, std::vector data { reportError("Failed to download change list: %d", status_code); } -#endif m_ui.downloadAndInstall->setEnabled(true); } @@ -542,10 +538,10 @@ void AutoUpdaterDialog::checkIfUpdateNeeded() const QString last_checked_version( QString::fromStdString(Host::GetBaseStringSettingValue("AutoUpdater", "LastVersion"))); - Console.WriteLn(Color_StrongGreen, "Current version: %s", GIT_TAG); + Console.WriteLn(Color_StrongGreen, "Current version: %s", BuildVersion::GitTag); Console.WriteLn(Color_StrongYellow, "Latest version: %s", m_latest_version.toUtf8().constData()); Console.WriteLn(Color_StrongOrange, "Last checked version: %s", last_checked_version.toUtf8().constData()); - if (m_latest_version == GIT_TAG || m_latest_version == last_checked_version) + if (m_latest_version == BuildVersion::GitTag || m_latest_version == last_checked_version) { Console.WriteLn(Color_StrongGreen, "No update needed."); diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index 8ff7b1507aaf8..78eb8f82a115f 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -19,7 +19,6 @@ #include "Settings/MemoryCardCreateDialog.h" #include "Tools/InputRecording/InputRecordingViewer.h" #include "Tools/InputRecording/NewInputRecordingDlg.h" -#include "svnrev.h" #include "pcsx2/Achievements.h" #include "pcsx2/CDVD/CDVDcommon.h" diff --git a/pcsx2-qt/QtHost.cpp b/pcsx2-qt/QtHost.cpp index fc751f740dc40..eb0a40b3f2ce9 100644 --- a/pcsx2-qt/QtHost.cpp +++ b/pcsx2-qt/QtHost.cpp @@ -10,10 +10,10 @@ #include "QtProgressCallback.h" #include "QtUtils.h" #include "SetupWizardDialog.h" -#include "svnrev.h" #include "pcsx2/CDVD/CDVDcommon.h" #include "pcsx2/Achievements.h" +#include "pcsx2/BuildVersion.h" #include "pcsx2/CDVD/CDVD.h" #include "pcsx2/Counters.h" #include "pcsx2/DebugTools/Debug.h" @@ -1468,7 +1468,7 @@ bool Host::RequestResetSettings(bool folders, bool core, bool controllers, bool QString QtHost::GetAppNameAndVersion() { - return QStringLiteral("PCSX2 " GIT_REV); + return QString("PCSX2 %1").arg(BuildVersion::GitRev); } QString QtHost::GetAppConfigSuffix() diff --git a/pcsx2/Achievements.cpp b/pcsx2/Achievements.cpp index 78608463074dd..677fcc95bf42e 100644 --- a/pcsx2/Achievements.cpp +++ b/pcsx2/Achievements.cpp @@ -4,6 +4,7 @@ #define IMGUI_DEFINE_MATH_OPERATORS #include "Achievements.h" +#include "BuildVersion.h" #include "CDVD/CDVD.h" #include "Elfheader.h" #include "Host.h" @@ -16,7 +17,6 @@ #include "Memory.h" #include "SaveState.h" #include "VMManager.h" -#include "svnrev.h" #include "vtlb.h" #include "common/Assertions.h" @@ -3039,7 +3039,7 @@ void Achievements::SwitchToRAIntegration() void Achievements::RAIntegration::InitializeRAIntegration(void* main_window_handle) { - RA_InitClient((HWND)main_window_handle, "PCSX2", GIT_TAG); + RA_InitClient((HWND)main_window_handle, "PCSX2", BuildVersion::GitTag); RA_SetUserAgentDetail(Host::GetHTTPUserAgent().c_str()); RA_InstallSharedFunctions(RACallbackIsActive, RACallbackCauseUnpause, RACallbackCausePause, RACallbackRebuildMenu, diff --git a/pcsx2/BuildVersion.cpp b/pcsx2/BuildVersion.cpp new file mode 100644 index 0000000000000..0fe5a265ae027 --- /dev/null +++ b/pcsx2/BuildVersion.cpp @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team +// SPDX-License-Identifier: GPL-3.0+ + +#include "svnrev.h" + +namespace BuildVersion +{ + const char* GitTag = GIT_TAG; + bool GitTaggedCommit = GIT_TAGGED_COMMIT; + int GitTagHi = GIT_TAG_HI; + int GitTagMid = GIT_TAG_MID; + int GitTagLo = GIT_TAG_LO; + const char* GitRev = GIT_REV; + const char* GitHash = GIT_HASH; + const char* GitDate = GIT_DATE; +} // namespace BuildVersion diff --git a/pcsx2/BuildVersion.h b/pcsx2/BuildVersion.h new file mode 100644 index 0000000000000..6b399404eac49 --- /dev/null +++ b/pcsx2/BuildVersion.h @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team +// SPDX-License-Identifier: GPL-3.0+ + +#pragma once + +// This file provides the same information as svnrev.h except you don't need to +// recompile each object file using it when said information is updated. +namespace BuildVersion +{ + extern const char* GitTag; + extern bool GitTaggedCommit; + extern int GitTagHi; + extern int GitTagMid; + extern int GitTagLo; + extern const char* GitRev; + extern const char* GitHash; + extern const char* GitDate; +} // namespace BuildVersion diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index 804ab2e406562..5430675614204 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -54,6 +54,7 @@ endif(WIN32) # Main pcsx2 source set(pcsx2Sources Achievements.cpp + BuildVersion.cpp Cache.cpp COP0.cpp COP2.cpp @@ -140,6 +141,7 @@ set(pcsx2Sources # Main pcsx2 header set(pcsx2Headers Achievements.h + BuildVersion.h Cache.h Common.h Config.h diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index c16af54cde6ad..a58f82d924ca3 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -10,6 +10,7 @@ #include "GS/Renderers/Vulkan/VKShaderCache.h" #include "GS/Renderers/Vulkan/VKSwapChain.h" +#include "BuildVersion.h" #include "Host.h" #include "common/Console.h" @@ -103,16 +104,15 @@ VkInstance GSDeviceVK::CreateVulkanInstance(const WindowInfo& wi, OptionalExtens if (!SelectInstanceExtensions(&enabled_extensions, wi, oe, enable_debug_utils)) return VK_NULL_HANDLE; - // Remember to manually update this every release. We don't pull in svnrev.h here, because - // it's only the major/minor version, and rebuilding the file every time something else changes - // is unnecessary. VkApplicationInfo app_info = {}; app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; app_info.pNext = nullptr; app_info.pApplicationName = "PCSX2"; - app_info.applicationVersion = VK_MAKE_VERSION(1, 7, 0); + app_info.applicationVersion = VK_MAKE_VERSION( + BuildVersion::GitTagHi, BuildVersion::GitTagMid, BuildVersion::GitTagLo); app_info.pEngineName = "PCSX2"; - app_info.engineVersion = VK_MAKE_VERSION(1, 7, 0); + app_info.engineVersion = VK_MAKE_VERSION( + BuildVersion::GitTagHi, BuildVersion::GitTagMid, BuildVersion::GitTagLo); app_info.apiVersion = VK_API_VERSION_1_1; VkInstanceCreateInfo instance_create_info = {}; diff --git a/pcsx2/Host.cpp b/pcsx2/Host.cpp index 6b18c685d90b1..bd64ad0770d43 100644 --- a/pcsx2/Host.cpp +++ b/pcsx2/Host.cpp @@ -1,12 +1,12 @@ // SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team // SPDX-License-Identifier: GPL-3.0+ +#include "BuildVersion.h" #include "GS.h" #include "GS/Renderers/HW/GSTextureReplacements.h" #include "Host.h" #include "LayeredSettingsInterface.h" #include "VMManager.h" -#include "svnrev.h" #include "common/Assertions.h" #include "common/CrashHandler.h" @@ -159,7 +159,7 @@ bool Host::ConfirmFormattedMessage(const std::string_view title, const char* for std::string Host::GetHTTPUserAgent() { - return fmt::format("PCSX2 " GIT_REV " ({})", GetOSVersionString()); + return fmt::format("PCSX2 {} ({})", BuildVersion::GitRev, GetOSVersionString()); } std::unique_lock Host::GetSettingsLock() diff --git a/pcsx2/ImGui/FullscreenUI.cpp b/pcsx2/ImGui/FullscreenUI.cpp index a26d494419f9c..44afb555a5366 100644 --- a/pcsx2/ImGui/FullscreenUI.cpp +++ b/pcsx2/ImGui/FullscreenUI.cpp @@ -3,6 +3,7 @@ #define IMGUI_DEFINE_MATH_OPERATORS +#include "BuildVersion.h" #include "CDVD/CDVDcommon.h" #include "GS/Renderers/Common/GSDevice.h" #include "GS/Renderers/Common/GSTexture.h" @@ -23,7 +24,6 @@ #include "USB/USB.h" #include "VMManager.h" #include "ps2/BiosTools.h" -#include "svnrev.h" #include "common/Console.h" #include "common/Error.h" @@ -6633,7 +6633,7 @@ void FullscreenUI::DrawAboutWindow() "This allows you to play PS2 games on your PC, with many additional features and benefits.")); ImGui::NewLine(); - ImGui::TextWrapped(FSUI_CSTR("Version: %s"), GIT_REV); + ImGui::TextWrapped(FSUI_CSTR("Version: %s"), BuildVersion::GitRev); ImGui::NewLine(); ImGui::TextWrapped("%s", diff --git a/pcsx2/ImGui/ImGuiOverlays.cpp b/pcsx2/ImGui/ImGuiOverlays.cpp index 319f3d5a8f920..b17459fbeff68 100644 --- a/pcsx2/ImGui/ImGuiOverlays.cpp +++ b/pcsx2/ImGui/ImGuiOverlays.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team // SPDX-License-Identifier: GPL-3.0+ +#include "BuildVersion.h" #include "Config.h" #include "Counters.h" #include "GS.h" @@ -24,7 +25,6 @@ #include "SIO/Pad/PadBase.h" #include "USB/USB.h" #include "VMManager.h" -#include "svnrev.h" #include "cpuinfo.h" #include "common/BitUtils.h" @@ -170,7 +170,7 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f if (GSConfig.OsdShowVersion) { - text.append_format("{}PCSX2 {}", first ? "" : " | ", GIT_REV); + text.append_format("{}PCSX2 {}", first ? "" : " | ", BuildVersion::GitRev); } if (!text.empty()) diff --git a/pcsx2/PINE.cpp b/pcsx2/PINE.cpp index 0bd6ec87cc12d..6103c0a64e5da 100644 --- a/pcsx2/PINE.cpp +++ b/pcsx2/PINE.cpp @@ -1,13 +1,13 @@ // SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team // SPDX-License-Identifier: GPL-3.0+ +#include "BuildVersion.h" #include "Common.h" #include "Host.h" #include "Memory.h" #include "Elfheader.h" #include "PINE.h" #include "VMManager.h" -#include "svnrev.h" #include #include @@ -607,14 +607,12 @@ PINEServer::IPCBuffer PINEServer::ParseCommand(std::span buf, std::vector(&ret_buffer[ret_cnt]), size, "PCSX2 %s", BuildVersion::GitRev); ret_cnt += size; break; } diff --git a/pcsx2/Recording/InputRecordingFile.cpp b/pcsx2/Recording/InputRecordingFile.cpp index 9adb43f42df96..b3c5fbd1c5dbf 100644 --- a/pcsx2/Recording/InputRecordingFile.cpp +++ b/pcsx2/Recording/InputRecordingFile.cpp @@ -3,13 +3,10 @@ #include "InputRecordingFile.h" +#include "BuildVersion.h" #include "Utilities/InputRecordingLogger.h" #include "common/FileSystem.h" -#include "common/StringUtil.h" -#include "DebugTools/Debug.h" -#include "MemoryTypes.h" -#include "svnrev.h" #include @@ -23,7 +20,7 @@ void InputRecordingFile::InputRecordingFileHeader::init() noexcept void InputRecordingFile::setEmulatorVersion() { - StringUtil::Strlcpy(m_header.m_emulatorVersion, "PCSX2-" GIT_REV, sizeof(m_header.m_emulatorVersion)); + snprintf(m_header.m_emulatorVersion, sizeof(m_header.m_emulatorVersion), "PCSX2-%s", BuildVersion::GitRev); } void InputRecordingFile::setAuthor(const std::string& _author) diff --git a/pcsx2/SIO/Memcard/MemoryCardFile.cpp b/pcsx2/SIO/Memcard/MemoryCardFile.cpp index 796ea9510ea13..e48a0eacb7ae2 100644 --- a/pcsx2/SIO/Memcard/MemoryCardFile.cpp +++ b/pcsx2/SIO/Memcard/MemoryCardFile.cpp @@ -20,8 +20,6 @@ #include "Host.h" #include "IconsPromptFont.h" -#include "svnrev.h" - #include "fmt/core.h" #include @@ -1075,4 +1073,4 @@ bool FileMcd_DeleteCard(const std::string_view name) } return true; -} \ No newline at end of file +} diff --git a/pcsx2/SIO/Memcard/MemoryCardFolder.cpp b/pcsx2/SIO/Memcard/MemoryCardFolder.cpp index cd49357d85d7e..bcdb121b253c0 100644 --- a/pcsx2/SIO/Memcard/MemoryCardFolder.cpp +++ b/pcsx2/SIO/Memcard/MemoryCardFolder.cpp @@ -21,8 +21,6 @@ #include "ryml_std.hpp" #include "ryml.hpp" -#include "svnrev.h" - #include #include #include @@ -2380,4 +2378,4 @@ bool FolderMemoryCardAggregator::ReIndex(uint slot, const bool enableFiltering, SetFiltering(enableFiltering); m_lastKnownFilter = filter; return false; -} \ No newline at end of file +} diff --git a/pcsx2/SaveState.cpp b/pcsx2/SaveState.cpp index ac90e6048139c..7fb881e4700d3 100644 --- a/pcsx2/SaveState.cpp +++ b/pcsx2/SaveState.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0+ #include "Achievements.h" +#include "BuildVersion.h" #include "CDVD/CDVD.h" #include "COP0.h" #include "Cache.h" @@ -27,7 +28,6 @@ #include "VMManager.h" #include "VUmicro.h" #include "ps2/BiosTools.h" -#include "svnrev.h" #include "common/Error.h" #include "common/FileSystem.h" @@ -64,7 +64,7 @@ static void PreLoadPrep() static void PostLoadPrep() { resetCache(); -// WriteCP0Status(cpuRegs.CP0.n.Status.val); + // WriteCP0Status(cpuRegs.CP0.n.Status.val); for (int i = 0; i < 48; i++) { if (std::memcmp(&s_tlb_backup[i], &tlb[i], sizeof(tlbs)) != 0) @@ -74,7 +74,8 @@ static void PostLoadPrep() } } - if (EmuConfig.Gamefixes.GoemonTlbHack) GoemonPreloadTlb(); + if (EmuConfig.Gamefixes.GoemonTlbHack) + GoemonPreloadTlb(); CBreakPoints::SetSkipFirst(BREAKPOINT_EE, 0); CBreakPoints::SetSkipFirst(BREAKPOINT_IOP, 0); @@ -157,8 +158,7 @@ bool SaveStateBase::FreezeBios() " Current BIOS: %s (crc=0x%08x)\n" " Savestate BIOS: %s (crc=0x%08x)\n", BiosDescription.c_str(), BiosChecksum, - biosdesc, bioscheck - ); + biosdesc, bioscheck); } return IsOkay(); @@ -178,11 +178,11 @@ bool SaveStateBase::FreezeInternals(Error* error) if (!FreezeTag("cpuRegs")) return false; - Freeze(cpuRegs); // cpu regs + COP0 - Freeze(psxRegs); // iop regs + Freeze(cpuRegs); // cpu regs + COP0 + Freeze(psxRegs); // iop regs Freeze(fpuRegs); - Freeze(tlb); // tlbs - Freeze(AllowParams1); //OSDConfig written (Fast Boot) + Freeze(tlb); // tlbs + Freeze(AllowParams1); //OSDConfig written (Fast Boot) Freeze(AllowParams2); // Third Block - Cycle Timers and Events @@ -224,7 +224,7 @@ bool SaveStateBase::FreezeInternals(Error* error) if (!FreezeTag("IOP-Subsystems")) return false; - FreezeMem(iopMem->Sif, sizeof(iopMem->Sif)); // iop's sif memory (not really needed, but oh well) + FreezeMem(iopMem->Sif, sizeof(iopMem->Sif)); // iop's sif memory (not really needed, but oh well) okay = okay && psxRcntFreeze(); @@ -294,7 +294,8 @@ memSavingState::memSavingState(VmStateBuffer& save_to) // Saving of state data void memSavingState::FreezeMem(void* data, int size) { - if (!size) return; + if (!size) + return; const int new_size = m_idx + size; if (static_cast(new_size) > m_memory.size()) @@ -313,7 +314,7 @@ memLoadingState::memLoadingState(const VmStateBuffer& load_from) } // Loading of state data from a memory buffer... -void memLoadingState::FreezeMem( void* data, int size ) +void memLoadingState::FreezeMem(void* data, int size) { if (m_error) { @@ -339,20 +340,20 @@ struct SysState_Component static int SysState_MTGSFreeze(FreezeAction mode, freezeData* fP) { - MTGS::FreezeData sstate = { fP, 0 }; + MTGS::FreezeData sstate = {fP, 0}; MTGS::Freeze(mode, sstate); return sstate.retval; } -static constexpr SysState_Component SPU2_{ "SPU2", SPU2freeze }; -static constexpr SysState_Component GS{ "GS", SysState_MTGSFreeze }; +static constexpr SysState_Component SPU2_{"SPU2", SPU2freeze}; +static constexpr SysState_Component GS{"GS", SysState_MTGSFreeze}; static bool SysState_ComponentFreezeIn(zip_file_t* zf, SysState_Component comp) { if (!zf) return true; - freezeData fP = { 0, nullptr }; + freezeData fP = {0, nullptr}; if (comp.freeze(FreezeAction::Size, &fP) != 0) fP.size = 0; @@ -408,7 +409,7 @@ static bool SysState_ComponentFreezeOut(SaveStateBase& writer, SysState_Componen return true; } -static bool SysState_ComponentFreezeInNew(zip_file_t* zf, const char* name, bool(*do_state_func)(StateWrapper&)) +static bool SysState_ComponentFreezeInNew(zip_file_t* zf, const char* name, bool (*do_state_func)(StateWrapper&)) { // TODO: We could decompress on the fly here for a little bit more speed. std::vector data; @@ -797,9 +798,8 @@ static bool SaveState_CompressScreenshot(SaveStateScreenshotData* data, zip_t* z if (setjmp(png_jmpbuf(png_ptr))) return false; - png_set_write_fn(png_ptr, zs, [](png_structp png_ptr, png_bytep data_ptr, png_size_t size) { - zip_source_write(static_cast(png_get_io_ptr(png_ptr)), data_ptr, size); - }, [](png_structp png_ptr) {}); + png_set_write_fn( + png_ptr, zs, [](png_structp png_ptr, png_bytep data_ptr, png_size_t size) { zip_source_write(static_cast(png_get_io_ptr(png_ptr)), data_ptr, size); }, [](png_structp png_ptr) {}); png_set_compression_level(png_ptr, 5); png_set_IHDR(png_ptr, info_ptr, data->width, data->height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); @@ -972,11 +972,14 @@ static bool SaveState_AddToZip(zip_t* zf, ArchiveEntryList* srclist, SaveStateSc VersionIndicator* vi = static_cast(std::malloc(sizeof(VersionIndicator))); vi->save_version = g_SaveVersion; -#if GIT_TAGGED_COMMIT - StringUtil::Strlcpy(vi->version, GIT_TAG, std::size(vi->version)); -#else - StringUtil::Strlcpy(vi->version, "Unknown", std::size(vi->version)); -#endif + if (BuildVersion::GitTaggedCommit) + { + StringUtil::Strlcpy(vi->version, BuildVersion::GitTag, std::size(vi->version)); + } + else + { + StringUtil::Strlcpy(vi->version, "Unknown", std::size(vi->version)); + } zip_source_t* const zs = zip_source_buffer(zf, vi, sizeof(*vi), 1); if (!zs) @@ -1089,11 +1092,11 @@ static bool CheckVersion(const std::string& filename, zip_t* zf, Error* error) // than the emulator recognizes. 99% chance that trying to load it will just corrupt emulation or crash. if (savever > g_SaveVersion || (savever >> 16) != (g_SaveVersion >> 16)) { - Error::SetString(error, fmt::format(TRANSLATE_FS("SaveState","This save state is outdated and is no longer compatible " - "with the current version of PCSX2.\n\n" - "If you have any unsaved progress on this save state, you can download the compatible version (PCSX2 {}) " - "from pcsx2.net, load the save state, and save your progress to the memory card."), - version_string)); + Error::SetString(error, fmt::format(TRANSLATE_FS("SaveState", "This save state is outdated and is no longer compatible " + "with the current version of PCSX2.\n\n" + "If you have any unsaved progress on this save state, you can download the compatible version (PCSX2 {}) " + "from pcsx2.net, load the save state, and save your progress to the memory card."), + version_string)); return false; } @@ -1135,7 +1138,7 @@ static bool LoadInternalStructuresState(zip_t* zf, s64 index, Error* error) memLoadingState state(buffer); if (!state.FreezeBios()) return false; - + if (!state.FreezeInternals(error)) return false; diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index 43f98b101b542..55fb77d761a59 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0+ #include "Achievements.h" +#include "BuildVersion.h" #include "CDVD/CDVD.h" #include "CDVD/IsoReader.h" #include "Counters.h" @@ -40,7 +41,6 @@ #include "Vif_Dynarec.h" #include "VMManager.h" #include "ps2/BiosTools.h" -#include "svnrev.h" #include "common/Console.h" #include "common/Error.h" @@ -2490,7 +2490,7 @@ void LogGPUCapabilities() void VMManager::LogCPUCapabilities() { - Console.WriteLn(Color_StrongGreen, "PCSX2 " GIT_REV); + Console.WriteLn(Color_StrongGreen, "PCSX2 %s", BuildVersion::GitRev); Console.WriteLnFmt("Savestate version: 0x{:x}\n", g_SaveVersion); Console.WriteLn(); diff --git a/pcsx2/pcsx2.vcxproj b/pcsx2/pcsx2.vcxproj index 41ff04385a77e..c7f68793cf98d 100644 --- a/pcsx2/pcsx2.vcxproj +++ b/pcsx2/pcsx2.vcxproj @@ -419,6 +419,7 @@ true + @@ -865,6 +866,7 @@ + diff --git a/pcsx2/pcsx2.vcxproj.filters b/pcsx2/pcsx2.vcxproj.filters index fd225c4d16083..51782a5fcf9d6 100644 --- a/pcsx2/pcsx2.vcxproj.filters +++ b/pcsx2/pcsx2.vcxproj.filters @@ -1292,6 +1292,9 @@ Misc + + Misc + System\Ps2\EmotionEngine\Hardware @@ -2244,6 +2247,9 @@ System\Ps2\Iop + + Misc + System\Ps2\EmotionEngine\Hardware