Detect unsampled writes to large mapped Vulkan textures #2050

Closed
lgr123 wants to merge 1 commit from upstream-pr/2050 into main
lgr123 commented 2026-11-25 19:02:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lgr123 on 2026-11-25T19:02:22Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5497391001 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2050). Originally posted by [lgr123](https://github.com/lgr123) on 2026-11-25T19:02:22Z. --- 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).
OreoFR commented 2026-11-29 12:42:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T12:42:30Z.


@lgr123 this PR now conflicts with main (runtime/shims/d3d12_vulkan_device.cpp, runtime/src/title_texture_refresh.h, runtime/test/d3d12_existing_heap_test.cpp, runtime/test/title_memory_map_test.cpp). Could you merge main into your branch (no force-push needed)? If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7256006270 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2050#issuecomment-7256006270). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T12:42:30Z. --- @lgr123 this PR now conflicts with `main` (`runtime/shims/d3d12_vulkan_device.cpp`, `runtime/src/title_texture_refresh.h`, `runtime/test/d3d12_existing_heap_test.cpp`, `runtime/test/title_memory_map_test.cpp`). Could you merge `main` into your branch (no force-push needed)? If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)
aslan2142 commented 2026-12-01 16:41:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:41:48Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318053782 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2050#issuecomment-7318053782). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:41:48Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2050
No description provided.