[pr-fix][rendering][memory] Refresh placed textures after streamed writes through an alias #433

Manually merged
TrustNo1 merged 1 commit from holoslicer/aliased-texture-writes into main 2026-12-05 04:51:33 +00:00 AGit
Contributor

Offline D3D12 reproduction and fix. Gameplay validation is pending. Refs #396 and #311.

Contributor role (optional)

Not requested.

What it changes

DirectStorage can finish writing through one virtual address while a bindless SRV samples another mapping of the same physical page. Main marks the buffer-watch bits but only passes the destination address to the placed-texture queue. Report the written byte range at each current mapping. Physical destinations already enumerate their mappings.

How it was tested

Tested 083918931e against f3840d73d3 on Windows 11 build 26300.9818, RTX 3090 24 GB, driver 617.42, Rust 1.98.1. The test uses generated tiled RGBA8 textures.

  1. Apply only the regression test to main for the control. Run cargo test --locked -p darner-gpu --lib streamed_texture_written_through_an_alias_reaches_a_full_queue -- --nocapture --test-threads=1 on both revisions.
  2. Start with two resident textures and 8,192 other pending texture uploads. Write through another mapping at a 4 KiB offset. Deliver 64 completion notices before polling, allow one upload, and read back all pixels.
  3. Rebind the same write address to the second physical page and repeat. Check the previous texture and the unwritten neighbour. Cross DARNER_LIGHT_REFRESH=0/1 with DARNER_PRELUDE_UPLOADS=0/1.
First eligible upload Main Fix
Correct pixels after the first write 0/1,024 1,024/1,024
Correct pixels after the remapped write 0/1,024 1,024/1,024
Passing fresh processes 0/4 12/12

The fix added just the affected slot to the queue in each pass. Both passes finished with the original 8,192 slots pending. The existing late-completion, guard and remap-cursor controls also passed.

No switch or budget defaults changed. This reproduces a specific missed invalidation. In-game frame time, visible flicker, full-VRAM behaviour and other GPUs remain unmeasured. Shader wave size is outside this change.

The asset policy and both workspace Clippy gates passed with warnings denied. The full serial workspace gate failed. The CLI child-exit and shader depth-output checks also failed on clean main. The nested-worker and reservation-split failures were recorded on the same main revision and passed in all eight isolated runs on the fix. Three loopback checks and one temporary-save hard-link check passed when rerun with normal Windows permissions.

Checklist

  • Gameplay is pending. Validation for this change was limited to the standalone D3D12 test.
  • One change based on official main.
  • The diff follows the asset policy.
  • Dependencies recorded. None.

Checked for overlap

  • Searched open and closed issues and PRs, including open PRs touching watch.rs.
  • Related PRs are #50 (mip refresh), #150 (write-watch tests), #219 (view guards) and #321 (free notifications). None handles this stream-completion path.
Offline D3D12 reproduction and fix. Gameplay validation is pending. Refs #396 and #311. ## Contributor role (optional) Not requested. ## What it changes DirectStorage can finish writing through one virtual address while a bindless SRV samples another mapping of the same physical page. Main marks the buffer-watch bits but only passes the destination address to the placed-texture queue. Report the written byte range at each current mapping. Physical destinations already enumerate their mappings. ## How it was tested Tested `083918931e` against `f3840d73d3` on Windows 11 build 26300.9818, RTX 3090 24 GB, driver 617.42, Rust 1.98.1. The test uses generated tiled RGBA8 textures. 1. Apply only the regression test to main for the control. Run `cargo test --locked -p darner-gpu --lib streamed_texture_written_through_an_alias_reaches_a_full_queue -- --nocapture --test-threads=1` on both revisions. 2. Start with two resident textures and 8,192 other pending texture uploads. Write through another mapping at a 4 KiB offset. Deliver 64 completion notices before polling, allow one upload, and read back all pixels. 3. Rebind the same write address to the second physical page and repeat. Check the previous texture and the unwritten neighbour. Cross `DARNER_LIGHT_REFRESH=0/1` with `DARNER_PRELUDE_UPLOADS=0/1`. | First eligible upload | Main | Fix | |---|---:|---:| | Correct pixels after the first write | 0/1,024 | 1,024/1,024 | | Correct pixels after the remapped write | 0/1,024 | 1,024/1,024 | | Passing fresh processes | 0/4 | 12/12 | The fix added just the affected slot to the queue in each pass. Both passes finished with the original 8,192 slots pending. The existing late-completion, guard and remap-cursor controls also passed. No switch or budget defaults changed. This reproduces a specific missed invalidation. In-game frame time, visible flicker, full-VRAM behaviour and other GPUs remain unmeasured. Shader wave size is outside this change. The asset policy and both workspace Clippy gates passed with warnings denied. The full serial workspace gate failed. The CLI child-exit and shader depth-output checks also failed on clean main. The nested-worker and reservation-split failures were recorded on the same main revision and passed in all eight isolated runs on the fix. Three loopback checks and one temporary-save hard-link check passed when rerun with normal Windows permissions. ## Checklist - [x] Gameplay is pending. Validation for this change was limited to the standalone D3D12 test. - [x] One change based on official main. - [x] The diff follows the asset policy. - [x] Dependencies recorded. None. ## Checked for overlap - [x] Searched open and closed issues and PRs, including open PRs touching `watch.rs`. - Related PRs are #50 (mip refresh), #150 (write-watch tests), #219 (view guards) and #321 (free notifications). None handles this stream-completion path.
Contributor

An in-game run of this change, since that was still open.

RTX 4090, i9-14900K, Series X, 1440p, DLSS Quality, frame generation 2x, hardware RT. Base: main f3840d7 with #310, #274 and #341 (DARNER_RANGE_LOCK=1); B = that tree with 0839189 merged (no conflict). The same save and drive into the city, 10 min each, the same evening. Note that A was a PGO build and B a plain --profile fast build, so if anything B is at a disadvantage on frame times.

A (without) B (with this PR)
a texture picked by index changed after its upload with nothing to tell of it warnings 202 81
frames over 50 ms 5.1 % of 15,309 3.3 % of 17,151
fps in the world, average 24.2 25.4
textures per frame (refresh) 1.6 ms, 8.3 MB 1.5 ms, 8.0 MB
  • The warning that names a texture changed without anything telling of it fell by about 60 %, which fits what this fixes (a streamed write through another mapping of the same page). The rest of them have another cause.
  • No cost seen: frame times no worse (better, but one run each and run-to-run spread is larger than that).
  • Visually the player noticed no difference on this route: some texture pop-in and wrong textures were there in both runs. So this does not seem to be the main cause of those here, but it does remove a share of the missed invalidations.
An in-game run of this change, since that was still open. RTX 4090, i9-14900K, Series X, 1440p, DLSS Quality, frame generation 2x, hardware RT. Base: `main` `f3840d7` with #310, #274 and #341 (`DARNER_RANGE_LOCK=1`); B = that tree with `0839189` merged (no conflict). The same save and drive into the city, 10 min each, the same evening. Note that A was a PGO build and B a plain `--profile fast` build, so if anything B is at a disadvantage on frame times. | | A (without) | B (with this PR) | |---|---:|---:| | `a texture picked by index changed after its upload with nothing to tell of it` warnings | 202 | **81** | | frames over 50 ms | 5.1 % of 15,309 | 3.3 % of 17,151 | | fps in the world, average | 24.2 | 25.4 | | textures per frame (refresh) | 1.6 ms, 8.3 MB | 1.5 ms, 8.0 MB | - The warning that names a texture changed without anything telling of it fell by about 60 %, which fits what this fixes (a streamed write through another mapping of the same page). The rest of them have another cause. - No cost seen: frame times no worse (better, but one run each and run-to-run spread is larger than that). - Visually the player noticed no difference on this route: some texture pop-in and wrong textures were there in both runs. So this does not seem to be the main cause of those here, but it does remove a share of the missed invalidations.
Contributor

Independent D3D12 reproduction of the full-queue alias regression on an RTX 4060 8 GB, NVIDIA driver 621.40, Windows 11 build 26300, Rust 1.98.1. I ran it in eight fresh processes: the exact parent f3840d73 with the PR’s test copied in, and PR head 08391893, each with all four combinations of DARNER_LIGHT_REFRESH=0/1 and DARNER_PRELUDE_UPLOADS=0/1. I added the same adapter assertion to both revisions to make a hardware skip or WARP fallback fail the test.

  • Parent, 4/4 expected failures: both alias placements read back 0/1,024 correct pixels. The dirty queue stayed at 8,192 after the write and the one-slot poll returned an unrelated slot.
  • PR head, 4/4 passed: both alias placements read back 1,024/1,024 correct pixels. The written texture’s slot ran first in each case and 8,192 unrelated entries remained pending.

I ran cargo +1.98.1 test --locked --offline -j 2 -p darner-gpu --lib watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue -- --exact --nocapture --test-threads=1. The built-in fixture writes through an alias and calls watch::stream_written directly. This checks GPU readback and queue ordering on the 4060. Gameplay and the actual DirectStorage API were outside the test.

Independent D3D12 reproduction of the full-queue alias regression on an RTX 4060 8 GB, NVIDIA driver 621.40, Windows 11 build 26300, Rust 1.98.1. I ran it in eight fresh processes: the exact parent `f3840d73` with the PR’s test copied in, and PR head `08391893`, each with all four combinations of `DARNER_LIGHT_REFRESH=0/1` and `DARNER_PRELUDE_UPLOADS=0/1`. I added the same adapter assertion to both revisions to make a hardware skip or WARP fallback fail the test. - Parent, 4/4 expected failures: both alias placements read back 0/1,024 correct pixels. The dirty queue stayed at 8,192 after the write and the one-slot poll returned an unrelated slot. - PR head, 4/4 passed: both alias placements read back 1,024/1,024 correct pixels. The written texture’s slot ran first in each case and 8,192 unrelated entries remained pending. I ran `cargo +1.98.1 test --locked --offline -j 2 -p darner-gpu --lib watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue -- --exact --nocapture --test-threads=1`. The built-in fixture writes through an alias and calls `watch::stream_written` directly. This checks GPU readback and queue ordering on the 4060. Gameplay and the actual DirectStorage API were outside the test.
TrustNo1 manually merged commit bd7e2a80c0 into main 2026-12-05 04:51:33 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
TrustNo1/Darner!433
No description provided.