D3D12.X: clamp ExecuteIndirect argument records and total work on the GPU #1795
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!1795
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1795"
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?
@mastrr9 on GitHub · 2026-11-24 20:51 UTC · original
mastrr9:feat/d3d12x-indirect-args-bounded-on-gpu→main· +573 −11 · 6 files · 1 commits · openSummary
Adds a small GPU compute clamp pass (
indirect_clamp.hlsl/indirect_clamp.rs) that runs beforeExecuteIndirectfor command signatures without root arguments. Corrupt or garbage indirect draw/dispatch counts can no longer triggerDXGI_ERROR_DEVICE_HUNG(0x887a0006): argument records and total work are bounded on the GPU before the PC reads them.XCL_INDIRECT_CLAMP=0disables it.Tested
Windows 11 x64, NVIDIA GeForce RTX 5080 16 GB.
cargo test -p xcl --lib indirect_clamp -- --nocapture --test-threads=1: 4 passed, 0 failed (includes live GPU execution ofgpu_records_are_clamped_and_budgeted)cargo test -p xcl --lib execute_indirect -- --test-threads=1: 2 passed, 0 failedcargo test -p xcl --lib -- --test-threads=1: 844 passed, 0 failed, 22 ignored (no new warnings)Regression run
Smoke run by @Anon64 in comment below: #1795
Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted.
main:
PR:
Tester's setup: RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,
XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, in one batch with themainrun.No device removals or crashes; 101 % of main's frames, 94 % of its peak commit.
Tester's AI use: Written with Claude Code (Claude Opus 5.5) from runs on the tester's machine.
Not tested
cargo test --workspacerun by the author: the widest run reported above is thexcllibrary tests.AI use
Assisted-bytrailer); the model is not recorded there.@futurepro62 on GitHub · 2026-11-24 21:31 UTC · original · edited 2026-11-24 21:51 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
7b9a1e0(on its baseb9b6ea6).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record: 891 passed, 0 failed, 42 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.signatures_without_root_arguments_are_bounded,a_signature_that_cannot_be_bounded_replaces_one_at_the_same_address,config_words_follow_the_shader,gpu_records_are_clamped_and_budgeted.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 893 passed, 0 failed, 42 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows),pso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)).--skipon NVIDIA. Both fail on main7f7e768too, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns their skips into failures.heap_window_out_of_memory_falls_back_to_the_switch_formskips whenXCL_HEAP_WINDOWSis unset (#1651), andshaders::tests::pso_measurement_compiles_an_exact_synthetic_recordskips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not setXCL_REQUIRE_GPU, so there both just print SKIPPED.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-24 23:41 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@ofc0urse on GitHub · 2026-11-24 23:46 UTC · original
Title run of
7b9a1e0on an 8 GB NVIDIA card, with the skipping it is meant for. The new head201d67dhas the sameindirect_clamp.rsand.hlsland resolves thebind.rsconflict the way I did below, so this should hold for it too. The clamp builds and runs, but it does not prevent the device removal here: every run with it on still ended in0x887a0006, at 152 to 269 s.Tested:
mainc4d37be+ #1798 + #1284 + this PR, release, merged locally. The only conflict wasexecute_indirectinbind.rs, wheremainnow wraps the PC call infresh_indirect_arguments; I kept that wrapper around both calls (bounded copy and original). RTX 4060 Ti 8 GB (32-lane waves, split wave64), driver 621.24, i5-14400F, 32 GB, Windows 11 Pro 26300, retail 1.0.2.1.XCL_PSO_WAIT_MS=50(so dispatches of pipelines still being built are skipped), A pressed at 115, 125 and 150 s, 600 s cap.XCL_LOOP_BUDGETXCL_INDIRECT_CLAMP=0, same binary)XCL_TEXTURE_PAGES_SYSTEM_MEMORY=1)Runs 3 to 8 also had #1323 (
XCL_GPU_CULPRIT=1) and a local line that logs its markers at the device removal, not only at a watchdog release. Runs 5 to 8 skipped compute programs by hash (a local test switch, below). In runs 7 and 8 local video memory peaked at 4,433 and 4,846 MB, against 14,000 to 15,000 MB in the others, so on this card the removal does not come from oversubscribed video memory.df837c748fdf56b8(CS_ScreenProbes_RadianceSpatialFilter), 14,400 groups, a directDispatch, not anExecuteIndirect. Its loop bounds come from memory.DrawInstanced,DrawIndexedInstancedand graphicsExecuteIndirecttoo (local change). Still nothing in flight at the removal (0 of 236 lists). What is left are the paths without a marker: XCL's own copies and texture uploads, CPU-expanded rect lists, clears and resolves.df837c748fdf56b8; runs 6 to 8 also skipped45a2f1928c4e6f73(CS_AllocBatchCSCullOutput) andcd4c7be781d7d2df(CS_ComputeHitDetectionSkinnedResults). Those two are the programs VIctory's NVIDIA testers skip withVICTORY_SKIP_PIPELINES=eeed82b877b44b5f,b83629b90cd2b7bc: VIctory names a shader by the first 16 hex digits of the BLAKE3 hash of the same bytes that XCL hashes with FNV-1a, and the two match these records. The device was still removed.gpu::tiling::Chain::detile_level(tiling.rs:438, called fromtitle_textures::subresources), reading title memory that was no longer mapped, before any skipped program had run.Not tested: more than one run with the clamp off. What was running at the removal in runs 3 and 5 to 8:
XCL_DRED=1made the driver rebuild every pipeline from the start, so the title never got past its first minutes. AMD.AI use: Claude Code (Claude Opus 5.5) merged the build, ran the title, read the logs and wrote this comment.
@Anon64 on GitHub · 2026-11-25 00:18 UTC · original
Regression run for this PR: head
201d67d, based onmain689f2db. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, in one batch with themainrun.main
689f2db:this PR:
No device removals or crashes; 101 % of main's frames, 94 % of its peak commit.
Not tested: the whole suite; whether the title reaches the changed code in these 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@JJAutoCompare on GitHub · 2026-11-25 03:20 UTC · original
PR #1795 — ExecuteIndirect clamp on Intel Arc A770
Tested commit
201d67da8bee82a099c99fd78ba5626373d6f932on STOR-WINLAB. Windows 11 Enterprise Evaluation build 26200.9974, Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175, wave sizes 8–32, no double-precision float shader ops or D3D12 debug layers. Rust 1.100.0 and DXC/DXIL 1.9.2609.5.Tested
cargo build --workspaceandcargo test --workspace --no-runpassed with debug info and incremental compilation disabled.cargo test -p xcl --lib indirect_clamp::tests -- --nocapturepassed all 4 tests. Three CPU tests checked signature parsing, signature replacement at a reused address, and shader config packing. The GPU test read back 2,000 indexed-draw records and verified per-record limits, preservation of other fields, and a total-work cutoff at record 1,383 (zero-based) across two shader chunks. It completed without skipping.cargo test -p xcl --lib execute_indirect -- --nocapturepassed all 3 existing binding tests, including a GPU check that ExecuteIndirect reads freshly written arguments. Both focused runs had 0 failed, 0 ignored, and 0 skip lines.cargo test --workspace --no-fail-fast -- --test-threads=4run exited 1. Summing 20 libtest summaries gives 954 passed, 25 failed, 45 ignored. The log contains 22SKIPPEDlines representing coverage gaps within the reported passes. All 7 focused tests also passed in this run.Failures and skips
CreateComputePipelineStatewith0x80070057. Four shader output checks disagreed on fused FMA, mip sampling, FP16 upper-half preservation, and a pixel wave reduction. The test-title E2E reported a blue pixel where the dynamic depth-bias check expected green.Not tested
No main baseline or retail-title smoke run, sample-data coverage, or other GPU vendors. The clamp readback exercised indexed draws. GPU dispatch and mesh clamping and the full title-to-clamp path were outside that test.
AI use
T3 Code / Codex (
gpt-6.2-sol,reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity,gemini-4-neon) verified counts againstpr1795-suite.logand published this report.@MacieGx on GitHub · 2026-11-25 11:49 UTC · original
FYI, a lock-order note from running this PR in the newer retail title's world (#505) on an RTX 5080, on a tree based on an older
main(689f2db) plus this PR, #1993 and others. On currentmainit should not happen any more, because892177b("a buffer's last release does not wait for the sparse state's lock") removed one half of it; I mention it becauseallocator_resetdepends on that.There, from a symbolised thread dump when every title thread had stopped:
sparse::readback_after_executeheld the sparseSTATElock and reset an allocator →indirect_clamp::allocator_reset→ waits forSCRATCH;indirect_clamp::allocator_resetheldSCRATCHand dropped the buffers overFREE_KEPT(s.free.truncate(FREE_KEPT)) → last Release →real::res_release→sparse::forget_buffer→ waits forSTATE.If you want
allocator_resetnot to rely on what a buffer's Release does: split the extra buffers off inside the lock (let over = s.free.split_off(FREE_KEPT);) and drop them after it. That was 15 lines locally, and the scene then ran 90–100 s of world frames with no stop.AI use: Claude Code (Claude Opus 5.5; a Claude Fable 5.2 subagent read the dump and wrote the local fix). I checked both call chains and that
892177bis inmain.@Royalflamejlh on GitHub · 2026-11-25 15:19 UTC · original
Linux (Wine + vkd3d-proton) + NVIDIA, the title, 3 runs with #1795 and 3 without: in each run with it, the clamp bounded each of the first 256
ExecuteIndirectcalls that reached it, and none of those 256 ran unbounded. The counter prints at the first 4 calls and then at powers of two; its last line was the 256th, so each run had 256 to 511 such calls, and those after the 256th were not seen one by one. The first bounded call came 0.9 to 1.8 s after the first#101stub call. Presents stopped 1.4 to 2.3 s after the first#101with #1795 and 0.6 to 2.4 s after it without. Neither tree had a fault, a device removal or a new kind of warning.Setup:
mainf087b99+ #684e56dbc3+ #1795201d67d, merged locally, plus one local commit that logs whatindirect_clamp::boundreturns at its call inbind.rs(8f2b802). Againstmainf087b99+ #684, merged locally (2f6a4ae); all six runs within one hour. Measured onf087b99; at201d67d, #1795 conflicts withmain06c9f55incrates/xcl/src/hle/d3d12x/bind.rs. RTX 4070 12 GB (615.71.09), Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, release, Series X profile, 120 s. The first-run screens were completed once, with no story progress. A was pressed once the title presented steadily (16.0 to 18.3 s).XCL_PSO_PRELOAD=0,WINEDEBUG=err+all,fixme-all.main+ #684 (3 runs)ExecuteIndirectcalls with a translated pipeline, bounded / not (the count prints at powers of two)#101ExecuteIndirect arguments run unbounded,ExecuteIndirect … skippedWARNlinesindirect_clamp::bound's call inbind.rs, so calls on PC pipelines and calls skipped before it are not in it. Each printed line was for a call withMaxCommandCount1.indirect_clampandexecute_indirecttests under Wine on the same card: 8 passed, 0SKIPPEDlines;gpu_records_are_clamped_and_budgetedran on the card.Not tested: today's
main06c9f55(the head conflicts with it); the GPU time of the copy pass; a run with a garbage record (the hang it prevents; neither tree hung here); the rest of the suite; Windows; AMD and Intel.AI use: Claude Code (Claude Opus 5.5) read the change, wrote the counter, ran the title and the tests, and wrote this comment.
Posted without review by a person: the account owner was away and reads replies later.
@jessenic on GitHub · 2026-11-25 21:12 UTC · original
A frame-rate cost of this PR on a retail title, and a fix: the scratch pool churns, under a lock every render thread takes. RTX 5070 Ti 16 GB (driver 610.88), Windows 11 26300, release. The PR is in a local integration tree (
main0829441+ about 40 open PRs). Newer retail title of #505, in the world.What the stack dumps showed. cdb dumps were taken while the title logged nothing for over 6 s. In every one, 3–4 of the title's render threads were waiting on
SCRATCH, inindirect_clamp::scratch/allocator_reset. The thread holding it was in one of two places:CreateCommittedResource, waiting inD3D12Core!CDevice::MakeResident_Worker→PerNodePagingOperation::Wait. Video memory was over budget, so a new committed resource waits for paging.allocator_reset→Vec::truncate→ the resources' lastRelease. With late release, that can wait on fences.Why it happens. A frame takes one scratch buffer per bounded
ExecuteIndirect, and this title has hundreds.FREE_KEPT = 64, so every allocator reset released everything past 64, and the next frame made them again. Each make and each release ran inside the globalSCRATCHlock.The change (diff below, against this PR's
indirect_clamp.rs):XCL_INDIRECT_SCRATCH_MB), not by count.CreateCommittedResourceand the releases happen outside the lock.Measured. One run each, same switches, warm caches, frames counted from the world's first
#101+ 60 s to the end of a 480 s run:With the change, the pool stopped growing at about 4,096 buffers (256 MB). No device removal, no crash.
diff
Not tested: AMD; other titles; a
scripts/smoke.ps1run; more than one run each. The 256 MB default is a guess: a title with bigger records may want more or less.AI use: Claude Code (Claude Opus 5.5) found this in the stack dumps, wrote the change, ran the runs and wrote this comment.
@DavidM1911 on GitHub · 2026-11-26 00:34 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.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.