mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-09 13:19:00 +00:00
Add configurable extra memory (#3513)
* Add configurable extra memory * lowercase getter and setter * Refactor memory setup to configure maximum memory limits at runtime * sir clang offnir, the all-formatting * Correctly update BackingSize on W*ndows too * small format change * remove total_memory_to_use from the header * i have no idea how to name this commit "addressing review comments" is a good name i guess * Do not include extraDmem in the general config
This commit is contained in:
@@ -115,6 +115,7 @@ public:
|
|||||||
static ConfigEntry<int> volumeSlider(100);
|
static ConfigEntry<int> volumeSlider(100);
|
||||||
static ConfigEntry<bool> isNeo(false);
|
static ConfigEntry<bool> isNeo(false);
|
||||||
static ConfigEntry<bool> isDevKit(false);
|
static ConfigEntry<bool> isDevKit(false);
|
||||||
|
static ConfigEntry<int> extraDmemInMbytes(0);
|
||||||
static ConfigEntry<bool> isPSNSignedIn(false);
|
static ConfigEntry<bool> isPSNSignedIn(false);
|
||||||
static ConfigEntry<bool> isTrophyPopupDisabled(false);
|
static ConfigEntry<bool> isTrophyPopupDisabled(false);
|
||||||
static ConfigEntry<double> trophyNotificationDuration(6.0);
|
static ConfigEntry<double> trophyNotificationDuration(6.0);
|
||||||
@@ -286,6 +287,14 @@ bool isDevKitConsole() {
|
|||||||
return isDevKit.get();
|
return isDevKit.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getExtraDmemInMbytes() {
|
||||||
|
return extraDmemInMbytes.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setExtraDmemInMbytes(int value) {
|
||||||
|
extraDmemInMbytes.base_value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool getIsFullscreen() {
|
bool getIsFullscreen() {
|
||||||
return isFullscreen.get();
|
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);
|
volumeSlider.setFromToml(general, "volumeSlider", is_game_specific);
|
||||||
isNeo.setFromToml(general, "isPS4Pro", is_game_specific);
|
isNeo.setFromToml(general, "isPS4Pro", is_game_specific);
|
||||||
isDevKit.setFromToml(general, "isDevKit", 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);
|
isPSNSignedIn.setFromToml(general, "isPSNSignedIn", is_game_specific);
|
||||||
isTrophyPopupDisabled.setFromToml(general, "isTrophyPopupDisabled", is_game_specific);
|
isTrophyPopupDisabled.setFromToml(general, "isTrophyPopupDisabled", is_game_specific);
|
||||||
trophyNotificationDuration.setFromToml(general, "trophyNotificationDuration",
|
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);
|
isSideTrophy.setTomlValue(data, "General", "sideTrophy", is_game_specific);
|
||||||
isNeo.setTomlValue(data, "General", "isPS4Pro", is_game_specific);
|
isNeo.setTomlValue(data, "General", "isPS4Pro", is_game_specific);
|
||||||
isDevKit.setTomlValue(data, "General", "isDevKit", 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);
|
isPSNSignedIn.setTomlValue(data, "General", "isPSNSignedIn", is_game_specific);
|
||||||
isConnectedToNetwork.setTomlValue(data, "General", "isConnectedToNetwork", 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);
|
isPSNSignedIn.set(false, is_game_specific);
|
||||||
isConnectedToNetwork.set(false, is_game_specific);
|
isConnectedToNetwork.set(false, is_game_specific);
|
||||||
directMemoryAccessEnabled.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
|
// Entries with game-specific settings that are in both the game-specific and global GUI
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ bool isDevKitConsole();
|
|||||||
void setDevKitConsole(bool enable, bool is_game_specific = false);
|
void setDevKitConsole(bool enable, bool is_game_specific = false);
|
||||||
|
|
||||||
bool vkValidationGpuEnabled(); // no set
|
bool vkValidationGpuEnabled(); // no set
|
||||||
|
int getExtraDmemInMbytes();
|
||||||
|
void setExtraDmemInMbytes(int value);
|
||||||
bool getIsMotionControlsEnabled();
|
bool getIsMotionControlsEnabled();
|
||||||
void setIsMotionControlsEnabled(bool use, bool is_game_specific = false);
|
void setIsMotionControlsEnabled(bool use, bool is_game_specific = false);
|
||||||
std::string getDefaultControllerID();
|
std::string getDefaultControllerID();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "common/alignment.h"
|
#include "common/alignment.h"
|
||||||
#include "common/arch.h"
|
#include "common/arch.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
#include "common/config.h"
|
||||||
#include "common/error.h"
|
#include "common/error.h"
|
||||||
#include "core/address_space.h"
|
#include "core/address_space.h"
|
||||||
#include "core/libraries/kernel/memory.h"
|
#include "core/libraries/kernel/memory.h"
|
||||||
@@ -27,7 +28,7 @@ asm(".zerofill SYSTEM_RESERVED,SYSTEM_RESERVED,__SYSTEM_RESERVED,0x7C0004000");
|
|||||||
|
|
||||||
namespace Core {
|
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
|
#ifdef _WIN32
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ struct MemoryRegion {
|
|||||||
|
|
||||||
struct AddressSpace::Impl {
|
struct AddressSpace::Impl {
|
||||||
Impl() : process{GetCurrentProcess()} {
|
Impl() : process{GetCurrentProcess()} {
|
||||||
|
BackingSize += Config::getExtraDmemInMbytes() * 1_MB;
|
||||||
// Allocate virtual address placeholder for our address space.
|
// Allocate virtual address placeholder for our address space.
|
||||||
MEM_ADDRESS_REQUIREMENTS req{};
|
MEM_ADDRESS_REQUIREMENTS req{};
|
||||||
MEM_EXTENDED_PARAMETER param{};
|
MEM_EXTENDED_PARAMETER param{};
|
||||||
@@ -432,6 +434,7 @@ enum PosixPageProtection {
|
|||||||
|
|
||||||
struct AddressSpace::Impl {
|
struct AddressSpace::Impl {
|
||||||
Impl() {
|
Impl() {
|
||||||
|
BackingSize += Config::getExtraDmemInMbytes() * 1_MB;
|
||||||
// Allocate virtual address placeholder for our address space.
|
// Allocate virtual address placeholder for our address space.
|
||||||
system_managed_size = SystemManagedSize;
|
system_managed_size = SystemManagedSize;
|
||||||
system_reserved_size = SystemReservedSize;
|
system_reserved_size = SystemReservedSize;
|
||||||
|
|||||||
@@ -42,6 +42,13 @@ void MemoryManager::SetupMemoryRegions(u64 flexible_size, bool use_extended_mem1
|
|||||||
if (Config::isDevKitConsole()) {
|
if (Config::isDevKitConsole()) {
|
||||||
total_size = is_neo ? ORBIS_KERNEL_TOTAL_MEM_DEV_PRO : ORBIS_KERNEL_TOTAL_MEM_DEV;
|
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) {
|
if (!use_extended_mem1 && is_neo) {
|
||||||
total_size -= 256_MB;
|
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.
|
// 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.
|
// 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.clear();
|
||||||
fmem_map.emplace(total_direct_size,
|
fmem_map.emplace(total_direct_size,
|
||||||
FlexibleMemoryArea{total_direct_size, remaining_physical_space});
|
FlexibleMemoryArea{total_direct_size, remaining_physical_space});
|
||||||
|
|||||||
Reference in New Issue
Block a user