d3d12_xs: depth, stencil and raster state for slot 57 native pipelines from state blob A (RT-SLOT57-DEPTH-RASTER) #1691
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1691
Loading…
Reference in a new issue
No description provided.
Delete branch "rt-slot57-depth-raster"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: RT-SLOT57-DEPTH-RASTER (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156345815)
Depends on: #1671, #1592
This builds on #1671: same functions in
runtime/shims/d3d12_xs_native_pso.handruntime/src/native_pso.h. Its commits are the first five here and drop out once it merges. #1592 has the same one-line#includeconflict as #1671. The real-boot test also used #1558 and #1547 to get past the landing screen on NVIDIA; this change doesn't need them.What and why
The slot 57 native factory built every PSO with depth
ALWAYSplus writes (wherever there was a DSV), no stencil, no culling and depth clip on. State blob A carries the real state in RDNA2 registers beside the blend registers #1671 decodes (vertex-pipeline offsets, +84 in mesh pipelines). Measured over all 25,471 graphics records of 1.0.2.1:+0xb8DB_DEPTH_CONTROL:Z_ENABLEis clear in 7,040 of 7,079 records;STENCIL_ENABLEis set only with stencil formats;GEQUAL(reversed depth).+0xbcDB_STENCIL_CONTROL: onlyKEEP,REPLACE_TEST,ADD_WRAP(operand 1),ZEROandINVERTare used.+0xc0/+0xc4DB_STENCILREFMASK(_BF): the two faces have equal masks in every stencil record.+0xa0PA_SU_SC_MODE_CNTL: no culling in 13,534 records, back faces in 11,873, front faces in 62.+0x9cPA_CL_CLIP_CNTL: D3D clip space in every record, and both z clips off (depth clamp) in 960.The layouts and counts are in
docs/fspx.md. Aggregate counts only; no blob bytes are quoted.runtime/src/native_pso.h:decode_state_a_depth_rasterreads the registers. It shares the shape and tag check with the blend decode.d3d12_depth_rastermaps them to D3D12. The compare functions are shifted by one. The stencil ops map as follows, with the adding ones only for an operand of 1:REPLACE_TEST→REPLACE;ADD_WRAP→INCR,ADD_CLAMP→INCR_SAT, and the subtracting ones likewise;ZERO,INVERTandKEEPmap to themselves._BFfields underBACKFACE_ENABLE. Cull comes fromCULL_FRONT/CULL_BACK,FrontCounterClockwise = !FACE, andDepthClipEnableis off when both z clips are off.runtime/shims/d3d12_xs_native_pso.h:fill_depth_raster_stateapplies the mapping to both the VS and the mesh paths. A pipeline without a DSV keeps depth and stencil off.Not built, falling back to today's defaults (logged):
None of these occurs in 1.0.2.1: a Python mirror of these rules maps all 25,471 records.
Out of scope: depth bias (
PA_SU_POLY_OFFSET_*), because its D3D12 units depend on the depth format.runtime/test/native_pso_depth_test.cpp(portable, standard library only): register reads for both families, every mapping above, and each refused form.What a real boot can and can't show. The first-run pages and the loading slideshow are drawn without a DSV, so this change must not alter them, and it doesn't. The 3D pipelines it changes only draw once a world frame is reached, which no build has yet. The one field whose effect isn't visible before then is the winding:
FACEmaps toFrontCounterClockwise = !FACE, as RADV and PAL program it.Tested
main+ #1558 + #1547 + #1671 + this branch, fresh first-run profile, factory on.native_pso_depth,native_pso_blend,xs_proxy_mockandxbox_native_base_drawpass.GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 591.59 (32.0.15.9159), Windows 11
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase). It's stacked on #1671, as stated above.docs/design.md, with how it was confirmed. (Not a translator change; the measurement is indocs/fspx.md.)🤖 Generated with Claude Code
@kawaii-shakal thanks for checking the decode. The counts, over all 25,471 graphics records of 1.0.2.1:
STENCILTESTVAL(+0xc0and+0xc4bits 7:0) is 0 in all 6,213 stencil-enabled records, front and back. So the reference always comes from the title (OMSetStencilRef), and leaving it out of the PSO loses nothing here. I'll note it indocs/fspx.md.POLY_OFFSET_FRONT_ENABLEandPOLY_OFFSET_BACK_ENABLE(bits 11 and 12) are set in all 25,471 records, so they don't tell which pipelines use a bias. The values look like the floats at+0xac/+0xb0, which fit the offset scale and offset: both 0 in 23,987 records, and nonzero in about 1,480 (for example 0.003 / 29.0 in 746, 0 / 16.0 in 631). That's the count a depth-bias follow-up should start from, together with the unit conversion for each depth format.AI-assisted.
Tested as part of the #1671 + #1691 + #1703 stack (188207a9d) on
mainbcaa13dad, in a real boot on an RTX 5070 Ti (NVIDIA 617.42, Windows 11). Menu text renders as glyphs instead of solid blocks, and no pipeline is refused. Details: https://github.com/ubiquitarianism/leonida/pull/1671. AI-assisted (Claude Code, Claude Opus 5.5).Merged, after #1703. Thank you, @OreoFR, and thanks to @kawaii-shakal for the stencil-reference and depth-bias questions and the real boot, and to @MoonEyes for the independent pass.
D3D12_DEPTH_STENCILOP_DESC, ref/mask fields,BACKFACE_ENABLE, cull, and both z clips off →DepthClipEnable = FALSE. All correct, on both the vertex and the mesh paths.FrontCounterClockwise = !FACEis the one field a frame hasn't confirmed yet, and the PR says so. Worth checking first once a world frame draws.CLIP_DISABLE(bit 16) andDX_RASTERIZATION_KILL(bit 22) inPA_CL_CLIP_CNTL, or note that they are clear in all records.mainwith #1703 + this branch: nothing goes from pass to fail;native_pso_depthpasses on both.main77baf9062+7a769396d: it merges cleanly; the semantic suite passes (489 files, 6,288 tests, 0 files failed); the 14 docs and writer tests pass;check_no_game_data.pyis clean on the 5 changed files.AI-assisted (Claude Code, Claude Opus 5.5).