Repository navigation
D3D12.X: pipelines in two passes are drawn (console MS via DispatchMesh, VS+GS via Draw*) - #215
RemingtonWilcox wants to merge 1 commit into
Conversation
…sh, VS+GS via Draw*) Console MS (NGG) and VS+GS pipelines were translated into two passes at PSO creation, but nothing ran them: draws sent DrawInstanced to the driver with a mesh PSO bound, and the console list's DispatchMesh was a stub. - bind::two_pass: compute PSO + ABI root signature over the kept graphics root arguments, record buffer in the list's upload memory, Dispatch, UAV barrier, then the mesh PSO and DispatchMesh(groups * mesh_groups_per_record). - MS: console list ivall#126 (ivall#128 on the newer layout) hooked as DispatchMesh, inferred from the PC order after RSSetShadingRate(Image) at ivall#124/ivall#125; it acts only with a console mesh pipeline bound, otherwise logs its arguments and drops. - GS: DrawInstanced / DrawIndexedInstanced run a generated vertex fetch (gpu::recomp::fetch, built at PSO creation from the input layout) into window 0, then the two passes. - Draw* with a mesh pipeline and ExecuteIndirect with a two-pass pipeline are skipped and logged instead of reaching the driver. - GPU tests without game data: synthetic MS and ES+GS containers through the real pipeline hooks, drawn through the console list handlers, read back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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 in
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.
Small notes, none blocking:
Tested
Not tested
AI use: Claude Code, Claude Opus 5.5. |
|
AMD run of Merge: the same
Tested
Slot #126 in a retail title: called once a frame, not DispatchMeshOn 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 The regression: 10–13 % fewer frames, from
|
| build | cold | warm | warm |
|---|---|---|---|
main 9ab7d76 |
1 129 | 1 164 | 1 100 |
| this PR (merged) | 814 | 1 032 | 961 |
| this PR without the #126 / #128 entries | 974 | 1 218 | 1 164 |
this PR, dispatch_mesh not waiting (below) |
1 258 | 1 158 | 1 071 |
No crash or device removal anywhere, and the same peak commit (~17.2 GB). Apart from the eight DispatchMesh slot called warnings, the logs have the same messages in the same counts.
The cause is dispatch_mesh → bound_two_pass → pso_async::resolve_wait on 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 gives main's frames back, and the PR's own tests still pass (6 / 6, lib 615 / 0):
pub(super) unsafe extern "system" fn dispatch_mesh(this: *mut c_void, x: u32, y: u32, z: u32) {
- let Some((real, tp)) = bound_two_pass(this).filter(|(_, tp)| tp.kind == "MS") else {
+ // not `bound_two_pass`: a title calls this slot once a frame with other pipelines bound, and
+ // `resolve_wait` would wait for (or build here) a pipeline still in the background; one still
+ // being built is not known to be a mesh pipeline yet and the call is dropped, as by the stub
+ let real = super::pso_async::resolve(with(this, |s| s.pso));
+ let Some((real, tp)) = super::real::two_pass_of(real).map(|tp| (real, tp)).filter(|(_, tp)| tp.kind == "MS") else {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:
xcl-smoke v1
commit: 9ab7d763197c7f420bff10cd9bf1310f07e2a9aa
gpu: SudoMaker Virtual Display Adapter
title: main_game.exe
seconds: 90
exit: 0x0
frames shown: 1164 (PresentX 1164)
presents per 2 s (last 3): 25 25 24
device removals: 0
crashes: 0
peak commit: 17183 MB
this PR merged onto main (local merge commit, no extra changes):
xcl-smoke v1
commit: 9b12bbfa39032e64d7df1a6accc52abf40bf3e78
gpu: SudoMaker Virtual Display Adapter
title: main_game.exe
seconds: 90
exit: 0x0
frames shown: 1032 (PresentX 1032)
presents per 2 s (last 3): 26 25 24
device removals: 0
crashes: 0
peak commit: 17189 MB
Not tested
- A title whose MS / GS draws reach the two passes; NVIDIA; the PR's head on its own (only the merge with
main). - The two experiment builds ran with uncommitted changes on top of the merge, so their smoke blocks are not pasted.
AI use
- Claude Code with Claude Opus 5.5: resolved the merge, ran the tests and the smoke runs, found the cause by the two builds above, wrote this report.
|
Retail-title confirmation of the DispatchMesh slot, on a GPU without mesh shaders Ran this branch's head ( 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 Tested
Not tested
AI use
|
|
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
Translating them instead of refusing them (local env switch: the 24 container is passed on as the MS, through main's
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. |
Console 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 (MS and GS programs translate with the title's memory windows #124 / Revise factual report on ivall/xcl project status #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