Shaders: a pixel program the console tests depth before (DB_SHADER_CONTROL.DEPTH_BEFORE_SHADER) is declared [earlydepthstencil]: glass no longer lies over what stands in front of it #353

Open
github-bot wants to merge 1 commit from github-bot/gh-353 into main AGit
Owner

@⁠Serph91P on GitHub · 2026-11-26 18:16 UTC · original
Serph91P:shader-early-depth → main · +24 −2 · 4 files · 1 commits · open

A character standing in front of a window pane had hair, neck and shirt smeared right of a straight vertical line, the pane's edge; panes seemed to shimmer through whatever was in front of them. One commit on 2de9980.

Cause: the glass pre-pass (PS_AlphaPrepass, d16aa632) also writes the pane's depth and velocity into a storage texture. The console tests depth before the program runs (bit 12 of DB_SHADER_CONTROL). The translator read the bit and did not pass it on, and D3D12 tests depth after a program that writes storage textures unless it is declared early. So the texture was written for every pixel the pane's mesh covers, behind the head too; PS_AlphaVelocityDepthResolve then put the pane's depth and velocity into the scene's at those pixels, and the title's TAA smeared them.

What this does: emit/lower.rs gives a pixel program with the bit set and no depth export the DXIL flag for early depth and stencil. In the frame looked at, 333 pixel programs carry the bit, 50 of them can kill pixels. TRANSLATOR_VERSION 1 → 2; #354 also goes 1 → 2 on its own, so whichever lands second needs 3.

Tested (RX 7900 XTX, RADV Mesa 26.3.1, vkd3d-proton 71cae091, Proton Experimental)

  • Recorded frame: replacing only this one program restores the hair strands and removes the line; the storage texture is non-zero on 798,390 texels instead of 1,146,013 (the head excluded); with every program retranslated the differences are on the character inside the pane's rectangle only.
  • In the title: panes are no longer drawn over characters or walls in several rooms (observer); steady frame time unchanged (median 62.1 ms).
  • This branch alone: builds for x86_64-pc-windows-msvc (cargo-xwin); the whole archive gives 25,694 that translate and 195 that do not, as before; cargo test -p victory-shader --lib (209 passed), cargo xtask policy and cargo test -p xtask pass.

Not tested: Windows, NVIDIA. No unit test for the flag. To watch: the 50 programs that can kill pixels now test and write depth before they run, as the console does; a problem would show as cut-outs (foliage, hair) hiding what is behind them.

No game data in the commit.

🤖 Generated with Claude Code

**@⁠Serph91P** on GitHub · 2026-11-26 18:16 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/353) `Serph91P:shader-early-depth` → `main` · +24 −2 · 4 files · 1 commits · open A character standing in front of a window pane had hair, neck and shirt smeared right of a straight vertical line, the pane's edge; panes seemed to shimmer through whatever was in front of them. One commit on 2de9980. **Cause:** the glass pre-pass (`PS_AlphaPrepass`, d16aa632) also writes the pane's depth and velocity into a storage texture. The console tests depth before the program runs (bit 12 of `DB_SHADER_CONTROL`). The translator read the bit and did not pass it on, and D3D12 tests depth after a program that writes storage textures unless it is declared early. So the texture was written for every pixel the pane's mesh covers, behind the head too; `PS_AlphaVelocityDepthResolve` then put the pane's depth and velocity into the scene's at those pixels, and the title's TAA smeared them. **What this does:** `emit/lower.rs` gives a pixel program with the bit set and no depth export the DXIL flag for early depth and stencil. In the frame looked at, 333 pixel programs carry the bit, 50 of them can kill pixels. `TRANSLATOR_VERSION` 1 → 2; #354 also goes 1 → 2 on its own, so whichever lands second needs 3. **Tested** (RX 7900 XTX, RADV Mesa 26.3.1, vkd3d-proton 71cae091, Proton Experimental) - Recorded frame: replacing only this one program restores the hair strands and removes the line; the storage texture is non-zero on 798,390 texels instead of 1,146,013 (the head excluded); with every program retranslated the differences are on the character inside the pane's rectangle only. - In the title: panes are no longer drawn over characters or walls in several rooms (observer); steady frame time unchanged (median 62.1 ms). - This branch alone: builds for `x86_64-pc-windows-msvc` (cargo-xwin); the whole archive gives 25,694 that translate and 195 that do not, as before; `cargo test -p victory-shader --lib` (209 passed), `cargo xtask policy` and `cargo test -p xtask` pass. **Not tested:** Windows, NVIDIA. No unit test for the flag. To watch: the 50 programs that can kill pixels now test and write depth before they run, as the console does; a problem would show as cut-outs (foliage, hair) hiding what is behind them. No game data in the commit. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The console's pixel programs say in DB_SHADER_CONTROL bit 12 that depth
and stencil are tested (and written) before they run; the translator
read the register but declared nothing. A host tests after a program
that writes unordered views unless the program is marked early, so such
a program wrote its views for pixels the depth test rejects.

Capture-1 (a character in front of a wire-mesh window): PS_AlphaPrepass
(d16aa632) tests the glass against the scene depth (greater-equal,
read-only) and also writes the glass's velocity and depth to an
unordered view (2560x1440 R32G32F). Its targets left out the head
correctly, but the view got the glass over the whole pane, head
included; PS_AlphaVelocityDepthResolve then put the glass's depth and
velocity into the scene depth and the velocity target there, and the
title's TAA smeared the hair and neck right of the pane's left edge (a
straight vertical line through the head). Replacing only that program by
its translation with the flag: the view holds 798,390 pixels (the glass
around the head) instead of 1,146,013 (the whole pane), and the picture
changes only on the character within the pane, whose hair keeps its
strands.

333 of the capture's pixel programs set the bit (50 of them kill);
programs that export depth are left as they were. 272 of the capture's
1476 shaders translate differently, so TRANSLATOR_VERSION goes to 3.
The archive (shaders.rpf): 25,694 shaders in the cache, 195 do not
translate (all "a container without a vertex, pixel, compute or mesh
program", as before).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:20:53 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/353/head:github-bot/gh-353'
git switch 'github-bot/gh-353'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-353'
git switch 'github-bot/gh-353'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-353'
git switch 'github-bot/gh-353'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-353'
git switch 'main'
git merge --squash 'github-bot/gh-353'
git switch 'main'
git merge --ff-only 'github-bot/gh-353'
git switch 'main'
git merge 'github-bot/gh-353'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.