D3D12.X: execute two-pass mesh shaders on DispatchMesh and ExecuteIndirect (supersedes #724) #2092
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!2092
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2092"
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?
@PracticalStudios on GitHub · 2026-11-25 03:47 UTC · original
PracticalStudios:mesh/two-pass-execution→main· +962 −9 · 6 files · 9 commits · openSupersedes #724 (@Cattn's, inactive since the reviews): its commit rebased onto
mainwith authorship kept, plus the five points @ivall listed on #724 before it can merge. Two-pass mesh pipelines (what #541 builds) run onDispatchMeshandExecuteIndirect; #1984 deferred this path to #724.Size: 907 lines, over the target. #724's own commit is 462 of them and the rest are its review fixes and their tests, one commit each; splitting further would leave a path that runs but is unsafe. @Cattn, happy to close this if you'd rather pull the commits into #724.
What is in it (
hle/d3d12x/bind.rsmostly, plusconsole_list.rs,device_x.rs,real.rs)4aaaf46#724's commit (rebased onto06c9f55; its slot 129 → 127 mapping is dropped, asmainnow has it).7dc8081the two-passioblock getsIO_UMA_BASE_HI.37233b5groups stay inside the record buffer;b56b311indirect Y / Z > 1 are folded into X.20bd310indirect arguments are read through unified memory instead of transitioning the title's buffer; per-list scratch is capped.28fef40an ExecuteIndirect withmax > 1runs one command at a time, so commands don't overwrite each other's records.5f5b7ddtwo-pass binds set the shared view heap first (heap windows read it).e856fa7pooled scratch stays within the recording's remaining budget (found and fixed by @WebIdentity1).Tested
cargo test --workspace --no-fail-fast -- --test-threads=2one856fa7: 1276 passed, 1 failed, 46 ignored. The failure (kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory) fails the same way onmainhere (#650).3442b58with #541: @cafeoh (RTX 2080 Ti) and @CharlyRien (RTX 3090) — the mesh draws now run (thousands per frame, none skipped; 6 685 pipelines refused without #541/#724).Regression run
.\scripts\smoke.ps1 -Game <retail title> -Seconds 60, no input,mainfirst, same machine:Not tested
AI use
https://claude.ai/code/session_01HqVqYwUoC2oJRwQSXDePn3
@WebIdentity1 on GitHub · 2026-11-25 04:05 UTC · original · edited 2026-11-25 04:08 UTC
Verified a small pool-reuse bug on
e9471c51ddfeef2019a7f3a9f43d194e77a90287:scratch_argscan exceed the recording's 16 MiB cap. With 1 MiB already taken, a second 1 MiB request selects a cached 16 MiB block, bringingscratch_takento 17 MiB. The initial guard checks the request size, but the pool filter checks the block against the full cap rather than the remaining budget.The attached fix uses the remaining budget for both checks. The same sequence then takes 2 MiB. The test also confirms the cached 16 MiB resource remains reusable by identity for an empty recording, and that recording rejects an additional 256-byte request at its cap.
Tested: native Windows 10 Home 19045, RTX 3090 driver 591.74, Ryzen 7 7800X3D, Rust/Cargo 1.98.1 MSVC, debug. Actual D3D12 resource allocations through
scratch_args; the test explicitly selects and prints the RTX 3090. Paired head+test vs head+test+fix: 0 passed / 1 failed / 0 ignored → 1 passed / 0 failed / 0 ignored, zero skips; Cargo exits 101 → 0. All 304 source hashes match before/after each run; both snapshots rebuilt.Not tested: no GPU commands submitted, shader output, visible geometry, retail smoke, AMD, or full suite. These are allocated scratch capacities, not measured peak VRAM/process commit or performance. Run this reproducer alone in a fresh process (
--exact --test-threads=1) to isolate the global pool; it is not qualified for arbitrary concurrent full-suite execution.Small runtime fix
Isolated native reproducer (applies to the original head)
AI assistance: Codex (GPT-6), investigation, fix/reproducer preparation, native Windows test execution and report. No competing PR.
@PracticalStudios on GitHub · 2026-11-25 04:14 UTC · original
@WebIdentity1 thanks — confirmed here too (RTX 3090: 17 825 792 B taken without the fix, 2 097 152 B with it). Your fix and test are in
47c7cc1, credited to you; the regression blocks for the new head follow.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@IAmTheSween on GitHub · 2026-11-25 05:12 UTC · original
Test report from a desktop RTX 5070 (Blackwell, 11 943 MiB, driver 32.0.16.2114), Ryzen 5 5600X / 31.9 GB, Windows 11 26300.9974, rustc 1.100.0, release build of head
47c7cc13c1b872ae5f45e4c9ffed6332ca74a4d0(its base iscbc296a, so the suite count is comparable to that tree).Suite: clean
cargo build --release -p xcl: clean.cargo test --workspace -- --test-threads=4: 971 passed, 0 failed, 43 ignored across 20 binaries, no flakes. 24SKIPPED: 18no wave64, 3 refused per-lane cases (f16×2,f32conversions),two_pass_binds_set_the_shared_view_heap(no heap windows),pso_measurement_compiles_an_exact_synthetic_record(no Developer Mode), andheap_window_out_of_memory_falls_back_to_the_switch_form. 4 runtimexcl: … skippednotices. The PR's own report has 970 passed / 1 failed on thexmem_virtual_query…test that also fails on its base here; that test passes on this machine.Title run: the new path is not exercised by my route
XCL_NETWORK=0,XCL_ACTIVITY=1,XCL_FRAME_DUMP=2, 300 s. To avoid colliding with another agent's runs on the same machine I used a privateXCL_DATA_ROOTwith the profile and DXIL cache copied over; a concurrentxcl.exewas competing for commit, so treat the frame numbers as lower-confidence than my earlier posts.two passeslines, 40 refusals (expected — #541 is not in this tree), 0no stand-inlines.Not a clean A/B against
mainmaincbc296abaseline on the same route/state crashed at 92.658 s with the knownunhandled exception 0xc0000005 in game_scarlett_master.exe+0x2215c35 (write at address 0x0), 885 frames, peak 13 505 MB. That is the title bug already reported elsewhere, not a device removal. Becausemaindied before reaching the late run phase, I cannot attribute the black last frame or the high commit to this PR.XCL_HEAP_WINDOWS=1,XCL_DIRECT_DXIL=1, and a run without the concurrent process.AI use
deepseek-v4-pro-uncensored); ran the build, suite and isolated title runs, wrote this from the preserved logs.@CharlyRien on GitHub · 2026-11-25 05:01 UTC · original · edited 2026-11-25 05:16 UTC
Update (in-title result): with #1803 and the heap addresses passed to the two-pass compute pass,
s23/s24do hold the heap bases (10 000 of 10 000 binds logged) and the records are still (1, 1), so the explanation in the third bullet below is refuted on my tree; base 16 and the need for the heap addresses stand. Details: #724A correction that concerns the (1, 1) records listed here as not fixed:
FIRST_SGPR_MS = 16is right, my "one register too late" on #724 was wrong. Details and the decoded per-stage table are in #724.Short version, from decoding the root-layout table of every stage in the retail title's shader pack (offline, no run behind it yet):
s16and pack exactly as XCL packs them (0 differences);[table, table, table, root SRV, 2 constants]that iss23/s24, and the code loads a V# froms23 + index × 32;So nothing to change in the base register; what this path needs is what #1803 does for compute and graphics.
AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the decoder) did this and drafted the comment.
@JoaoPauluu on GitHub · 2026-11-25 05:22 UTC · original
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with
main(1386 here; 1371 and 1356 on the twomainruns). Notwo-pass DispatchMeshline appears in the log, and the same 40 mesh pipelines as onmainarerefused(MS … in the AS slot), so the two-pass path is not reached here; this is a regression run only. The lastconsole code so farline read 16384 draws and 826 dispatches at 59.5 s, against 10243 / 512 (58.4 s) and 11488 / 512 (54.3 s) on the twomainruns. Those lines are printed at milestones, so these are not exact totals.Tested
x86_64-pc-windows-gnu.47c7cc1as it is (based on1d027e5) andmainf5c5bdf, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Runs in order: main, this PR (with other PRs in between), main.Regression run
main (first run):
this PR:
The second
mainrun: 1356 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 05:43 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@CharlyRien on GitHub · 2026-11-25 07:08 UTC · original
In-title result for the two-pass path, on the tree of my #724 comments (this PR's
3442b58state with #541, #1887, #1803): once the buffers the mesh programs and the culling read are readable, the records carry real meshlet counts and geometry reaches the depth target and the G-buffer.Details, setup and limits are in #697. What matters for this PR:
One run plus one partial run, RTX 3090; the copies that made the GPU view readable are a local experiment.
AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the ports and the runs) did this and drafted the comment.
@ettehn on GitHub · 2026-11-25 07:25 UTC · original · edited 2026-11-25 07:28 UTC
Synthetic mesh readback on RTX 5070 Ti Laptop. I tested
47c7cc1plus a local test-only extension on Windows 11 25H2 (26200.9974), NVIDIA driver 32.0.16.2124, Ryzen 9 8945HX, Rust 1.97.1 MSVC and DXC 1.8.2502.11.XCL_ADAPTER=nvidia,XCL_HEAP_WINDOWS=0,XCL_DIRECT_DXIL=0.cargo test --locked --offline -j 2 -p xcl --lib <filter> -- --nocapture --test-threads=1ran 7 tests, all passed with zero skips across these filters:gpu_mesh_mode(2): read the expected vertex table from the second memory window, with a decoy table in the first. The two-pass test read back 3 vertices and 1 primitive per group and the expected triangle pixels, including identical pixels through the split passthrough.gpu_indirect_two_pass(4): the additional fixture rewrites 130 commands with a count of 65. The last live command in the second 64-thread group was correct in both output arrays. Commands after it had zero groups, and the output guard remained intact. The same four tests passed on WARP.gpu_two_pass_indirect_commands_keep_their_own_records(1): verified the record isolation with the test’s stand-in compute passes and D3D12ExecuteIndirect.These fixtures cover synthetic inputs. Retail GPU-view aliases, visible world geometry and heap-window mode were outside this run. Testing and the test-only extension assisted by OpenAI Codex (GPT-6).
Heap-window follow-up. On the same build base and machine with
XCL_HEAP_WINDOWS=1, three focused tests passed with zero skips using the command above.two_pass_binds_set_the_shared_view_heapobserved both stages bind the shared view heap on a command-list stand-in that started with no heap. I extendedgpu_mesh_mode_reads_memory_windowsto compile and execute the descriptor-heap variant: readback matched all three expected window-1 vertex positions for both descriptor-heap and root-UAV translations, while the one-window control read the decoy.gpu_heap_windows_reject_out_of_uma_aliasingalso passed. The binding fixture and shader readback are separate checks. Retail GPU-view aliasing and an actual title run remain untested. Verification and test extension assisted by OpenAI Codex (GPT-6).@imnicho on GitHub · 2026-11-25 09:18 UTC · original
RTX 5080 16 GB,
47c7cc1with #541 and #1803 in the retail title: the mesh draws run here too, nothing is refused, and the visibility target stays emptyA third NVIDIA card, on the current heads and on a newer base than the runs above.
Setup. RTX 5080 16 GB (driver 610.47, 32-lane waves), i7-7700K, 16 GB RAM, Windows 10 22H2, release. The retail title of #505 (my own copy),
XCL_NETWORK=0, scripted pad, binds waiting (noXCL_PSO_WAIT_MS),XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_HUGE_PSO_CONCURRENCY=2, compute pipelines prebuilt with--precompile --used-only.Tree (local): #2057 at
41303e4+ #2067 + #684 + #266 + #1515 + #495 + #1405 + #751, then this PR at47c7cc1, #1803 atcb00751, #1887 at5fe5b41and #541's four own commits (70f9185…6bd8f64), plus six local lines that pass #1803's heap addresses to both two-pass stages (with_heapsoveruser_data_ms/user_data_gfxintwo_pass_io). For the second run also #2050.Conflicts, for whoever merges the same
real.rs, two blocks. The list's slot table (that base adds 131 / 132, this PR 127: both kept) andNEWER_LIST_SLOTS(that base adds(69, 67), this PR(129, 127): 23 entries with both).runner.rs, one block against #2067'su6..u9binds (kept #2067's, which bindu2..u5too).bind.rsthree blocks andconsole_list.rstwo, all both-sides-added (theheapsfield next to the scratch fields,s.heaps = [0; 2]in the reset, the triple inbind_abi,Layout::heapsnext toinline_ms,with_heapsafteruser_data_ms).translated_mesh_stream_once.mainnow defers every lazy MS withreturn None; I kept that for the moved MS too and added #541's "translated as MS" log after it.Measured
mesh pipeline … in the AS slot – refused0x887a0005with local video memory at 20.7 GB (budget 15.1 GB)nvwgf2umx.dllat 561 s, local video memory 21.7 GB (budget 15.1 GB)two-pass DispatchMeshwith real group counts (92 groups in the first ones),two-pass ExecuteIndirect(DispatchMesh)and 31two-pass MS PSOlines. One mesh pipeline was refused:the driver rejected the mesh pipeline from the console MS (0x80070057)at 414.7 s, the line @ThiagoAlexsander also got on an RTX 5080 on #541. I have not found out which one or why.XCL_DUMP_TARGETS=3000,4, one run, four world frames): a frame has 5,500 to 9,900 draws and dispatches into 35 to 43 render targets, every draw "ran" (0 stand-in, 0 PC, 0 skipped). The 2560x1440R32_UINTtarget takes 180 draws a frame (360 in one) and is all zero in all four frames. The 2560x1440R16G16B16A16_FLOATtarget takes 216 to 562 draws; 291 of 230,400 sampled texels are not zero in the first frame, about 198,000 in the other three, where the most common raw words are0x00020000and0x00050001. So the mesh draws execute and nothing lands in the target they share, which is what the (1, 1) records above give. The presented frame is the uniform grey.Not tested
main, and the suite on it: every number here is from the tree above.AI use: Claude Code with Claude Fable 5.2 merged the tree, ran the title and wrote this.
@CharlyRien on GitHub · 2026-11-25 09:25 UTC · original
Offer: one commit for the compute pass's heap addresses once #1803 is in (or if you want to take #1803's
with_heapsalong).With #2092 (
47c7cc1) and #1803 (cb00751) merged together, the two-pass compute pass still builds its user data withuser_data_msalone, so a mesh program whose root signature hasCBV_SRV_UAV_HEAP_DIRECTLY_INDEXEDreads 0 where its view-heap address should be. In a retail title, the mesh programs built for the most common mesh root signature[table, table, table, root SRV, 2 constants]load their meshlet list's descriptor froms23 + index × 32. Their container's root-layout table puts the view heap at user-data dword 15 =s23and the sampler heap ats24, right after the arguments, with your first register 16 (format on #724: #724). Two testers have already wired this by hand: ettehn for a synthetic readback (#697) and imnicho in the retail title just above (six local lines, both two-pass stages). So this is the same change as a commit with a unit test, so that it does not have to be redone on each tree. In-title numbers with an equivalent local change are on #697 (#697). That tree is larger; the change was necessary there, not sufficient on its own: as in imnicho's run, the targets stay empty until the buffers the culling and the mesh programs read from the GPU view of the title's 24 GB reservation are readable (#697).The commit below is on top of a local merge of your head with #1803's head. Both sides of each conflict were kept:
Layout(inline_ms+heaps),user_data_msnext towith_heaps, andreset()clearsheapsas well as your scratch / resource buffers. It changestwo_pass_ioonly (onewith_heapscall, aheapsparameter fromState::heaps), and it adds a unit test: the 5-slot layout with both flags givess16..s24= t0 t4 t8 d.lo d.hi c c H S. Without the flags, nothing follows the arguments. The mesh pass's pixel shader is left as it is.Feel free to squash it into your branch once #1803 lands, or tell me and I will open it as a stacked PR instead.
Tested on an RTX 3090 24 GB (driver 616.56), Ryzen 9 5950X, Windows 11 22631, debug build. On the merged tree,
cargo test -p xcl --lib two_pass:12 passed; 0 failed; 0 ignored(one SKIPPED line: no heap windows). Without thewith_heapscall the new test fails (left: [256, 288, 320, 20480, 7, 1, 2, 0, 0]).cargo build -p xclbuilds with no new warning. Not run: the whole suite, the retail title with this exact head.AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 writing the code and tests).
Patch (
git format-patch, applies on47c7cc1+cb00751merged)@ivall on GitHub · 2026-11-25 13:05 UTC · original
Title runs on AMD RDNA4 with the geometry stack: the mesh draws run and nothing is refused in the AS slot; one of three runs ended in a GPU hang whose cause is not known yet.
Tree:
main1a0bbe3+ #1803cb00751+ this47c7cc1+ CharlyRien's heap-address patch for the compute pass + #5416bd8f64+ #2080 / #2107 / #2126, direct DXIL, release,XCL_NETWORK=0, a retail title's world load.ExecuteIndirectDispatchMesharguments look right (92, 52, 2 groups).The slot: in the newer list layout
DispatchMeshis #129 and the older layout's is #127 (#126 is RSSetShadingRate, #127 RSSetShadingRateImage, #128 one struct pointer), two slots before like the rest of that range. I run with that and will put it onmainas its own commit; please keep it out of this PR when you rebase (it conflicts withmainnow).AI use: Claude Code (Claude Opus 5.5) ran this and wrote the comment on the maintainer's behalf.
@imnicho on GitHub · 2026-11-25 13:33 UTC · original
Counted in the retail title's world on a 16 GB card: the two-pass record and scratch buffers hold up to 4.8 GB of video memory at once, and 1 318 of them (22.8 GB) are made in about two minutes of world. That is about as much as this card is over its budget in that run (19.8 GB of local video memory against 15.2 GB). It may bear on the hang in @ivall's run 3 above ("may have filled video memory").
Setup
XCL_NETWORK=0, scripted pad,XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1, compute and graphics pipelines warm.4df1e6e+mainat0f13d2a+ this PR at47c7cc1+ #1803, #1887, #541 (the two-pass stages get #1803's heap addresses), + #2067, #684, #266, #1515, #495, #1405, #751, #2050, and the change of #2306 in its form for #2057's uploads, switched on (it halves the texture pages; without it the run is further over the budget).res_buf,res_retired),ALLOC_RESandFREE_RES, and it counts the calls ofdefault_uav_buffer.One run of 300 s (world set up at 116 s; no device loss in this one):
memory:line names nor the 4.1 GB copy of the committed window (1.2 GB in the menus).41303e4without this PR, #541, #1803 and #1887 (three runs), 4.1 – 5.0 GB with them (six runs), 6.8 – 7.4 GB in the three runs that drew 3 – 5 times as much.How I read it (from the code, not measured further): a list that draws a two-pass pipeline through
ExecuteIndirecttakes a buffer of 32 MiB (ensure_res_buffer(this, 32 << 20)), up to 195 lists held one at a time in the samples above, a list's reset hands its buffer to the allocator until that one is reset, andFREE_RESkeeps 16 buffers / 256 MiB, so what comes back beyond that is released and made again: 1 318 buffers of 17 MiB on average for at most 289 alive.Not measured: whether a smaller buffer for the indirect path, a larger free pool or buffers shared by the lists of a queue would be the right change - yours to decide; I can run a patch on this card if that helps. AMD; other titles.
AI use: Claude Code with Claude Fable 5.2 wrote the counter, ran the run on the machine named and wrote this.
@voiceovarian1-max on GitHub · 2026-11-25 20:39 UTC · original
Under Wine the shared argument-scaling pipeline faults on release (
pso_release, read at 0x10): 4 runs in a row ended in it in the world. One pipeline per recording thread fixed it here: none of the ~35 runs since.Setup: Linux, Proton Experimental's Wine + vkd3d-proton 3.1, RTX 4070 Ti 12 GB (NVIDIA 620.73.04), i7-14700K. Retail title, Series S profile. Tree: #2057's head with this PR and others merged locally, not this PR's exact head.
Where:
execute_indirect→make_scaled_args_buffer→emit_transition→real::pso_release.scale_indirect_pipelinekeeps one root signature and pipeline per device in astatic Mutex<…HashMap…>, shared by every recording thread. Under Wine, XCL puts an object's own vtable back while it is handed to vkd3d-proton (UnadoptGuard, #867). A release on one thread while another has the pipeline in that state ends in the fault.The change (
bind.rs, 10 lines): the cache becomes per thread.Not tested: Windows (no
UnadoptGuardthere, so it may not happen), AMD, this PR's exact head.AI use: found, fixed and written with Claude Code (Claude Opus 5.5) from runs it made on this machine.
@CharlyRien on GitHub · 2026-11-25 21:52 UTC · original
The record buffers that made local video memory grow in the world here were the ones held for PC allocators
alloc_poolhad put aside. Giving them back once the GPU has passed such an allocator took the growth from 40 to 5 MB/s on an RTX 3090 (same build, the switch alone). With #1422 that give-back already happens throughconsole_list::allocator_reset, where this PR releases its buffers; a test that keeps it when the two meet is below.Setup
main689f2db+ #1329, #1448, #1323, #889, #684, #929, #640, #1850, #765, #541, this PR's branch at3442b58(before its rebase onto06c9f55: the same seven commits as4aaaf46..28fef40here, plus #724's slot 129 → 127 mapping, without5f5b7ddande856fa7), #1887, #1803, #1982, #1405, #1464, #2229, #1055, #1102 (the last three ported locally), plus three commits from wondercrash's fork that file a recording's unified memory, and with it these buffers, under the PC allocator it is on (150e635,761ada5,9b70233: #1422's filing without its give-back), plus local diagnostics.XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_DIRECT_DXIL=1 XCL_NETWORK=0 XCL_GPU_WAIT_RELEASE_MS=250 XCL_PAGE_BUDGET_MB=4096.console_list::allocator_resetat once instead of when it is used again. A local counter walkedALLOC_RES, the lists' buffers andFREE_RESevery 10 s.Measured (one run each; least squares from the world-load burst +10 s to +70 s, read from the
memory:lines; R2a and R2b are the same build, V3 is that build without the counter and the switch)memory:line namesXCL_ACTIVITY)FREE_RESkeeps 16 / 256 MiB): driver time, not memory.From the code (not run)
real::alloc_resetcallsconsole_list::allocator_reset(title allocator)also whenalloc_poolput the PC allocator aside: they go back toFREE_RES(or are released) while the GPU may still run that recording, the case #1358 / #1422 fix for unified memory. On our tree, which logs a Reset with submits the GPU has not finished, that line appeared in none of six world runs (V3, R2a, R2b and three earlier), so we have not seen it happen with this title.bindgets the PC allocator, sohold_res_until_resetfiles the buffers there, anddone_withcallsconsole_list::allocator_resetat each title Reset for every PC allocator of it the GPU has passed (in use or put aside). With this PR'srelease_allocator_rescall in there, that is the give-back above, a little wider (also allocators a list still records on, which is safe:ALLOC_RESonly holds ended recordings' buffers).reclaim_idledrops spare allocators aftertake_pending(f)but does not callrelease_allocator_res(f), so their buffers would stay inALLOC_RESfor good.Test for whichever of #1422 and this PR lands second (
alloc_pool.rstests, two#[cfg(test)]helpers inbind.rs): a put-aside allocator's buffer stays while the GPU has not passed the allocator and goes at the title's next Reset after it has. Onmain6d12f58+ #14227901856+ this PRe856fa7merged locally (conflicts inrunner.rs,bind.rsexecute_indirectandconsole_list.rstests resolved by hand), RTX 3090 (616.56), Rust 1.100.0, debug: it passes;cargo test -p xcl --lib: 1314 passed, 0 failed, 26 ignored (26 SKIPPED lines:no wave64and per-lane refusals ingpu::recomp,two_pass_binds_set_the_shared_view_heap_first,pso_measurement_compiles_an_exact_synthetic_record);hle::d3d12x::with--test-threads=1: 269 passed, 0 failed, 2 ignored. With therelease_allocator_resline taken out ofconsole_list::allocator_resetit fails:left: (1, 0),right: (0, 1)(the buffer is still held after the GPU passed).diff
Not tested: #1422 + this PR in the title (the runs above are on the fork's filing plus the local switch, not on #1422's
done_with);mainalone; other cards, AMD; the whole suite on the merged tree.AI use: Claude Code (Claude Opus 5.5 coordinating; Claude Opus 5.5 agents wrote the counter, the switch, the test and this text and read the logs). The coordinating session ran the runs on the machine above and checked the slopes and the census lines in their logs.
@pvfreis on GitHub · 2026-11-26 04:22 UTC · original
By reading only, not run, at
e856fa7:dispatch_mesh(bind.rs:651,:654) and the two-passExecuteIndirect(make_scaled_args_buffer,bind.rs:609-610,:620; the steps,:731,:735) callResourceBarrieron whatever list the title recorded into. Bundles reach these hooks too;fresh_indirect_argumentsleaves them out for that reason (bind.rs:857-859). A two-pass mesh draw recorded into a bundle therefore puts calls in it that D3D12 does not allow there. #2519 reports the retail title's dispatches arriving on bundles. The barrier between the passes cannot be dropped, so skipping (and counting) two-pass draws on bundles (list_x::tracked_list_type) looks like the smallest fix.ALLOC_RES(bind.rs:53-72) is emptied only byrelease_allocator_res, called only fromconsole_list::allocator_reset(console_list.rs:354), which onlyalloc_resetcalls.alloc_release(real.rs:6842-6851) dropsdispatch_chain's recordings for the released allocator, but not these. A title that releases allocators and makes new ones keeps every record buffer and argument block filed under the old ones (32 MiB for each recording that drew a two-passExecuteIndirect) until an allocator made later at the same address is reset. Arelease_allocator_rescall inalloc_releasewould hand them back. (mainkeeps the unified-memory blocks inPENDINGthe same way.)AI use: Claude Code (Claude Opus 5.5) found this; Claude Fable 5.2 rechecked it; checked by a person before posting.
@Eterst on GitHub · 2026-11-26 05:56 UTC · original
Two-pass
ExecuteIndirectdraws whose arguments are in a PC buffer outside unified memory are skipped. In a retail title's world these are most of the main-view mesh draws. Reading the arguments through that buffer's GPU address instead runs all of them.Setup
e856fa7d, plus #1887, #1803 (with a local commit that gives its heap addresses to both two-pass stages), #541, #1989 and #2246.XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_GPU_VIEW_BUFFERS=1 XCL_GPU_VIEW_MB=1536 XCL_TRACE_FRAME=1, mesh compute passes precompiled with #2246.What happens
The skip comes from
execute_indirect(bind.rs):its arguments are not in a console buffer in unified memory.Between two frame dumps (30 frames) in the world, draws into the 2560×1440 main depth target: 12 757 two-pass
ExecuteIndirectskipped this way, 8 966 run.Every skipped call had the same kind of argument buffer, from a local log of the buffer at the skip:
HEAP_TYPE_DEFAULT,ALLOW_UNORDERED_ACCESS;CreatePlacedResourceX), not registered as a console buffer in unified memory;It looks like GPU culling output that the mesh draws consume.
Local change (an experiment, not a PR)
ALLOW_UNORDERED_ACCESS;max · stride≤Width.indirect_guard::checkalready binds a title buffer's address the same way.ExecuteIndirectran into that target, 8 300 of them with arguments read this way.indirect_guard;Record buffers on a 12 GB card, for the numbers above
Not tested: AMD; the count-buffer path; the debug layer;
mainwithout the other PRs listed.AI use: Claude Code (Claude Opus 5.5) ran the builds and runs and wrote the local change and this text. I checked it before posting.
@claudetools-gh on GitHub · 2026-11-26 06:05 UTC · original
@Eterst a data point on why that argument buffer is outside unified memory in the first place: here it depends on the size of the coherent window.
Setup
main08db802+ MacieGx's lab branch (8e95067a) + local diagnostics.XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_SHADOW_TILED=1, retail title, warm caches, the 1004CS_RaytracingResolverecords refused.XCL_COHERENT_MB(1024 against the default 4095).Result
0x18e6973c0here)ExecuteIndirectpath. Every one was refused byindirect_clamp::bound_withinas "args not a console buffer": 1,048,576 by 283 s, all on that one 32,768-byte buffer, max count 1, offsets 0x0, 0x20, 0x40, …, the same shape as yours.0x18_xxxx_xxxx–0x1f_…;VirtualQuery:MEM_COMMIT, protect0x404) falls outside the windows. Every buffer placed there becomes a lone resource with an empty V#, so the culling output is never written where the mesh pass looks for it.XCL_OUTSIDE_BUFFERS=1(MacieGx's lab switch) is no fix for these. It moves them to sparse addresses without CPU pages, and the title writes them through the CPU: an access violation atgame_scarlett_master.exe+0x501eb5060 s in (run 145).So reading the arguments through the PC buffer's address, as in your experiment, helps when the culling shader's writes reach that buffer. Here they did not with the small window. With the default window there was nothing left to skip.
Not tested: your tree; the count-buffer case; whether any of the 128 buffers still outside with the default window is read by a draw.
AI-assisted.
@claudetools-gh on GitHub · 2026-11-26 07:26 UTC · original
@PracticalStudios a measured issue in the two-pass buffer pool at this head (
e856fa7): the pool of freed buffers fills with small entries, so the freed 4 MiB record buffers are never reused.What happens
FREE_REStakes three kinds of buffer: the record buffers ofensure_res_buffer(4 MiB and up), the 1 MiB argument scratch blocks, and the per-call scaled-argument copies ofmake_scaled_args_buffer, which can be any size.pool_keepsadmits a buffer only whilecount < 16. In a retail world the pool fills with small copies and stays full, so every freed record buffer is dropped, and the next two-pass call creates a new one.Measured (RTX 5070 Ti 16 GB, retail title, the world; local tree with this PR's two-pass code and MacieGx's lab branch)
freein the logRun 153 also had other changes (a newer lab branch), so I don't attribute its fps (3.2 → 3.5 in our scene) to this alone. The buffer counts are this change's.
The change we run (
bind.rs; the 16-entry rule becomes 64 entries / 256 MiB, and past either the smallest go first):The test that pins the failure:
freed_two_pass_buffers_kept_for_reuse_are_cappedneeds the same rewrite aroundpool_insert. Herecargo test --release -p xcl --lib -- d3d12x::bindpasses: 24 passed.Not tested: your tree as is; AMD; whether 64 / 256 MiB is the right size for smaller cards. On a 16 GB card it keeps up to 256 MiB of record buffers resident.
AI-assisted.
@DavidM1911 on GitHub · 2026-11-26 07:28 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.@evan-kolberg on GitHub · 2026-11-26 07:30 UTC · original
Independent Apple Silicon check for the two-pass dispatch path. I tested a local port on XCL Mac integration
efef3078, using the #541 mesh-slot changes and the direct/indirect dispatch work from #724 and this PR. Hardware was an Apple M4 Pro with 48 GiB, macOS 27.2.1, and CrossOver with D3DMetal 4.0 beta 3.The generated offscreen fixture checked direct
DispatchMeshand mesh-onlyExecuteIndirectthrough both console command-list layouts. The base used the same two-pass pipelines and stayed at the blue clear in all four draw cases. With the local dispatch port, all four cases produced the same 32×32 RGBA8 image with 276 green and 748 blue pixels (FNV-1a64d338ab8d282f4fcd). The zero-count indirect control stayed blue in both builds. All ten cases ran serially on the same renderer and completed as expected.Coverage was one mesh group per record and indirect arguments in GPU-visible console memory. Presentation, retail gameplay, and larger split-group draws remain unverified by this test. Thanks to the contributors on #541, #724, and #2092. Test preparation and verification were assisted by Codex.
@GodlyBDS on GitHub · 2026-11-26 11:54 UTC · original
Independent Ampere failure after the all-root-views fix
6737e7bd587441cd18489a5b0e226d14246e5ddd(verified ancestor of the tested NVIDIA baseaf2cecc40886a8682ecf3267f5328c6dc4b66ad7). RTX 3090 Ti, driver 621.40, Windows 10, 32 GiB RAM. Matched warmed-cache replays and exact outcomes are in the #2762 test report.In the replay with a confirmed Windows display recovery, DRED showed exactly one partially executed list (56/921), with a Dispatch as its next unfinished operation and zero fault VA. The same unlabeled PSO precedes this sequence in all 13 occurrences visible in that list's diagnostic excerpt:
Dispatch → Barrier → ExecuteIndirect → Barrier → mesh ExecuteIndirect. The sequence matches the XCL argument rewrite followed by the two geometry passes. The unlabeled pointer and DRED's coarse progress mean this is a candidate workload, not a confirmed faulting shader or root cause. The named root-view guard was already present in this run.An isolated diagnostics-only build registers the successfully created rewrite PSO with its host DXIL hash. The existing root-view test, three synthetic indirect-argument GPU tests and four DRED marker tests passed. The new label has not been validated in a retail device-removal trace. The change is one line, immediately after the successful PSO creation in
scale_indirect_pipeline:AI assistance was used for test orchestration and this summary.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.