diff --git a/src/graphics/host_gpu/renderer/cache/textureCache.cpp b/src/graphics/host_gpu/renderer/cache/textureCache.cpp index fd8d2777c..e3faefd1f 100644 --- a/src/graphics/host_gpu/renderer/cache/textureCache.cpp +++ b/src/graphics/host_gpu/renderer/cache/textureCache.cpp @@ -1859,7 +1859,7 @@ void TextureCache::InvalidateCpuAliases(uint64_t address, uint64_t size) { const auto page_end = (address + size + TRACKER_PAGE_SIZE - 1) & ~(TRACKER_PAGE_SIZE - 1); for (const auto id: FindImagesInRegion(address, size, true)) { auto owner = m_slot_images.try_get(id); - if (owner == nullptr || owner->depth_id) { + if (owner == nullptr) { continue; } if (owner->Overlaps(address, size)) { diff --git a/tests/ShaderRecompilerComputeTests.cpp b/tests/ShaderRecompilerComputeTests.cpp index 86e7bb2d5..06cfb5552 100644 --- a/tests/ShaderRecompilerComputeTests.cpp +++ b/tests/ShaderRecompilerComputeTests.cpp @@ -5395,6 +5395,16 @@ public: "or stole its stencil association"); constexpr uint64_t second_stencil_offset = 0x90000; + auto stencil_storage_desc = MakeLinearDesc( + base + second_stencil_offset, ms_stencil_size, vk::Format::eR8Uint, + Prospero::BufferFormat::k8UInt, Prospero::ImageType::kColor2D, + {256, 256, 1}, 256, 1, 1); + stencil_storage_desc.type = BindingType::Storage; + stencil_storage_desc.view_info.usage = vk::ImageUsageFlagBits::eStorage; + const auto stencil_storage_image = + texture_cache.FindImage(stencil_storage_desc); + (void)texture_cache.FindTexture(stencil_storage_image, + stencil_storage_desc); auto switched_ms_depth = ms_depth_desc; switched_ms_depth.info.stencil = {base + second_stencil_offset, ms_stencil_size}; @@ -5414,10 +5424,21 @@ public: texture_cache.GetImage(first_stencil_association).depth_id == ms_depth_image && second_stencil_association && + second_stencil_association == stencil_storage_image && + texture_cache.GetImage(second_stencil_association).IsTracked() && texture_cache.GetImage(second_stencil_association).depth_id == ms_depth_image, "changing stencil address recreated depth or discarded an " "existing lightweight association"); + Require(name, "CPU write to tracked stencil association", + resources.HandleFault(PageFaultAccess::Write, + base + second_stencil_offset) && + !texture_cache.GetImage(second_stencil_association).IsTracked() && + texture_cache.GetImage(second_stencil_association).IsCpuDirty() && + texture_cache.GetImage(second_stencil_association).depth_id == + ms_depth_image, + "CPU invalidation left a reused stencil image write-protected"); + memory[second_stencil_offset] = 0x5a; constexpr uint64_t added_stencil_depth_offset = 0x60000; constexpr uint64_t added_stencil_offset = 0x70000;