Renderer port 1 ordering: a run of in-place indirect executions with only state between them clamped in one pass (VICTORY_PORT_CONSTANTS_ORDER_BATCH=1, off by default) #438

Open
github-bot wants to merge 1 commit from github-bot/gh-438 into main AGit
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-27 07:17 UTC · original
HAL9000RELOADED:contrib/order-batch → main · +379 −16 · 2 files · 1 commits · open

With VICTORY_PORT_CONSTANTS_ORDER (on by default since 7ab13ed), every indirect execution whose arguments sit in port 1's in-place memory is clamped by a pass of its own, between two waits for all earlier work. In the heavy 4K scenes here that is about 2,060 passes a frame, and the ordering costs about 15 ms: in run ab-order-4k (VICTORY_AB=20,VICTORY_PORT_CONSTANTS_ORDER, the 15 phases a side with at least 1,500 draws) the median of phase medians was 40.8 ms with it off and 56.0 ms with it on.

VICTORY_PORT_CONSTANTS_ORDER_BATCH=1 (off by default) clamps a run of them in one pass. A run is in-place executions of one record without a count, with nothing but state recorded between them (pipelines, root arguments, heaps, targets, viewports). The first opens a batch right before it, after a wait for every earlier write, and the next ones read it. Anything else ends the run: a draw or dispatch that is not one of it, a copy, a clear, a resolve, a barrier or pipeline sync, a value write or wait, another host list. A member that may write buffers (a dispatch, shaders that store, a light probe pass) ends it after itself.

So between the pass and each member the card runs only earlier members, which write no buffer, and each member reads the bytes its own clamp would have read. That is the difference from VICTORY_PORT_CONSTANTS_ORDER_ALONE=0, whose batch was kept across direct draws, other executions, barriers and clears (run pop-15). What it still relies on: Translated::stores being right (it is true when the code is not known), and our own work recorded with a member writing no title buffer.

=<n> caps the executions a pass. In diagnostics builds VICTORY_AB=<s>,VICTORY_PORT_CONSTANTS_ORDER_BATCH switches it while the title runs, and the port 1 frame line now gives the passes and the executions a pass. In list.rs the copy, clear, resolve, value write and wait methods end the run.

Run ab-batch-4k: RX 7900 XTX (driver 32.0.32015.7029), i7-13700KF, Windows 10 Pro 22H2, Series X at 4K, renderer ports 1, 2, 5, 6, 7 (VICTORY_PORT_CONSTANTS, _DESCRIPTORS, _CBV, _GUARD, _JOURNAL), VICTORY_INDIRECT_BATCH=2, VICTORY_INDIRECT_WINDOW=1, VICTORY_AB=20,VICTORY_PORT_CONSTANTS_ORDER_BATCH, 59 phases of 20 s. The 10 phases a side with at least 1,500 draws:

each alone (main today) ORDER_BATCH=1
median of phase medians 57.05 ms 44.25 ms
mean p90 83.9 ms 62.6 ms
draws a frame (mean) 3,544 3,719
passes / in-place executions a frame (median of frame lines with at least 1,500) 2,060 / 2,093 121 / 2,150
flicker events counted automatically on the screen recording 1.7 a minute 2.0 a minute

Trees and palms did not drop out on either side. Both sides ran one binary: 126acb3 with this commit and our local input, overlay and light stand-in commits. This branch is the same patch alone on 014d52d.

I left it off by default. That is one run on one card, the batched side counted slightly more flicker events, and the change relies on stores being right in every scene. A run on your side in the pop-14..17 places would settle the default.

cargo test -p victory-gpu --lib on the same machine: seven new tests in draw::in_place_run_tests. One of them records every sequence of six operations of five kinds, at four batch sizes, and checks that no execution reads a record clamped before a write recorded ahead of it. With the Agility runtime staged (014d52d + #165 + the two test-export commits from my comment there): 401 passed, 0 failed, 35 ignored, against 394 / 0 / 35 without this commit. Without the runtime, this branch and main 014d52d both fail only depth_bounds_pipeline_loads_and_filters_draws (400 and 393 others pass).

Refs #43

AI-assisted (Claude Code): measured and tested on my machine, code and text drafted with Claude.

**@⁠HAL9000RELOADED** on GitHub · 2026-11-27 07:17 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/438) `HAL9000RELOADED:contrib/order-batch` → `main` · +379 −16 · 2 files · 1 commits · open With `VICTORY_PORT_CONSTANTS_ORDER` (on by default since 7ab13ed), every indirect execution whose arguments sit in port 1's in-place memory is clamped by a pass of its own, between two waits for all earlier work. In the heavy 4K scenes here that is about 2,060 passes a frame, and the ordering costs about 15 ms: in run `ab-order-4k` (`VICTORY_AB=20,VICTORY_PORT_CONSTANTS_ORDER`, the 15 phases a side with at least 1,500 draws) the median of phase medians was 40.8 ms with it off and 56.0 ms with it on. `VICTORY_PORT_CONSTANTS_ORDER_BATCH=1` (off by default) clamps a run of them in one pass. A run is in-place executions of one record without a count, with nothing but state recorded between them (pipelines, root arguments, heaps, targets, viewports). The first opens a batch right before it, after a wait for every earlier write, and the next ones read it. Anything else ends the run: a draw or dispatch that is not one of it, a copy, a clear, a resolve, a barrier or pipeline sync, a value write or wait, another host list. A member that may write buffers (a dispatch, shaders that store, a light probe pass) ends it after itself. So between the pass and each member the card runs only earlier members, which write no buffer, and each member reads the bytes its own clamp would have read. That is the difference from `VICTORY_PORT_CONSTANTS_ORDER_ALONE=0`, whose batch was kept across direct draws, other executions, barriers and clears (run pop-15). What it still relies on: `Translated::stores` being right (it is true when the code is not known), and our own work recorded with a member writing no title buffer. `=<n>` caps the executions a pass. In diagnostics builds `VICTORY_AB=<s>,VICTORY_PORT_CONSTANTS_ORDER_BATCH` switches it while the title runs, and the port 1 frame line now gives the passes and the executions a pass. In `list.rs` the copy, clear, resolve, value write and wait methods end the run. Run `ab-batch-4k`: RX 7900 XTX (driver 32.0.32015.7029), i7-13700KF, Windows 10 Pro 22H2, Series X at 4K, renderer ports 1, 2, 5, 6, 7 (`VICTORY_PORT_CONSTANTS`, `_DESCRIPTORS`, `_CBV`, `_GUARD`, `_JOURNAL`), `VICTORY_INDIRECT_BATCH=2`, `VICTORY_INDIRECT_WINDOW=1`, `VICTORY_AB=20,VICTORY_PORT_CONSTANTS_ORDER_BATCH`, 59 phases of 20 s. The 10 phases a side with at least 1,500 draws: | | each alone (main today) | `ORDER_BATCH=1` | |---|---:|---:| | median of phase medians | 57.05 ms | 44.25 ms | | mean p90 | 83.9 ms | 62.6 ms | | draws a frame (mean) | 3,544 | 3,719 | | passes / in-place executions a frame (median of frame lines with at least 1,500) | 2,060 / 2,093 | 121 / 2,150 | | flicker events counted automatically on the screen recording | 1.7 a minute | 2.0 a minute | Trees and palms did not drop out on either side. Both sides ran one binary: 126acb3 with this commit and our local input, overlay and light stand-in commits. This branch is the same patch alone on 014d52d. I left it off by default. That is one run on one card, the batched side counted slightly more flicker events, and the change relies on `stores` being right in every scene. A run on your side in the pop-14..17 places would settle the default. `cargo test -p victory-gpu --lib` on the same machine: seven new tests in `draw::in_place_run_tests`. One of them records every sequence of six operations of five kinds, at four batch sizes, and checks that no execution reads a record clamped before a write recorded ahead of it. With the Agility runtime staged (014d52d + #165 + the two test-export commits from my comment there): 401 passed, 0 failed, 35 ignored, against 394 / 0 / 35 without this commit. Without the runtime, this branch and main 014d52d both fail only `depth_bounds_pipeline_loads_and_filters_draws` (400 and 393 others pass). Refs #43 _AI-assisted (Claude Code): measured and tested on my machine, code and text drafted with Claude._
Alone, every such execution was a clamp of its own between two full waits
(2,500-3,000 a frame in heavy scenes: 31-35 ms of the card waiting). With
the switch, the first execution of a run opens a batch right before it,
after a wait for every earlier write, and the next ones read it, until
anything but state is recorded (a draw or dispatch not of the run, a copy,
a clear, a resolve, a barrier or sync, a value write or wait, another host
list) or a member that may write buffers has run. Unlike
VICTORY_PORT_CONSTANTS_ORDER_ALONE=0 (run pop-15), the batch is never read
across a direct draw, another execution, a barrier or a clear.

In victory-gpu: draw.rs (InPlaceRun, the switch, the frame line, tests in
in_place_run_tests) and list.rs (copies, clears, resolves, value writes
and waits end a run).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 07:17:53 +00:00
Author
Owner

@⁠ThomasHFWright on GitHub · 2026-11-27 09:53 UTC · original

We tested a port of c110868 on an RTX 5090 under Proton. Both arms used the same executable and warm cache seed for the Series S 1080p cell replay with RT on and ambient fallback off. Over elapsed seconds 240–295, batching cut median clamp passes from about 1,440 to 133 per frame. Median Present interval rose from 113.3 to 192.8 ms (8.83 to 5.19 FPS), with zero budget refusals in both arms.

In a separate 3,200-draw GPU fixture with 12 executions per batch, the legacy and ordered paths took 2.06 and 2.41 ms respectively, with matching vertex counts and budget checks. The size of the replay regression is still unexplained. If anyone repeats the test on NVIDIA, counts for clamp passes, executed indirect work, and copyback alongside Present intervals would help narrow it down. LinVxtory replay and fixture results

**@⁠ThomasHFWright** on GitHub · 2026-11-27 09:53 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/438#issuecomment-7215220203) We tested a port of `c110868` on an RTX 5090 under Proton. Both arms used the same executable and warm cache seed for the Series S 1080p cell replay with RT on and ambient fallback off. Over elapsed seconds 240–295, batching cut median clamp passes from about 1,440 to 133 per frame. Median Present interval rose from 113.3 to 192.8 ms (8.83 to 5.19 FPS), with zero budget refusals in both arms. In a separate 3,200-draw GPU fixture with 12 executions per batch, the legacy and ordered paths took 2.06 and 2.41 ms respectively, with matching vertex counts and budget checks. The size of the replay regression is still unexplained. If anyone repeats the test on NVIDIA, counts for clamp passes, executed indirect work, and copyback alongside Present intervals would help narrow it down. [LinVxtory replay and fixture results](https://github.com/ThomasHFWright/LinVxtory/blob/7af79b0990aa26800540c1b2c1d3cd98f39614ea/docs/7900/README.md#other-performance-trials)
Author
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-27 11:35 UTC · original

Not NVIDIA, but the same counters from my run: RX 7900 XTX, Windows 10 Pro, native D3D12 (no Proton), Series X at 4K, RT off, ambient stand-in 0.8, renderer ports 1, 2, 5, 6, 7. The binary was 8db4c15, which carries the same patch as c110868 (equal git patch-id). One process with VICTORY_AB=20,VICTORY_PORT_CONSTANTS_ORDER_BATCH, 20 s phases; below are the 10 phases a side with at least 1,500 draws, elapsed 41-441 s. It is not a replay, so draws differ by phase. Present rows come from the A/B phase lines; the others are medians of the 5 s frame lines and ~1 s port 1 lines inside those phases.

each alone batched
Present interval, median of phase medians 57.05 ms 44.25 ms
Present interval p90, mean of phases 83.9 ms 62.6 ms
draws a frame (mean of phases) 3,544 3,719
clamp passes / in-place executions a frame 1,457 / 1,489 (1.0 a pass) 121 / 1,822 (13.4 a pass)
indirect commands between two full waits a frame 1,190 277
indirect dropped / records run empty for budget 0 / 0 0 / 0
copy-back a frame 17.9 ms, 20.8 MB 19.4 ms, 15.0 MB
"on the GPU" a frame / card busy 10.4 ms / 93% 5.1 ms / 91%
submitting thread waiting for the card a frame 13.1 ms 3.9 ms

Only phases with at least 3,000 draws: 65.45 ms (6 phases) alone, 48.5 ms (7) batched. So here batching reduces both the passes and the full waits around our dispatches, and the frame gets shorter.
Differences from your run that I can list but have not tested: NVIDIA under Proton vs AMD native D3D12, RT on (BVH builder) vs off, ambient fallback off vs 0.8, Series S 1080p replay vs Series X 4K free run, and ~113 ms vs ~57 ms frames before the switch.

AI-assisted (Claude Code): measured on my machine, text drafted with Claude.

**@⁠HAL9000RELOADED** on GitHub · 2026-11-27 11:35 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/438#issuecomment-7217256779) Not NVIDIA, but the same counters from my run: RX 7900 XTX, Windows 10 Pro, native D3D12 (no Proton), Series X at 4K, RT off, ambient stand-in 0.8, renderer ports 1, 2, 5, 6, 7. The binary was `8db4c15`, which carries the same patch as `c110868` (equal `git patch-id`). One process with `VICTORY_AB=20,VICTORY_PORT_CONSTANTS_ORDER_BATCH`, 20 s phases; below are the 10 phases a side with at least 1,500 draws, elapsed 41-441 s. It is not a replay, so draws differ by phase. Present rows come from the A/B phase lines; the others are medians of the 5 s frame lines and ~1 s port 1 lines inside those phases. | | each alone | batched | |---|---:|---:| | Present interval, median of phase medians | 57.05 ms | 44.25 ms | | Present interval p90, mean of phases | 83.9 ms | 62.6 ms | | draws a frame (mean of phases) | 3,544 | 3,719 | | clamp passes / in-place executions a frame | 1,457 / 1,489 (1.0 a pass) | 121 / 1,822 (13.4 a pass) | | indirect commands between two full waits a frame | 1,190 | 277 | | indirect dropped / records run empty for budget | 0 / 0 | 0 / 0 | | copy-back a frame | 17.9 ms, 20.8 MB | 19.4 ms, 15.0 MB | | "on the GPU" a frame / card busy | 10.4 ms / 93% | 5.1 ms / 91% | | submitting thread waiting for the card a frame | 13.1 ms | 3.9 ms | Only phases with at least 3,000 draws: 65.45 ms (6 phases) alone, 48.5 ms (7) batched. So here batching reduces both the passes and the full waits around our dispatches, and the frame gets shorter. Differences from your run that I can list but have not tested: NVIDIA under Proton vs AMD native D3D12, RT on (BVH builder) vs off, ambient fallback off vs 0.8, Series S 1080p replay vs Series X 4K free run, and ~113 ms vs ~57 ms frames before the switch. _AI-assisted (Claude Code): measured on my machine, text drafted with Claude._
Author
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-27 14:46 UTC · original

One more set from the same RX 7900 XTX / Windows 10 machine, this time on main 014d52d + #165 at 4K output with render scale 0.5 (ports 1, 2, 5, 6, 7, PORT_BUFFERS=1, INPLACE=2), one 10-minute run per arm on the same save, the boat scripted through the mission. 5-second lines with 3,000-4,999 draws:

ORDER on (main) ORDER on + ORDER_BATCH=1
lines 53 57
frame mean / median / p90 67.4 / 68.3 / 75.7 ms 41.3 / 40.5 / 44.8 ms
CPU preparation 23.7 ms 23.2 ms
card busy (median) 97% 93%
in-place executions / clamp passes a frame (median) 4,210 / 4,210 (one each) 4,352 / 991
copy-back (median) 10.7 ms, 9.2 MB 11.2 ms, 9.0 MB

For scale, ORDER=0 on two nearby trees in the same setup (main + #337 + #339, and VIctory-RDNA e3bfddf + #165) gave 37.1 and 36.2 ms, so here the per-execution clamp costs about 30 ms a frame and batching gets most of it back. These are separate runs, not an in-run A/B, and there was no screen recording, so flicker was not counted this time.

AI-assisted (Claude Code): measured on my machine, text drafted with Claude.

**@⁠HAL9000RELOADED** on GitHub · 2026-11-27 14:46 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/438#issuecomment-7221205911) One more set from the same RX 7900 XTX / Windows 10 machine, this time on main 014d52d + #165 at 4K output with render scale 0.5 (ports 1, 2, 5, 6, 7, `PORT_BUFFERS=1`, `INPLACE=2`), one 10-minute run per arm on the same save, the boat scripted through the mission. 5-second lines with 3,000-4,999 draws: | | `ORDER` on (main) | `ORDER` on + `ORDER_BATCH=1` | |---|---:|---:| | lines | 53 | 57 | | frame mean / median / p90 | 67.4 / 68.3 / 75.7 ms | 41.3 / 40.5 / 44.8 ms | | CPU preparation | 23.7 ms | 23.2 ms | | card busy (median) | 97% | 93% | | in-place executions / clamp passes a frame (median) | 4,210 / 4,210 (one each) | 4,352 / 991 | | copy-back (median) | 10.7 ms, 9.2 MB | 11.2 ms, 9.0 MB | For scale, `ORDER=0` on two nearby trees in the same setup (main + #337 + #339, and VIctory-RDNA e3bfddf + #165) gave 37.1 and 36.2 ms, so here the per-execution clamp costs about 30 ms a frame and batching gets most of it back. These are separate runs, not an in-run A/B, and there was no screen recording, so flicker was not counted this time. _AI-assisted (Claude Code): measured on my machine, text drafted with Claude._
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/438/head:github-bot/gh-438'
git switch 'github-bot/gh-438'

Merge

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