diff --git a/src/render/rt64_texture_cache.cpp b/src/render/rt64_texture_cache.cpp index 7e8c10a..309a70a 100644 --- a/src/render/rt64_texture_cache.cpp +++ b/src/render/rt64_texture_cache.cpp @@ -1079,22 +1079,22 @@ namespace RT64 { descSet->setTexture(descSet->TMEM, dstTexture->tmem.get(), RenderTextureLayout::SHADER_READ); descSet->setTexture(descSet->RGBA32, dstTexture->texture.get(), RenderTextureLayout::GENERAL); beforeDecodeBarriers.emplace_back(dstTexture->texture.get(), RenderTextureLayout::GENERAL); + + // If the databases that were loaded have different hash versions, we have much to to check for all possible replacements with all possible hashes. + for (uint32_t hashVersion : textureMap.replacementMap.resolvedHashVersions) { + // If the database uses an older hash version, we hash TMEM again with the version corresponding to the database. + uint64_t databaseHash = upload.hash; + if (hashVersion < TMEMHasher::CurrentHashVersion) { + databaseHash = TMEMHasher::hash(upload.bytesTMEM.data(), upload.loadTile, upload.width, upload.height, upload.tlut, hashVersion); + } + + // Add this hash so it's checked for a replacement. + replacementQueueCopy.emplace_back(ReplacementCheck{ upload.hash, databaseHash }); + } } - - // If the databases that were loaded have different hash versions, we have much to attempt to check for all possible replacements with all possible hashes. - for (uint32_t hashVersion : textureMap.replacementMap.resolvedHashVersions) { - // If the database uses an older hash version, we hash TMEM again with the version corresponding to the database. - uint64_t databaseHash = upload.hash; - if (upload.decodeTMEM && (hashVersion < TMEMHasher::CurrentHashVersion)) { - databaseHash = TMEMHasher::hash(upload.bytesTMEM.data(), upload.loadTile, upload.width, upload.height, upload.tlut, hashVersion); - } - - // Add this hash so it's checked for a replacement. - replacementQueueCopy.emplace_back(ReplacementCheck{ upload.hash, databaseHash }); - - if (!upload.decodeTMEM) { - break; - } + else { + // Hash version differences from database versions are not possible when TMEM doesn't need to be decoded. + replacementQueueCopy.emplace_back(ReplacementCheck{ upload.hash, upload.hash }); } }