GPU/draw: reduce CPU work when preparing descriptor tables #1189

Open
nicolasveilleux wants to merge 3 commits from upstream-pr/1192 into main
nicolasveilleux commented 2026-11-25 23:24:43 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by nicolasveilleux on 2026-11-25T23:24:43Z.


What changes

  • Build the static descriptor-table layout once per host pipeline stage. Preserve shader order on cache hits and keep the first declared resource for aliases in the same 32-byte record; use one ordered pass when rebuilding a table.
  • Use a fixed slot set instead of sorting and deduplicating a temporary vector. Keep the first eight remapped offsets inline, with overflow for larger sets.
  • Group dynamic view expressions by table at pipeline creation and avoid allocating the selection list for zero or one expression. Evaluate the expressions with live root constants on each bind.

Descriptor contents, cache keys, fallback paths and GPU commands are unchanged. The expected benefit is less CPU work while recording draws and dispatches; no gameplay FPS gain has been measured.

Validation

On Windows 11 with an RTX 2070 Super, using public code and synthetic test data only, release build with diagnostics:

  • cargo test -p victory-gpu --lib --release --offline --locked --features diagnostics table_: 3 passed.
  • cargo test -p victory-gpu --lib --release --offline --locked --features diagnostics descriptor::: 28 passed.
  • git diff --check: clean.
<!-- greyfinch-sync:fxceless/victory-fork:issue:5500936718 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1192). Originally posted by [nicolasveilleux](https://github.com/nicolasveilleux) on 2026-11-25T23:24:43Z. --- ## What changes - Build the static descriptor-table layout once per host pipeline stage. Preserve shader order on cache hits and keep the first declared resource for aliases in the same 32-byte record; use one ordered pass when rebuilding a table. - Use a fixed slot set instead of sorting and deduplicating a temporary vector. Keep the first eight remapped offsets inline, with overflow for larger sets. - Group dynamic view expressions by table at pipeline creation and avoid allocating the selection list for zero or one expression. Evaluate the expressions with live root constants on each bind. Descriptor contents, cache keys, fallback paths and GPU commands are unchanged. The expected benefit is less CPU work while recording draws and dispatches; no gameplay FPS gain has been measured. ## Validation On Windows 11 with an RTX 2070 Super, using public code and synthetic test data only, release build with diagnostics: - `cargo test -p victory-gpu --lib --release --offline --locked --features diagnostics table_`: 3 passed. - `cargo test -p victory-gpu --lib --release --offline --locked --features diagnostics descriptor::`: 28 passed. - `git diff --check`: clean.
UwUCammie commented 2026-11-26 00:06:11 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by UwUCammie on 2026-11-25T23:52:43Z.


I tried this with #927. Its half-precision buffer views can lie past the range's first declared descriptor, so they still need to contribute to the table length after indexed expressions move into the stage layout. Otherwise the slot containing the half view can end up outside the fresh table.

I pushed the combined three commits on top of #927. The path with zero or one expression still avoids allocating when there are no extra half views. The slot-set, inline offset and layout tests passed, and the existing a_fresh_table_holds_the_half_views_past_its_range_starts regression passed under Wine 11.22 with RADV 26.3.1 on the RX 7900 XT. This is useful if both PRs land.

I also tried an integration build with both changes and our other renderer patches. With scripted input enabled the run ended in device loss 95.7 seconds into startup, before the first-room timing window. I excluded it from the performance results. That run does not isolate the cause. The synthetic compatibility test above passed.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7178160485 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1192#issuecomment-7178160485). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-25T23:52:43Z. --- I tried this with #927. Its half-precision buffer views can lie past the range's first declared descriptor, so they still need to contribute to the table length after indexed expressions move into the stage layout. Otherwise the slot containing the half view can end up outside the fresh table. I pushed [the combined three commits on top of #927](https://github.com/UwUCammie/victory-amd/tree/test/1192-half-views). The path with zero or one expression still avoids allocating when there are no extra half views. The slot-set, inline offset and layout tests passed, and the existing `a_fresh_table_holds_the_half_views_past_its_range_starts` regression passed under Wine 11.22 with RADV 26.3.1 on the RX 7900 XT. This is useful if both PRs land. I also tried an integration build with both changes and our other renderer patches. With scripted input enabled the run ended in device loss 95.7 seconds into startup, before the first-room timing window. I excluded it from the performance results. That run does not isolate the cause. The synthetic compatibility test above passed.
alpz1000 commented 2026-11-26 06:07:02 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by alpz1000 on 2026-11-26T05:09:03Z.


I built cee1b7d into a local Windows diagnostics build and ran it on an i5-8400, RTX 3060 12 GB (610.88), 32 GB RAM. Both builds used the same local base and settings, the same stationary Series S checkpoint, and separate copies of the same initial pipeline library. The candidate adds only this PR and the merge resolution that retained the base's diagnostic counters.

Warm checkpoint metric Base With this PR
Frames measured 286 319
FPS 5.09 4.83
p90 frame time 239 ms 261 ms
Combined recording time per frame 400.6 ms 382.6 ms
Recording calls per frame 38,822 38,803
Submission preparation per frame 158.4 ms 163.3 ms

I selected windows with 4,250–4,750 draws and under 1 ms of pipeline waiting. FPS and p90 include long frames. Recording time sums all recording threads, so the 18 ms reduction does not imply an 18 ms change in frame time. This was one run per build. It shows lower recording time, with no gameplay FPS gain in this sample.

In the integrated tree, cargo test --profile diag --locked -p victory-gpu --features diagnostics --lib table_ -- --test-threads=1 passed 3/3, and the corresponding descriptor:: filter passed 30/30. AI-assisted test and write-up.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7183225532 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1192#issuecomment-7183225532). Originally posted by [alpz1000](https://github.com/alpz1000) on 2026-11-26T05:09:03Z. --- I built `cee1b7d` into a local Windows diagnostics build and ran it on an i5-8400, RTX 3060 12 GB (610.88), 32 GB RAM. Both builds used the same local base and settings, the same stationary Series S checkpoint, and separate copies of the same initial pipeline library. The candidate adds only this PR and the merge resolution that retained the base's diagnostic counters. | Warm checkpoint metric | Base | With this PR | |---|---:|---:| | Frames measured | 286 | 319 | | FPS | 5.09 | 4.83 | | p90 frame time | 239 ms | 261 ms | | Combined recording time per frame | 400.6 ms | 382.6 ms | | Recording calls per frame | 38,822 | 38,803 | | Submission preparation per frame | 158.4 ms | 163.3 ms | I selected windows with 4,250–4,750 draws and under 1 ms of pipeline waiting. FPS and p90 include long frames. Recording time sums all recording threads, so the 18 ms reduction does not imply an 18 ms change in frame time. This was one run per build. It shows lower recording time, with no gameplay FPS gain in this sample. In the integrated tree, `cargo test --profile diag --locked -p victory-gpu --features diagnostics --lib table_ -- --test-threads=1` passed 3/3, and the corresponding `descriptor::` filter passed 30/30. AI-assisted test and write-up.
KainanP commented 2026-11-27 15:13:48 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KainanP on 2026-11-27T15:13:48Z.


Independent A/B of this PR on the RTX 4060 Laptop, against its own merge base b8994e1 (the PR is 112 commits behind main and conflicts).

Bench: pipeline::list_bench::table_bench (KainanP/victory-fork bench/desc-tables, #[ignore]) ports the draw sequence of our VIctory list bench to the fork. Each draw binds a material table (one constant buffer view and five textures the title placed in memory), and each table sits at its own place in the title's heap. A list has 2,000 tables, and half of them repeat the contents of an earlier one, as in #1379. A list is closed (timed) and reset every 2,000 draws. Cells are ns per draw for the whole sequence (table, root CBV, 4 constants, index buffer, draw), each the median of 7 interleaved processes, each process the best of 5. RTX 4060 Laptop, i7-14650HX. A headless Chrome from other work used about 2 cores. This bench times recording only: lists are not submitted, so fills done at submission do not show here.

build 1 thread 5 threads (per thread)
base b8994e1 10,302 15,319
PR cee1b7d 10,025 (−3 %) 14,668 (−4 %)

An earlier run of 7 gave 17,303 / 23,496 for the base and 12,680 / 23,254 for the PR. The base cell in that run is noise: its single runs ranged from 10.5 to 38 µs.

So it is at most a few percent, within this machine's noise. The bookkeeping it trims is small next to what a table made afresh costs here (diagnostics build, a 6-slot table): about 10 µs to make the five texture views, about 6 µs to make the entries readable, and about 1 µs for the view lookups.

Correctness. Our tables_show_their_views passes: every texture slot of the tables made for 64 draws, over three lists, holds the descriptor the host makes of its view, and its host texture. fresh_table_offsets_preserve_slots_and_failure_marker, fresh_table_slots_preserve_sorted_unique_order and table_layout_preserves_shader_order_and_first_record_alias pass.

For the texture-view part: #1484.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7221793348 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1192#issuecomment-7221793348). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-27T15:13:48Z. --- Independent A/B of this PR on the RTX 4060 Laptop, against its own merge base `b8994e1` (the PR is 112 commits behind `main` and conflicts). **Bench:** `pipeline::list_bench::table_bench` ([KainanP/victory-fork `bench/desc-tables`](https://github.com/KainanP/victory-fork/commit/8099f728afae8ed80ac4deff2f471ae3683aa589), `#[ignore]`) ports the draw sequence of our VIctory list bench to the fork. Each draw binds a material table (one constant buffer view and five textures the title placed in memory), and each table sits at its own place in the title's heap. A list has 2,000 tables, and half of them repeat the contents of an earlier one, as in #1379. A list is closed (timed) and reset every 2,000 draws. Cells are ns per draw for the whole sequence (table, root CBV, 4 constants, index buffer, draw), each the median of 7 interleaved processes, each process the best of 5. RTX 4060 Laptop, i7-14650HX. A headless Chrome from other work used about 2 cores. This bench times **recording only**: lists are not submitted, so fills done at submission do not show here. | build | 1 thread | 5 threads (per thread) | |---|---|---| | base `b8994e1` | 10,302 | 15,319 | | PR `cee1b7d` | 10,025 (−3 %) | 14,668 (−4 %) | An earlier run of 7 gave 17,303 / 23,496 for the base and 12,680 / 23,254 for the PR. The base cell in that run is noise: its single runs ranged from 10.5 to 38 µs. So it is at most a few percent, within this machine's noise. The bookkeeping it trims is small next to what a table made afresh costs here (diagnostics build, a 6-slot table): about 10 µs to make the five texture views, about 6 µs to make the entries readable, and about 1 µs for the view lookups. **Correctness.** Our `tables_show_their_views` passes: every texture slot of the tables made for 64 draws, over three lists, holds the descriptor the host makes of its view, and its host texture. `fresh_table_offsets_preserve_slots_and_failure_marker`, `fresh_table_slots_preserve_sorted_unique_order` and `table_layout_preserves_shader_order_and_first_record_alias` pass. For the texture-view part: #1484. _AI use: Claude Code (Claude Opus 5.5)._
akimfomin commented 2026-11-28 02:03:23 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by akimfomin on 2026-11-28T02:03:23Z.


Pairing cee1b7de with #854 changes the same draw.rs code and conflicted in the pinned trial. If both are kept, a compact check is to replay a pipeline with mixed buffer view widths and assert that a cold layout and a cached one pick exactly the same first alias. Vary the selected wave lowering without changing the descriptor record; readback bytes should remain the same.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7232099258 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1192#issuecomment-7232099258). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T02:03:23Z. --- Pairing `cee1b7de` with [#854](https://github.com/fxceless/victory-fork/pull/854) changes the same `draw.rs` code and conflicted in the pinned trial. If both are kept, a compact check is to replay a pipeline with mixed buffer view widths and assert that a cold layout and a cached one pick exactly the same first alias. Vary the selected wave lowering without changing the descriptor record; readback bytes should remain the same.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1192:upstream-pr/1192'
git switch 'upstream-pr/1192'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1192'
git switch 'upstream-pr/1192'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1192'
git switch 'upstream-pr/1192'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1192'
git switch 'main'
git merge --squash 'upstream-pr/1192'
git switch 'main'
git merge --ff-only 'upstream-pr/1192'
git switch 'main'
git merge 'upstream-pr/1192'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!1189
No description provided.