GPU: indirect records clamped into a ring of the list's behind one enhanced barrier, and in the list's prelude where the list did not write them #1000

Open
github-bot wants to merge 8 commits from github-bot/gh-1000 into main AGit
Owner

@⁠PiloteCode on GitHub · 2026-11-25 15:34 UTC · original
PiloteCode:pr/indirect-prelude → main · +1461 −92 · 11 files · 8 commits · open

Based on 085ee7c4 (the first version was on 0b0074e0). main has since moved to 9c184b35, five commits on: as of now the branch merges with it without conflict, and the merged tree builds and passes the checks (see "Tested"). Eight commits:

  • Three clippy fixes for main. The two this PR had before (draw.rs, indirect.rs and resource.rs; shadow.rs) are still needed, and main's seven newer commits need a third (fpsbox.rs, pipeline/library.rs, queue.rs, shadow.rs; with all features draw.rs and watch.rs). Without them cargo clippy --workspace --all-targets --locked -- -D warnings fails on 085ee7c4 with the pinned toolchain: 8 errors in victory-gpu, 10 with --all-features. No change of behaviour; each can be left out on its own.
  • The ring.
  • The clamps in the prelude.
  • A guard for title memory in place.
  • One README line.
  • A lock in the tests of indirect.rs, for runs of the suite on several threads (see "Tested").

The changes are in indirect.rs, host.rs, draw.rs, copystat.rs and shadow.rs. Everything new keeps main's clamp program as it is: its group charging, the budget in the card's memory, the windows and the gathered records (both off by default).

What changed since the first version

  • Rebuilt on main's gathered records (VICTORY_INDIRECT_GATHER, 465b94f5). The conflicts were in indirect.rs, draw.rs, host.rs and the README. main's gather is unchanged: gather, GatherSet, record_gather_as, record_gathers and the program's bit 2 are byte for byte main's.
  • record_clamp_as is main's, byte for byte. The first version rewrote its argument code into a helper. Now the helper (clamp_arguments) serves only the clamps that write room of the ring, and the clamp into the one scratch buffer keeps its own code.
  • The prelude's clamps have a budget of their own, zeroed first in the prelude. In the first version they charged the list's own budget, which the list zeroes inside itself: they started from what the list's last run had left, and what they charged was zeroed away. Found while placing them beside the gathered records; a test now holds it.
  • A prelude that cannot record its clamps fails, as one that cannot record the gathered passes does. In the first version it recorded nothing and the list ran.
  • The window check is told where its record is: in the list's ring (an enhanced barrier) or in a scratch buffer (changes of state), which a gathered record's slot always is.
  • Tests: the count buffer and the budget through the ring's path, and the prelude's clamps, on the test's own device with a clamp made for it; the two budgets; a prelude with gathered records and clamps side by side.

What was wrong

Every indirect execution's records are clamped by a compute pass of ours into the list's one scratch buffer. That costs two changes of state per clamp: the buffer goes from indirect arguments to unordered access before the pass, and back after it. Each change waits for all the card's work before it.

So every clamp waited for the last indirect call to have read the buffer, and the call after it waited for the clamp. The title makes about 2,500 such calls a frame in the gameplay. In a timing run of the gameplay's opening (RTX 5090, our tree, before main's changes to the clamp), our clamps took 33 ms of the card's ~100 ms a frame.

What changes

A ring of clamped records (indirect::ring, HostList::indirect_ring)

Each clamp writes room of its own in a ring of the list's, so it overwrites nothing an earlier call still reads:

  • one barrier of the enhanced kind (compute writes → indirect argument read) replaces the two changes of state around the clamp, with no barrier before it;
  • a full ring is replaced by one twice as big (the old one is kept until the list is reset), and after a reset the ring is taken from its start;
  • the clamp now returns where in its buffer the records start; a window keeps that place, and the window check reads a ring record behind an enhanced barrier.

The ring is on where the device reports enhanced barriers (D3D12_OPTIONS12). VICTORY_INDIRECT_RING=0 clamps into the one scratch buffer, as before, through main's record_clamp_as.

Measured in that timing run: the clamps went from 33 to 19 ms of card time a frame, the card's commands from 102 to 95 ms, and frames from 179 to 171 ms (median) and 210 to 189 ms (mean). Part of the wait moved to the indirect calls: the card still switches from drawing to compute and back for each clamp.

Clamps in the list's prelude (indirect::early, HostList::writes_declared)

A clamp in the list still stops the card twice: it turns from drawing to compute and back, and the barrier after it holds up the indirect call, so the calls around it cannot overlap.

Some records are not written by any shader the list recorded before the command. The list now keeps the ranges its shaders declare written (Step::GpuWrite), each once. For records outside them, the card holds them as they are when the list begins: the title's CPU or an earlier list wrote them. Their clamps (no count buffer) are noted for the list's prelude, which the card runs just before the list at each of its submissions:

  • the prelude's budget zeroed;
  • a global barrier after every earlier shader write;
  • the clamps, with no wait between them (each writes room of its own in the ring; the budget is taken atomically);
  • one barrier from their writes to the indirect reads.

The command reads its room of the ring as before, and the list keeps its pipeline and root bindings: nothing of ours goes into the list for such a record.

The budget. The prelude's clamps are charged to a budget of their own (HostList::early_budget, 256 bytes in the card's memory, made at the first such clamp), which the prelude zeroes first at each submission, the way main does for its gathered records. The list's own budget is zeroed inside the list, where its first clamp is recorded, so a clamp that runs before the list can neither start from zero in it nor leave its charge there. A list's work is so bounded once for each place its records are clamped in: the prelude's gathered records, the prelude's clamps, the list.

Of the clamps of a timing run of the gameplay, 788 draw clamps a frame had records from before the list and 228 had records written in it; dispatches, 228 and 679. Before this change, our clamps took 6.8 ms of card time a frame at the start of the gameplay. With it, they took about 1.25 ms a frame: about 0.5 ms for the ~990 clamps left in the lists and about 0.75 ms for the preludes. That second timing run was of a later build of our tree, which had other changes too.

The prelude needs the ring. VICTORY_INDIRECT_EARLY=0 clamps every record in the list, as before.

Records in title memory in place. Shaders that write title memory in place (VICTORY_INPLACE, off by default) declare nothing. Records in such memory are taken as written and clamped in the list.

With main's gathered records (VICTORY_INDIRECT_GATHER=1)

Both put clamps in the prelude. They are kept apart:

  • Which record goes where. A draw's single record that misses its window is gathered first, exactly as on main. What is not gathered (a dispatch, several records, a count buffer, shaders that store to buffers, a list that no longer gathers, a full set) is clamped by this PR's code: in the prelude if the list did not write it and it has no count buffer, otherwise in the list, into the ring.
  • Buffers. A gathered record's slot stays in its set's scratch buffer, with main's two changes of state a list. Gathered records do not go to the ring.
  • Order in the prelude. The gathered sets' passes are recorded first, as on main, then this PR's clamps. Up to and including the gathered passes the prelude is what main records; with VICTORY_INDIRECT_EARLY=0, or no such clamp, it is main's prelude.
  • Budgets. The gathered records keep theirs, the prelude's clamps have theirs, the list has its own. Neither kind changes what the other clamps or leaves empty, so the order between the two decides nothing but which waits first.
  • Diagnostics. The frame shot's line for the prelude also counts this PR's clamps.

Diagnostics (diagnostics builds)

  • The timing run (VICTORY_GPU_TIMING) times the prelude as one command ("prelude (ours): N clamps"); the list keeps two of its timestamps for it.
  • The frame line counts the clamps by where their records come from: draws and dispatches, written in the list or from before it, and those clamped in preludes.

Measured effect, and what was not measured here

The numbers above are from timing runs of our tree on an RTX 5090. There these changes are on by default, and the general test runs of our integration branches with them (opening cutscene, gameplay from a save) had no device loss. HrHd ported the first version onto a tree of his own on current main and measured 253.9-272.8 → 227.7-231.7 ms a frame on an RTX 4060 Ti, with no device removal (comment above).

This branch, as it is on 085ee7c4: its tests ran on the software adapter and on an RTX 5090 (see "Tested"); in the title it has not drawn an indirect command yet (see "Not tested").

Switches

Switch Default Effect
VICTORY_INDIRECT_RING on where enhanced barriers are supported =0: the one scratch buffer, as before
VICTORY_INDIRECT_EARLY on with the ring =0: every clamp in the list, as before

Tested

On 085ee7c4, with the host device on the software adapter (VICTORY_D3D12_WARP=1, --features diagnostics). The software adapter takes enhanced barriers, so the ring and prelude tests ran rather than being skipped. The test runs below were made at 00c97825; the tip b333628b differs from it by three lines of a test's comment, and at it the checks that build, the serial run and 5 runs on several threads were made again: clippy clean both ways, the policy and both builds pass, 206 passed and 1 failed serially, and the 5 runs on several threads all completed with the same result.

  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo xtask policy: passes (host.rs is 425,559 bytes of the 524,288 allowed).
  • cargo build --release -p victory and cargo build --profile diag -p victory --features diagnostics: both pass.
  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1: 206 passed, 1 failed, 6 ignored.
  • The same with the default test threads (32 here), 12 runs: 11 completed (206 passed and 1 failed in 7 of them, 205 and 2 in 4), and 1 died of an access violation (below).
  • VICTORY_INDIRECT_RING=0: serially 205 passed, 2 failed, 6 ignored; of 5 runs on several threads 4 completed (206 passed, 1 failed) and 1 died. The host-list tests that follow the switch (bound, bound_ahead, the window check) then take main's scratch buffer; the tests that ask for the ring still run it.
  • VICTORY_INDIRECT_GATHER=1 (ring on): serially 205 passed, 2 failed, 6 ignored; 5 runs on several threads all completed (206 passed and 1 failed in 3, 205 and 2 in 1, 204 and 3 in 1). The switch is read in draw.rs, which no test reaches: what covers the two together is the test of a prelude with both, named below, whatever the switch.

The failures are main's:

  • depth_bounds_pipeline_loads_and_filters_draws fails in every run: the software adapter does not reject the pixels outside the depth bounds. The same on main.
  • One of watch's tests failed in one run on several threads (a_view_mapped_beside_a_guarded_one_makes_it_check_again); three others of them did so in main's runs on several threads here.
  • warp_budget_saturates_without_wraparound_and_preserves_draw_fields fails in some runs: its two groups of records may charge the budget in either order (#849, #970). It runs main's record_clamp_as, which this PR does not change. Alone, it passed 2 times of 20 on plain main here, and 56 of 200 at this branch's tip.

Plain main (085ee7c4), run the same way: serially 199 passed, 1 failed (depth_bounds_pipeline_loads_and_filters_draws), 6 ignored. Of 10 runs on several threads, 4 completed (199 passed and 1 failed in 2, 198 and 2 in 2: the same two tests) and 6 died of an access violation.

Runs on several threads. On plain main, the suite run with the default test threads died of an access violation in 6 runs of 10 through cargo, and in 6 of 11 run earlier from the test binary, here: inside the software rasterizer (d3d10warp.dll), at a different place each time (in the two crash dumps read, which came from a build of main with a change to the test harness, not plain main: a null read in a call made by a queue2 test, and a wild write on one of the rasterizer's own threads). It needs the device tests of indirect.rs running side by side: with none of that module's tests, none of 10 runs died. With the seven tests this PR adds it died more often (17 runs of 22). The last commit makes those tests take a lock of their module while they use a device, so that one of them runs at a time: of 39 runs with it (12 while trying it, the 12, 5 and 5 above, and 5 at the tip), 37 completed and 2 died, and in each of the 37 both tests of the ring and of the prelude passed: 12 and then 11 times in a row, and in all 5 at the tip. Nothing changes in a serial run. The cause inside the rasterizer was not found; this keeps the suite's own tests from meeting it.

On an RTX 5090 (the branch's tip, the host device on the card, no VICTORY_D3D12_WARP): cargo test -p victory-gpu --features diagnostics -- --test-threads=1: 207 passed, 0 failed, 6 ignored. The card takes enhanced barriers, so the ring and prelude tests ran on it; the depth-bounds test and the budget test both passed there.

Merged with 9c184b35 (a trial merge, not pushed): cargo clippy --workspace --all-targets --locked -- -D warnings and the same with --all-features are clean, cargo xtask policy passes, and the serial run on the software adapter gives 205 passed, 2 failed, 6 ignored: the same two tests as above. main's profile::tests::stacks_that_mean_nothing_are_walked_without_a_fault was left out of that run: on this machine it ends the test process with an access violation, on main as well.

The debug layer was not on. The D3D12 debug layer is not installed on the machine these ran on, so the tests' checks of its messages (host.log_messages()) found nothing to read, for this version and for the first. What the debug layer says of the ring's barriers has not been seen.

New and changed tests:

  • The ring: each clamp gets room of its own, a full ring is replaced by a bigger one, a submission runs with the enhanced barriers, and after a reset the room is taken from the ring's start.

  • The count buffer through the ring's path (the test's own device, a clamp made for it): the two executions of main's count-buffer test, each clamped into room of its own in one buffer. The garbage past the count charges nothing, all five valid dispatches run, the title's records and counts stay as they were, and the second clamp leaves the first's room alone.

  • The budget through the ring's path (the same way): it saturates without wrapping, two draws fit, every other one runs empty with its other words kept, and nothing is written before the clamp's room. The two draws that fit are the first two of either group: which group charges first is the card's choice.

  • The prelude on a host list: three clamps noted for a list's prelude run there at each submission. Each record is read clamped: a record of 70,000 groups runs 65,535, and one of all ones runs empty. The title's records stay as they were. A second submission, with records the CPU changed in between, clamps them again. A reset forgets the clamps.

  • The prelude on the test's own device (a clamp made for it, passed as an argument): a list recorded once runs twice behind a prelude recorded for each run; the budget then holds the second run's charge alone.

  • The two budgets: a list whose own clamps spend its budget leaves a record clamped in its prelude to run, at a second submission too; and the other way round.

  • Gathered records and the prelude's clamps side by side on a host list: each command reads its record clamped, from the set's scratch buffer or from the ring, at a second submission too; what one kind spends of its budget leaves the other kind's records theirs.

  • The scratch buffer's reuse is tested on its own path (the ring off).

  • The window executions run on both paths.

  • The budget test (host_list_budget_starts_empty_at_each_submission) clamps its spending and the record after it together. Two clamps into the ring are not ordered on the card: a clamp has no barrier before it, and the one after it orders the indirect read, not the next clamp. A general test on the RTX 5090 found the second clamp's charge first.

    This is not a change of behaviour in the title. With the ring, a list's clamps charge its budget in the card's order, so once garbage records spend the budget, which records run empty is the card's choice. The budget still bounds the list's work.

The two points of the review

  1. clamp_arguments and the count path. Not reproduced. Each test alone on the software adapter, the two forms of record_clamp_as built from this branch's tip and run in turn: warp_count_buffer_ignores_garbage_tail_and_preserves_source passed 20 times of 20 with main's inline code and 20 of 20 with the first version's helper; warp_budget_saturates_without_wraparound_and_preserves_draw_fields passed 9 of 20 and 3 of 20, and over 200 runs each 56 and 52. That second test fails on plain main too (2 passes of 20): it is the test of #849 and #970. The helper computes the same constants and addresses; no defect was found in it. Even so record_clamp_as is now main's own code, and the count buffer and the budget are also tested through the ring's path.
  2. The two new tests in a full run. The clamp pipeline is made on the host device, and both tests record on host lists of that device, so they run the pipeline of their own device; alone and in serial runs they pass. What does fail is the whole suite on several threads, on plain main as well (above). With the lock, both tests passed in each of the 37 runs that completed (of 39). The prelude's clamps also take the pipeline as an argument now, and a test runs them on its own device.

Overlaps with open pull requests

  • #993 (our second translator PR) changes the same two functions, indirect::bound and indirect::bound_ahead: the scratch size of a split dispatch, whose records are bigger. Whichever goes in second takes both changes, as in our tree: a scratch_bytes size passed to the ring or the scratch buffer. #993 also adds a kind to the clamp program, which this PR does not touch.
  • #992 starts with the same two clippy commits as this PR.
  • #849 and #970 fix the order the budget test expects of its two groups; this PR leaves that test alone, and its new budget test through the ring takes either order.
  • #862, #864, #899 and #663 change the window bounds, the order of a window's records, the budget order across groups, and the invalidation of windows. Each touches indirect.rs or draw.rs near these changes.
  • #889 and #780 are closed.

Not tested

  • This branch in the title. One run of the save on the RTX 5090 (240 s, the ring, the prelude's clamps, VICTORY_INDIRECT_WINDOW=1 and VICTORY_INDIRECT_GATHER=1) had no device removal and no exception, but with this build's cold pipeline cache it was still loading when it ended: no indirect command was drawn. The first version ran on an RTX 4060 Ti in the reviewer's port.
  • What stands in for it: our own tree, where main (085ee7c4) is merged with the indirect code placed as in this branch (gathered records first, then the prelude's clamps with their own budget, the rest in the list into the ring). One run of the save's gameplay there on the RTX 5090 with all of it on, at about 3,900 draws a frame: 1,324 commands a frame read from a window, 1,195 read a gathered record, 843 were clamped in preludes and the rest in their lists; 210 s, no device removal, and neither of the two "could not be clamped in its prelude" errors. That tree has other changes too.
  • GPUs without enhanced barriers: the ring and the prelude are off there, and main's path is taken.
  • The D3D12 debug layer's view of the barriers; AMD and Intel GPUs; Linux/Proton.
**@⁠PiloteCode** on GitHub · 2026-11-25 15:34 UTC · [original](https://github.com/fxceless/victory-fork/pull/1000) `PiloteCode:pr/indirect-prelude` → `main` · +1461 −92 · 11 files · 8 commits · open Based on `085ee7c4` (the first version was on `0b0074e0`). `main` has since moved to `9c184b35`, five commits on: as of now the branch merges with it without conflict, and the merged tree builds and passes the checks (see "Tested"). Eight commits: - Three clippy fixes for `main`. The two this PR had before (`draw.rs`, `indirect.rs` and `resource.rs`; `shadow.rs`) are still needed, and `main`'s seven newer commits need a third (`fpsbox.rs`, `pipeline/library.rs`, `queue.rs`, `shadow.rs`; with all features `draw.rs` and `watch.rs`). Without them `cargo clippy --workspace --all-targets --locked -- -D warnings` fails on `085ee7c4` with the pinned toolchain: 8 errors in `victory-gpu`, 10 with `--all-features`. No change of behaviour; each can be left out on its own. - The ring. - The clamps in the prelude. - A guard for title memory in place. - One README line. - A lock in the tests of `indirect.rs`, for runs of the suite on several threads (see "Tested"). The changes are in `indirect.rs`, `host.rs`, `draw.rs`, `copystat.rs` and `shadow.rs`. Everything new keeps `main`'s clamp program as it is: its group charging, the budget in the card's memory, the windows and the gathered records (both off by default). ## What changed since the first version - **Rebuilt on `main`'s gathered records** (`VICTORY_INDIRECT_GATHER`, 465b94f5). The conflicts were in `indirect.rs`, `draw.rs`, `host.rs` and the README. `main`'s gather is unchanged: `gather`, `GatherSet`, `record_gather_as`, `record_gathers` and the program's bit 2 are byte for byte `main`'s. - **`record_clamp_as` is `main`'s, byte for byte.** The first version rewrote its argument code into a helper. Now the helper (`clamp_arguments`) serves only the clamps that write room of the ring, and the clamp into the one scratch buffer keeps its own code. - **The prelude's clamps have a budget of their own**, zeroed first in the prelude. In the first version they charged the list's own budget, which the list zeroes inside itself: they started from what the list's last run had left, and what they charged was zeroed away. Found while placing them beside the gathered records; a test now holds it. - **A prelude that cannot record its clamps fails**, as one that cannot record the gathered passes does. In the first version it recorded nothing and the list ran. - **The window check is told where its record is**: in the list's ring (an enhanced barrier) or in a scratch buffer (changes of state), which a gathered record's slot always is. - **Tests**: the count buffer and the budget through the ring's path, and the prelude's clamps, on the test's own device with a clamp made for it; the two budgets; a prelude with gathered records and clamps side by side. ## What was wrong Every indirect execution's records are clamped by a compute pass of ours into the list's one scratch buffer. That costs two changes of state per clamp: the buffer goes from indirect arguments to unordered access before the pass, and back after it. Each change waits for all the card's work before it. So every clamp waited for the last indirect call to have read the buffer, and the call after it waited for the clamp. The title makes about 2,500 such calls a frame in the gameplay. In a timing run of the gameplay's opening (RTX 5090, our tree, before `main`'s changes to the clamp), our clamps took 33 ms of the card's ~100 ms a frame. ## What changes ### A ring of clamped records (`indirect::ring`, `HostList::indirect_ring`) Each clamp writes room of its own in a ring of the list's, so it overwrites nothing an earlier call still reads: - one barrier of the enhanced kind (compute writes → indirect argument read) replaces the two changes of state around the clamp, with no barrier before it; - a full ring is replaced by one twice as big (the old one is kept until the list is reset), and after a reset the ring is taken from its start; - the clamp now returns where in its buffer the records start; a window keeps that place, and the window check reads a ring record behind an enhanced barrier. The ring is on where the device reports enhanced barriers (`D3D12_OPTIONS12`). `VICTORY_INDIRECT_RING=0` clamps into the one scratch buffer, as before, through `main`'s `record_clamp_as`. Measured in that timing run: the clamps went from 33 to 19 ms of card time a frame, the card's commands from 102 to 95 ms, and frames from 179 to 171 ms (median) and 210 to 189 ms (mean). Part of the wait moved to the indirect calls: the card still switches from drawing to compute and back for each clamp. ### Clamps in the list's prelude (`indirect::early`, `HostList::writes_declared`) A clamp in the list still stops the card twice: it turns from drawing to compute and back, and the barrier after it holds up the indirect call, so the calls around it cannot overlap. Some records are not written by any shader the list recorded before the command. The list now keeps the ranges its shaders declare written (`Step::GpuWrite`), each once. For records outside them, the card holds them as they are when the list begins: the title's CPU or an earlier list wrote them. Their clamps (no count buffer) are noted for the list's prelude, which the card runs just before the list at each of its submissions: - the prelude's budget zeroed; - a global barrier after every earlier shader write; - the clamps, with no wait between them (each writes room of its own in the ring; the budget is taken atomically); - one barrier from their writes to the indirect reads. The command reads its room of the ring as before, and the list keeps its pipeline and root bindings: nothing of ours goes into the list for such a record. **The budget.** The prelude's clamps are charged to a budget of their own (`HostList::early_budget`, 256 bytes in the card's memory, made at the first such clamp), which the prelude zeroes first at each submission, the way `main` does for its gathered records. The list's own budget is zeroed inside the list, where its first clamp is recorded, so a clamp that runs before the list can neither start from zero in it nor leave its charge there. A list's work is so bounded once for each place its records are clamped in: the prelude's gathered records, the prelude's clamps, the list. Of the clamps of a timing run of the gameplay, 788 draw clamps a frame had records from before the list and 228 had records written in it; dispatches, 228 and 679. Before this change, our clamps took 6.8 ms of card time a frame at the start of the gameplay. With it, they took about 1.25 ms a frame: about 0.5 ms for the ~990 clamps left in the lists and about 0.75 ms for the preludes. That second timing run was of a later build of our tree, which had other changes too. The prelude needs the ring. `VICTORY_INDIRECT_EARLY=0` clamps every record in the list, as before. **Records in title memory in place.** Shaders that write title memory in place (`VICTORY_INPLACE`, off by default) declare nothing. Records in such memory are taken as written and clamped in the list. ### With `main`'s gathered records (`VICTORY_INDIRECT_GATHER=1`) Both put clamps in the prelude. They are kept apart: - **Which record goes where.** A draw's single record that misses its window is gathered first, exactly as on `main`. What is not gathered (a dispatch, several records, a count buffer, shaders that store to buffers, a list that no longer gathers, a full set) is clamped by this PR's code: in the prelude if the list did not write it and it has no count buffer, otherwise in the list, into the ring. - **Buffers.** A gathered record's slot stays in its set's scratch buffer, with `main`'s two changes of state a list. Gathered records do not go to the ring. - **Order in the prelude.** The gathered sets' passes are recorded first, as on `main`, then this PR's clamps. Up to and including the gathered passes the prelude is what `main` records; with `VICTORY_INDIRECT_EARLY=0`, or no such clamp, it is `main`'s prelude. - **Budgets.** The gathered records keep theirs, the prelude's clamps have theirs, the list has its own. Neither kind changes what the other clamps or leaves empty, so the order between the two decides nothing but which waits first. - **Diagnostics.** The frame shot's line for the prelude also counts this PR's clamps. ### Diagnostics (diagnostics builds) - The timing run (`VICTORY_GPU_TIMING`) times the prelude as one command ("prelude (ours): N clamps"); the list keeps two of its timestamps for it. - The frame line counts the clamps by where their records come from: draws and dispatches, written in the list or from before it, and those clamped in preludes. ## Measured effect, and what was not measured here The numbers above are from timing runs of our tree on an RTX 5090. There these changes are on by default, and the general test runs of our integration branches with them (opening cutscene, gameplay from a save) had no device loss. HrHd ported the first version onto a tree of his own on current `main` and measured 253.9-272.8 → 227.7-231.7 ms a frame on an RTX 4060 Ti, with no device removal (comment above). This branch, as it is on `085ee7c4`: its tests ran on the software adapter and on an RTX 5090 (see "Tested"); in the title it has not drawn an indirect command yet (see "Not tested"). ## Switches | Switch | Default | Effect | |---|---|---| | `VICTORY_INDIRECT_RING` | on where enhanced barriers are supported | `=0`: the one scratch buffer, as before | | `VICTORY_INDIRECT_EARLY` | on with the ring | `=0`: every clamp in the list, as before | ## Tested On `085ee7c4`, with the host device on the software adapter (`VICTORY_D3D12_WARP=1`, `--features diagnostics`). The software adapter takes enhanced barriers, so the ring and prelude tests ran rather than being skipped. The test runs below were made at `00c97825`; the tip `b333628b` differs from it by three lines of a test's comment, and at it the checks that build, the serial run and 5 runs on several threads were made again: clippy clean both ways, the policy and both builds pass, 206 passed and 1 failed serially, and the 5 runs on several threads all completed with the same result. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `cargo xtask policy`: passes (`host.rs` is 425,559 bytes of the 524,288 allowed). - `cargo build --release -p victory` and `cargo build --profile diag -p victory --features diagnostics`: both pass. - `cargo test -p victory-gpu --features diagnostics -- --test-threads=1`: 206 passed, 1 failed, 6 ignored. - The same with the default test threads (32 here), 12 runs: 11 completed (206 passed and 1 failed in 7 of them, 205 and 2 in 4), and 1 died of an access violation (below). - `VICTORY_INDIRECT_RING=0`: serially 205 passed, 2 failed, 6 ignored; of 5 runs on several threads 4 completed (206 passed, 1 failed) and 1 died. The host-list tests that follow the switch (`bound`, `bound_ahead`, the window check) then take `main`'s scratch buffer; the tests that ask for the ring still run it. - `VICTORY_INDIRECT_GATHER=1` (ring on): serially 205 passed, 2 failed, 6 ignored; 5 runs on several threads all completed (206 passed and 1 failed in 3, 205 and 2 in 1, 204 and 3 in 1). The switch is read in `draw.rs`, which no test reaches: what covers the two together is the test of a prelude with both, named below, whatever the switch. The failures are `main`'s: - `depth_bounds_pipeline_loads_and_filters_draws` fails in every run: the software adapter does not reject the pixels outside the depth bounds. The same on `main`. - One of `watch`'s tests failed in one run on several threads (`a_view_mapped_beside_a_guarded_one_makes_it_check_again`); three others of them did so in `main`'s runs on several threads here. - `warp_budget_saturates_without_wraparound_and_preserves_draw_fields` fails in some runs: its two groups of records may charge the budget in either order (#849, #970). It runs `main`'s `record_clamp_as`, which this PR does not change. Alone, it passed 2 times of 20 on plain `main` here, and 56 of 200 at this branch's tip. **Plain `main` (`085ee7c4`), run the same way:** serially 199 passed, 1 failed (`depth_bounds_pipeline_loads_and_filters_draws`), 6 ignored. Of 10 runs on several threads, 4 completed (199 passed and 1 failed in 2, 198 and 2 in 2: the same two tests) and 6 died of an access violation. **Runs on several threads.** On plain `main`, the suite run with the default test threads died of an access violation in 6 runs of 10 through cargo, and in 6 of 11 run earlier from the test binary, here: inside the software rasterizer (`d3d10warp.dll`), at a different place each time (in the two crash dumps read, which came from a build of `main` with a change to the test harness, not plain `main`: a null read in a call made by a `queue2` test, and a wild write on one of the rasterizer's own threads). It needs the device tests of `indirect.rs` running side by side: with none of that module's tests, none of 10 runs died. With the seven tests this PR adds it died more often (17 runs of 22). The last commit makes those tests take a lock of their module while they use a device, so that one of them runs at a time: of 39 runs with it (12 while trying it, the 12, 5 and 5 above, and 5 at the tip), 37 completed and 2 died, and in each of the 37 both tests of the ring and of the prelude passed: 12 and then 11 times in a row, and in all 5 at the tip. Nothing changes in a serial run. The cause inside the rasterizer was not found; this keeps the suite's own tests from meeting it. **On an RTX 5090** (the branch's tip, the host device on the card, no `VICTORY_D3D12_WARP`): `cargo test -p victory-gpu --features diagnostics -- --test-threads=1`: 207 passed, 0 failed, 6 ignored. The card takes enhanced barriers, so the ring and prelude tests ran on it; the depth-bounds test and the budget test both passed there. **Merged with `9c184b35`** (a trial merge, not pushed): `cargo clippy --workspace --all-targets --locked -- -D warnings` and the same with `--all-features` are clean, `cargo xtask policy` passes, and the serial run on the software adapter gives 205 passed, 2 failed, 6 ignored: the same two tests as above. `main`'s `profile::tests::stacks_that_mean_nothing_are_walked_without_a_fault` was left out of that run: on this machine it ends the test process with an access violation, on `main` as well. **The debug layer was not on.** The D3D12 debug layer is not installed on the machine these ran on, so the tests' checks of its messages (`host.log_messages()`) found nothing to read, for this version and for the first. What the debug layer says of the ring's barriers has not been seen. New and changed tests: - **The ring:** each clamp gets room of its own, a full ring is replaced by a bigger one, a submission runs with the enhanced barriers, and after a reset the room is taken from the ring's start. - **The count buffer through the ring's path** (the test's own device, a clamp made for it): the two executions of `main`'s count-buffer test, each clamped into room of its own in one buffer. The garbage past the count charges nothing, all five valid dispatches run, the title's records and counts stay as they were, and the second clamp leaves the first's room alone. - **The budget through the ring's path** (the same way): it saturates without wrapping, two draws fit, every other one runs empty with its other words kept, and nothing is written before the clamp's room. The two draws that fit are the first two of either group: which group charges first is the card's choice. - **The prelude on a host list:** three clamps noted for a list's prelude run there at each submission. Each record is read clamped: a record of 70,000 groups runs 65,535, and one of all ones runs empty. The title's records stay as they were. A second submission, with records the CPU changed in between, clamps them again. A reset forgets the clamps. - **The prelude on the test's own device** (a clamp made for it, passed as an argument): a list recorded once runs twice behind a prelude recorded for each run; the budget then holds the second run's charge alone. - **The two budgets:** a list whose own clamps spend its budget leaves a record clamped in its prelude to run, at a second submission too; and the other way round. - **Gathered records and the prelude's clamps side by side** on a host list: each command reads its record clamped, from the set's scratch buffer or from the ring, at a second submission too; what one kind spends of its budget leaves the other kind's records theirs. - **The scratch buffer's reuse** is tested on its own path (the ring off). - **The window executions** run on both paths. - **The budget test** (`host_list_budget_starts_empty_at_each_submission`) clamps its spending and the record after it together. Two clamps into the ring are not ordered on the card: a clamp has no barrier before it, and the one after it orders the indirect read, not the next clamp. A general test on the RTX 5090 found the second clamp's charge first. This is not a change of behaviour in the title. With the ring, a list's clamps charge its budget in the card's order, so once garbage records spend the budget, which records run empty is the card's choice. The budget still bounds the list's work. ## The two points of the review 1. **`clamp_arguments` and the count path.** Not reproduced. Each test alone on the software adapter, the two forms of `record_clamp_as` built from this branch's tip and run in turn: `warp_count_buffer_ignores_garbage_tail_and_preserves_source` passed 20 times of 20 with `main`'s inline code and 20 of 20 with the first version's helper; `warp_budget_saturates_without_wraparound_and_preserves_draw_fields` passed 9 of 20 and 3 of 20, and over 200 runs each 56 and 52. That second test fails on plain `main` too (2 passes of 20): it is the test of #849 and #970. The helper computes the same constants and addresses; no defect was found in it. Even so `record_clamp_as` is now `main`'s own code, and the count buffer and the budget are also tested through the ring's path. 2. **The two new tests in a full run.** The clamp pipeline is made on the host device, and both tests record on host lists of that device, so they run the pipeline of their own device; alone and in serial runs they pass. What does fail is the whole suite on several threads, on plain `main` as well (above). With the lock, both tests passed in each of the 37 runs that completed (of 39). The prelude's clamps also take the pipeline as an argument now, and a test runs them on its own device. ## Overlaps with open pull requests - **#993** (our second translator PR) changes the same two functions, `indirect::bound` and `indirect::bound_ahead`: the scratch size of a split dispatch, whose records are bigger. Whichever goes in second takes both changes, as in our tree: a `scratch_bytes` size passed to the ring or the scratch buffer. #993 also adds a kind to the clamp program, which this PR does not touch. - **#992** starts with the same two clippy commits as this PR. - **#849** and **#970** fix the order the budget test expects of its two groups; this PR leaves that test alone, and its new budget test through the ring takes either order. - **#862**, **#864**, **#899** and **#663** change the window bounds, the order of a window's records, the budget order across groups, and the invalidation of windows. Each touches `indirect.rs` or `draw.rs` near these changes. - #889 and #780 are closed. ## Not tested - This branch in the title. One run of the save on the RTX 5090 (240 s, the ring, the prelude's clamps, `VICTORY_INDIRECT_WINDOW=1` and `VICTORY_INDIRECT_GATHER=1`) had no device removal and no exception, but with this build's cold pipeline cache it was still loading when it ended: no indirect command was drawn. The first version ran on an RTX 4060 Ti in the reviewer's port. - What stands in for it: our own tree, where `main` (`085ee7c4`) is merged with the indirect code placed as in this branch (gathered records first, then the prelude's clamps with their own budget, the rest in the list into the ring). One run of the save's gameplay there on the RTX 5090 with all of it on, at about 3,900 draws a frame: 1,324 commands a frame read from a window, 1,195 read a gathered record, 843 were clamped in preludes and the rest in their lists; 210 s, no device removal, and neither of the two "could not be clamped in its prelude" errors. That tree has other changes too. - GPUs without enhanced barriers: the ring and the prelude are off there, and `main`'s path is taken. - The D3D12 debug layer's view of the barriers; AMD and Intel GPUs; Linux/Proton.
`cargo clippy --workspace --all-targets -- -D warnings` (CI) fails on 9376fd6
with this toolchain: unnecessary_sort_by in draw.rs, the bench's
depth_written in indirect.rs never read, and placed_filler_twins unused
without the diagnostics feature. No code changes.
`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c4 with the pinned toolchain (1.98.1), after the two fixes before
this one too: map_entry in fpsbox.rs, collapsible_if in
pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and
with --all-features in draw.rs and watch.rs (twice). No change of
behaviour.
Each clamp writes room of its own, so it no longer waits for the last
indirect call to have read the one scratch buffer, and one barrier of the
host's enhanced kind (compute writes -> indirect argument read) replaces
the two changes of state around it. Timing run of the opening of the
gameplay (RTX 5090, our tree before main's second-night changes to the
clamp): the clamps 33 -> 19 ms a frame, the card's commands 102 -> 95 ms;
frames 179 -> 171 ms (median), 210 -> 189 ms (mean). On where the host
takes enhanced barriers; VICTORY_INDIRECT_RING=0 clamps into the one
scratch buffer as before.

The clamp now says where in its buffer the records start: a window keeps
it, and the window check reads a record of the ring behind an enhanced
barrier.

The clamp into the one scratch buffer (record_clamp_as) is left as main
has it. A clamp into the ring works out its root constants and addresses
in a helper of its own (clamp_arguments) and records the pass with no
barrier (record_clamp_into).

Records gathered for a list's prelude (VICTORY_INDIRECT_GATHER) do not go
to the ring: they keep their sets' scratch buffers and changes of state,
and the window check is told which of the two it reads from.

Tests: the scratch buffer's reuse on its own path; the ring gives each
clamp room of its own, replaces a full ring, and starts from its
beginning after a reset; the window executions run on both paths. The
budget test clamps its spending and the record after it together: two
clamps into the ring are not ordered on the card (a general test on the
RTX 5090 found the small record's charge first). The count-buffer test
and the budget test of the software adapter also run through the ring's
path, on the test's own device with a clamp made for it: the garbage past
the count charges nothing, every valid dispatch runs, the title's records
stay as they were, and a second clamp leaves the first's room alone.
A clamp in the list stops the card twice: it turns from drawing to
compute for the clamp and back, and the barrier after it waits for it
before the indirect call, so the calls around it cannot overlap (the
clamps took 19 ms of the card's ~95 a frame in the gameplay's timing
run, 2,500 a frame; 6.8 ms in 1,021 at the start of the gameplay). Where
no shader the list recorded before the command may write the records (by
the writes its shaders declare, now kept per list as ranges of title
memory), the card holds them as they are when the list begins: the
title's CPU wrote them, or an earlier list's shaders. Their clamps now go
to the list's prelude, which runs just before the list at each of its
submissions: a wait for earlier shader writes, the clamps with no wait
between them (each writes room of its own in the list's ring; the budget
is taken atomically), and one barrier from their writes to the indirect
reads. The command reads its room of the ring as before, and the list
keeps its pipeline and root bindings. In that timing run's clamps: draws
788 a frame with records from before the list, 228 written in it;
dispatches 228 and 679.

The prelude's clamps are charged to a budget of their own, which the
prelude zeroes first at each submission, as main's gathered records are
to theirs. The list's own budget is zeroed inside the list, where its
first clamp is recorded: a clamp in the prelude would find in it what the
list's last run left, and what it charged would be zeroed away (as this
change was first sent, it charged the list's budget so). Nothing of ours
goes into the list for such a record, the zeroing of a budget included.

With main's gathered records (VICTORY_INDIRECT_GATHER=1) the prelude
records the gathered sets' passes first, as they are on main, then these
clamps: the two write different buffers and charge different budgets, so
neither changes what the other clamps or leaves empty. A draw's single
record that misses its window is gathered first, as without this change;
what is not gathered comes here if the list did not write it. A prelude
that cannot record these clamps fails, as one that cannot record the
gathered passes does: the rooms would hold no clamped records.

The timing run times the prelude as one command ("prelude (ours)"), and
the frame lines count the clamps by where their records come from.
VICTORY_INDIRECT_EARLY=0 clamps every record in the list, as before; it
needs the ring (enhanced barriers). Tested with the host device on the
software adapter: the clamps noted for the prelude cut a record past
65,535 groups and empty one of all ones, leave the title's records as
they were, and clamp anew at a second submission of the list; a list
whose own clamps spend its budget leaves a record clamped in its prelude
to run at each submission, and the other way round. And on the test's
own device with a clamp made for it (the prelude's clamps take the clamp
as an argument there): a list recorded once runs twice behind a prelude
recorded for each run, and the budget holds the second run's charge
alone.
A list's indirect records go to its prelude when no shader recorded before
in the list may write them, as the shaders declare their writes. Shaders
that write title memory in place (VICTORY_INPLACE, off by default) do not
declare their writes: records there are taken as written and clamped in
the list, behind the shaders before them, as before the prelude clamps.
One line in the speed section: the ring (clamps 33 -> 19 ms of card time a
frame in a timing run of the gameplay's opening, VICTORY_INDIRECT_RING=0)
and the clamps in the prelude (our clamps 6.8 ms of card time a frame at
the start of the gameplay before, about 1.25 ms after, in timing runs of
two builds of our tree; VICTORY_INDIRECT_EARLY=0).
Run side by side on the software adapter, the tests of indirect.rs that
use a device brought the whole suite down with an access violation
inside the rasterizer (d3d10warp.dll), at a different place each time: on
a thread of its own, or in a call of another module's test. With the host
device on the software adapter (VICTORY_D3D12_WARP=1, diagnostics) and 32
test threads, main's suite (085ee7c4) died so in 12 runs of 21, and in
none of 10 without this module's tests; with the seven tests this branch
adds, in 17 of 22.

They now take a lock of the test module for as long as they use a device,
the software adapter's harness and the tests on host lists alike: 2 runs
of 34 died, and the tests of the ring and of the prelude passed in each
of the 32 that completed. One after the other these tests take about a
second and a half. Run serially (--test-threads=1) nothing changes. What
in the rasterizer fails was not found: the lock keeps this module's tests
from meeting it among themselves, not the other modules' from meeting it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:35 +00:00
Author
Owner

@⁠HrHd on GitHub · 2026-11-25 20:32 UTC · original

Measured here on an RTX 4060 Ti at 1080p-in / 8-bit out, clamp + ambient on, 4.8k draws, four samples 70 s apart: 227.7, 229.3, 230.0, 231.7 ms (0.047 ms/draw), 0 device removals, picture unchanged. Before the ring the same configuration was 253.9-272.8 ms (0.052), so this is about 10 % off the clamp for free — thanks, it is the best rung so far.

Two things from porting it onto current main (this branch is based on 0b0074e0):

  1. clamp_arguments regresses the count path. warp_count_buffer_ignores_garbage_tail_and_preserves_source and warp_budget_saturates_without_wraparound_and_preserves_draw_fields fail, alone and on WARP, after the refactor: two of five valid dispatches are dropped and the budget keeps a second wave. Keeping record_clamp_as's old inline argument code (with the narrow-wait path) makes both pass again, so that is what runs here, and dispatch_clamp serves only record_gather_as.
  2. The two new tests (ring_gives_each_clamp_room_of_its_own, early_clamps_run_in_the_prelude_at_each_submission) pass on their own but fail in the full suite on WARP: the clamp pipeline is a process-global OnceLock, so a later test's device runs the first test's pipeline.

The gather still works against the ring: its dispatch passes the offset table as root view 2, not the source (with the source there every slot stays 0xEEEEEEEE and the WARP gather test catches it).

**@⁠HrHd** on GitHub · 2026-11-25 20:32 UTC · [original](https://github.com/fxceless/victory-fork/pull/1000#issuecomment-7173833710) Measured here on an RTX 4060 Ti at 1080p-in / 8-bit out, clamp + ambient on, 4.8k draws, four samples 70 s apart: **227.7, 229.3, 230.0, 231.7 ms** (0.047 ms/draw), 0 device removals, picture unchanged. Before the ring the same configuration was 253.9-272.8 ms (0.052), so this is about 10 % off the clamp for free — thanks, it is the best rung so far. Two things from porting it onto current `main` (this branch is based on `0b0074e0`): 1. `clamp_arguments` regresses the count path. `warp_count_buffer_ignores_garbage_tail_and_preserves_source` and `warp_budget_saturates_without_wraparound_and_preserves_draw_fields` fail, alone and on WARP, after the refactor: two of five valid dispatches are dropped and the budget keeps a second wave. Keeping `record_clamp_as`'s old inline argument code (with the narrow-wait path) makes both pass again, so that is what runs here, and `dispatch_clamp` serves only `record_gather_as`. 2. The two new tests (`ring_gives_each_clamp_room_of_its_own`, `early_clamps_run_in_the_prelude_at_each_submission`) pass on their own but fail in the full suite on WARP: the clamp pipeline is a process-global `OnceLock`, so a later test's device runs the first test's pipeline. The gather still works against the ring: its dispatch passes the offset **table** as root view 2, not the source (with the source there every slot stays 0xEEEEEEEE and the WARP gather test catches it).
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 22:19 UTC · original

@⁠HrHd thanks for porting it and for the numbers: 253.9-272.8 → 227.7-231.7 ms on a 4060 Ti with no device removal is the first measurement of this on a card that is not ours.

The branch is rebuilt on 085ee7c4, with main's gathered records. On your two points:

1. clamp_arguments and the count path. We could not reproduce a regression, on the software adapter, each test alone, the two forms of record_clamp_as built from the new tip and run in turn:

Test main's inline code the first version's helper
warp_count_buffer_ignores_garbage_tail_and_preserves_source 20 of 20 20 of 20
warp_budget_saturates_without_wraparound_and_preserves_draw_fields 9 of 20, 56 of 200 3 of 20, 52 of 200

The budget test fails with either, and on plain main too (2 passes of 20 here): its two groups of records may charge the budget in either order, which is what #849 and #970 fix. "The budget keeps a second wave" is that. The count-buffer test we never saw fail; the helper computes the same constants and addresses as the inline code, so if it dropped two dispatches in your tree, the place to look is where the merge met the narrow-wait path.

Even so, you are right that the refactor bought nothing there: record_clamp_as is now main's own code, byte for byte, and clamp_arguments serves only the clamps that write room of the ring. The count buffer and the budget are now also tested through the ring's path, on the test's own device.

2. The two new tests in a full run. The pipeline is not what fails: clamp() is made on the host device, and both tests record on host lists of that same device. What we did find is that the whole suite dies on several test threads with the host device on the software adapter: an access violation inside d3d10warp.dll, at a different place each time. Plain main does it too (12 runs of 21 here); it needs the device tests of indirect.rs running side by side (none of 10 runs died without them), and this PR's extra tests made it more frequent (17 of 22). The last commit makes those tests take a lock while they use a device: 2 runs of 39 have died since, and both tests passed in each of the other 37. The prelude's clamps also take the pipeline as an argument now, and a test runs them on its own device with a pipeline made for it.

The gather. record_gather_as is left as main has it (the table as root view 2). In the prelude the gathered sets' passes come first, then this PR's clamps; gathered records do not go to the ring.

One thing your port has from the first version and may want changed: the prelude's clamps charged the list's own budget, which the list zeroes inside itself, so they started from what the list's last run had left and their charge was zeroed away. They now have a budget of their own, zeroed first in the prelude (HostList::early_budget), as main's gathered records have.

On a card. The branch's tests on an RTX 5090 (the host device on the card): 207 passed, 0 failed, 6 ignored, the ring and prelude tests among them. In the title this exact branch has not drawn an indirect command yet: one 240 s run of a save was still loading when it ended (a cold pipeline cache for this build; no device removal). Our own tree, with main merged and the indirect code placed as here, ran the save's gameplay with the ring, the prelude's clamps and VICTORY_INDIRECT_GATHER=1 together: per frame 1,324 commands read from a window, 1,195 read a gathered record, 843 were clamped in preludes; 210 s, no device removal. If you run this version on your 4060 Ti, your numbers would be the first of it on main proper.

main moved on to 9c184b35 meanwhile: the branch merges with it without conflict, and the merged tree passes clippy, the policy check and the serial test run (205 passed, the two known failures).

Not seen yet: what the D3D12 debug layer says of the ring's barriers (it is not installed on the machine the tests ran on).

**@⁠PiloteCode** on GitHub · 2026-11-25 22:19 UTC · [original](https://github.com/fxceless/victory-fork/pull/1000#issuecomment-7176230559) @⁠HrHd thanks for porting it and for the numbers: 253.9-272.8 → 227.7-231.7 ms on a 4060 Ti with no device removal is the first measurement of this on a card that is not ours. The branch is rebuilt on `085ee7c4`, with `main`'s gathered records. On your two points: **1. `clamp_arguments` and the count path.** We could not reproduce a regression, on the software adapter, each test alone, the two forms of `record_clamp_as` built from the new tip and run in turn: | Test | `main`'s inline code | the first version's helper | |---|---|---| | `warp_count_buffer_ignores_garbage_tail_and_preserves_source` | 20 of 20 | 20 of 20 | | `warp_budget_saturates_without_wraparound_and_preserves_draw_fields` | 9 of 20, 56 of 200 | 3 of 20, 52 of 200 | The budget test fails with either, and on plain `main` too (2 passes of 20 here): its two groups of records may charge the budget in either order, which is what #849 and #970 fix. "The budget keeps a second wave" is that. The count-buffer test we never saw fail; the helper computes the same constants and addresses as the inline code, so if it dropped two dispatches in your tree, the place to look is where the merge met the narrow-wait path. Even so, you are right that the refactor bought nothing there: `record_clamp_as` is now `main`'s own code, byte for byte, and `clamp_arguments` serves only the clamps that write room of the ring. The count buffer and the budget are now also tested through the ring's path, on the test's own device. **2. The two new tests in a full run.** The pipeline is not what fails: `clamp()` is made on the host device, and both tests record on host lists of that same device. What we did find is that the whole suite dies on several test threads with the host device on the software adapter: an access violation inside `d3d10warp.dll`, at a different place each time. Plain `main` does it too (12 runs of 21 here); it needs the device tests of `indirect.rs` running side by side (none of 10 runs died without them), and this PR's extra tests made it more frequent (17 of 22). The last commit makes those tests take a lock while they use a device: 2 runs of 39 have died since, and both tests passed in each of the other 37. The prelude's clamps also take the pipeline as an argument now, and a test runs them on its own device with a pipeline made for it. **The gather.** `record_gather_as` is left as `main` has it (the table as root view 2). In the prelude the gathered sets' passes come first, then this PR's clamps; gathered records do not go to the ring. One thing your port has from the first version and may want changed: the prelude's clamps charged the list's own budget, which the list zeroes inside itself, so they started from what the list's last run had left and their charge was zeroed away. They now have a budget of their own, zeroed first in the prelude (`HostList::early_budget`), as `main`'s gathered records have. **On a card.** The branch's tests on an RTX 5090 (the host device on the card): 207 passed, 0 failed, 6 ignored, the ring and prelude tests among them. In the title this exact branch has not drawn an indirect command yet: one 240 s run of a save was still loading when it ended (a cold pipeline cache for this build; no device removal). Our own tree, with `main` merged and the indirect code placed as here, ran the save's gameplay with the ring, the prelude's clamps and `VICTORY_INDIRECT_GATHER=1` together: per frame 1,324 commands read from a window, 1,195 read a gathered record, 843 were clamped in preludes; 210 s, no device removal. If you run this version on your 4060 Ti, your numbers would be the first of it on `main` proper. `main` moved on to `9c184b35` meanwhile: the branch merges with it without conflict, and the merged tree passes clippy, the policy check and the serial test run (205 passed, the two known failures). Not seen yet: what the D3D12 debug layer says of the ring's barriers (it is not installed on the machine the tests ran on).
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/copystat.rs
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/fpsbox.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/indirect.rs
  • crates/victory-gpu/src/pipeline/library.rs
  • crates/victory-gpu/src/resource.rs
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.
git fetch -u origin '+refs/pull/1000/head:github-bot/gh-1000'
git switch 'github-bot/gh-1000'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1000'
git switch 'github-bot/gh-1000'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1000'
git switch 'github-bot/gh-1000'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1000'
git switch 'main'
git merge --squash 'github-bot/gh-1000'
git switch 'main'
git merge --ff-only 'github-bot/gh-1000'
git switch 'main'
git merge 'github-bot/gh-1000'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.