d3d12: give mesh pipelines the resource index map #390
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/390"
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 brcly/TuxBox. Originally posted by MathiewMay on 2026-11-28T09:20:18Z.
Draft: this can expose a GPU hang in ProjectScarlett that I have not solved. With this change the game runs its terrain mesh draws, which
mainskips. In three of my runs, all with #386, the GPU then hung on the same draw: the first draw of the terrain pass whose packed root constant is non-zero (0xb8…), mesh programMS_VS_TransformTerrainNormalTint, one group. RADV reported no memory fault, only a hard recovery. Two other runs, of 30 and 7 minutes, did not hit it. I am tracing that draw's inputs and will update this.Summary
Under descriptor paging, a mesh pipeline whose root indexes the resource heap directly (
CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED) got no index map:mesh_table::reflectedsetindex_map: None. Its draws were then skipped as having no paged descriptor layout. In ProjectScarlett every run that reached the first cinematic skipped such work from there on, up to #2048 logged per run.mesh_table::reflectedappends the map's root SRV (t0, space32766, all stages) when the root indexes the heap directly and the map's two DWORDs still fit after the pixel stage's mirrored tables (RootSig::heap_index_map_fits, the same 62-DWORD rulecompute_tableapplies to compute and raster roots).rootsig::append_heap_index_map,rootsig::with_index_map,shader_cache::mesh_stage,mesh_pixel_request,mesh_link_source). The request is derived from the one on the declared root rather than rebuilt: other parts keep their bytes and directory order, and only the root changes. So the requests a launch recorded can be prepared offline byte for byte.stream.rslogs it. A failed pipeline would end ProjectScarlett instead.Merge #386 first. In game, ProjectScarlett's first mapped mesh draws faulted the GPU at their root SRV plus
0xFFFFEF70(runs C6j and C6m). That was the masked-lane raw load #386 fixes: the draws this change stops skipping run into it.In game I tested this on an older
maintogether with other fixes of mine, #386 among them, not on this branch alone. One run translated 5,904 mesh and 6,176 pixel programs with the map appended (compiled live, as new requests), and with all my fixes a 30-minute run had no fault.Tested
No GPU test of the new path. Lanes has console compute and vertex programs that index the heap directly (
compute-heap-stride,raster-heap-stride), but no console mesh or pixel program in a mesh pipeline that does, and I have not written one. The rewriting of roots and requests is covered by three unit tests inruntime/dxbc/src/tests/rootsig.rs:appended_heap_map_keeps_guest_bindings_and_sampler_words: version 1.0 and 1.1 roots keep their parameters, samplers and flags, and gain the map as the last parameter.heap_map_budget_includes_pixel_mirrors_and_every_parameter_kind.index_map_requests_replace_only_the_root_and_keep_the_directory_order.The GPU suites below include every mesh gate (
d3d12-mesh,lanes-selftest-mesh-signature,lanes-mesh-samplers,lanes-mesh-sampler-single,lanes-mesh-sampler-rootless), which check that mesh pipelines without such a root are unchanged.GPU, driver and backend: AMD Radeon RX 9070 (1002:7550, RADV GFX1201), Mesa 26.2.7, Linux 7.3, GE-Proton11-14 (
--backend proton).Commands run and their results:
The D3D12 controls ran with the tool's own case table, staging and
validate, but outside its Bubblewrap/xvfb-runsandbox, which stalls on this machine (it has no Xvfb).Checks
No evidence JSON changes.
Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-29T23:33:41Z.
I can test this on an RX 9070 XT (
1002:7550, RDNA 4, RADV / Mesa 26.3.1, GE-Proton11-14) once it's rebased, including whether theMS_VS_TransformTerrainNormalTinthang reproduces on RDNA 4.A trial merge onto current
main(f360038d) conflicts inmesh_table.rsandstream.rs. Since this branch,mainappends the pixel stage's heap write bitmap parameter to mesh roots and to the pixel root. That parameter competes with the index map for the 64-DWORD root budget. A pixel stage translated on the declared root with only the map appended would also not write that bitmap. I didn't try to resolve it myself.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T00:02:23Z.
@MathiewMay @Kayotic1337 we've been carrying a resolved copy of this in our game builds; here it is as a clean branch, in case it saves you the rebase:
d3d12/mesh-index-map-bitmaponf482572a(de1a16f0). @MathiewMay it keeps your commit and authorship, with a paragraph added to the message; please take what you want, I'm not opening a PR for it.On the heap write bitmap, which it keeps:
check --no-gpupasses; the two added tests are guards that I haven't shown failing. No GPU check has run on this branch. Our game builds with the same code ran on an RTX 5090 (620.70.10): the hang in the description isn't something I can rule out, and 75c was lost in mesh draws after 501 s (cause unknown, #520).Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-30T01:39:09Z.
@NickStallman thanks for the resolved branch. Results for
d3d12/mesh-index-map-bitmap(de1a16f0) on an RX 9070 XT (1002:7550, RDNA 4, RADV / Mesa 26.3.1, GE-Proton11-14, Linux 7.3.6):Full check:
tuxbox.py check --adapter 1002:7550 --proton GE-Proton11-14 --prefix … --windows-dxc <DXC 1.9.2609 x64>gives 14 passed, 0 failed, 0 not run. That includes the D3D12 regression controls, the shader translator on the GPU andlanes-selftest-mesh-signature. In an earlier run without--protonthere was one failure inguest-present-4k-splash. It passed on a rerun of the present suite and in the full check, so I count it as flaky. The branch doesn't touch present.Game: three runs of
de1a16f0+ #557 (needed to get pastGame Initsince #527),TUXBOX_XMEM_PRIVATE_VIEWS=1. None of them had aMS_VS_TransformTerrainNormalTinthang or a device loss in mesh draws, and Xbox mesh pipelines are created and used. All three end around the first cutscene, each with a different crash:int_chase, frame 1743, half-rendered cutscene framesgame_scarlett_master.exe + 0x469517int_prolo, frame 1814, nothing on screen0x741041mainint_prolo, frame 1712, half-rendered cutscene frames+0x32E8313mainSo on RDNA 4 nothing gets worse with this branch, as far as I can see. Only
+0x469517is new, and it happened once in three runs, so I'm not attributing it to this branch.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:12:28Z.
Heads-up: main just landed a large cleanup (up to
e5d2e913), so this PR needs a rebase.rustfmt.toml).unwrap(), lossyascasts and undocumentedunsafeoutside tests.cargo fmt --check, rustdoc with warnings denied, and Miri on the providers' unit tests.The least painful way is to format your branch first, so the rebase only shows real changes:
Then run
python tuxbox.py check --no-gpu, which now includes the format step.If clippy flags something new:
Fromfor widening,TryFromfor narrowing, and a mask for bit fields.unwrap(): use?, orexpectwith the reason it can't fail.unsafeblock: it needs a// SAFETY:comment.CONTRIBUTING's "Code checks" section lists the commands. Thanks!
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T05:35:10Z.
@MathiewMay @Kayotic1337 two things on this, from looking into a GPU loss (#232/#472).
1. It fixes a real gap on main that isn't "skipped draws". Measured: on
e5d2e913, a mesh pipeline whose table is reflected and whose root indexes the heap directly gets no index map (mesh_table::reflected:layout.direct_resourcestrue,index_mapNone); a test of that fails there and passes on this change. By reading: such a draw is neither skipped nor mapped (Recording::drawsends any reflected table towith_reflected_tablebeforepaged_layout_gapis reached), so its shaders use guest heap indices as they are. I haven't run one on a GPU. Draws whose pipeline has no reflected table are the ones that are skipped, and the commit message's "draws were skipped" is true only for those; this change doesn't touch them. "Without the map the draw is skipped" isn't so for a reflected table whose root has no room either.2. Rebased onto main's reformat (your authorship kept):
d3d12/mesh-index-map-bitmapis now f172e332 one5d2e913: your commit, two tests of ours, and the test above. fmt, clippy -D warnings, rustdoc,check --no-gpuand 23 of its unit tests pass; the new test ran on lavapipe only. No GPU check on it. The rest of my earlier notes about it still stand. @MathiewMay please take what you want from it.One overlap: until #563 is in, an untraced pixel stage with the bitmap no longer counts its own table views as written once a mesh table has the map.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T06:49:44Z.
A game run that separates what this fixes (from @Jerkin42 on #472, RX 9060 XT, RADV, default mode, one run of our rebased copy of this on
f482572a+ #557 + #389 + #566 + #564): every earlier run of that build hit a scalar-read fault during the PROLOGUE mesh draws, 9 to 11 minutes after the title, and with this change none of those draws faulted and the run reached the world. About 90 s into the world it faulted again, in a different pair (MS 4db9a403/PS 9b9409d0), which is also among the unfinished draws in our losses. One run, so not a rate; but it's the first direct sign that this change matters in the game. It fits the gap found by the test one5d2e913(a reflected table used without its map).Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T01:35:51Z.
@MathiewMay a game result for the other half of what I wrote above (draws whose pipeline has no reflected table are skipped), and a small follow-up that depends on this PR.
What was skipped. On an RTX 5090 (620.70.10, GE-Proton11-15), an integration build with this PR's commits skipped about 340 draws a frame in ProjectScarlett's world from one depth-only mesh pipeline, a cascade-shadow caster (236,263 draws in 1,111 s): no reflected table, so under paging no index map, so
paged_layout_gapleft it out. 75 other depth-only mesh pipelines draw.Cause, confirmed by a log line in the next run: the pipeline changes no table (no table slot or register differs from what the root declares), so
mesh_table::reflectedreturned none, and only a table carries the map. The program's root indexes the heap directly.Follow-up (one commit on top of this PR's, in three files, not pushed): for a depth-only pipeline on a directly indexed root, with room for the map's two DWORDs,
reflectedbuilds a table with the title's parameters unchanged plus the map, used only if the mesh stage translates with it. Pipelines with a pixel stage are left out on purpose.Run with it (one, 20 min, 18.5 min in the slow phase): the line "no table changes, so it is given one only for the resource index map" appears for that program, its skips go from 338 a frame to 0 and it is drawn 344 times a frame. No device loss, no refusal. Total skipped calls fell from 307,000 and 236,000 in two earlier runs to 58,000, and the picture has shadow edges it didn't have. That build also carries other changes since those runs, so I don't claim the picture for this commit alone.
Not shown: no GPU check reaches this path (it needs a console-format mesh program in a depth-only pipeline on a directly indexed root under a capped heap), and it has not run on AMD.
I'd rather not open it while this is open, since it can't merge first. Say if you want to take it into this PR; otherwise I'll file it after.
Imported from brcly/TuxBox. Originally posted by brcly on 2026-12-01T15:14:37Z.
@MathiewMay #617 merged today (
4cc17f52). It uses your request derivation for the mesh and amplification stages (credited in its description), and keeps the map only when every stage that reads the heap has a translation that reads it. So I think this PR's change is now on main in that form.Is anything here not covered by #617, for example the terrain-pass hang you were tracing? If not, I'll close this one. If the hang still shows on current main, a new issue with the draw's inputs would be the best place for it.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.