[PR #2050] Detect unsampled writes to large mapped Vulkan textures #2058

Open
opened 2026-11-26 21:19:53 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2050
Author: @lgr123
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: rt/large-mapped-texture-chunks


📝 Commits (1)

  • a8757fe Audit changes to large persistently mapped title textures

📊 Changes

4 files changed (+220 additions, -15 deletions)

View changed files

📝 runtime/shims/d3d12_vulkan_device.cpp (+97 -14)
📝 runtime/src/title_texture_refresh.h (+37 -0)
📝 runtime/test/d3d12_existing_heap_test.cpp (+65 -1)
📝 runtime/test/title_memory_map_test.cpp (+21 -0)

📄 Description

Claimed as RT-TITLE-LARGE-MAPPED-SAMPLE-MISS. Coordination claim

What and why

The periodic full comparison only covers mapped textures up to 4 MiB. For a larger persistent CPU mapping, an ordinary store outside the fixed sample windows can leave the image unchanged indefinitely while the mapping stays readable and no explicit dirty event fires.

Track chunk hashes from the bytes used for the last accepted upload. Each refresh can audit one 256 KiB chunk, with round-robin turns across eligible mappings. A mismatch queues the existing priority upload. The audit reuses the guarded streaming copy into cached scratch for write-combined memory. Staged completion checks the live resource, source revision and submission state before publishing hashes. A late successful write to the same live resource leaves it dirty for a retry when its source or upload serial is stale.

Validation

  • Native Windows Release on the RTX 5070 with driver 621.24. The identical GPU fixture failed the new readback assertion on stock for both the ordered host copy and forced staged paths. With the change, both read back the new byte in the 8 MiB RGBA8 texture. The initial and sampled-write controls passed.
  • Native source-extraction tests passed coverage across three competing mappings, below-limit and notified-write controls, delayed staged completion after layout replacement, out-of-order acceptance and failed upload retry.
  • One 256 KiB audit took 82 µs median on cached memory and 137 µs median on write-combined memory over 21 interleaved batches. The respective p90s were 103 and 177 µs. A steady 8 MiB mapping was visited within 33 successful refresh passes in the single-mapping case.

The reproductions use generated texture data. The results establish the Vulkan texture update and readback behavior for this case. The contribution is independent of the existing full-scan optimization in #1705.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2050 **Author:** [@lgr123](https://github.com/lgr123) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `rt/large-mapped-texture-chunks` --- ### 📝 Commits (1) - [`a8757fe`](https://github.com/ubiquitarianism/leonida/commit/a8757fe7f9fda50c051005860e2087b0a227fb76) Audit changes to large persistently mapped title textures ### 📊 Changes **4 files changed** (+220 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+97 -14) 📝 `runtime/src/title_texture_refresh.h` (+37 -0) 📝 `runtime/test/d3d12_existing_heap_test.cpp` (+65 -1) 📝 `runtime/test/title_memory_map_test.cpp` (+21 -0) </details> ### 📄 Description Claimed as `RT-TITLE-LARGE-MAPPED-SAMPLE-MISS`. [Coordination claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7171272177) ### What and why The periodic full comparison only covers mapped textures up to 4 MiB. For a larger persistent CPU mapping, an ordinary store outside the fixed sample windows can leave the image unchanged indefinitely while the mapping stays readable and no explicit dirty event fires. Track chunk hashes from the bytes used for the last accepted upload. Each refresh can audit one 256 KiB chunk, with round-robin turns across eligible mappings. A mismatch queues the existing priority upload. The audit reuses the guarded streaming copy into cached scratch for write-combined memory. Staged completion checks the live resource, source revision and submission state before publishing hashes. A late successful write to the same live resource leaves it dirty for a retry when its source or upload serial is stale. ### Validation - Native Windows Release on the RTX 5070 with driver 621.24. The identical GPU fixture failed the new readback assertion on stock for both the ordered host copy and forced staged paths. With the change, both read back the new byte in the 8 MiB RGBA8 texture. The initial and sampled-write controls passed. - Native source-extraction tests passed coverage across three competing mappings, below-limit and notified-write controls, delayed staged completion after layout replacement, out-of-order acceptance and failed upload retry. - One 256 KiB audit took 82 µs median on cached memory and 137 µs median on write-combined memory over 21 interleaved batches. The respective p90s were 103 and 177 µs. A steady 8 MiB mapping was visited within 33 successful refresh passes in the single-mapping case. The reproductions use generated texture data. The results establish the Vulkan texture update and readback behavior for this case. The contribution is independent of the existing full-scan optimization in [#1705](https://github.com/ubiquitarianism/leonida/pull/1705). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2058
No description provided.