startup: apply the decoded slot 57 depth-stencil state behind X2W_DEPTH_STATE #2161
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2169"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-25T02:36:12Z.
Refs #1999 (item A, second half)
Change
This applies the slot 57 depth-stencil decoder from #2124 to translated draws behind a new switch
X2W_DEPTH_STATE=1. The switch is off by default.translation_forind3d12_draw.inl. Wheninfo->path == 57, the pipeline has no depth-stencil state yet and the switch is on, block A is passed toread_depth_stencil_words/decode_depth_stencil. Slot 57 pipelines carry no desktopDEPTH_STENCILsubobject, so this block is the only thing that can sethas_depth_stencilthere; the check stays in place as a guard.pipeline_foruses the decoded state only when a DSV is bound. The binding already exists (slot 50, used bystartup_stream_depth), so item D is not needed for this part.draw_translatedsets it withOMSetStencilRefright afterSetPipelineState. That overrides any earlier titleOMSetStencilReffor the draw. Whether the console expects this order is not measured, and the docs say so.src/startup_stubs/depth_state_apply.h. The decoder itself is unchanged.startup_depth_stateand its controlstartup_depth_state_switch_control, which fails under--mutate switch;startup_stream_depth_*andstartup_slot57_blend_draw_*, which still pass.Test
New fixture
tests/startup_slot57_depth.cpp+tests/startup_slot57_depth_check.py. The same renderer runs on WARP and on hardware (skip 77 where none is available), with synthetic shaders and two overlapping triangles at z = 0.25 and z = 0.75:Mutations: each fails the fixtures.
rz_greaterdraws green instead of red.startup_pipeline_statealso fails.st_equal_hitdraws blue instead of green.Run on
7019d041, rebased on5d02dd37, with an NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), WARP 10.0.26100.9818 and Windows 11 build 26200:Not covered: raster state and depth bias (item B), depth bounds, back-face-only stencil state, interaction with a title
OMSetStencilRef, clears (#1806), and derived path 55 pipelines that inherit the state. The offsets 0xB8–0xC4 are #2124's and were not measured again.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:38:44Z.
Review: COMMENTED
Review of head
7019d041d3(comment only, no approval).Read:
depth_state_apply.h, thed3d12_draw.inlhunks, CMake wiring,git diff --stat origin/main...HEAD(8 files, +654/-3).Commands executed locally (Linux):
python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 402 links OK.python3 tests/bidi_controls_check.py: self-test passed, 1456 files, no bidi controls.git diff --check origin/main...HEAD: clean.g++ -std=c++17 -Isrc tests/startup_depth_state_check.cpp: cannot build here,d3d12.his missing on Linux. So the C++ tests and the--mutate switchcontrol were NOT run by me. I did not run a mutation of the new logic.gh pr checks 2169: Linux Python job passes. Windows build/test and gfx1013 jobs were still pending when I looked. I did not run a separate Win2025 job.Findings:
d3d12_draw.inl~1191): the decoded stencil reference is applied withOMSetStencilRefon every draw of that pipeline. It overwrites anyOMSetStencilRefthe title issued before. That matches the doc comment, but it is worth a line indocs/startup-runtime.mdthat the switch makes register state win over list state.d3d12_draw.inl~1191): the guardpass.dsv_format != UNKNOWN || bound->dsv_format != UNKNOWNrepeats thedsv_formatchoice made inpipeline_for(line 492). Both give the same result today. A shared helper would stop them drifting apart.static LONG loggedis shared by the applied and refused log paths, so 24 lines of one kind can hide the other. Only affects diagnostics.What looks right:
select_depth_stencilreturns nothing and the desktop state is unchanged.DepthStencilStateassignment agree.Not verified: the Windows/WARP result of
startup_slot57_depth_*andstartup_depth_state*. Please rely on the Windows CI job finishing green before Ready.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:58:37Z.
Review: COMMENTED
Review of head
3b184b31f6daf7b44c74c0d308382e0c156ffa46(2 commits on top of main).Verdict: no blockers found. Two small notes (P2) and one nit.
Checked locally (Linux)
git diff --stat origin/main...HEAD: 8 files, +662/-4.python3 tests/docs_links_check.py: pass (18 files, 402 links).python3 tests/bidi_controls_check.py: pass.git diff --check origin/main...HEAD: clean.python3 -I -m py_compile tests/startup_slot57_depth_check.py: ok.x86_64-w64-mingw32-g++ -std=c++17 -Isrc tests/startup_depth_state_check.cpp: compiles. I could not run the binary: wine here exits with code 53 for any binary, so no pass/fail result and no mutation result from me for the device-free test. The author's mutation table in the PR body (switch ignored, ZFUNC swapped, stencil ref not set) was not re-run by me.startup_slot57_depth_*) needs the Windows job to count.Read-through
depth_state_apply.his small and pure. Switch off returns the empty default before anything reads the block. Short block and decoder refusal both set a reason and apply nothing. Stencil ref is carried only whenStencilEnableis true. Matches the unit test cases.translation_for: guardinfo->path == 57 && !bound->has_depth_stencilis right. The desktop state is kept when the decoder refuses.pipeline_for: the PSO key hashes the depth desc only when it is actually used, so a no-DSV pass shares the default PSO. Good.startup_slot57_depthtarget and the tests are wired in CMake like the neighbouringstartup_stream_depth. The--mutate switchcontrol uses WILL_FAIL, likestartup_pipeline_state_offset_control.Findings
src/startup_stubs/d3d12_draw.inl(draw_translated, theOMSetStencilRefcall): the reference is list state and stays set after this draw. A later draw of a different pipeline that relies on an earlier titleOMSetStencilRefwill now see this value instead. The PR body and docs already say the order is unmeasured. Suggest a one-line note in the docs that the value is not restored, or restore it, so the next reader does not assume it is scoped.static LONGand capped at 24. Fine for a switch that is off by default. If the cap is hit, a later refusal reason is silent. Optional: log the reason once per distinct string.depth_boundsis reported in the log ("depth bounds not applied"). Consider anOMSetDepthBoundsfollow-up item in the docs, if not already listed.No clean-room or title concerns: the title is neutral, and the decoder cites register layout sources only.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-25T02:56:01Z.
@tedin7, the three nits are in
3b184b31:docs/startup-runtime.mdnow says that with the switch on, the register state wins over list state for the stencil reference.pass_dsv_format(bound, pass)helper now picks the depth format for both the pipeline key inpipeline_forand the stencil-reference guard indraw_translated.ctest --preset dev --no-tests=error -R '^startup_(depth_state|slot57_|stream_depth|pipeline_state)'passes 10/10 on WARP 10.0.26100.9818 and an RTX 3080 (32.0.16.2124), Windows 11 build 26200, includingstartup_slot57_depth_{warp,hardware}.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T03:25:55Z.
Resolved the CMake overlap with the depth-target tests and scoped the decoded stencil reference to the slot 57 draw. The next draw sees the saved guest reference, and a successful Reset starts at zero. The mixed-pipeline fixture observes both in pixel readback. The Windows Release selection passed 8/8 with WARP and RTX 4060 Laptop, zero skips. Rebuilding with just the restore removed made st_ref_restore draw blue instead of green on both backends.