Publish written depth planes before later draws in the same list #1541

Merged
invismann merged 1 commit from upstream-pr/1541 into main 2026-11-29 08:16:55 +00:00
invismann commented 2026-11-28 21:25:41 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by invismann on 2026-11-28T21:25:41Z.


Supersedes #1018 and replaces the depth-plane portion of #1532.

A draw can depth-test against stale values when an earlier shader wrote the depth-plane twin and the copy waits until the list closes. Publish the written plane before later commands in the same list. Restore the render targets and invalidate cached state after the internal pass.

Validation

  • 35 targeted GPU tests passed on Windows with an RTX 4090, including the depth and stencil twin tests.
  • The same-list lighting readback matched the expected result. Disabling early publication made the same assertion fail.
  • The changed files passed the pre-commit asset policy.

On upstream 77df871e, strict Clippy reports existing shader diagnostics and the full-tree asset policy flags the existing size of emit/lower.rs. The test-module split for that file is in #1460.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5544721342 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1541). Originally posted by [invismann](https://github.com/invismann) on 2026-11-28T21:25:41Z. --- Supersedes #1018 and replaces the depth-plane portion of #1532. A draw can depth-test against stale values when an earlier shader wrote the depth-plane twin and the copy waits until the list closes. Publish the written plane before later commands in the same list. Restore the render targets and invalidate cached state after the internal pass. ## Validation - 35 targeted GPU tests passed on Windows with an RTX 4090, including the depth and stencil twin tests. - The same-list lighting readback matched the expected result. Disabling early publication made the same assertion fail. - The changed files passed the pre-commit asset policy. On upstream `77df871e`, strict Clippy reports existing shader diagnostics and the full-tree asset policy flags the existing size of `emit/lower.rs`. The test-module split for that file is in #1460.
nick0451 commented 2026-11-28 22:35:40 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nick0451 on 2026-11-28T22:35:40Z.


Tested in play: RTX 3090 24 GB (driver 610.88), i9-14900K, Windows 11. A release build of this PR merged onto main 923e38c, run in turn with main and four other PR builds. Series S, DLSS Performance, frame generation off. The same frozen save, outdoors on a balcony, standing still. A warm-up start per build, then two rounds, each run 40 s to settle and 60 s measured, then a screenshot. Main: 25.4 and 24.8 fps, 10 compute programs refused (no wave32 lowering). I compare round 2 only, because round 1 was slow for every new build.

  • No crash in the measured runs, no device loss and no ERROR line. The picture matches main, and the same 10 programs are refused as on main, so nothing in this scene visibly depends on this change.
  • fps in round 2: 24.1 against 24.8-25.4 for main, within this setup's noise.
  • So this is a no-harm check; the case it fixes did not show in this scene.

The first start of every new build in this session crashed while loading at +0x23cf683 (main and all five PRs alike; see #628), so that is not from this change.

Tested with an AI assistant (Claude Code); results are from this PC.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7246845415 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1541#issuecomment-7246845415). Originally posted by [nick0451](https://github.com/nick0451) on 2026-11-28T22:35:40Z. --- Tested in play: RTX 3090 24 GB (driver 610.88), i9-14900K, Windows 11. A release build of this PR merged onto main `923e38c`, run in turn with main and four other PR builds. Series S, DLSS Performance, frame generation off. The same frozen save, outdoors on a balcony, standing still. A warm-up start per build, then two rounds, each run 40 s to settle and 60 s measured, then a screenshot. Main: 25.4 and 24.8 fps, 10 compute programs refused (`no wave32 lowering`). I compare round 2 only, because round 1 was slow for every new build. - No crash in the measured runs, no device loss and no `ERROR` line. The picture matches main, and the same 10 programs are refused as on main, so nothing in this scene visibly depends on this change. - fps in round 2: 24.1 against 24.8-25.4 for main, within this setup's noise. - So this is a no-harm check; the case it fixes did not show in this scene. The first start of every new build in this session crashed while loading at `+0x23cf683` (main and all five PRs alike; see #628), so that is not from this change. Tested with an AI assistant (Claude Code); results are from this PC.
KyleS98 commented 2026-11-28 23:57:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by KyleS98 on 2026-11-28T23:57:56Z.


An in-game case for this, with a trace, in case it helps the review: mirrors.

The title draws what a mirror shows as a second view of its own (programs *MirrorReflection*, into images of the picture's size rounded up to 16, in a centred rectangle the size of the mirror on screen). Right before those draws, PS_Prepass_StencilCulling (drawn with MS_VS_TransformD_PositionOnly) marks the mirror's pixels by writing that view's depth image through an unordered-access view (an R32_FLOAT view of an R32G8X24 image), in the same list. With the plane drawn from its twin only when the list closed, every draw of the mirror's view was tested against the plane as it had been: with VICTORY_DUMP_TARGETS all ten of the view's images held one colour each at the end of the frame, and the mirror showed the sky (first house, the bathroom).

What the list does with that depth image, from a trace of twin_use in my fork:

  1. the title clears the depth image;
  2. the prepass writes the twin;
  3. a use of the depth image that is no draw comes next, copies the stencil plane's twin and puts the depth plane's pass off to the list's close (late);
  4. then 55 to 150 draws against it, each with behind [Some(false), Some(true)]: nothing owed by behind[0] any more.

So by the time the draws come the plane is owed through late alone. Publishing right after the writer, as this does, is ahead of all that: the plane is up to date before step 3. (My own first attempt looked at behind[0] before each draw and did nothing in this list, for that reason.)

Tested: d4b5d517 + this commit cherry-picked (clean) + #1762, RTX 3090 Ti (616.92), Series S, DLSS Quality, builder off, first house's bathroom: "times used before the pass" 0 at the end of a 200 s run (2,300 "not given back to a twin"), and the mirror's view is drawn. With this alone the mirror turns from sky to black, because the view's own lighting has only the sun's direct light without the rays; #1762 is the light for it, and with both the mirror shows the room.

AI-assisted (Claude Code, Claude Fable 5.2).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7247780045 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1541#issuecomment-7247780045). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-28T23:57:56Z. --- An in-game case for this, with a trace, in case it helps the review: **mirrors**. The title draws what a mirror shows as a second view of its own (programs `*MirrorReflection*`, into images of the picture's size rounded up to 16, in a centred rectangle the size of the mirror on screen). Right before those draws, `PS_Prepass_StencilCulling` (drawn with `MS_VS_TransformD_PositionOnly`) marks the mirror's pixels by writing that view's depth image through an unordered-access view (an R32_FLOAT view of an R32G8X24 image), in the same list. With the plane drawn from its twin only when the list closed, every draw of the mirror's view was tested against the plane as it had been: with `VICTORY_DUMP_TARGETS` all ten of the view's images held one colour each at the end of the frame, and the mirror showed the sky (first house, the bathroom). What the list does with that depth image, from a trace of `twin_use` in my fork: 1. the title clears the depth image; 2. the prepass writes the twin; 3. a use of the depth image that is no draw comes next, copies the stencil plane's twin and puts the depth plane's pass off to the list's close (`late`); 4. then 55 to 150 draws against it, each with `behind [Some(false), Some(true)]`: nothing owed by `behind[0]` any more. So by the time the draws come the plane is owed through `late` alone. Publishing right after the writer, as this does, is ahead of all that: the plane is up to date before step 3. (My own first attempt looked at `behind[0]` before each draw and did nothing in this list, for that reason.) **Tested:** `d4b5d517` + this commit cherry-picked (clean) + #1762, RTX 3090 Ti (616.92), Series S, DLSS Quality, builder off, first house's bathroom: "times used before the pass" 0 at the end of a 200 s run (2,300 "not given back to a twin"), and the mirror's view is drawn. With this alone the mirror turns from sky to black, because the view's own lighting has only the sun's direct light without the rays; #1762 is the light for it, and with both the mirror shows the room. AI-assisted (Claude Code, Claude Fable 5.2).
amazedturnip commented 2026-11-29 05:38:32 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by amazedturnip on 2026-11-29T05:38:32Z.


Tested alongside #1762 on 9800X3D + RTX 5070 Ti 16 GB (Series X 1440p DLSS, RT off). Same-list depth publish ran cleanly across 20+ min gameplay with zero depth glitches or stalls.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7251373737 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1541#issuecomment-7251373737). Originally posted by [amazedturnip](https://github.com/amazedturnip) on 2026-11-29T05:38:32Z. --- Tested alongside #1762 on 9800X3D + RTX 5070 Ti 16 GB (Series X 1440p DLSS, RT off). Same-list depth publish ran cleanly across 20+ min gameplay with zero depth glitches or stalls.
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
trustno1-coder/VIctory-NVIDIA!1541
No description provided.