Game: recover depth-bounds-enabled states in pipeline prebuild #3040

Closed
github-bot wants to merge 1 commit from gh-pr/3040/head into gh-pr/3040/base
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 04:57 UTC · original
fuzeofficlal:fix/game-pipelines-depth-bounds → main · +165 −18 · 1 files · 1 commits · closed without merging

Problem

crates/victory-game/src/pipelines.rs documents compact depth-stencil byte 15 as depth-bounds test and serializes c[15] into D3D12_DEPTH_STENCIL_DESC1.DepthBoundsTestEnable at offset 0x34 (which victory-gpu now honors on the host after #158).

However, when Named::find recovers depth-stencil states not present in an SGD5 database:

  • depth_from_registers reads DB_DEPTH_CONTROL bits 0..2, 4..10, and 20..22 but skips bit 3 (DEPTH_BOUNDS_ENABLE), leaving b[15] = 0.
  • depth_space also leaves b[15] = 0.

As a result, any graphics pipeline in a shader pack whose depth-stencil state enables the depth bounds test misses both register recovery and fallback enumeration, so Named::find fails to resolve its hash and prebuild skips it as Unnamed::DepthStencil.

Fix

  • Decode DB_DEPTH_CONTROL bit 3 (control >> 3 & 1) into compact byte 15 in depth_from_registers. When depth_on is false and bit 3 is clear, try both 0 and 1 (mirroring how depth_on == false enumerates depth enable/write/func in case the driver cleared DB_DEPTH_CONTROL without a depth target).
  • Enumerate b[15] in [0, 1] for the stencil-off loop in depth_space (+128 candidates, leaving the 2.5M stencil-on enumeration unchanged).

Verification

  • cargo test --locked -p victory-game (17 passed, including new unit tests covering depth_from_registers, depth_space, and end-to-end Named::find + stream recovery of a depth-bounds-enabled graphics record with no databases)
  • cargo test --locked -p victory (18 passed)
  • cargo clippy --locked -p victory-game -p victory --all-targets -- -D warnings
  • rustfmt --edition 2024 --check crates/victory-game/src/pipelines.rs
  • cargo xtask policy (191 files ok)
**@⁠fuzeofficlal** on GitHub · 2026-11-26 04:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/3040) `fuzeofficlal:fix/game-pipelines-depth-bounds` → `main` · +165 −18 · 1 files · 1 commits · closed without merging ### Problem `crates/victory-game/src/pipelines.rs` documents compact depth-stencil byte 15 as `depth-bounds test` and serializes `c[15]` into `D3D12_DEPTH_STENCIL_DESC1.DepthBoundsTestEnable` at offset `0x34` (which `victory-gpu` now honors on the host after #158). However, when `Named::find` recovers depth-stencil states not present in an SGD5 database: - `depth_from_registers` reads `DB_DEPTH_CONTROL` bits `0..2`, `4..10`, and `20..22` but skips bit 3 (`DEPTH_BOUNDS_ENABLE`), leaving `b[15] = 0`. - `depth_space` also leaves `b[15] = 0`. As a result, any graphics pipeline in a shader pack whose depth-stencil state enables the depth bounds test misses both register recovery and fallback enumeration, so `Named::find` fails to resolve its hash and prebuild skips it as `Unnamed::DepthStencil`. ### Fix - Decode `DB_DEPTH_CONTROL` bit 3 (`control >> 3 & 1`) into compact byte 15 in `depth_from_registers`. When `depth_on` is false and bit 3 is clear, try both `0` and `1` (mirroring how `depth_on == false` enumerates depth enable/write/func in case the driver cleared `DB_DEPTH_CONTROL` without a depth target). - Enumerate `b[15]` in `[0, 1]` for the stencil-off loop in `depth_space` (+128 candidates, leaving the 2.5M stencil-on enumeration unchanged). ### Verification - `cargo test --locked -p victory-game` (17 passed, including new unit tests covering `depth_from_registers`, `depth_space`, and end-to-end `Named::find` + `stream` recovery of a depth-bounds-enabled graphics record with no databases) - `cargo test --locked -p victory` (18 passed) - `cargo clippy --locked -p victory-game -p victory --all-targets -- -D warnings` - `rustfmt --edition 2024 --check crates/victory-game/src/pipelines.rs` - `cargo xtask policy` (191 files ok)
`pipelines::depth_stencil_desc` already serializes compact depth-stencil
byte 15 into `D3D12_DEPTH_STENCIL_DESC1.DepthBoundsTestEnable` (used by
`victory-gpu` after #158), but both `depth_from_registers` and the
stencil-off fallback enumeration in `depth_space` always left byte 15 at
zero.

Decode `DB_DEPTH_CONTROL` bit 3 (`DEPTH_BOUNDS_ENABLE`) in
`depth_from_registers` (and try both `0` and `1` when the hardware depth
test bit is off, matching the existing depth-enable/write/func recovery),
and include `b[15] in [0, 1]` in the stencil-off `depth_space` fallback.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:27:19 +00:00
github-bot closed this pull request 2026-11-26 06:27:19 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 05:20 UTC · original

Note for maintainers: #3048 (stacked on #3047) also addresses b[15] recovery in depth_from_registers alongside b[14] and stencil fields (trying b[15] in 0..=1 even when DB_DEPTH_CONTROL bit 3 is clear). Happy to close this in favour of #3048 if the #3047/#3048 stack is preferred, or keep this as the standalone b[15] + depth_space patch.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 05:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/3040#issuecomment-7183401250) Note for maintainers: #3048 (stacked on #3047) also addresses `b[15]` recovery in `depth_from_registers` alongside `b[14]` and stencil fields (trying `b[15]` in `0..=1` even when `DB_DEPTH_CONTROL` bit 3 is clear). Happy to close this in favour of #3048 if the #3047/#3048 stack is preferred, or keep this as the standalone `b[15]` + `depth_space` patch.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 06:15 UTC · original

Automated triage for the maintainers.

The gap is real. In crates/victory-game/src/pipelines.rs, depth_from_registers and depth_space never set compact byte 15 (the depth-bounds test), so a state with it set cannot be named. Reading DB_DEPTH_CONTROL bit 3 as DEPTH_BOUNDS_ENABLE matches the public register layout. Two things stand in the way of merging it as is:

  • The decision rule rests on an assumption with no evidence behind it. When depth is on and bit 3 is clear, depth_from_registers tries only b[15] = 0. #3048 measured shaders.rpf and reports the opposite: several descriptions set b14/b15 while DEPTH_BOUNDS_ENABLE is clear, so it tries both values in every case. If that measurement holds, this PR still misses those states. Please give evidence for the rule (states from a shader pack it names that are otherwise unnamed), or try both values as #3048 does.
  • It overlaps #3048, which is stacked on #3047 and changes the same function with measured results. Only one approach should land. You already offered to step back in favour of #3048. The part #3048 does not cover is the depth_space enumeration of b[15]. If that is worth keeping, a rebase on top of #3048 with a pack measurement showing that it names something would make this a clear, separate change.

The tests use synthetic registers and a synthetic pack only, with no title data, which is fine.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 06:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/3040#issuecomment-7184243817) <!-- victory-triage v1 head=5130555f184bc4bc16704d3adf04bba80fa1ac83 verdict=needs-work at=2026-11-26T06:24:00Z --> Automated triage for the maintainers. The gap is real. In `crates/victory-game/src/pipelines.rs`, `depth_from_registers` and `depth_space` never set compact byte 15 (the depth-bounds test), so a state with it set cannot be named. Reading `DB_DEPTH_CONTROL` bit 3 as `DEPTH_BOUNDS_ENABLE` matches the public register layout. Two things stand in the way of merging it as is: - **The decision rule rests on an assumption with no evidence behind it.** When depth is on and bit 3 is clear, `depth_from_registers` tries only `b[15] = 0`. #3048 measured `shaders.rpf` and reports the opposite: several descriptions set b14/b15 while `DEPTH_BOUNDS_ENABLE` is clear, so it tries both values in every case. If that measurement holds, this PR still misses those states. Please give evidence for the rule (states from a shader pack it names that are otherwise unnamed), or try both values as #3048 does. - **It overlaps #3048**, which is stacked on #3047 and changes the same function with measured results. Only one approach should land. You already offered to step back in favour of #3048. The part #3048 does not cover is the `depth_space` enumeration of `b[15]`. If that is worth keeping, a rebase on top of #3048 with a pack measurement showing that it names something would make this a clear, separate change. The tests use synthetic registers and a synthetic pack only, with no title data, which is fine. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 06:26 UTC · original

Closing in favour of #3048 (stacked on #3047), which already covers b[15] in depth_from_registers unconditionally with measured shader-pack results.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 06:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/3040#issuecomment-7184430816) Closing in favour of #3048 (stacked on #3047), which already covers `b[15]` in `depth_from_registers` unconditionally with measured shader-pack results.

Pull request closed

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/Marvisak--VIctory!3040
No description provided.