From c5fbb400de9e92ae30a96e16bebedb6083858577 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 1 Sep 2022 19:05:20 -0700 Subject: [PATCH] Replacement: Detect OOM even with replacements. Also allow saving video textures if so configured. --- GPU/Common/TextureCacheCommon.cpp | 2 +- GPU/Vulkan/TextureCacheVulkan.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index acce603667..599c39c9db 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2380,7 +2380,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt } } - if (plan.isVideo || isPPGETexture) { + if (isPPGETexture) { plan.replaced = &replacer_.FindNone(); plan.replaceValid = false; } else { diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index c903451deb..d11e92ba05 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -508,7 +508,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { image->SetTag(texName); bool allocSuccess = image->CreateDirect(cmdInit, plan.createW, plan.createH, plan.depth, plan.levelsToCreate, actualFmt, imageLayout, usage, mapping); - if (!allocSuccess && !lowMemoryMode_ && !replacer_.Enabled()) { + if (!allocSuccess && !lowMemoryMode_) { WARN_LOG_REPORT(G3D, "Texture cache ran out of GPU memory; switching to low memory mode"); lowMemoryMode_ = true; decimationCounter_ = 0; @@ -628,7 +628,8 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { entry->vkTex->UploadMip(cmdInit, i, mipWidth, mipHeight, 0, texBuf, bufferOffset, stride / bpp); VK_PROFILE_END(vulkan, cmdInit, VK_PIPELINE_STAGE_TRANSFER_BIT); } - if (replacer_.Enabled() && plan.replaced->IsInvalid()) { + // Format might be wrong in lowMemoryMode_, so don't save. + if (replacer_.Enabled() && plan.replaced->IsInvalid() && !lowMemoryMode_) { // When hardware texture scaling is enabled, this saves the original. int w = dataScaled ? mipWidth : mipUnscaledWidth; int h = dataScaled ? mipHeight : mipUnscaledHeight;