Skip to content

help wanted: GPU translation, part 3 (render state and indirect draws) #1999

Backlog

Description

@denn0x

The startup runtime draws translated pipelines with a default fixed-function state. Once more geometry is drawn (ExecuteIndirect #1759, mesh programs #1760), the picture depends on the state the console pipeline itself carries. These pieces are independent; each can be one pull request with a source-built fixture.

Pieces (pick one, say so in a comment)

Item Piece Notes
A Decode depth / stencil state from the pipeline register block and apply it to the desktop pipeline state Depth enable, write enable, compare function (including reversed-Z use of GREATER), stencil ops. Behind a switch that is off by default until a run has exercised it.
B Decode rasteriser state: cull mode, front-face winding, polygon offset Same pattern.
C Command-list depth-stencil clear The call is a no-op in the stand-in today, so a depth test would fail everywhere after the first frame.
D Depth-stencil target binding for translated draws Check that a bound depth target reaches the desktop command list together with the colour targets, including depth-only passes (no colour target, no pixel stage). On WARP a mesh pipeline without a pixel stage removed the device in a local test, so that case needs a hardware fixture or a capability skip.
E Indirect Draw / DrawIndexed with console-only primitive topologies Rect lists and other topologies without a desktop equivalent need a conversion step that works with GPU-written argument buffers. Extends #1759 / #1909.
F Render-target variants for pixel stages that write integer or 32-bit float targets A pixel stage translated for a four-channel UNORM target cannot be bound to an integer target without a variant.

What a pull request needs

  • A source-built fixture with pixel or depth read-back on WARP (and on hardware where WARP cannot run it, reported separately), plus a negative control that fails when the piece is disabled.
  • Default behaviour unchanged when the switch is off; say how that was checked.
  • The register fields cited from the public gfx10 register headers (Mesa) in the commit message.

Where this comes from

Observed on a private executable (no bytes, keys, addresses or logs can be shared): with the default state, the geometry that does draw appears unordered and untextured, and most indirect draws are refused for their topology.

Related: #1759, #1760, #1909, #1916.

Activity

  1. changed the title [-]help wanted: fixed-function state, depth clears and indirect-draw topologies for translated pipelines in the startup runtime[/-] [+]help wanted: GPU translation, part 3 (render state and indirect draws)[/+] on Nov 24, 2026
  2. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    Item C already has an implementation in #1806. Please continue there, with the remaining check focused on restoring the bound read-only DSV and preserving the command-list state. Item D can still be taken separately. A useful first slice is one source-built raster pass with a bound depth target plus a second pass whose result changes when the depth binding is omitted. Check pixels and debug-layer messages after the fence. Keep depth-only mesh as a follow-up if its adapter capability differs, and report a capability skip separately. Item E can build on the landed desktop record fixtures in #1759 and should keep a console-topology conversion and its negative control distinct.

  3. JB2WIN commented on Nov 24, 2026

    @JB2WIN
    Contributor

    I'll take item A, depth/stencil state, starting with the decode. Today stream_translation (d3d12_draw.inl) copies only a desktop DEPTH_STENCIL/DEPTH_STENCIL1 subobject from the pipeline stream. First I'll find where the console pipeline carries its register block in the stand-in. Then I'll decode DB_DEPTH_CONTROL (Z enable and write, the compare function including GREATER, stencil enable and functions) plus DB_STENCILREFMASK from the field layout in Mesa's public gfx10 register headers, and apply it behind a switch that is off by default. Evidence will be a WARP fixture with depth readback, together with a negative control where the switch is off. If the register block turns out not to be reachable from the stand-in, I'll report that here instead of guessing.

    AI-assisted (Claude Code).

  4. added a commit that references this issue on Nov 24, 2026
  5. JB2WIN commented on Nov 24, 2026

    @JB2WIN
    Contributor

    Item A, first finding. Nothing is built yet, because the register offset would have to be guessed.

    • Where the block comes from. Slot-57 pipelines carry two raw state blocks, state_a and state_b, copied from title memory at creation (d3d12_capture.inl:22, :118, :120).
    • What is known about its layout. The only measured position is the eight CB_BLENDn_CONTROL words at +0xD0 in block A (startup-runtime: decode colour-blend registers into the desktop blend state #1216, state_block_blend.h). No DB_* register (DB_DEPTH_CONTROL, DB_STENCIL_CONTROL, DB_STENCILREFMASK) is documented or measured anywhere in the repository, and it is not established that the blocks carry them at all.
    • Existing logging. d3d12_draw.inl:365-370 already logs the first 0x1a0 bytes of both blocks for the first 24 pipelines when no blend is found.

    Has anyone located the DB words in block A or B, as #1216 did for blend? If not, I'll measure it locally from my own run, using that existing hex log, and match the words against Mesa's gfx10 field layouts. Only the offsets and the field interpretation would go into the PR, never the bytes. Until then the decode would rest on an assumed offset, which item A shouldn't.

    AI-assisted (Claude Code).

  6. denn0x commented on Nov 24, 2026

    @denn0x
    CollaboratorAuthor

    Yes. The depth-stencil and rasteriser registers were located locally in block A, next to the CB_BLENDn_CONTROL words from #1216. A decoder now exists in a local build:

    • Decoded: DB_DEPTH_CONTROL, DB_STENCIL_CONTROL, DB_STENCILREFMASK(_BF), PA_SU_SC_MODE_CNTL (cull, face, polygon offset enables) and the polygon offset scale and offset words. Field layouts follow Mesa's gfx10 register JSON.
    • Behind switches, all off by default: it is applied to translated draws, and command-list ClearDepthStencilView is forwarded.
    • Aggregate over about 25,000 pipeline state sets from a private executable: depth tested in just over half of them (almost all of the mesh pipelines), reversed-Z GREATER_EQUAL the most common compare, back-face culling the most common cull mode, and no word the decoder has to refuse.

    To avoid two implementations, I'd suggest splitting it:

    • Mine: a PR with the pure decoder and a device-free check that uses hand-made register words, plus a negative control for a shifted offset.
    • Yours, if you want it: the WARP depth-readback fixture with the switch on and off, applying the decoded state to stream_translation.

    Does that work for you? If you'd rather do the whole item, I'll post the word positions here instead.

  7. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The split in the latest reply is a good fit. Please keep the pure depth/stencil decoder and its source-built register-word controls together. Link that PR here so the existing item A claimant can build the real draw fixture on the same decoder interface.

    For the draw fixture, use synthetic shader inputs and two overlapping triangles with unequal depths. Show the expected winner with reversed-Z and the different result with the switch disabled or the compare direction intentionally wrong. Check the stencil result separately with a known reference and include the original desktop state fallback. Reuse the same renderer on WARP and hardware. Keep raster bias and extra forwarding cases in their existing scope so either part can be reviewed independently.

  8. denn0x commented on Nov 25, 2026

    @denn0x
    CollaboratorAuthor

    The decoder offered above is up as #2124: the pure depth-stencil decode from the slot 57 state block plus a device-free check with a shifted-offset control. It does not apply the state to draws and adds no read-back fixture, so item A's WARP fixture and the application in stream_translation remain open for the claimant. Rasteriser state (item B) is not in it.

  9. JB2WIN commented on Nov 25, 2026

    @JB2WIN
    Contributor

    Thanks, @denn0x. I'll build item A's application and the draw fixture on top of #2124's decoder interface, as described above:

    • two overlapping triangles with unequal depths and synthetic shader inputs;
    • the reversed-Z winner, plus the different result with the switch off or the compare direction wrong;
    • a separate stencil check against a known reference;
    • the original desktop-state fallback;
    • the same renderer on WARP and hardware.

    I'll start once #2124 has settled, so the interface doesn't move underneath.

    AI-assisted (Claude Code).

  10. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The slot 57 decoder is on main via #2124 (f475217). I independently compiled it with MSVC /O2, checked all 35 synthetic assertions, and confirmed the shifted-offset counterexample failed. The original bit fields match the Mesa gfx10 register table. The item A draw claimant can now build against this header. Its depth-bounds and unequal front/back flag states still need an explicit fallback or refusal in that integration; the decoder alone does not apply them to draws.

  11. tedin7 commented on Nov 25, 2026

    @tedin7
    Collaborator

    Picking up Item D (depth-stencil target binding for translated draws, including depth-only) and Item F (integer / 32-bit float render-target variants) as two separate PRs with D3D12 WARP readback tests.

  12. tedin7 commented on Nov 25, 2026

    @tedin7
    Collaborator

    Update: Item D appears already covered on main via #1430 (slot 50 DSV bind) and tests/startup_stream_depth_check.py, so we are skipping Item D and continuing only with Item F.

  13. 30 remaining items

  14. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The rectangle-list indirect Draw path landed in #2173 (214ed093). The Windows fixture compares a full image on WARP and RTX 4060 Laptop, including distinct scratch for concurrent submissions. The shared-scratch mutation was detected, and a live compute root binding is still refused. This covers the rectangle-list conversion; the other draw families and title-side evidence remain open here.

  15. RavenCurseBurg commented on Nov 25, 2026

    @RavenCurseBurg
    Contributor

    I will measure the narrow RGBA8 integer targets left open by #2148, formats 30 (UINT) and 32 (SINT). The source-built fixture will use distinct in-range and out-of-range channel words, compare saturation with low-byte truncation, and verify the independently typed UNORM target. I will report FXC/DXC on WARP and RTX 4060, with an explicit distinction between the translated desktop result and native guest hardware.

  16. RavenCurseBurg commented on Nov 25, 2026

    @RavenCurseBurg
    Contributor

    The RGBA8 measurement is complete; implementation and regression tests are in #2378. I compared translated pixel shaders with independently compiled typed HLSL on local RTX 4060, local WARP, and Windows Server 2025 WARP, using FXC and DXC for each. All 36 comparisons matched the saturated CPU reference on the integer target and ff0000ff on the simultaneous UNORM target.

    Input channel words (hex) UINT bytes SINT bytes Low eight bits
    ffffffff ffffff80 00000080 00000100 ffff80ff ff807f7f ff808000
    ffffff7f 0000007f 00000002 000000fe ff7f02fe 807f027f 7f7f02fe
    00000000 00000001 0000007f 00000042 00017f42 00017f42 00017f42

    The source-built comparison and hosted WARP debug-layer results are public. The evidence establishes desktop output-merger behavior on these two views. Native console readback is still outstanding.

  17. RavenCurseBurg commented on Nov 25, 2026

    @RavenCurseBurg
    Contributor

    I’ll take a stream-path winding follow-up for item B now that #1567 has landed. Its synthetic triangle distinguishes front from back culling, but its test currently accepts either ordering of the two images and always sets FrontCounterClockwise to false. I’ll check the exact 8×4 image for each cull direction, toggle the winding bit on both RASTERIZER and RASTERIZER1, and verify the test detects a swapped cull or ignored winding field. This exercises the translated slot-86 stream in addition to the desktop reference from #2260.

  18. RavenCurseBurg commented on Nov 25, 2026

    @RavenCurseBurg
    Contributor

    For item F I’m measuring the remaining narrow integer RTVs together after #2378: single- and two-channel 8/16-bit views, RGBA16, and the mixed-width R10G10B10A2_UINT view. I’ll compare source-built exports with independently compiled typed HLSL, check the destination bytes and simultaneous UNORM target, and distinguish per-channel saturation from discarded high bits. I’ll record any unsupported view or adapter separately before proposing changes.

    Completed in #2392. All 198 translated/direct comparisons matched, including 132 where the low-bit shader gave different bytes; the remaining 66 were in-range controls. The exact PR head passed all three focused Windows Server WARP tests, with 22 narrow-target readbacks across FXC and DXC. Independent measurement and exact-head tests.

  19. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The item B stream winding follow-up landed in #2387 (a4900150). My Windows Release run passed 4/4 on WARP and RTX 4060 Laptop with the debug layer enabled. The fixture checked all 32 pixels with both cull directions, both windings, and both rasterizer subobject types. Build startup_stream_rasterizer, then run ctest --preset release --no-tests=error -j 1 -R '^startup_stream_rasterizer(_ignore)?_(hardware|warp)$' -V. Item F stays open for the remaining typed views you are measuring.

  20. denn0x commented on Nov 25, 2026

    @denn0x
    CollaboratorAuthor

    On item B and the question about the PA_SU_SC_MODE_CNTL word index: I've put up the decode logic only, in #2480.

    • What it does: a pure function turns a PA_SU_SC_MODE_CNTL value into D3D12 cull, front-face winding and fill mode, and refuses the forms D3D12 can't express. It comes with a device-free synthetic fixture and three wrong-field controls.
    • What it leaves out: where a slot 57 pipeline keeps that word. The index we use locally is our own measurement and has not been independently established, so following the guidance above, we are not publishing it. The caller passes the register value in. Once the location is established independently, the slot 57 integration can feed this function from it.
    • Winding: FACE 0 is taken as counter-clockwise front, as in radeonsi. The function also takes a flip_winding switch, because that convention is not established against the D3D12 viewport.
    • Polygon offset: left as a separate slice.
  21. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The standalone PA_SU_SC_MODE_CNTL decoder landed in #2480 (53a7d10e). Its four Windows Release checks cover cull, fill and winding, including the invalid-mode controls. Item B still needs independent evidence for where the runtime record stores the word and which winding the viewport requires. A source-built front/back pair with a swapped-winding negative control can separate those two questions before wiring the decoder into slot 57.

  22. added
    priority: P0
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: P0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions