mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
VideoCommon: Abort texture prefetching on low RAM
There is no nice way to correctly "detect" the "used" memory, so we just say we're fine to use 50% of the physical memory for custom textures. This will fix out-of-memory crashes, but we still might run into swapping issues.
This commit is contained in:
@ -16,6 +16,7 @@
|
||||
#include "Common/FileSearch.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Flag.h"
|
||||
#include "Common/MemoryUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Thread.h"
|
||||
#include "Common/Timer.h"
|
||||
@ -167,6 +168,7 @@ void HiresTexture::Prefetch()
|
||||
Common::SetCurrentThreadName("Prefetcher");
|
||||
|
||||
size_t size_sum = 0;
|
||||
size_t max_mem = MemPhysical() / 2;
|
||||
u32 starttime = Common::Timer::GetTimeMs();
|
||||
for (const auto& entry : s_textureMap)
|
||||
{
|
||||
@ -203,6 +205,14 @@ void HiresTexture::Prefetch()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (size_sum > max_mem)
|
||||
{
|
||||
g_Config.bCacheHiresTextures = false;
|
||||
|
||||
OSD::AddMessage(StringFromFormat("Custom Textures prefetching after %.1f MB aborted, not enough RAM available", size_sum / (1024.0 * 1024.0)), 10000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
u32 stoptime = Common::Timer::GetTimeMs();
|
||||
OSD::AddMessage(StringFromFormat("Custom Textures loaded, %.1f MB in %.1f s", size_sum / (1024.0 * 1024.0), (stoptime - starttime) / 1000.0), 10000);
|
||||
|
Reference in New Issue
Block a user