mirror of https://github.com/PCSX2/pcsx2.git
CDVD: Adjust ram requirements when precaching.
This commit is contained in:
parent
c6d1c8063b
commit
cc30f529d5
|
@ -181,6 +181,10 @@ private:
|
||||||
extern u64 GetTickFrequency();
|
extern u64 GetTickFrequency();
|
||||||
extern u64 GetCPUTicks();
|
extern u64 GetCPUTicks();
|
||||||
extern u64 GetPhysicalMemory();
|
extern u64 GetPhysicalMemory();
|
||||||
|
#ifdef _WIN32
|
||||||
|
// TODO: Someone do linux/mac.
|
||||||
|
extern u64 GetAvailablePhysicalMemory();
|
||||||
|
#endif
|
||||||
/// Spin for a short period of time (call while spinning waiting for a lock)
|
/// Spin for a short period of time (call while spinning waiting for a lock)
|
||||||
/// Returns the approximate number of ns that passed
|
/// Returns the approximate number of ns that passed
|
||||||
extern u32 ShortSpin();
|
extern u32 ShortSpin();
|
||||||
|
|
|
@ -57,6 +57,14 @@ u64 GetPhysicalMemory()
|
||||||
return status.ullTotalPhys;
|
return status.ullTotalPhys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u64 GetAvailablePhysicalMemory()
|
||||||
|
{
|
||||||
|
MEMORYSTATUSEX status;
|
||||||
|
status.dwLength = sizeof(status);
|
||||||
|
GlobalMemoryStatusEx(&status);
|
||||||
|
return status.ullAvailPhys;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculates the Windows OS Version and processor architecture, and returns it as a
|
// Calculates the Windows OS Version and processor architecture, and returns it as a
|
||||||
// human-readable string. :)
|
// human-readable string. :)
|
||||||
std::string GetOSVersionString()
|
std::string GetOSVersionString()
|
||||||
|
|
|
@ -266,10 +266,26 @@ bool ThreadedFileReader::Precache2(ProgressCallback* progress, Error* error)
|
||||||
|
|
||||||
bool ThreadedFileReader::CheckAvailableMemoryForPrecaching(u64 required_size, Error* error)
|
bool ThreadedFileReader::CheckAvailableMemoryForPrecaching(u64 required_size, Error* error)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
// We want to check available physical memory instead of total.
|
||||||
|
const u64 memory_available = GetAvailablePhysicalMemory();
|
||||||
|
// Reserve 2GB of available memory for headroom.
|
||||||
|
constexpr u64 memory_reserve = 2147483648;
|
||||||
|
const u64 max_precache_size = std::max(0LL, static_cast<s64>(memory_available - memory_reserve));
|
||||||
|
|
||||||
|
if (required_size > max_precache_size)
|
||||||
|
{
|
||||||
|
Error::SetStringFmt(error,
|
||||||
|
TRANSLATE_FS("CDVD", "Not enough free memory available for precaching, ({}GB) required."),
|
||||||
|
(required_size + memory_reserve) / _1gb);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
// Don't allow precaching to use more than 50% of system memory.
|
// Don't allow precaching to use more than 50% of system memory.
|
||||||
// Hopefully nobody's running 2-4GB potatoes anymore....
|
// Hopefully nobody's running 2-4GB potatoes anymore....
|
||||||
const u64 memory_size = GetPhysicalMemory();
|
const u64 memory_size = GetPhysicalMemory();
|
||||||
const u64 max_precache_size = memory_size / 2;
|
const u64 max_precache_size = memory_size / 2;
|
||||||
|
|
||||||
if (required_size > max_precache_size)
|
if (required_size > max_precache_size)
|
||||||
{
|
{
|
||||||
Error::SetStringFmt(error,
|
Error::SetStringFmt(error,
|
||||||
|
@ -277,6 +293,7 @@ bool ThreadedFileReader::CheckAvailableMemoryForPrecaching(u64 required_size, Er
|
||||||
required_size / _1gb, max_precache_size / _1gb);
|
required_size / _1gb, max_precache_size / _1gb);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue