Replacement: Detect OOM even with replacements.

Also allow saving video textures if so configured.
This commit is contained in:
Unknown W. Brackets 2022-09-01 19:05:20 -07:00
parent 1033fa6cd7
commit c5fbb400de
2 changed files with 4 additions and 3 deletions

View File

@ -2380,7 +2380,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt
}
}
if (plan.isVideo || isPPGETexture) {
if (isPPGETexture) {
plan.replaced = &replacer_.FindNone();
plan.replaceValid = false;
} else {

View File

@ -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;