From f44e8acccb256d8568d75b417776f9bcc849be0a Mon Sep 17 00:00:00 2001 From: Dan Weatherford Date: Sun, 1 Oct 2017 23:03:02 -0500 Subject: [PATCH] Invalidate overlapping textures when creating resolve texture This fixes a case where we would leave an uploaded texture lying around that was inadvertantly generated when a game sampled from a resolve texture that had not been populated yet. --- src/xenia/gpu/vulkan/texture_cache.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/xenia/gpu/vulkan/texture_cache.cc b/src/xenia/gpu/vulkan/texture_cache.cc index 9b7acb89a..9e58ee664 100644 --- a/src/xenia/gpu/vulkan/texture_cache.cc +++ b/src/xenia/gpu/vulkan/texture_cache.cc @@ -456,6 +456,16 @@ TextureCache::Texture* TextureCache::DemandResolveTexture( texture_info.guest_address, texture_info.input_length, cpu::MMIOHandler::kWatchWrite, &WatchCallback, this, texture); + // Invalidate any textures that share this memory location + for (auto it = textures_.begin(); it != textures_.end(); ++it) { + if (it->second->texture_info.guest_address == texture_info.guest_address) { + it->second->pending_invalidation = true; + invalidated_textures_mutex_.lock(); + invalidated_textures_->push_back(it->second); + invalidated_textures_mutex_.unlock(); + } + } + textures_[texture_hash] = texture; COUNT_profile_set("gpu/texture_cache/textures", textures_.size()); return texture;