Proposal: translate repeating command lists once (list templates): 75 % of list calls repeat in shape, only descriptor-table bases change (measurements, looking for collaborators) #447

Open
opened 2026-11-27 02:29:54 +00:00 by github-bot · 2 comments
Owner

@⁠JFIREonFIRE on GitHub · 2026-11-27 02:18 UTC · original

Proposal: translate repeating command lists once ("list templates") instead of every frame

Is anyone already working on something like this? Looking for collaborators and for objections before building it.

Why

On an RTX 3090 / i9-9900K / 32 GB (cool_fox-based tree, Series S, renderer port 1), the card is busy ~4 ms a frame while a frame takes ~70–80 ms in steady play. Most of the rest is on the CPU side of the layer: ~29,000 list calls a frame translated by VICTORY_THIN's threads, plus the memory sync. Shaders and pipelines are already done ahead of time (victory shaders, warm --used, 0.0 ms a frame waiting for pipelines), so the per-frame list translation is the largest piece of "emulation" left that a native port would not have.

Measurement

A local switch fingerprints each title list as VICTORY_THIN writes its stream (every word = "exact"; the op sequence only = "shape") and compares with the lists of the frame before. 4-minute runs in the prison, 5-second windows:

lists calls
exactly as in the frame before ~56 % ~1 %
same calls, other arguments ~93 % 62–77 %

Within lists of the same shape, which calls' arguments differ from the frame before (one 5-second window):

call (thin.rs op) calls arguments differ
COMPUTE_TABLE ~103,000 100 %
GRAPHICS_TABLE ~85,000–104,000 100 %
COMPUTE_CONSTANTS ~42,000–44,000 14–19 %
GRAPHICS_CONSTANTS ~36,000–46,000 14–16 %
BARRIER_GROUPS ~23,000 14 %
EXECUTE_INDIRECT ~68,000–76,000 7 %
DRAW / DISPATCH ~6,000–26,000 7–24 %
GRAPHICS_VIEW ~20,000 4 %
WRITE32, WRITE64, COMPUTE_VIEW, COPY_BUFFER < 2,100 each 100 %

(Corrected: an earlier version of this table had the op numbers of the second half off by three.)

So plain caching of identical lists gives nothing (~1 % of calls), but three quarters of the calls sit in lists whose structure repeats, and what changes in them is almost only where each descriptor table starts: the title writes its tables into a ring, so the same draw points at another slot each frame.

Idea

  1. Key a translated list by its shape plus the arguments that are not descriptor-table bases (pipelines, draw counts, root constants, targets).
  2. Translate descriptor-table bases into heap indices passed as root constants, the way translated shaders already index the heap directly for views picked from it (SM 6.6 ResourceDescriptorHeap); a table base then becomes a number, not a GPU handle.
  3. For a list seen before: write this frame's numbers into a small argument buffer and replay the translated work with ExecuteIndirect (root constants + draw/dispatch arguments), split at pipeline changes since a command signature cannot change the PSO. Lists that differ elsewhere translate as today.

Open questions (the reasons to ask before building)

  • Whether the table bases move by one offset per list (then one root constant per list would do) or independently per draw.
  • How many pipeline changes the repeated lists hold (each splits the indirect batch); I will measure that next.
  • Interaction with VICTORY_PORT_DESCRIPTORS / VICTORY_PORT_JOURNAL, the heap sync, and the shader-written ranges each list declares.
  • Whether NVIDIA's 1,000,000-view cap on shader-visible heaps (#346) gets in the way of indexing the title's heap by root constant.

The measurement switch (VICTORY_LIST_REPEATS=1, ~120 lines in list/thin.rs, off by default) can come over as a small PR against a-publier if it is useful to others.

Measured and written with Claude Code (AI). No game files.

**@⁠JFIREonFIRE** on GitHub · 2026-11-27 02:18 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/447) ## Proposal: translate repeating command lists once ("list templates") instead of every frame Is anyone already working on something like this? Looking for collaborators and for objections before building it. ### Why On an RTX 3090 / i9-9900K / 32 GB (cool_fox-based tree, Series S, renderer port 1), the card is busy ~4 ms a frame while a frame takes ~70–80 ms in steady play. Most of the rest is on the CPU side of the layer: ~29,000 list calls a frame translated by `VICTORY_THIN`'s threads, plus the memory sync. Shaders and pipelines are already done ahead of time (`victory shaders`, `warm --used`, 0.0 ms a frame waiting for pipelines), so the per-frame list translation is the largest piece of "emulation" left that a native port would not have. ### Measurement A local switch fingerprints each title list as `VICTORY_THIN` writes its stream (every word = "exact"; the op sequence only = "shape") and compares with the lists of the frame before. 4-minute runs in the prison, 5-second windows: | | lists | calls | |---|---|---| | exactly as in the frame before | ~56 % | **~1 %** | | same calls, other arguments | ~93 % | **62–77 %** | Within lists of the same shape, which calls' arguments differ from the frame before (one 5-second window): | call (`thin.rs` op) | calls | arguments differ | |---|---|---| | `COMPUTE_TABLE` | ~103,000 | 100 % | | `GRAPHICS_TABLE` | ~85,000–104,000 | 100 % | | `COMPUTE_CONSTANTS` | ~42,000–44,000 | 14–19 % | | `GRAPHICS_CONSTANTS` | ~36,000–46,000 | 14–16 % | | `BARRIER_GROUPS` | ~23,000 | 14 % | | `EXECUTE_INDIRECT` | ~68,000–76,000 | 7 % | | `DRAW` / `DISPATCH` | ~6,000–26,000 | 7–24 % | | `GRAPHICS_VIEW` | ~20,000 | 4 % | | `WRITE32`, `WRITE64`, `COMPUTE_VIEW`, `COPY_BUFFER` | < 2,100 each | 100 % | (Corrected: an earlier version of this table had the op numbers of the second half off by three.) So plain caching of identical lists gives nothing (~1 % of calls), but three quarters of the calls sit in lists whose structure repeats, and what changes in them is almost only where each descriptor table starts: the title writes its tables into a ring, so the same draw points at another slot each frame. ### Idea 1. Key a translated list by its shape plus the arguments that are not descriptor-table bases (pipelines, draw counts, root constants, targets). 2. Translate descriptor-table bases into heap indices passed as root constants, the way translated shaders already index the heap directly for views picked from it (SM 6.6 `ResourceDescriptorHeap`); a table base then becomes a number, not a GPU handle. 3. For a list seen before: write this frame's numbers into a small argument buffer and replay the translated work with `ExecuteIndirect` (root constants + draw/dispatch arguments), split at pipeline changes since a command signature cannot change the PSO. Lists that differ elsewhere translate as today. ### Open questions (the reasons to ask before building) - Whether the table bases move by one offset per list (then one root constant per list would do) or independently per draw. - How many pipeline changes the repeated lists hold (each splits the indirect batch); I will measure that next. - Interaction with `VICTORY_PORT_DESCRIPTORS` / `VICTORY_PORT_JOURNAL`, the heap sync, and the shader-written ranges each list declares. - Whether NVIDIA's 1,000,000-view cap on shader-visible heaps (#346) gets in the way of indexing the title's heap by root constant. The measurement switch (`VICTORY_LIST_REPEATS=1`, ~120 lines in `list/thin.rs`, off by default) can come over as a small PR against `a-publier` if it is useful to others. Measured and written with Claude Code (AI). No game files.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:29:54 +00:00
Author
Owner

@⁠JFIREonFIRE on GitHub · 2026-11-27 02:26 UTC · original

The two open questions, measured (same PC and switch, 4 minutes, five 5-second windows):

How table bases move. For each list of the same shape as one in the frame before, the distinct differences between this frame's and that frame's COMPUTE_TABLE / GRAPHICS_TABLE handles, weighted by calls:

distinct offsets in the list share of calls
none (no tables) 2.7–4.4 %
one 0.4–0.6 %
2–4 61.6–76.8 %
5–16 20.1–33.4 %
more than 16 0.0 %

So the bases do not move independently per draw: a list's tables come from a few rings (2–16 offsets), so a handful of root constants per list would carry what changes.

Pipeline changes. 9.0–11.9 SET_PIPELINE per repeated list, 7–9 calls between two. That makes ExecuteIndirect the wrong tool (each batch would hold a draw or two). D3D12 bundles fit better: a bundle may set pipelines itself and inherits the root arguments the calling list set, so a repeated stretch (~10 pipelines, ~100 calls) could replay as one ExecuteBundle after setting its few offsets as root constants. Bundles cannot hold barriers, render-target changes or clears, so lists would be cut there.

The cost moves to the shader translator: a table read becomes "heap index = a root constant + a fixed index" instead of a descriptor-table base. Anyone who knows that part of emit/lower.rs well: does that look reachable, given how views picked from the heap are already lowered?

AI-assisted (Claude Code).

**@⁠JFIREonFIRE** on GitHub · 2026-11-27 02:26 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/447#issuecomment-7208133152) The two open questions, measured (same PC and switch, 4 minutes, five 5-second windows): **How table bases move.** For each list of the same shape as one in the frame before, the distinct differences between this frame's and that frame's `COMPUTE_TABLE` / `GRAPHICS_TABLE` handles, weighted by calls: | distinct offsets in the list | share of calls | |---|---| | none (no tables) | 2.7–4.4 % | | one | 0.4–0.6 % | | 2–4 | 61.6–76.8 % | | 5–16 | 20.1–33.4 % | | more than 16 | 0.0 % | So the bases do not move independently per draw: a list's tables come from a few rings (2–16 offsets), so a handful of root constants per list would carry what changes. **Pipeline changes.** 9.0–11.9 `SET_PIPELINE` per repeated list, 7–9 calls between two. That makes `ExecuteIndirect` the wrong tool (each batch would hold a draw or two). D3D12 bundles fit better: a bundle may set pipelines itself and inherits the root arguments the calling list set, so a repeated stretch (~10 pipelines, ~100 calls) could replay as one `ExecuteBundle` after setting its few offsets as root constants. Bundles cannot hold barriers, render-target changes or clears, so lists would be cut there. The cost moves to the shader translator: a table read becomes "heap index = a root constant + a fixed index" instead of a descriptor-table base. Anyone who knows that part of `emit/lower.rs` well: does that look reachable, given how views picked from the heap are already lowered? AI-assisted (Claude Code).
Author
Owner

@⁠JFIREonFIRE on GitHub · 2026-11-27 02:57 UTC · original

Where the CPU goes, for this proposal's scope (RTX 3090 / i9-9900K 8C/16T, VICTORY_PROFILE=150,210,5,... over one minute of steady play in the prison, symbolized with the diag build's PDB; same tree as above):

threads CPU in 60 s share
the title's own (56) 166 s 36 %
victory-list-* (8, VICTORY_THIN) 124 s 27 %
memory sync: victory-submit, -wide, -land, -relay, -aside, -heap-sync ~108 s ~24 %
other ours ~59 s ~13 %

7.6 cores busy on average on an 8-core CPU, i.e. this CPU is the limit at ~13 fps, the card being ~4 ms busy a frame. The title's two busiest threads use ~38 % of a core each; most of the rest of its time is short jobs waking and sleeping.

Inside victory-list-* (inclusive, of all samples; ~58 % of samples are idle waits): draw::State::bind 32 %, State::execute_indirect 19 %, State::prepare_for 18 %, HostList::scratch_at → take_chunk → upload_buffer 10 %, HostHeap::make_listed 7 %, heap_textures 5 %, draw::readable 5 %, contended mutexes 6 %.

The upload_buffer part was new 4 MiB scratch chunks: on 32 GB PCs the scratch pool keeps SPARE_MOST (128 MiB) instead of SPARE_KEPT (1 GiB) (limited_host_ram, see #455). With a local switch keeping 1 GiB it leaves the profile and the list threads' CPU drops 124 → 108 s a minute. Worth a look by anyone on a 32 GB PC.

So for list templates the target is State::bind and prepare_for (per-draw binding and bookkeeping), not the D3D12 calls themselves (nvwgf2umx + D3D12Core ~7 % of the list threads' samples).

AI-assisted (Claude Code).

**@⁠JFIREonFIRE** on GitHub · 2026-11-27 02:57 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/447#issuecomment-7208580265) Where the CPU goes, for this proposal's scope (RTX 3090 / i9-9900K 8C/16T, `VICTORY_PROFILE=150,210,5,...` over one minute of steady play in the prison, symbolized with the diag build's PDB; same tree as above): | threads | CPU in 60 s | share | |---|---|---| | the title's own (56) | 166 s | 36 % | | `victory-list-*` (8, `VICTORY_THIN`) | 124 s | 27 % | | memory sync: `victory-submit`, `-wide`, `-land`, `-relay`, `-aside`, `-heap-sync` | ~108 s | ~24 % | | other ours | ~59 s | ~13 % | 7.6 cores busy on average on an 8-core CPU, i.e. this CPU is the limit at ~13 fps, the card being ~4 ms busy a frame. The title's two busiest threads use ~38 % of a core each; most of the rest of its time is short jobs waking and sleeping. Inside `victory-list-*` (inclusive, of all samples; ~58 % of samples are idle waits): `draw::State::bind` 32 %, `State::execute_indirect` 19 %, `State::prepare_for` 18 %, `HostList::scratch_at` → `take_chunk` → `upload_buffer` 10 %, `HostHeap::make_listed` 7 %, `heap_textures` 5 %, `draw::readable` 5 %, contended mutexes 6 %. The `upload_buffer` part was new 4 MiB scratch chunks: on 32 GB PCs the scratch pool keeps `SPARE_MOST` (128 MiB) instead of `SPARE_KEPT` (1 GiB) (`limited_host_ram`, see #455). With a local switch keeping 1 GiB it leaves the profile and the list threads' CPU drops 124 → 108 s a minute. Worth a look by anyone on a 32 GB PC. So for list templates the target is `State::bind` and `prepare_for` (per-draw binding and bookkeeping), not the D3D12 calls themselves (nvwgf2umx + D3D12Core ~7 % of the list threads' samples). AI-assisted (Claude Code).
This discussion has been locked. Commenting is limited to contributors.
No description provided.