diff --git a/src/common/config.cpp b/src/common/config.cpp index be0c38cfb..7d88c29bb 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -115,6 +115,7 @@ public: static ConfigEntry volumeSlider(100); static ConfigEntry isNeo(false); static ConfigEntry isDevKit(false); +static ConfigEntry extraDmemInMbytes(0); static ConfigEntry isPSNSignedIn(false); static ConfigEntry isTrophyPopupDisabled(false); static ConfigEntry trophyNotificationDuration(6.0); @@ -286,6 +287,14 @@ bool isDevKitConsole() { return isDevKit.get(); } +int getExtraDmemInMbytes() { + return extraDmemInMbytes.get(); +} + +void setExtraDmemInMbytes(int value) { + extraDmemInMbytes.base_value = 0; +} + bool getIsFullscreen() { return isFullscreen.get(); } @@ -830,6 +839,9 @@ void load(const std::filesystem::path& path, bool is_game_specific) { volumeSlider.setFromToml(general, "volumeSlider", is_game_specific); isNeo.setFromToml(general, "isPS4Pro", is_game_specific); isDevKit.setFromToml(general, "isDevKit", is_game_specific); + if (is_game_specific) { // do not get this value from the base config + extraDmemInMbytes.setFromToml(general, "extraDmemInMbytes", is_game_specific); + } isPSNSignedIn.setFromToml(general, "isPSNSignedIn", is_game_specific); isTrophyPopupDisabled.setFromToml(general, "isTrophyPopupDisabled", is_game_specific); trophyNotificationDuration.setFromToml(general, "trophyNotificationDuration", @@ -1032,6 +1044,9 @@ void save(const std::filesystem::path& path, bool is_game_specific) { isSideTrophy.setTomlValue(data, "General", "sideTrophy", is_game_specific); isNeo.setTomlValue(data, "General", "isPS4Pro", is_game_specific); isDevKit.setTomlValue(data, "General", "isDevKit", is_game_specific); + if (is_game_specific) { + extraDmemInMbytes.setTomlValue(data, "General", "extraDmemInMbytes", is_game_specific); + } isPSNSignedIn.setTomlValue(data, "General", "isPSNSignedIn", is_game_specific); isConnectedToNetwork.setTomlValue(data, "General", "isConnectedToNetwork", is_game_specific); @@ -1155,6 +1170,7 @@ void setDefaultValues(bool is_game_specific) { isPSNSignedIn.set(false, is_game_specific); isConnectedToNetwork.set(false, is_game_specific); directMemoryAccessEnabled.set(false, is_game_specific); + extraDmemInMbytes.set(0, is_game_specific); } // Entries with game-specific settings that are in both the game-specific and global GUI diff --git a/src/common/config.h b/src/common/config.h index 6e7fdecd0..0d41d2c99 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -116,6 +116,8 @@ bool isDevKitConsole(); void setDevKitConsole(bool enable, bool is_game_specific = false); bool vkValidationGpuEnabled(); // no set +int getExtraDmemInMbytes(); +void setExtraDmemInMbytes(int value); bool getIsMotionControlsEnabled(); void setIsMotionControlsEnabled(bool use, bool is_game_specific = false); std::string getDefaultControllerID(); diff --git a/src/core/address_space.cpp b/src/core/address_space.cpp index 9e37b4fa4..5ded48df4 100644 --- a/src/core/address_space.cpp +++ b/src/core/address_space.cpp @@ -6,6 +6,7 @@ #include "common/alignment.h" #include "common/arch.h" #include "common/assert.h" +#include "common/config.h" #include "common/error.h" #include "core/address_space.h" #include "core/libraries/kernel/memory.h" @@ -27,7 +28,7 @@ asm(".zerofill SYSTEM_RESERVED,SYSTEM_RESERVED,__SYSTEM_RESERVED,0x7C0004000"); namespace Core { -static constexpr size_t BackingSize = ORBIS_KERNEL_TOTAL_MEM_DEV_PRO; +static size_t BackingSize = ORBIS_KERNEL_TOTAL_MEM_DEV_PRO; #ifdef _WIN32 @@ -71,6 +72,7 @@ struct MemoryRegion { struct AddressSpace::Impl { Impl() : process{GetCurrentProcess()} { + BackingSize += Config::getExtraDmemInMbytes() * 1_MB; // Allocate virtual address placeholder for our address space. MEM_ADDRESS_REQUIREMENTS req{}; MEM_EXTENDED_PARAMETER param{}; @@ -432,6 +434,7 @@ enum PosixPageProtection { struct AddressSpace::Impl { Impl() { + BackingSize += Config::getExtraDmemInMbytes() * 1_MB; // Allocate virtual address placeholder for our address space. system_managed_size = SystemManagedSize; system_reserved_size = SystemReservedSize; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index ea06c9640..cfe5ffb26 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -42,6 +42,13 @@ void MemoryManager::SetupMemoryRegions(u64 flexible_size, bool use_extended_mem1 if (Config::isDevKitConsole()) { total_size = is_neo ? ORBIS_KERNEL_TOTAL_MEM_DEV_PRO : ORBIS_KERNEL_TOTAL_MEM_DEV; } + s32 extra_dmem = Config::getExtraDmemInMbytes(); + if (Config::getExtraDmemInMbytes() != 0) { + LOG_WARNING(Kernel_Vmm, + "extraDmemInMbytes is {} MB! Old Direct Size: {:#x} -> New Direct Size: {:#x}", + extra_dmem, total_size, total_size + extra_dmem * 1_MB); + total_size += extra_dmem * 1_MB; + } if (!use_extended_mem1 && is_neo) { total_size -= 256_MB; } @@ -58,7 +65,7 @@ void MemoryManager::SetupMemoryRegions(u64 flexible_size, bool use_extended_mem1 // Insert an area that covers the flexible memory physical address block. // Note that this should never be called after flexible memory allocations have been made. - const auto remaining_physical_space = ORBIS_KERNEL_TOTAL_MEM_DEV_PRO - total_direct_size; + const auto remaining_physical_space = total_size - total_direct_size; fmem_map.clear(); fmem_map.emplace(total_direct_size, FlexibleMemoryArea{total_direct_size, remaining_physical_space});