Add a consistent feature check - only desktops get to use CacheFullISOInRAM.

This commit is contained in:
Henrik Rydgård 2025-03-27 01:02:28 +01:00
parent 8d9b3f28f2
commit b05d6171d4
6 changed files with 30 additions and 11 deletions

View file

@ -219,6 +219,8 @@ enum SystemProperty {
SYSPROP_CAN_READ_BATTERY_PERCENTAGE,
SYSPROP_BATTERY_PERCENTAGE,
SYSPROP_ENOUGH_RAM_FOR_FULL_ISO,
};
enum class SystemNotification {

View file

@ -21,6 +21,7 @@
#include "Common/Thread/ThreadUtil.h"
#include "Common/TimeUtil.h"
#include "Common/Log.h"
#include "Core/FileLoaders/RamCachingFileLoader.h"
// Takes ownership of backend.
@ -91,6 +92,7 @@ void RamCachingFileLoader::InitCache() {
// Overallocate for the last block.
cache_ = (u8 *)malloc((size_t)blockCount << BLOCK_SHIFT);
if (cache_ == nullptr) {
ERROR_LOG(Log::IO, "Failed to allocate cache for Cache full ISO in RAM! Will fall back to regular reads.");
return;
}
aheadRemaining_ = blockCount;
@ -178,6 +180,8 @@ void RamCachingFileLoader::SaveIntoCache(s64 pos, size_t bytes, Flags flags) {
if (blocksToRead >= MAX_BLOCKS_PER_READ) {
break;
}
// TODO: Shouldn't we break as soon as we see a 1?
}
}
}

View file

@ -425,15 +425,17 @@ bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) {
IdentifiedFileType type = Identify_File(loadedFile, &g_CoreParameter.errorString);
g_CoreParameter.fileType = type;
if (g_Config.bCacheFullIsoInRam) {
switch (g_CoreParameter.fileType) {
case IdentifiedFileType::PSP_ISO:
case IdentifiedFileType::PSP_ISO_NP:
loadedFile = new RamCachingFileLoader(loadedFile);
break;
default:
INFO_LOG(Log::System, "RAM caching is on, but file is not an ISO, so ignoring");
break;
if (System_GetPropertyBool(SYSPROP_ENOUGH_RAM_FOR_FULL_ISO)) {
if (g_Config.bCacheFullIsoInRam) {
switch (g_CoreParameter.fileType) {
case IdentifiedFileType::PSP_ISO:
case IdentifiedFileType::PSP_ISO_NP:
loadedFile = new RamCachingFileLoader(loadedFile);
break;
default:
INFO_LOG(Log::System, "RAM caching is on, but file is not an ISO, so ignoring");
break;
}
}
}

View file

@ -625,7 +625,13 @@ bool System_GetPropertyBool(SystemProperty prop) {
#endif
case SYSPROP_CAN_READ_BATTERY_PERCENTAGE:
return true;
default:
case SYSPROP_ENOUGH_RAM_FOR_FULL_ISO:
#if defined(MOBILE_DEVICE)
return false;
#else
return true;
#endif
default:
return false;
}
}

View file

@ -1341,7 +1341,10 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
if (System_GetPropertyBool(SYSPROP_HAS_KEYBOARD))
systemSettings->Add(new CheckBox(&g_Config.bBypassOSKWithKeyboard, sy->T("Use system native keyboard")));
systemSettings->Add(new CheckBox(&g_Config.bCacheFullIsoInRam, sy->T("Cache ISO in RAM", "Cache full ISO in RAM")))->SetEnabled(!PSP_IsInited());
if (System_GetPropertyBool(SYSPROP_ENOUGH_RAM_FOR_FULL_ISO)) {
systemSettings->Add(new CheckBox(&g_Config.bCacheFullIsoInRam, sy->T("Cache ISO in RAM", "Cache full ISO in RAM")))->SetEnabled(!PSP_IsInited());
}
systemSettings->Add(new CheckBox(&g_Config.bCheckForNewVersion, sy->T("VersionCheck", "Check for new versions of PPSSPP")));
systemSettings->Add(new CheckBox(&g_Config.bScreenshotsAsPNG, sy->T("Screenshots as PNG")));
static const char *screenshotModeChoices[] = { "Final processed image", "Raw game image" };

View file

@ -406,6 +406,8 @@ bool System_GetPropertyBool(SystemProperty prop) {
return true;
case SYSPROP_CAN_READ_BATTERY_PERCENTAGE:
return true;
case SYSPROP_ENOUGH_RAM_FOR_FULL_ISO:
return true;
default:
return false;
}