WIP: [pr-diagnostics] Count the CPU cost of per-draw descriptor tables, plus DARNER_DIAG_SUBMIT_DELAY_US (diagnostics builds only) #307
Loading…
Reference in a new issue
No description provided.
Delete branch "Jesper-A/Darner:up-diag-desc-tables"
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?
Refs #269
Contributor role (optional)
What it changes
State::tablesindraw.rs), or where inside it the time goes. The descriptor switches in #269 (DARNER_LIST_VIEWS_FRAME,DARNER_FAST_LIST_VIEWS,DARNER_DIRECT_DYNAMIC_CBV,DARNER_SHARED_TABLES,DARNER_SAME_TABLES) cut descriptor work, and on my card that does not show in fps. I could not say how big the work is or whether a CPU-bound PC would see it. Read from the code and measured on one PC; see below.This adds counters and one test switch. It changes nothing in how the game runs. It exists so that testers on other PCs can send a log that answers the question (see #269), and so the counters are upstream for anyone measuring descriptor work.
Counters (
crates/darner-gpu/src/copystat.rs, hooks indraw.rsanddescriptor/host.rs; all behind thediagnosticsfeature):Commit
a7e2a32cf. Per frame, the time inState::tables, in building theRecordHashkeys and the records hashed, in the fill loop and the slots it filled,fresh_tableshits and misses, views created against slots served bymake_listed, and root one-slot tables made. Logged next to the other copy counters as:desc tables: per frame N tables() calls X ms (P% of Y ms list calls); hash X ms for N records; dynamic() X ms; fill X ms for N slots; fresh_tables N hits N misses; N views created, N slots from make_listed; N root tablesCommit
599bf6f3a. Splits the fill cost: time and calls inside theCreate*View/CreateSamplercalls, insideCopyDescriptors/CopyDescriptorsSimple(calls and descriptors), inmake_listedlookups (and how many made a view), and the rest of the fill. Counted per thread inside the fill and added to the shared counters once per fill, not with an atomic per call. Logged as:desc fill split: per frame fill X ms = create X ms in N calls + copy X ms in N calls (N descriptors) + make_listed X ms in N calls (N made a view) + rest X msNew switch
DARNER_DIAG_SUBMIT_DELAY_US(microseconds, default 0 = off; only in diagnostics builds):c03ed4e4c. Read incopystat::submit_delay_us(copystat.rs): firstcrate::hot::over, so aDARNER_HOT_ABfile can change it while the title runs; otherwise once from the environment into aOnceLock. From the environment, a value that is not a whole number counts as 0 (a non-numericDARNER_HOT_ABvalue falls through to the environment). When above 0 it logsdiag: submit delay N us per frameonce (environment path).copystat::submit_delay()is called once per shown frame at the start ofqueue::show_planes, just beforepresent_placed, and spins on the clock for that long.DARNER_D3D12_WARP.Does a release build change? By the diff, no behaviour change, and the counters are compiled out. I did not build or time a release exe, so this is read from the code, not measured.
copystatis only compiled withall(windows, feature = "diagnostics")(lib.rs). Without it,lib.rshas a stub module with four#[inline(always)]functions:create,copiedandlistedrun the closure they are given,submit_delayis empty.descriptor/host.rsnow wrap the existingCreate*View/CreateSampler/CopyDescriptors*calls in those closures. Same calls in the same order.draw.rsare each behind#[cfg(feature = "diagnostics")].State::tablesis split in two:tables(the same signature) calls the newtables_inner, which holds the old body. With diagnostics offtablesonly callstables_inner. The compiler may inline it or not, so the machine code of that function can differ; the behaviour does not.How it was tested
599bf6f3a(two commits on mainf3840d73d) for the runs;c03ed4e4c(a third commit, how the switch is read) for the gates.cargo build --locked --profile diag -p darner --features diagnosticson599bf6f3a: built; this is the exe all six runs below used.Game runs, 2026-12-04, diag exe, one run per arm, 6 runs in a row (one unscored settle run first). Series S, DLSS Performance, frame generation off, my usual play set of switches, free roaming. Numbers are the last 180 one-second lines of each run. The "fill" column is the
desc tables:fill time per frame, summed over the recording threads (mean of the last 40 counter lines).Split of the fill with no switches and no delay (mean of the last 40 counter lines, ms per frame summed over threads): create 16.9, copy 2.5,
make_listed51.2, rest 39.8. Last line: 53k create calls, 23k copy calls (73k descriptors), 72kmake_listedcalls of which 22k made a view.diagnosticsfeature, and the new switch is off unless set.c03ed4e4c(599bf6f3aplus the switch-reading commit; the runs below used599bf6f3a, whose code differs only in how the switch is read):cargo clippy --workspace --all-targets --locked -- -D warningspassed, and the same with--all-featurespassed.cargo test -p darner-gpu --lib copystat --all-features --locked: 11 passed.cargo test --workspace --lockedfailed indarner-shader --libon four GPU/DXIL-validation tests (emit::barycentric_tests::first_half_values_render_on_hardware_and_warp,emit::rect::tests::rectangles_are_drawn_whole,emit::rect::tests::the_rectangle_stage_is_a_geometry_shader,emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders). This PR does not touchdarner-shader. The same four failed on this PC for other branches that do not touch it either (one rebased on mainf899d8cff); I did not rerun them on mainf3840d73ditself. The run stopped at that crate, so the crates after it were not run.darner-shader; memory not recorded. The runs were not taken to prove the counters are exact: the sum of the split parts equals the fill time by construction (rest = fill minus the other three), so only the three timed parts are independent measurements.Spec dependence
Likely general: the counters time ordinary code paths and the switch spins on the clock. The numbers above, and what they say about where the frame is limited, depend on my specs (RTX 2070 SUPER, Turing, 8 GB, ReBAR off, Ryzen 7 5800X, Series S + DLSS Performance). On a fast card the CPU may be the limit instead; that is the question the counters are for, and it is untested on any other PC.
Checklist
main.docs/asset-policy.md. No game data; text only.Checked for overlap
descriptor/host.rs: #231 (skip cached raw descriptor writes when disabled) and #245 (retry temporary stand-in texture allocation failures). Different functions; #231's hunks sit at lines 6177-6325 of the base, near my wrapped calls at 6082-6730, so a textual conflict is possible there.draw.rs: #187, #143, #57, #48, #17, #15, #14. Their hunks are in other functions; the nearest is #48 (a hunk at about line 6943, just after my fill loop at 6446-6913).README.md; mine adds one row in another table.This pull request was written with AI assistance (Claude Code).