renderer: respect buffer ownership in image downloads

This commit is contained in:
nmzik
2026-08-23 17:31:00 +02:00
parent 4d8d3b6d25
commit 30fa9dddc5
2 changed files with 21 additions and 2 deletions
+2 -2
View File
@@ -1209,7 +1209,7 @@ ImageId TextureCache::FindImageFromRange(uint64_t address, uint64_t size, bool e
if (ensure_valid && owner->depth_id) { if (ensure_valid && owner->depth_id) {
owner = m_slot_images.try_get(owner->depth_id); owner = m_slot_images.try_get(owner->depth_id);
} }
if (owner == nullptr || (ensure_valid && !owner->SafeToDownload())) { if (owner == nullptr || (ensure_valid && !SafeToDownload(*owner))) {
continue; continue;
} }
matches.push_back(id); matches.push_back(id);
@@ -1580,7 +1580,7 @@ bool BufferCache::SynchronizeBufferFromImage(Buffer& buffer, uint64_t vaddr, uin
if (owner->depth_id) { if (owner->depth_id) {
owner = m_texture_cache.m_slot_images.try_get(owner->depth_id); owner = m_texture_cache.m_slot_images.try_get(owner->depth_id);
} }
if (owner != nullptr && owner->SafeToDownload()) { if (owner != nullptr && m_texture_cache.SafeToDownload(*owner)) {
matches.push_back(id); matches.push_back(id);
} }
} }
+19
View File
@@ -5673,6 +5673,25 @@ public:
texture_cache.GetImage(exact_image).IsGpuModified(), texture_cache.GetImage(exact_image).IsGpuModified(),
"image ownership discarded or conflicted with disjoint dirty " "image ownership discarded or conflicted with disjoint dirty "
"Buffer bytes on the same tracker page"); "Buffer bytes on the same tracker page");
auto exact_buffer = resources.GetBufferCache().ObtainBuffer(
base + exact_image_offset, sizeof(uint32_t), true);
Require(name, "overlapping buffer ownership allocation",
exact_buffer.first != nullptr,
"failed to create the overlapping dirty Buffer owner");
exact_buffer.first->Fill(exact_buffer.second, sizeof(uint32_t),
dirty_sibling_value);
Libs::Graphics::Buffer exact_download(
m_runtime_context, scheduler, MemoryUsage::DeviceLocal,
base + exact_image_offset, AllFlags, sizeof(uint32_t));
Require(name, "overlapping buffer ownership rejection",
!texture_cache.FindImageFromRange(base + exact_image_offset,
sizeof(uint32_t)) &&
!BufferCacheTestAccess::SynchronizeBufferFromImage(
resources.GetBufferCache(), exact_download,
base + exact_image_offset, sizeof(uint32_t)),
"dirty Buffer bytes did not block the stale image source");
resources.GetBufferCache().ReadMemory(base + exact_image_offset,
sizeof(uint32_t));
resources.GetBufferCache().ReadMemory(base + dirty_sibling_offset, resources.GetBufferCache().ReadMemory(base + dirty_sibling_offset,
sizeof(dirty_sibling_value)); sizeof(dirty_sibling_value));