D3D12.X: pipelines in two passes are drawn (console MS via DispatchMesh, VS+GS via Draw*) #215
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!215
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/215/head"
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?
@RemingtonWilcox on GitHub · 2026-11-23 21:09 UTC · original
two-pass-draws→main· +1250 −24 · 7 files · 1 commits · closed without mergingConsole mesh (NGG) and VS+GS pipelines are already translated into two passes at PSO creation
(
real::finish_two_pass: a compute pass writing one record per group + a pass-through mesh pipeline), but nothingran them.
graphics_boundtreated the mesh PSO as a PC pipeline and issuedDrawInstancedon it, and the consolelist's DispatchMesh was a stub. So every MS and GS draw of a title was dropped. Only the test harness
(
runner::mesh_draw_split) ran both passes.This runs them at draw time:
bind::two_pass: compute PSO + ABI root signature, io from the kept graphics root arguments, a record bufferof
groups · record_dwordsin the list's upload memory,Dispatch(groups), UAV barrier, then the mesh PSO andDispatchMesh(groups · mesh_groups_per_record).the PC order after RSSetShadingRate / RSSetShadingRateImage (#124 / #125), not seen in a title. The handler only
acts with a console mesh pipeline bound. Otherwise it logs the arguments and drops the call like the stub, so a
retail log will confirm or refute the slot.
DrawInstanced/DrawIndexedInstancedfirst run a generated vertex-fetch compute shader(
gpu::recomp::fetch, built at PSO creation from the input layout, elements matched to the ES's ISG1 by semantic).It fills
io[IO_GS_VERTICES]in window 0 from the bound vertex and index buffers, and then the two passes run overceil(prims / 21)groups.being sent to the driver. Indirect two-pass draws need a GPU-side bound on the record buffer (follow-up).
Tests without game data (
hle::d3d12x::two_pass_tests): a synthetic console MS container and a synthetic ES+GS pairgo through the real pipeline hooks. Draws are recorded through the console list's handlers on a list made as for a
title, and the target is read back and checked per pixel (MS: two groups' triangles, value = group; GS: both
triangles' parallelograms by DrawInstanced, and one through 16-bit indices at an odd offset by DrawIndexedInstanced).
Tested on RTX 3090 (driver 616.92, Windows 11):
cargo test --workspace -- --test-threads=2all green (library: 542 passed; every integration test binary passed; the retail-pack tests skip themselves withoutXCL_SAMPLE_RPF).AI-assisted (Claude Code).
🤖 Generated with Claude Code
@Kalmarv on GitHub · 2026-11-23 21:17 UTC · original
I checked this against #199 (rect lists through a generated GS), which touches the same three files, and merge-tested the two together. They don't collide in behaviour, and neither needs to change for the other. This PR does need a rebase on main, though.
Rebase needed (with main, not with #199). This branch starts from
38b05b7. On current main (6da33fa) it conflicts inbind.rs, where main changedbind_abiafter38b05b7.7495271made a compute shader take no more user SGPRs than it has:pso_user_sgprs,console_list::inline_for/user_data_for, with the wait for a background pipeline moved ahead of them. Your refactor moves that code intoabi_views+set_abi. To test the merge I resolved it like this:abi_viewskeeps main's argument logic and takes the pipeline (abi_views(this, pso, gfx, res, io_patch));bind_abipasses itspso;two_passpasses 0, since it calls withgfx = true, where main's user-SGPR limit doesn't apply.That resolution builds and passes everything below. When you rebase, please check that the two-pass compute pass should really get the graphics-side user data. That is unchanged from your branch.
With #199: no collision.
bind.rs,list_x.rsandreal.rsmerge without conflicts apart from the main conflict above. In the merged code:translated_gs_pso(your two passes) before #199 decides whether to add its rect-list GS. That decision is only for a translated VS+PS pipeline with no GS. So a GS pipeline never gets the generated GS, andreal::has_rect_list_gsis false for it.gs_drawruns first and returns for a two-pass GS pipeline, andgraphics_boundreturns None for a mesh pipeline. So main'sdraw_rects(the CPU rect expansion) and #199's skip in it never see either kind. That is right: expanding a rect on the CPU in front of a console GS would hand the GS two triangles where the console gives it one primitive.list_xstores 17 as TRIANGLELIST, sogs_drawaccepts it and gives the GS 3-vertex primitives. The GS output is drawn as it is, with no rect completion. That matches what AMD's drivers imply: PAL'sGraphicsPipeline::CalculateOutputNumVerticesaccepts only point, line and triangle output when a GS or mesh shader is present. This comes from driver source, not a measurement.Small notes, none blocking:
two_pass_tests::ready()returns early on a missing DXC, device, unified memory or mesh-shader tier, after aprintln!. That counts as a pass and doesn't go throughrunner::skip_test, soXCL_REQUIRE_GPUcan't turn a skip into a failure. Here both tests drew (no "skipping" in--nocaptureoutput).gpu_console_gs_pipeline_draws_through_draw_instancedwith topology 17, expecting the same image as with 4.Tested
7ac4048(on main6da33fa) + this PR at6904870, with theabi_viewsresolution above. Not pushed.cargo test -p xcl --lib -- --test-threads=2: 594 passed, 0 failed, 20 ignored. Two wave64 tests skip because this GPU has no 64-lane waves. Among the passes:gpu_console_gs_pipeline_draws_through_draw_instancedandgpu_console_mesh_pipeline_draws_through_dispatch_mesh; a separate--nocapturerun showed neither skipped;gpu_mesh_mode_two_passes.Not tested
6904870, and on top of main without #199.AI use: Claude Code, Claude Opus 5.5.
@srcamarda on GitHub · 2026-11-23 22:50 UTC · original
AMD run of
6904870merged ontomain9ab7d76, plus what a retail log says about slot #126, and a frame-rate regression with its cause.Merge: the same
bind.rsconflict @Kalmarv describes, resolved his way:abi_views(this, pso, gfx, res, io_patch);user_sgprs = if gfx { None } else { pso_user_sgprs(resolve_wait(pso)) };bind_abipasses itspso,two_passpasses 0;io_patchloop (main's root-signature binding lives inbind_abi/set_abihere).Tested
two_pass/fetchtests: 6 passed, includinggpu_console_mesh_pipeline_draws_through_dispatch_meshandgpu_console_gs_pipeline_draws_through_draw_instanced. NoSKIPPED.cargo test --workspace -- --test-threads=4: 655 passed, 0 failed, 40 ignored.XCL_SPLIT_WAVE64=1 cargo test -p xcl --lib: 615 passed, 0 failed.Slot #126 in a retail title: called once a frame, not DispatchMesh
On
mainthe title (the newer one in the README table) calls #126 once per frame: 1 291 stub calls in a run of 1 291 frames,[STUB] … ID3D12GraphicsCommandList10::#126 (not on PC) first called from main_game.exe+0x3263e. With this PR, the first calls log:The arguments look like addresses, not group counts, so here #126 is probably not DispatchMesh. This title's mesh pipelines are the "MS in the AS slot" ones
mainrefuses, so its draws never reach the two-pass path.The regression: 10–13 % fewer frames, from
dispatch_mesh'sresolve_waitscripts/smoke.ps1, 90 s,XCL_NETWORK=0, release. Each binary starts with a cold translation cache, then runs warm:main9ab7d76dispatch_meshnot waiting (below)No crash or device removal anywhere, and the same peak commit (~17.2 GB). Apart from the eight
DispatchMesh slot calledwarnings, the logs have the same messages in the same counts.The cause is
dispatch_mesh→bound_two_pass→pso_async::resolve_waiton whatever pipeline is bound at that call, once a frame. For a pipeline still in the background, it waits for it, or builds it on the title's render thread when no worker has started it.main's stub returned at once. A non-waiting check givesmain's frames back, and the PR's own tests still pass (6 / 6, lib 615 / 0):Trade-off: a real DispatchMesh issued while its mesh pipeline is still building is dropped for that frame instead of waited for. Your call whether that is acceptable, or whether the slot should first be confirmed in a title before it is hooked at all.
Regression run (
gpu:names a virtual display adapter here, but XCL ran on the RX 7800 XT). The second warm run of each binary, as printed by the script:main:this PR merged onto
main(local merge commit, no extra changes):Not tested
main).AI use
@MKS2508 on GitHub · 2026-11-23 23:14 UTC · original
Retail-title confirmation of the DispatchMesh slot, on a GPU without mesh shaders
Ran this branch's head (
6904870, built frompull/215/head) against a retail title(
game_scarlett_master.exe1.0.2.1) on AMD Radeon RX 5700 (RDNA1, no D3D12 mesh shaders),Windows 11, Rust 1.99.1, release build.
The slot is confirmed — the hook fires and the title calls it every frame:
So #126 is right from a real title, not only from the synthetic tests.
The bound pipeline is
0x0in every call: on this adapter the mesh PSOs are never created, so thecalls are dropped exactly as designed. That is not a defect of the branch — but it does mean the
branch cannot change what this GPU draws. The remaining gap for non-mesh adapters is on the PSO
creation side, not the draw hook.
Tested
cargo build --release -p xclat6904870600 frames presentedWARNING: no mesh shaders: the game's geometry and NGG programs are not drawnNot tested
DispatchMeshpairing itself is untested here.Draw*two passes) — this title's log shows no GS two-pass pipeline reaching that path.AI use
@grahamster2 on GitHub · 2026-11-24 00:17 UTC · original
I logged what the retail title does with its "mesh pipeline with its MS … in the AS slot – refused" pipelines (the minimap ones in HANDOFF). This bears on how this PR's console-MS draws would reach them. Before anyone writes code for it there is a design question, at the end.
What the streams hold (main
0e946cf+ local logging only, RTX 3080, driver 610.88, release build)(0,8) (24,16) (2,16) (3,16) (4,16) (5,16) (8,328) (9,4) (10,44) (21,56) (17,8) (12,16) (14,4) (15,36) (16,4)That is the order of a graphics desc (RS, VS, PS, DS, HS, GS, blend, …), but type 24 sits where the VS would be. There is no type 1 and no type 25, and the stream has an INPUT_LAYOUT (12) and a PRIMITIVE_TOPOLOGY (14). The container in 24 parses with stage
MS.xcl shaders shaders.rpf: 9,282 programs with DXIL stage MS (hardware stage NGG), 0 with stage AS.Translating them instead of refusing them (local env switch: the 24 container is passed on as the MS, through main's
translated_mesh_stream/ two passes)XCL_FRAME_DUMP=300). The title stays at its first-run menus in both:last_frame_dumpframe 3020 with 517,959 / 518,400 non-dark samples;So at the menus, translating them no longer blacks out the image on current main. Each of the 16 "console code so far" lines in each run shows 0 skipped draws and 0 draws with PC pipelines.
Design question: what is console subobject 24 here?
Until a world run shows the draw call, should main keep refusing them, or translate them as MS? The second is measured above as no change at the menus, but it isn't drawn yet. I'm not writing code for this until that's decided. I can rerun with this logging on top of this PR once it's rebased.
AI-assisted (Claude Code, Claude Opus 5.5): ran the logging build and the runs, and wrote this comment. The numbers come from those runs.
Pull request closed