Remove largely ineffective and nearly not functional "low memory mode". Unlikely to save us.

This commit is contained in:
Henrik Rydgård committed 2026-07-16 15:28:40 +02:00
1 parent 672b549109
commit 57e6bafb62
8 files changed
+10 -48

No files matched your search

+1 -2
View File
@@ -433,8 +433,7 @@ void GLQueueRunner::RunInitSteps(const FastVec<GLRInitStep> &steps, bool skipGLC
// Calling glGetError() isn't great, but at the end of init, only after creating textures, shouldn't be too bad...
GLenum err = glGetError();
if (err == GL_OUT_OF_MEMORY) {
WARN_LOG(Log::G3D, "GL ran out of GPU memory; switching to low memory mode");
sawOutOfMemory_ = true;
WARN_LOG(Log::G3D, "GL ran out of GPU memory! Bad!");
} else if (err != GL_NO_ERROR) {
// We checked the err anyway, might as well log if there is one.
std::string errorString = GLEnumToString(err);
-4
View File
@@ -367,10 +367,6 @@ public:
targetHeight_ = height;
}
bool SawOutOfMemory() {
return sawOutOfMemory_;
}
std::string GetGLString(int name) const;
private:
-4
View File
@@ -825,10 +825,6 @@ public:
void StartThread(); // Currently only used on iOS, since we fully recreate the context on Android
bool SawOutOfMemory() {
return queueRunner_.SawOutOfMemory();
}
// Only supports a common subset.
std::string GetGLString(int name) const {
return queueRunner_.GetGLString(name);
+4 -13
View File
@@ -879,14 +879,13 @@ void TextureCacheCommon::Decimate(const TexCacheEntry *const exceptThisOne, bool
const u32 had = cacheSizeEstimate;
ForgetLastTexture();
int killAgeBase = lowMemoryMode_ ? TEXTURE_KILL_AGE_LOWMEM : TEXTURE_KILL_AGE;
for (TexCache::iterator iter = cache_.begin(); iter != cache_.end(); ) {
if (iter->second.get() == exceptThisOne) {
++iter;
continue;
}
bool hasClutVariants = (iter->second->status & TexStatus::MANY_CLUT_VARIANTS) != 0;
int killAge = hasClutVariants ? TEXTURE_KILL_AGE_CLUT : killAgeBase;
int killAge = hasClutVariants ? TEXTURE_KILL_AGE_CLUT : TEXTURE_KILL_AGE;
if (iter->second->lastFrame + killAge < gpuStats.totals.numFlips) {
DeleteTexture(iter++);
} else {
@@ -907,8 +906,7 @@ void TextureCacheCommon::Decimate(const TexCacheEntry *const exceptThisOne, bool
++iter;
continue;
}
// In low memory mode, we kill them all since secondary cache is disabled.
if (lowMemoryMode_ || iter->second->lastFrame + TEXTURE_SECOND_KILL_AGE < gpuStats.totals.numFlips) {
if (iter->second->lastFrame + TEXTURE_SECOND_KILL_AGE < gpuStats.totals.numFlips) {
ReleaseTexture(iter->second.get(), true);
secondCacheSizeEstimate -= iter->second->EstimateTexMemoryUsage();
iter = secondCache_.erase(iter);
@@ -2719,7 +2717,7 @@ bool TextureCacheCommon::CheckFullHash(TexCacheEntry *entry, bool &doDelete) {
if (!isVideo) {
// If it's failed a bunch of times, then the second cache is just wasting time and VRAM.
// In that case, skip.
if (entry->numInvalidated > 2 && entry->numInvalidated < 128 && !lowMemoryMode_) {
if (entry->numInvalidated > 2 && entry->numInvalidated < 128) {
// We have a new hash: look for that hash in the secondary cache.
const u64 secondKey = fullhash | ((u64)entry->cluthash << 32);
TexCache::iterator secondIter = secondCache_.find(secondKey);
@@ -2864,13 +2862,6 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt
plan.scaleFactor = standardScaleFactor_;
plan.depth = 1;
// Rachet down scale factor in low-memory mode.
// TODO: I think really we should just turn it off?
if (lowMemoryMode_ && !plan.hardwareScaling) {
// Keep it even, though, just in case of npot troubles.
plan.scaleFactor = plan.scaleFactor > 4 ? 4 : (plan.scaleFactor > 2 ? 2 : 1);
}
if (plan.hardwareScaling) {
plan.scaleFactor = shaderScaleFactor_;
}
@@ -3115,7 +3106,7 @@ void TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, s
}
}
if (plan.saveTexture && !lowMemoryMode_) {
if (plan.saveTexture) {
ReplacedTextureDecodeInfo replacedInfo;
replacedInfo.cachekey = entry.CacheKey();
replacedInfo.hash = entry.fullhash;
-1
View File
@@ -457,7 +457,6 @@ protected:
ShaderManagerCommon *shaderManager_;
bool clearCacheNextFrame_ = false;
bool lowMemoryMode_ = false;
int decimationCounter_ = 0;
int texelsScaledThisFrame_ = 0;
-17
View File
@@ -130,23 +130,6 @@ static void ConvertColors(void *dstBuf, const void *srcBuf, Draw::DataFormat dst
}
}
void TextureCacheGLES::StartFrame() {
TextureCacheCommon::StartFrame();
GLRenderManager *renderManager = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
if (!lowMemoryMode_ && renderManager->SawOutOfMemory()) {
lowMemoryMode_ = true;
decimationCounter_ = 0;
auto err = GetI18NCategory(I18NCat::ERRORS);
if (standardScaleFactor_ > 1) {
g_OSD.Show(OSDType::MESSAGE_WARNING, err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
g_OSD.Show(OSDType::MESSAGE_WARNING, err->T("Warning: Video memory FULL, switching to slow caching mode"), 2.0f);
}
}
}
// TODO: This is almost the same as the Common one, just with some extra color conversion. Should merge.
void TextureCacheGLES::UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple) {
const u32 clutBaseBytes = clutFormat == GE_CMODE_32BIT_ABGR8888 ? (clutBase * sizeof(u32)) : (clutBase * sizeof(u16));
-1
View File
@@ -37,7 +37,6 @@ public:
~TextureCacheGLES();
void Clear(bool delete_them) override;
void StartFrame() override;
void SetFramebufferManager(FramebufferManagerGLES *fbManager);
void SetDrawEngine(DrawEngineGLES *td) {
+5 -6
View File
@@ -723,16 +723,16 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
VulkanBarrierBatch barrier;
bool allocSuccess = image->CreateDirect(plan.createW, plan.createH, plan.depth, plan.levelsToCreate, actualFmt, imageLayout, usage, &barrier, mapping);
barrier.Flush(cmdInit);
if (!allocSuccess && !lowMemoryMode_) {
WARN_LOG(Log::G3D, "Texture cache ran out of GPU memory; switching to low memory mode");
lowMemoryMode_ = true;
if (!allocSuccess) {
WARN_LOG(Log::G3D, "Texture cache ran out of GPU memory; decimating");
decimationCounter_ = 0;
Decimate(entry, true);
Decimate(entry, true); // note: First parameter is "exceptThisOne".
// TODO: We should stall the GPU here and wipe things out of memory.
// As is, it will almost definitely fail the second time, but next frame it may recover.
auto err = GetI18NCategory(I18NCat::ERRORS);
// TODO: These messages are not really accurate.
if (plan.scaleFactor > 1) {
g_OSD.Show(OSDType::MESSAGE_WARNING, err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
@@ -853,8 +853,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
loadLevel(uploadSize, i == 0 ? plan.baseLevelSrc : i, byteStride, plan.scaleFactor);
entry->vkTex->CopyBufferToMipLevel(cmdInit, &copyBatch, i, mipWidth, mipHeight, 0, texBuf, bufferOffset, pixelStride);
}
// Format might be wrong in lowMemoryMode_, so don't save.
if (plan.saveTexture && !lowMemoryMode_) {
if (plan.saveTexture) {
// When hardware texture scaling is enabled, this saves the original.
const int w = dataScaled ? mipWidth : mipUnscaledWidth;
const int h = dataScaled ? mipHeight : mipUnscaledHeight;