startup: decode slot 57 depth-stencil registers into a desktop state #2116

Merged
denn0x merged 1 commit from upstream-pr/2124 into main 2026-11-25 01:12:15 +00:00
denn0x commented 2026-11-25 00:54:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T00:54:02Z.


Refs #1999

This is the decoder and device-free check offered for item A on #1999. The WARP depth read-back fixture and applying the decoded state to translated draws are left to the item A claimant.

State block A of a slot 57 pipeline holds the depth-stencil register words before the CB_BLENDn_CONTROL words of #1216:

Offset in block A Register
+0xB8 DB_DEPTH_CONTROL
+0xBC DB_STENCIL_CONTROL
+0xC0 DB_STENCILREFMASK
+0xC4 DB_STENCILREFMASK_BF

The positions were measured locally; no captured bytes are included. Other pipeline layouts are not covered.

src/startup_stubs/pipeline_state_decode.h is a pure header:

  • read_depth_stencil_words reads the four words and refuses a block that is too short.
  • decode_depth_stencil returns a D3D12_DEPTH_STENCIL_DESC and the stencil reference, using the field layouts and enumerations of Mesa's src/amd/registers/gfx10.json (MIT). CompareFrag maps in order onto D3D12_COMPARISON_FUNC. STENCIL_REPLACE_TEST maps to REPLACE, and the add / subtract ops map to INCR(_SAT) / DECR(_SAT) only when STENCILOPVAL is 1.
  • Refused, with a reason: stencil ops without a D3D12 form (ONES, REPLACE_OP, the logic ops, add or subtract by other than one) and colour writes tied to the depth result (DB_DEPTH_CONTROL bits 30-31).
  • Flagged, not applied: DEPTH_BOUNDS_ENABLE, and back-face masks or a back-face reference that differ from the front (D3D12 has one of each).
  • A disabled depth or stencil test gets a canonical description, so equal states give one pipeline.

Nothing in the draw path uses the header yet.

New test tests/startup_pipeline_state_check.cpp, registered as startup_pipeline_state in CMakeLists.txt and described in docs/startup-runtime.md. It decodes hand-built register words for each compare function, each stencil op with a D3D12 form, the refusals and the flags, and a synthetic block. Negative control (WILL_FAIL): startup_pipeline_state_offset_control places the words one word later in the block.

Verification (branch head 97223879 on main 246a875d, Windows 11 Pro 10.0.26300, MSVC 14.50, Visual Studio 18 Build Tools):

cmake --preset dev
cmake --build --preset dev --target startup_pipeline_state_check startup_state_block_blend_check
ctest --preset dev --no-tests=error -R '^startup_(pipeline_state|state_block_blend)'
  • 100% tests passed, 0 tests failed out of 3. The check prints 0 of 35 checks failed; the offset control reports 2 of 35 checks failed, as expected.
  • python -B tests/docs_links_check.py -> Checked 18 Markdown files and 395 links.
  • git diff --check main..HEAD -> clean.
  • Not run: no device, no draw. The decoder is checked on synthetic words only.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6594600737 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2124). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T00:54:02Z. --- Refs #1999 This is the decoder and device-free check offered for item A on #1999. The WARP depth read-back fixture and applying the decoded state to translated draws are left to the item A claimant. State block A of a slot 57 pipeline holds the depth-stencil register words before the `CB_BLENDn_CONTROL` words of #1216: | Offset in block A | Register | |---|---| | +0xB8 | `DB_DEPTH_CONTROL` | | +0xBC | `DB_STENCIL_CONTROL` | | +0xC0 | `DB_STENCILREFMASK` | | +0xC4 | `DB_STENCILREFMASK_BF` | The positions were measured locally; no captured bytes are included. Other pipeline layouts are not covered. `src/startup_stubs/pipeline_state_decode.h` is a pure header: - `read_depth_stencil_words` reads the four words and refuses a block that is too short. - `decode_depth_stencil` returns a `D3D12_DEPTH_STENCIL_DESC` and the stencil reference, using the field layouts and enumerations of Mesa's `src/amd/registers/gfx10.json` (MIT). `CompareFrag` maps in order onto `D3D12_COMPARISON_FUNC`. `STENCIL_REPLACE_TEST` maps to `REPLACE`, and the add / subtract ops map to `INCR(_SAT)` / `DECR(_SAT)` only when `STENCILOPVAL` is 1. - Refused, with a reason: stencil ops without a D3D12 form (`ONES`, `REPLACE_OP`, the logic ops, add or subtract by other than one) and colour writes tied to the depth result (`DB_DEPTH_CONTROL` bits 30-31). - Flagged, not applied: `DEPTH_BOUNDS_ENABLE`, and back-face masks or a back-face reference that differ from the front (D3D12 has one of each). - A disabled depth or stencil test gets a canonical description, so equal states give one pipeline. Nothing in the draw path uses the header yet. New test `tests/startup_pipeline_state_check.cpp`, registered as `startup_pipeline_state` in `CMakeLists.txt` and described in `docs/startup-runtime.md`. It decodes hand-built register words for each compare function, each stencil op with a D3D12 form, the refusals and the flags, and a synthetic block. Negative control (`WILL_FAIL`): `startup_pipeline_state_offset_control` places the words one word later in the block. Verification (branch head `97223879` on `main` `246a875d`, Windows 11 Pro 10.0.26300, MSVC 14.50, Visual Studio 18 Build Tools): ```powershell cmake --preset dev cmake --build --preset dev --target startup_pipeline_state_check startup_state_block_blend_check ctest --preset dev --no-tests=error -R '^startup_(pipeline_state|state_block_blend)' ``` - `100% tests passed, 0 tests failed out of 3`. The check prints `0 of 35 checks failed`; the offset control reports `2 of 35 checks failed`, as expected. - `python -B tests/docs_links_check.py` -> `Checked 18 Markdown files and 395 links.` - `git diff --check main..HEAD` -> clean. - Not run: no device, no draw. The decoder is checked on synthetic words only. AI-assisted.
upstream-sync closed this pull request 2026-11-25 02:01:50 +00:00
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
R0Y00/Xbox2Windows!2116
No description provided.