Skip to content

Game: try what depth-stencil registers do not keep (stacked on #3047) - #3048

Open
zed6000 wants to merge 3 commits into
Marvisak:mainfrom
zed6000:pr-depth-registers
Open

zed6000 wants to merge 3 commits into
Marvisak:mainfrom
zed6000:pr-depth-registers

Conversation

@zed6000

@zed6000 zed6000 commented Nov 26, 2026

Copy link
Copy Markdown

The depth-stencil half of #2930. Stacked on #3047: the first commit here is #3047's, and this PR's own change is the second commit (1d5afa0). Once #3047 is in, only that commit remains.

After rasterisers, the pre-build's largest named-state gap is 139 records (13 hashes) with depth-stencil state not named. Comparing depth_from_registers's candidates with the descriptions that do match shows three things the registers don't keep:

  • b14 and b15 (the depth-bounds test): set in several descriptions while DEPTH_BOUNDS_ENABLE is clear. Both are now tried as 0 and 1.
  • The write mask of a stencil that can write nothing: with stencil on and keep everywhere, DB_STENCILREFMASK holds 0 where the description has 0xFF (or the read mask). Both are tried.
  • A disabled stencil's ops and funcs: with STENCIL_ENABLE clear, DB_DEPTH_CONTROL / DB_STENCIL_CONTROL still hold the faces the engine's description names. They are tried next to the D3D12 default faces.

depth_from_registers now wraps the old body (depth_kept) and adds those variants. The face decoding moved to stencil_faces so both use it. The CityHash64 still decides.

Measured on shaders.rpf 1.0.2.1 (offline, RX 7900 XTX):

  • 11 of the 13 hashes are named (136 of 139 records), all from the registers; the enumeration names none now. Records with all three states named go from 25,329 to 25,465 of 25,471. Named::find takes ~88 ms.
  • translate --cache --pipelines skips 41 of 28,164 pipelines (main: 1,029): 3 depth-stencil, 3 blend, and the 35 shader causes. Every pipeline it made was created.
  • cargo test -p victory-game 18/0 (1 new test, on synthetic registers), and clippy clean.

The 2 hashes still unnamed (3 records) have depth on and a stencil whose registers keep nothing it writes. A search over every op and func of both faces didn't match them, so they're left alone.

🤖 Generated with Claude Code

zed6000 and others added 2 commits November 26, 2026 01:16
The pack's register images keep the rasteriser registers 0x28 bytes into
the fixed part (PA_CL_CLIP_CNTL, PA_SU_SC_MODE_CNTL, the poly-offset
clamp, front scale and front offset). Reading cull, winding, depth clip,
clamp, slope (scale / 16) and bias from them names every rasteriser hash
of the pack, including six whose clamped, fractional slope biases no
enumeration reached: all three states of 25,329 of 25,471 records are
named instead of 24,477, so the pre-build makes 852 more pipelines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The register images leave out b14 and the depth-bounds test (b15), keep
the write mask of a stencil that can write nothing as 0, and still hold
the ops and funcs of a stencil that is off, which the engine's
descriptions name. Trying those as well names 11 of the 13 depth-stencil
hashes the pack's records had unnamed (136 of 139 records): all three
states of 25,465 of 25,471 records are named, and the pre-build skips 41
of 28,164 pipelines instead of 1,029.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of commit 1d5afa02 (stacked on #3047) in crates/victory-game/src/pipelines.rs.

depth_from_registers cleanly wraps depth_kept and tries the four combinations of (b[14], b[15]), the 0xFF / read-mask write-mask variants when DB_STENCILREFMASK has write mask 0 with stencil enabled, and the register-encoded stencil faces when STENCIL_ENABLE is clear. Trying (b[14], b[15]) unconditionally also catches descriptions that enable depth bounds even when DB_DEPTH_CONTROL bit 3 is clear, and CityHash64 remains the exact arbiter. Clean factoring via stencil_faces and clear unit tests.

@kotekompotek kotekompotek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified (delta over #3047): stencil_faces is a faithful extraction of the inline decode (same control/stencil shifts, back=front when back-face stencil is off). The enumeration bounds at faces(≤2) × writes(≤3) × tail(4) = 24 candidates and covers exactly the non-kept fields the doc names: b14/b15, register-decoded faces under stencil-off, and write-mask alternatives under kept-0. The test discriminates each variant. 25,465 of 25,471 records named.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Verdict: merge candidate, after #3047. The PR's first commit is #3047's. The only change of its own is 1d5afa0 in crates/victory-game/src/pipelines.rs. depth_from_registers now wraps the old body (renamed depth_kept) and also tries:

  • b14 and b15 (the depth-bounds test) as 0 and 1,
  • a write mask of 0xFF or the read mask when stencil is on and the register mask is 0,
  • for a disabled stencil, the faces that DB_STENCIL_CONTROL/DB_DEPTH_CONTROL still hold.

The face decoding is moved unchanged into stencil_faces. A candidate still counts only when its CityHash64 matches the record's, so the extra variants cannot name a wrong state. The search stays small, at most a few hundred candidates per register image.

Note for the maintainer: #3040 also changes depth_from_registers and depth_space to recover the depth-bounds bit (b15), and the two will conflict textually. This PR covers b15 in the register path more broadly. #3040 also adds b15 to the enumeration and checks the stream output. Pick one, or rebase the other.

CI: check passing.


Generated by Claude Code

@futurepro62

Copy link
Copy Markdown

Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 1d5afa0 (on its base 63bcca4).

Tested

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
…arvisak#3048's test)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
- Night round: record the Windows CI run at 9b3715b, credit wbkepler on
  Marvisak#2175/Marvisak#2465 and note only the first 2 commits of Marvisak#3102 were taken,
  credit ff0e3be to the review of Marvisak#3047 (not Marvisak#3048), and say Marvisak#2065 was
  already merged in the evening round (the night round adds only the
  by-ordinal census).
- New late night round section: its 23 tracks with provenance, what to
  check on the Mac, and how it was tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A disabled stencil can retain a read mask in the register image while its compact description uses that value for both masks. Try the existing zero-write-mask candidates in this case as well. The original state hash still gates every match.

Add a generated regression with a non-default mask. AI-assisted with Codex.
@steven-seagull27

Copy link
Copy Markdown

I found one more case for the write-mask reconstruction. With stencil disabled, the register image can retain a non-default read mask and a zero write mask. A compact description with matching read and write masks currently goes unnamed because the extra candidates are tried only when stencil is enabled.

I put a one-commit follow-up on your exact head 1d5afa0. It reuses your existing candidates and still requires the full description to match its CityHash64. The generated regression uses read mask 0x52. It fails on your head and passes with the fix. All 19 crate tests, strict Clippy, and the asset-policy check passed on Windows. Commit 79d344a

To take it on your branch:

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/contrib/3048-disabled-stencil-write-mask
git cherry-pick 79d344a1221d9bee9dcc1edfff2297d756df6043

AI-assisted with Codex.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

@zed6000 I checked Steven's disabled-stencil follow-up together with #3047, #3048 and the separate blend-factor change in #3499. Tested integration at a74fe1d keeps the existing PR commits and applies Steven's 79d344a with his Git authorship.

The added regression feeds a generated graphics record through Pack::parse and Named::find. It requests a rasterizer with a fractional bias clamp, disabled stencil with both masks equal to 0x52, and an independently masked blend target with separate alpha factors.

I used separate Cargo target directories for the controls and the combined tree. All 22 victory-game library tests, all-target/all-feature Clippy with warnings denied, and the asset check passed. The counts are for the synthetic record.

The integration test is a74fe1d. If folded into another commit, please retain Git authorship or add Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>.

AI-assisted with Codex.

@zed6000

zed6000 commented Nov 28, 2026

Copy link
Copy Markdown
Author

Thanks @steven-seagull27. Your disabled-stencil fix is now on this branch as your own commit, 79d344a, with your authorship unchanged. On an RX 7900 XTX, victory-game --lib passes (19 tests, including your regression), strict clippy passes with and without --all-features, and so does the asset-policy check.

@andrewpozdnakov7-jpg, thanks for testing the combination. I left out your integration test (a74fe1d), because its blend-target case needs #3499, which isn't part of this stack. It would make a good test for whichever of the two lands second.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

Agreed. The blend-target case in a74fe1d relies on #3499. The combined coverage can go with whichever lands second. I checked the new head 79d344a and its Windows CI is green.

AI-assisted with OpenAI Codex.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

I combined the exact 79d344a head with #3724 at 97f1f0c in integration commit 2073973. Both original commits are parents. Git merged the change directly into depth_kept, where each repeated base row used to run the variant expansion again.

Across 3,840 generated cases, the combined path reduced emitted rows from 1,098,240 to 1,048,080. All 835,296 first occurrences retained the same bytes and order. The default-mask and already-off back-face controls each halved their emitted rows and time, while controls with distinct rows kept the original counts. The fixture hashes each candidate, and includes the downstream variant expansion.

All 19 game tests passed, including the disabled-stencil retained-mask regression. Strict Clippy and the asset policy passed. @zed6000, the branch is available for merge coordination. Please retain the Git authors on cherry-pick or rebase.

AI-assisted with OpenAI Codex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants