Repository navigation
D3D12.X: ExecuteIndirect checks of a run of draws share one pass - #3128
Raul-Paiva wants to merge 1 commit into
Conversation
|
@Raul-Paiva the whole suite of your head on an RTX 3090 against its base on the same machine: no failure the base doesn't have; its 5 new tests pass ( Tested:
Not tested: a title run; a release build; AMD / Intel. AI use: an agent swarm: Claude Fable 5.2, Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon. |
|
On a native RTX 5070 12 GB (driver 616.92), the opted-in draw guard preserved the input-assembler counts across the 32-job batch boundary at
Each row ran in a fresh process. The fixture varied vertex count, instance count and start vertex, called production The fixture registered one 4 KiB CPU-visible native argument buffer as test window 0, then used the production window lookup, batch shader and GPU execution. It ended the batch explicitly at close. This covers contiguous non-indexed draws on one direct list. It does not measure retail frame time, guest allocation, automatic batch breaks, or indexed draws. AI use: OpenAI Codex (GPT-6) prepared the test-only fixture, ran the four native controls and wrote this report. |
5ed4bd7 to
c7729b4
Compare
c7729b4 to
2df9e9d
Compare
2df9e9d to
299104a
Compare
|
#3009 goes after the same cost (the per-check barriers of AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
Each checked ExecuteIndirect records, in front of itself, a UAV barrier on everything, a Dispatch(1, 1, 1) of the count check and two transitions of its output buffer. A retail title makes thousands of these a frame. Another open-source runtime for the same platform measured this pattern at 14-16 us a check and got its replayed frame from 86.1 to 77.7 ms by checking all the arguments between two points where they can change in one compute pass. With XCL_INDIRECT_GUARD_BATCH=1 the checks of draws (Draw and DrawIndexed signatures) go in batches of up to 32 per list. The first draw of a batch records the barrier, one pass and one transition of the output buffer to INDIRECT_ARGUMENT; the pass reads a block of jobs in CPU-visible memory (window, offset, slot, kind; the program id and title address for the log) that the CPU fills while the list is recorded, before it is submitted. A later draw of the batch only writes its job: no barrier, dispatch or transition. The counts are read through the memory windows (eight bound as root UAVs); counts elsewhere, dispatches (clamped after the check) and the compare diagnostic are checked alone, as before. A batch ends, with the output buffer back to COMMON, at: - an ExecuteIndirect that is not of a plain Draw / DrawIndexed signature (dispatches, mesh, root changes, several arguments), at the top of the hook, before any of its paths (indirect_guard::before_execute_indirect), and a DispatchMesh; - any other title call on the list but ExecuteIndirect, root constant and root view sets, the pipeline set, topology, scissors, viewports, blend factor, stencil ref and index / vertex buffer sets (bind::before_list_call, now also installed with this switch): barriers, draws, dispatches, copies, clears, render targets, queries, waits, writes, flushes, root signature and descriptor table sets and the console's other methods all end it; - a check that goes alone; - the list's Close and the PC Close of a segment (split, KickoffX); - a Reset, a split or the list's release forgets it (nothing left to record). Between the first draw of a batch and the last one the title makes no call that writes memory but plain indirect draws, and what those write reaches a later draw's counts only through a barrier, which ends the batch: the pass reads the counts each draw would have read. A recording keeps its blocks of jobs (16384 in all, 17 MB) until its PC allocator is reset (console_list::allocator_reset), when the GPU is done with it: a list submitted again reads its own jobs, and the CPU never writes a block the GPU may still read. With no block free, a check goes alone. Off by default, to be measured first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
299104a to
ee2abf2
Compare
|
Thanks for the review. Head is now ee2abf2 (rebased onto
The nit is fixed in the commit message and the description: root signature and descriptor table sets end a batch. Tested on an RTX 3070 Laptop (driver 621.40):
Still open: the smoke ran with the switch off, so the batch path is still not measured in XCL; that is your finding 4. Claude Code (Claude Opus 5.5) helped with the fixes and this reply; I checked each point. |
|
Follow-up review (head ee2abf2, since 299104a, diff read, not a merge-check):
New:
Fine: with the switch off the default path only gains the atomic AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
Each checked ExecuteIndirect (
indirect_guard) records, in front of itself, a UAV barrier on everything, aDispatch(1, 1, 1)of the count check and two transitions of its output buffer. A retail title makes thousands of these a frame. Another open-source runtime for the same platform measured the same per-call pattern at 14–16 µs a check; by checking all the arguments between two points where they can change in one compute pass that reads a job table the CPU fills while the list is recorded, it went from 2,355 checks a frame to 980 passes and a replayed frame from 86.1 to 77.7 ms (with fewer batch breaks, 133 passes and 84.6 → 75.3 ms). Those are its numbers, not measured here. This PR does the same in XCL, written anew, behindXCL_INDIRECT_GUARD_BATCH=1(off by default) so it can be measured first.With the switch on, the checks of draws (Draw / DrawIndexed signatures) go in batches of up to 32 per list. The first draw of a batch records the barrier, one pass and one transition of the output buffer to INDIRECT_ARGUMENT; each later draw of the batch only writes its job (window, offset, slot, kind, and the program id and title address for the log) into a block of CPU-visible memory before the list is submitted. The pass reads the counts through the memory windows (8 bound as root UAVs). Counts outside them, dispatches (their counts are clamped after the check) and
XCL_INDIRECT_GUARD=compareare checked alone, as before.A batch ends (output buffer back to COMMON) at an ExecuteIndirect that is not of a plain Draw / DrawIndexed signature (dispatches, mesh, root changes, several arguments: checked at the top of the hook, before any of its paths) and at a DispatchMesh; at any other title call on the list but root constant and root view sets, the pipeline set, topology, scissors, viewports, blend factor, stencil ref and index / vertex buffer sets (root signature and descriptor table sets end it); at a check that goes alone; and at the list's Close and the PC Close of a segment (split, KickoffX). Reset, a split and the list's release forget it. Between the first draw of a batch and the last one the title makes no call that writes memory but plain indirect draws, and what those write reaches a later draw's counts only through a barrier, which ends the batch: the pass reads the counts each draw would have read.
A recording keeps its blocks of jobs (16,384 in all, 17 MB) until its PC allocator is reset, when the GPU is done with it: a list submitted again reads its own jobs, and the CPU never writes a block the GPU may still read. With no block free, a check goes alone.
Changed after the review of 12-01 (Foniass): non-draw ExecuteIndirects and DispatchMesh now end a batch (a count written inside a batch could be read before that write); the job blocks went from a ring to blocks held per recording until the allocator reset (a block could be reused with no fence); a GPU test of the batch pass.
Related: #3009 (open) keeps the same buffer in INDIRECT_ARGUMENT between single checks; the two touch the same lines of
checkandexecute_indirectand will need a rebase on each other. amd-dev has a different batching of its own dispatch guard (XCL_INLINE_GUARD_BATCH);indirect_guardis not on that branch.What is in it
hle/d3d12x/indirect_guard.rs:XCL_INDIRECT_GUARD_BATCH, the batch pass (batch_program,BatchPass, 16,384 job blocks, 17 MB, held per recording inBlocksuntil the allocator reset),batchedincheck,end_batch,before_execute_indirect(only a plain draw goes on),retire_batches/allocator_reset,Checked::runwithout transitions for a batched check; unit tests of which checks are batched, which ExecuteIndirects keep a batch, which counts make a job, when a check joins the open batch, how blocks are held and given back, and the pass's window bindings; a GPU test that runs the batch pass over a block of jobs in two windows.hle/d3d12x/bind.rs:guard_batch_end_wanted(the calls a batch goes on across; DispatchMesh ends it) and its test;before_list_callends a batch;execute_indirect_snapshotcallsbefore_execute_indirectfirst;flush_two_passends it at Close and segment Close;reset,inherit_for_splitand the list's release retire its blocks to the allocator.hle/d3d12x/console_list.rs:allocator_resetgives the allocator's job blocks back.hle/d3d12x/real.rs: the hook in front of each list call is also installed with the switch.Tested
main5b0d5fa (same commands, same machine). The head pushed here is this change, with the review fixes described above, rebased ontomainb2b1f10 without conflicts;main's newer commits also changebind.rs,real.rs, which the rebase merged. The full-suite counts below were measured before the review fixes and that rebase.mainb2b1f10), the lib tests of the modules this PR touches (hle::d3d12x::bind,hle::d3d12x::indirect_guard,hle::d3d12x::real,hle::d3d12x::console_list), release, serial, with the 20 skips: 308 passed, 3 failed, 0 ignored; the new GPU testthe_batch_pass_checks_each_job_through_its_windowran (not skipped). The 3 failures (bind::tests::gpu_two_pass_indirect_commands_keep_their_own_records,real::dispatch_chain::tests::an_indirect_dispatch_runs_its_chain_without_any_whole_form,real::dispatch_chain::tests::failed_binding_keeps_indirect_commands_until_allocator_reset) fail the same way onmaind52ff48 (E_INVALIDARG from the driver on this adapter;maind52ff48 with the first three modules: 287 passed, 3 failed, 0 ignored); not rerun onmainb2b1f10.cargo test --release --workspace --no-fail-fast -- --test-threads=4: the lib test binary ends early onmaintoo (exit 0x80004005 aftersparse upload preparation still failed after bounded retries), so the lib was also run alone, serially (--test-threads=1), with--skipfor the 20 tests that end the binary onmain(6list_x, 12sparse, 1texture_upload, 1uma_driver; each passes alone).main5b0d5fa):main: 139 passed, 0 failed, 20 ignored. The failure,gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs, is intermittent onmaintoo (run 8 times alone onmain: 2 failures).main: 2604 passed, 13 failed, 29 ignored. The same 13 failures asmain(12title_textures, 1vram::d32s8_targets_take_their_own_size_of_video_memory); the 5 more passing are this PR's new tests.XCL_INDIRECT_GUARD_BATCH, so the batch pass is off there.main): the wave64 forms (no wave64), three f16/f32 per-lane forms refused by the recompiler, and the heap-window tests (no heap windows).Regression run
scripts/smoke.ps1 -Seconds 120 -Title 'retail title A', release builds of clean trees, one after the other on the machine in Tested, withXCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WATCH_HOT=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=60000. The title is left on its own, with no input; the shader cache was warmed by two runs ofmainbefore.main:This PR:
Not tested
AI use
🤖 Generated with Claude Code