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

Manually merged
github merged 1 commit from github-bot/gh-1541 into main 2026-11-29 08:21:06 +00:00 AGit
Owner

@⁠invismann on GitHub · 2026-11-28 21:25 UTC · original
invismann:fix/same-list-depth-plane-publication → main · +95 −112 · 3 files · 1 commits · merged 2026-11-29 08:16 UTC

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.

**@⁠invismann** on GitHub · 2026-11-28 21:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1541) `invismann:fix/same-list-depth-plane-publication` → `main` · +95 −112 · 3 files · 1 commits · merged 2026-11-29 08:16 UTC 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 21:30:57 +00:00
github-bot changed title from [pr-fix] [rendering] Publish written depth planes before later draws in the same list to Publish written depth planes before later draws in the same list 2026-11-28 21:37:37 +00:00
Author
Owner

@⁠nick0451 on GitHub · 2026-11-28 22:35 UTC · original

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.

**@⁠nick0451** on GitHub · 2026-11-28 22:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1541#issuecomment-7246845415) 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.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-28 23:57 UTC · original

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).

**@⁠KyleS98** on GitHub · 2026-11-28 23:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1541#issuecomment-7247780045) 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).
Author
Owner

@⁠amazedturnip on GitHub · 2026-11-29 05:38 UTC · original

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.

**@⁠amazedturnip** on GitHub · 2026-11-29 05:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1541#issuecomment-7251373737) 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.
github manually merged commit ce821609be into main 2026-11-29 08:21:06 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1541
No description provided.