GPU: draws that only read-mark join clamp hoists and windows #3531

Open
github-bot wants to merge 166 commits from github-bot/gh-3531 into main AGit
Owner

@⁠neonbyte1 on GitHub · 2026-11-27 14:58 UTC · original
neonbyte1:pr/clamp-read-mark-rule → main · +13301 −2307 · 59 files · 166 commits · draft

Stacked on #2472 and #3197 (plus the Wine compile fix Slay326 is taking into #3197), so this is a draft until they land. The change to review is the last commit, d4e44ed5 (draw.rs, copystat.rs). Follow-up to #3197 as Slay326 asked there.

What's wrong

#2472's hoist and #3197's window both refuse every pipeline that has view marks at all
(pipeline_writes_uav tested p.marks.is_some(), may_store tests marks and
view_marks). Nearly every pixel shader in the title read-marks the textures it takes from
the heap, so the hoisted prefix ends at the first G-buffer draw and almost every G-buffer
draw is clamped on its own. On my stack (RTX 5090, Wine + vkd3d-proton) that is 4,909
single clamps a frame, 35.4 ms of GPU command time; with the rule 1,133 clamps and 9.7 ms
(155.4 → 64.8 ms of command time a frame, 398 → 311 ms a frame in game).

The rule, and why it is safe

Marks come in two kinds, and only one of them can write an argument.

  • A write mark is set beside a store or atomic through an unordered buffer view from
    the heap. mark_view_write only marks handles in view_index, and only heap_handle
    (heap-made views) puts them there; such a view is a table's, the heap's own, or a root
    UAV's view, so a stage that writes marks has one of those write flags anyway. The page
    table's write handle was removed from view_index, and title-memory writes go through
    memory.
  • A read mark is a bit in our own bitmap: u1 (VIEW_WRITES) in MEMORY_SPACE. That
    buffer is host-owned and is never title memory, so it can never be an argument or count
    buffer.
    So a stage with marks and none of the write flags only sets read marks, and a draw or
    dispatch whose only extra write is that bitmap cannot change what any later execution
    reads as arguments. The DXIL of the census shaders agrees: the G-buffer pixel shaders
    (43e24028, 94d28115, 62f761fb) and the mesh shaders (b7a81f5b, df4b2c77) have no
    store op at all, and the one handle they write through is
    createHandleFromBinding(.. [1, 1, 2, i8 1]), props 4107 (a typed buffer), written only
    by read-mark atomics (7, 29, 29, 1, 4 of them); every other handle they make is read.
    43fba464 (one store) and 5ad3a82b (ten) also store through a heap texture UAV, and they
    still clamp on their own.

What changes

One predicate, one decision. draw::may_write_arguments (with
draw::stage_may_write_arguments) replaces pipeline_writes_uav and may_store and tests
only the write flags: table UAVs (used), heap writes (heap_writes), root UAVs as root
descriptors or as their heap views (ROOT_UAV_VIEW), and title memory (memory,
memory_writes, and the stage's memory/memory_dirty). marks and view_marks are not
among them.
draw::clamp_route is that rule's decision, and execute_indirect asks it once:

  • a dispatch, or a pipeline that may write arguments, is clamped on its own, whatever
    the prelude has room for and whatever the window switch says;
  • everything else is hoisted when the prelude takes it (#2472), else joins a
    window
    when VICTORY_CLAMP_WINDOW=1 (#3197), else clamped on its own.
    bind ends the hoisted prefix with the same predicate when a command writes. A draw that
    may write and is clamped on its own goes through crate::indirect::bound, which calls
    end_window first, so the writer always ends the window: no later record can be clamped
    by a pass that runs after the writer's stores, and the writer's own clamp is not moved
    before the window's earlier draws' reads.
    Titles are unaffected: nothing about which draws run, in which order, or what they read
    changes. Only the record clamp of an indirect draw moves, from its own pass into a pass
    that runs before the same draw. Diagnostics: clamps per frame: is now logged whatever
    the switch and splits passes into singles and windows, with draws per window, draws
    hoisted to preludes, the hoisted/windowed ones this rule let in (ClampReadMarked), and
    the ones left alone as they may write arguments (ClampStoring).

Tests (CPU, no device)

  • draw::tests::a_stage_that_only_read_marks_may_join_a_clamp_batch
  • draw::tests::a_table_uav_store_ends_a_clamp_batch
  • draw::tests::a_heap_store_ends_a_clamp_batch
  • draw::tests::a_root_uav_ends_a_clamp_batch (root descriptor, stage facts,
    ROOT_UAV_VIEW; a ROOT_SRV_VIEW does not disqualify)
  • draw::tests::title_memory_ends_a_clamp_batch (shader flags, stage memory and
    memory_dirty)
  • draw::tests::a_read_marking_draw_may_join_a_window_and_the_writer_ends_it: a
    read-marking draw joins a window, the argument-writing draw after it is clamped alone
    (which ends the window) and the next read-marking draw opens a new one; the writer is not
    hoisted even with a free prelude, a dispatch is never hoisted or windowed.
  • indirect::tests::every_clamp_compiles_without_a_root_signature_attribute still covers
    the single, batched and window shaders.

Measured share of the rule (perf stack, #2472 + #3197 + the Wine fix)

Same tree (perf/best2), same binary but for this commit reverted, same switches
(VICTORY_GPU_OVERLAP=1 VICTORY_CLAMP_WINDOW=1 VICTORY_LOG=info), 420 s runs, medians of the
last 30 heavy reports; RTX 5090, Wine + vkd3d-proton:

windows, old rule windows + rule
passes a frame 2,847 1,138
single clamps 2,780 1,032
windows (draws) 67 (2,150) 106 (3,170)
draws left alone, may write 1,865 117
draws with read marks joined — 1,745 (+706 hoisted)
on the GPU 124.2 ms 78.0 ms
frame 246.8 ms 209.1 ms
So on this stack the rule is worth **46.2 ms of GPU time and 37.7 ms of frame time a
frame** (37 % and 15 %), and 1,709 fewer clamp passes. Four more runs of the same control
binary agree within 197.1–214.0 ms and 73.8–77.0 ms; the norule run's minimum frame
(231.3 ms) is above every control median. The ≈26 µs each removed clamp takes off the GPU is
the barrier and rebind the single-clamp path puts around every draw, not the clamp pass alone
(7.3 µs measured). Frame preparation rises by ≈5 ms (79.1 vs 74.2) for the extra window
bookkeeping, well inside the gain.
Pictures at frames 1700 and 2048 match, judged on luma rather than pixels (two runs of the
same exe differ in 14–16 % of pixels by framing, hint timing and the lit/hazy alternation):
mean luma 31.8 vs 32.5 and 32.5 vs 32.3, luma-histogram correlation 0.994 and 1.000, and the
only blocks that differ are the character's animation phase and the input hint's box. No
missing geometry, shadows or lighting.

Overlap

  • #2472 (hoist) and #3197 (window): the rule changes which draws each may take.
    Because the rule gates both, this branch is stacked: #3197's head 0c997d40 merged onto
    #2472 as 055b5c89, the Wine compile fix 916655cc (Slay326 is taking that into #3197
    with my authorship), then the rule as one commit. Against 0c997d40 the branch therefore
    also shows #2472 and our fork's history (59 files); the change to review is d4e44ed5
    alone — git diff 916655cc d4e44ed5, draw.rs and copystat.rs — or rebased onto your
    head once #2472 and 916655cc are in.
  • Machad3x's "storing draws can close a window": it composes — his change lets a
    storing draw join a window as its last member and end the window right after it is
    recorded, mine widens which draws may be ordinary members. Both go through
    indirect::windowed and both end the window before anything that follows can be
    clamped. His next step (track written table UAVs instead of every table UAV, stores()
    counts used, not written) would narrow the predicate further; I keep used because a
    table's UAV is not classified read or written here yet.
  • VICTORY_CLAMP_WINDOW stays off by default, as you asked. The rule helps with the
    switch either way: without windows it extends the hoisted prefix, with them it fills the
    windows.
    AI-assisted (Claude); measured on my machine, no game data shared.
**@⁠neonbyte1** on GitHub · 2026-11-27 14:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3531) `neonbyte1:pr/clamp-read-mark-rule` → `main` · +13301 −2307 · 59 files · 166 commits · draft **Stacked on #2472 and #3197 (plus the Wine compile fix Slay326 is taking into #3197), so this is a draft until they land. The change to review is the last commit, `d4e44ed5` (`draw.rs`, `copystat.rs`). Follow-up to #3197 as Slay326 asked there.** ## What's wrong #2472's hoist and #3197's window both refuse every pipeline that has view marks at all (`pipeline_writes_uav` tested `p.marks.is_some()`, `may_store` tests `marks` and `view_marks`). Nearly every pixel shader in the title read-marks the textures it takes from the heap, so the hoisted prefix ends at the first G-buffer draw and almost every G-buffer draw is clamped on its own. On my stack (RTX 5090, Wine + vkd3d-proton) that is 4,909 single clamps a frame, 35.4 ms of GPU command time; with the rule 1,133 clamps and 9.7 ms (155.4 → 64.8 ms of command time a frame, 398 → 311 ms a frame in game). ## The rule, and why it is safe Marks come in two kinds, and only one of them can write an argument. - A **write mark** is set beside a store or atomic through an unordered buffer view from the heap. `mark_view_write` only marks handles in `view_index`, and only `heap_handle` (heap-made views) puts them there; such a view is a table's, the heap's own, or a root UAV's view, so a stage that writes marks has one of those write flags anyway. The page table's write handle was removed from `view_index`, and title-memory writes go through `memory`. - A **read mark** is a bit in our own bitmap: `u1` (`VIEW_WRITES`) in `MEMORY_SPACE`. That buffer is host-owned and is never title memory, so it can never be an argument or count buffer. So a stage with marks and none of the write flags only sets read marks, and a draw or dispatch whose only extra write is that bitmap cannot change what any later execution reads as arguments. The DXIL of the census shaders agrees: the G-buffer pixel shaders (`43e24028`, `94d28115`, `62f761fb`) and the mesh shaders (`b7a81f5b`, `df4b2c77`) have no store op at all, and the one handle they write through is `createHandleFromBinding(.. [1, 1, 2, i8 1])`, props `4107` (a typed buffer), written only by read-mark atomics (7, 29, 29, 1, 4 of them); every other handle they make is read. `43fba464` (one store) and `5ad3a82b` (ten) also store through a heap texture UAV, and they still clamp on their own. ## What changes One predicate, one decision. `draw::may_write_arguments` (with `draw::stage_may_write_arguments`) replaces `pipeline_writes_uav` and `may_store` and tests only the write flags: table UAVs (`used`), heap writes (`heap_writes`), root UAVs as root descriptors or as their heap views (`ROOT_UAV_VIEW`), and title memory (`memory`, `memory_writes`, and the stage's `memory`/`memory_dirty`). `marks` and `view_marks` are not among them. `draw::clamp_route` is that rule's decision, and `execute_indirect` asks it once: - a dispatch, or a pipeline that may write arguments, is **clamped on its own**, whatever the prelude has room for and whatever the window switch says; - everything else is **hoisted** when the prelude takes it (#2472), else **joins a window** when `VICTORY_CLAMP_WINDOW=1` (#3197), else clamped on its own. `bind` ends the hoisted prefix with the same predicate when a command writes. A draw that may write and is clamped on its own goes through `crate::indirect::bound`, which calls `end_window` first, so the writer always ends the window: no later record can be clamped by a pass that runs after the writer's stores, and the writer's own clamp is not moved before the window's earlier draws' reads. Titles are unaffected: nothing about which draws run, in which order, or what they read changes. Only the record clamp of an indirect draw moves, from its own pass into a pass that runs before the same draw. Diagnostics: `clamps per frame:` is now logged whatever the switch and splits passes into singles and windows, with draws per window, draws hoisted to preludes, the hoisted/windowed ones this rule let in (`ClampReadMarked`), and the ones left alone as they may write arguments (`ClampStoring`). ## Tests (CPU, no device) - `draw::tests::a_stage_that_only_read_marks_may_join_a_clamp_batch` - `draw::tests::a_table_uav_store_ends_a_clamp_batch` - `draw::tests::a_heap_store_ends_a_clamp_batch` - `draw::tests::a_root_uav_ends_a_clamp_batch` (root descriptor, stage facts, `ROOT_UAV_VIEW`; a `ROOT_SRV_VIEW` does not disqualify) - `draw::tests::title_memory_ends_a_clamp_batch` (shader flags, stage `memory` and `memory_dirty`) - `draw::tests::a_read_marking_draw_may_join_a_window_and_the_writer_ends_it`: a read-marking draw joins a window, the argument-writing draw after it is clamped alone (which ends the window) and the next read-marking draw opens a new one; the writer is not hoisted even with a free prelude, a dispatch is never hoisted or windowed. - `indirect::tests::every_clamp_compiles_without_a_root_signature_attribute` still covers the single, batched and window shaders. ## Measured share of the rule (perf stack, #2472 + #3197 + the Wine fix) Same tree (`perf/best2`), same binary but for this commit reverted, same switches (`VICTORY_GPU_OVERLAP=1 VICTORY_CLAMP_WINDOW=1 VICTORY_LOG=info`), 420 s runs, medians of the last 30 heavy reports; RTX 5090, Wine + vkd3d-proton: | | windows, old rule | windows + rule | |---|---:|---:| | passes a frame | 2,847 | **1,138** | | single clamps | 2,780 | 1,032 | | windows (draws) | 67 (2,150) | 106 (3,170) | | draws left alone, may write | 1,865 | 117 | | draws with read marks joined | — | 1,745 (+706 hoisted) | | `on the GPU` | **124.2 ms** | **78.0 ms** | | frame | **246.8 ms** | **209.1 ms** | So on this stack the rule is worth **46.2 ms of GPU time and 37.7 ms of frame time a frame** (37 % and 15 %), and 1,709 fewer clamp passes. Four more runs of the same control binary agree within 197.1–214.0 ms and 73.8–77.0 ms; the norule run's minimum frame (231.3 ms) is above every control median. The ≈26 µs each removed clamp takes off the GPU is the barrier and rebind the single-clamp path puts around every draw, not the clamp pass alone (7.3 µs measured). Frame preparation rises by ≈5 ms (79.1 vs 74.2) for the extra window bookkeeping, well inside the gain. Pictures at frames 1700 and 2048 match, judged on luma rather than pixels (two runs of the same exe differ in 14–16 % of pixels by framing, hint timing and the lit/hazy alternation): mean luma 31.8 vs 32.5 and 32.5 vs 32.3, luma-histogram correlation 0.994 and 1.000, and the only blocks that differ are the character's animation phase and the input hint's box. No missing geometry, shadows or lighting. ## Overlap - **#2472** (hoist) and **#3197** (window): the rule changes which draws each may take. Because the rule gates both, this branch is stacked: #3197's head `0c997d40` merged onto #2472 as `055b5c89`, the Wine compile fix `916655cc` (Slay326 is taking that into #3197 with my authorship), then the rule as one commit. Against `0c997d40` the branch therefore also shows #2472 and our fork's history (59 files); the change to review is `d4e44ed5` alone — `git diff 916655cc d4e44ed5`, `draw.rs` and `copystat.rs` — or rebased onto your head once #2472 and `916655cc` are in. - **Machad3x's "storing draws can close a window"**: it composes — his change lets a storing draw join a window as its *last* member and end the window right after it is recorded, mine widens which draws may be ordinary members. Both go through `indirect::windowed` and both end the window before anything that follows can be clamped. His next step (track written table UAVs instead of every table UAV, `stores()` counts `used`, not written) would narrow the predicate further; I keep `used` because a table's UAV is not classified read or written here yet. - `VICTORY_CLAMP_WINDOW` stays **off** by default, as you asked. The rule helps with the switch either way: without windows it extends the hoisted prefix, with them it fills the windows. _AI-assisted (Claude); measured on my machine, no game data shared._
How one console wave64 runs as two 32-lane host waves under our
per-lane structurisation, what has to cross halves, why exchanges need
uniform regions, how to test on a machine with both GPU kinds, and the
order of the remaining steps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A compute shader that reads other lanes declares the console's wave
size. NVIDIA runs waves of 32 lanes only (D3D12 reports 32..32), so a
console wave64 program of that kind was refused at pipeline creation
and its dispatches were dropped without saying why.

The host's wave range (D3D12 options 1) now goes into translation as
`emit::Target`. A shader that needs a wave size the host does not run
stops there with the reason, the shader cache keys entries by the range,
and the run logs the range once with a warning when 64-lane waves are
missing. `victory translate --host-lanes 32-32` counts these shaders
without a GPU.

This is the first step towards running these programs as two 32-lane
waves on such hosts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`emit::host::Host::on(name)` and `VICTORY_ADAPTER` choose a hardware
adapter by part of its description, and `adapters()` lists them, so a
machine with an AMD and an NVIDIA GPU can run a test on each: the
native wave64 form as the reference on the one with 64-lane waves, the
32-lane form on the other. A new test checks on every adapter that a
wave64 program reading other lanes translates exactly when the adapter
runs 64-lane waves, and that the adapter then takes it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On a host without 64-lane waves (NVIDIA), a console wave64 compute
program whose lanes read only their own 32-lane half (DPP, ds_swizzle)
now declares WaveSize(32) instead of failing to translate. It must
read no mask whole, test no bit of a mask held as a number, have no
whole-wave sections and use no LDS. Every other wave64 program that
depends on the lane layout still stops with the reason from the
previous step. Mask ballots, wave reductions and lane-bit tests refuse
the split form as a safety net.

New GPU tests run hand-assembled programs on every hardware adapter
and check each lane against the console's layout. On an RTX 5070 the
split form is exact for 1-D groups of 32, 64 and 128 threads and for
3-D groups up to 8x8x4. A Radeon iGPU runs the same programs natively
as the reference, and a read across halves (v_readlane 40) still needs
64-lane waves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A console wave64 program that reads masks whole or lanes of the other
half now runs on a host without 64-lane waves when its group is one
console wave (64 threads or fewer, no LDS). It runs as the console
does ("console flow"):

- `structure::structure_console` never resolves mask joins from what
  the lanes arriving know (every lane arrives); `Structured::execs`
  gives each vector instruction's EXEC bit.
- Vector instructions are guarded by EXEC. Branches are the console's
  s_cbranch_*: EXEC, VCC and mask-operation SCC tests are the console
  wave's, from both halves' ballots exchanged through group-shared
  memory between group barriers, which every thread reaches since both
  halves branch alike.
- Masks read whole are the exchanged ballots. v_readlane and
  v_readfirstlane read the owning half; v_writelane, v_mbcnt and mask
  bit tests use the console lane.

The per-lane form is tried first; a program that needs the console
flow is lowered again from the console structure.

GPU tests on an RTX 5070 are exact against the console: s_bcnt1 over
both halves (64, 48 and 32 threads), v_readlane 40, an exchange inside
a branch only the lower half takes, and a loop the halves leave at
different iterations with a lane read in each. The last one shows that
the per-lane form, which hosts with 64-lane waves get, is wrong for it
(on a Radeon iGPU): noted in docs/wave64-on-wave32.md, not changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wave64 program split over two 32-lane waves took the DPP row index
from the host lane, so the upper half (console rows 2 and 3) read
row_mask bits 0 and 1. The row now comes from the console lane there.
New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only,
exact on an RTX 5070 (split) and a Radeon iGPU (native).

Found in review against #189 and #192, which both get this right.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
v_readfirstlane reads the console wave's first lane. A wave64 program
with DPP or ds_swizzle and a v_readfirstlane was split into two 32-lane
waves, where the upper half read its own first lane: with all 64 lanes
active, lanes 32 to 63 got lane 32's value where the console gives
lane 0's (measured on an RTX 5070).

Such programs now take the console flow, which reads the first lane in
EXEC of the whole console wave (groups of at most 64 threads, no LDS),
or stop with the reason as they did before the split existed.

New test, exact on an RTX 5070 and a Radeon iGPU. Found by running the
same program against #192, which has the same result on both adapters.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
On the console v_readlane and v_writelane ignore EXEC, and a wave runs a
loop while any of its lanes does. The per-lane form runs branches and
loops per lane, so a lane that left a loop or skipped a branch is not
there to be read or written, and never sees the scalars set inside
(#225):

- a loop lane t runs t times, reading lane L in each iteration: 12 of
  32 lanes wrong in waves of 32 (RTX 5070, Radeon iGPU), 24 of 64 in
  waves of 64 (Radeon);
- v_writelane to lane 40 inside a branch only lanes below 20 take: lane
  40 was never written.

A compute program with v_readlane or v_writelane, a branch that is not
uniform, no ds_(b)permute and no whole-wave sections now runs in the
console flow on every host. Where the host runs the console's wave
size, one host wave is the console wave: ballots are the wave's own and
nothing is exchanged, so any group size and LDS are fine. A program the
console flow cannot lower keeps the per-lane form
(`Parts::per_lane_only`), so nothing that translated before is refused.

Both cases are now exact on an RTX 5070 (wave32 natively, wave64 in two
halves) and on a Radeon iGPU (both natively).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The loop form compilers emit keeps the lanes that are done in an exit
mask that starts as 0 (s_mov_b64 s[2:3], 0; in the loop s_or_b64
s[2:3], vcc, s[2:3] and s_andn2_b64 exec, exec, s[2:3]). In the console
flow every mask join is a phi, and its incoming values had to be masks
derived from EXEC or a VALU result, so such a loop stopped with "a
lane-mask join of an untracked mask".

`Structured::others` gives the lane's bit of the other values read as
masks (constants, uniform selects, opaque ones), and the console flow's
mask joins take them. The per-lane form is unchanged.

New test: a loop in that form with a lane read in every iteration and
the exit mask counted afterwards. It was refused on an RTX 5070 before
and is exact there (in two halves) and on a Radeon iGPU now.

Found through the test report on #233 that tried #269's programs.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Drivers create pipelines from some modules the DXIL validator refuses
(D3D12 checks only the container hash we write). The hand-assembled
split and console-flow programs now go through dxil.dll's validator
before pipeline creation, where one is installed. All of them pass.

Prompted by a report on #233 of pipelines created from modules that
fail validation.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
On the console one wave shares LDS without s_barrier, because it runs
an instruction in all 64 lanes before the next. A wave64 program of one
console wave per group that uses LDS stopped on hosts without 64-lane
waves (`a wave64 group sharing LDS without barriers`), and so did such
a program with cross-lane reads.

Both now take the console flow there. The halves reach every LDS
access together, and a group barrier before each access puts it after
every earlier one, whichever half made it.

What still stops says why: a group of more than 64 threads, ds_permute
across the halves, or a whole-wave section.

Two new tests (LDS written and read across the halves, one with the
lower half kept busy first) are exact on an RTX 5070 and a Radeon iGPU.
They also pass on the RTX 5070 with the barrier left out, so they check
the result, not that the barrier is needed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The validator's message for an operation the stage or the entry's
properties do not allow ("Entry function performs some operation that
is incompatible with the shader stage or other entry properties") names
neither the operation nor the property, and it is the only message when
the call is in the entry function itself.

`victory translate --validate` now adds to each validator failure what
our own module declares and calls: its thread-group size, its wave size
and its dx.op operations (`emit::last_module_summary`, kept per thread
when a module is finished). Nothing of the console program is in it, so
a report of counts per reason is enough to see what the refused modules
have in common.

Prompted by a report on #233: modules that fail validation with that
message and still create pipelines, 20 of them new with #320, which I
cannot reproduce with hand-assembled programs.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The scan test of the previous commit goes through the carry of a prefix
sum only. These cover the other branch, where each half's reduction is
exchanged and combined: the sum of the lane ids, their maximum (in the
upper half), their minimum (in the lower half) and their bitwise or,
and a sum over a mask of lanes below 40, which straddles the halves.
A group with a partial upper half, or none, still stops with the
section's reason.

All exact on an RTX 5070 (two halves) and a Radeon iGPU (native).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
One console wave with no s_barrier whose LDS write and read sit in
different exec-masked blocks: every lane (or, after a 4096-iteration
loop, only lanes 32..63) writes dword t, then lanes 0..31 read dword
t + 32. A third case has the same masks with no branch around either
access. Hand-assembled; exact on an RTX 5070 (two 32-lane waves, console
flow) and a Radeon iGPU (one 64-lane wave).

The pattern is the one a reviewer measured stale reads for on #189. The
console flow orders the first two cases twice: a branch on EXEC is
decided by both halves through an exchange (a group barrier), and each
LDS access has a group barrier before it, so they also pass with the
second left out. The third has no branch, and with the barrier before
each LDS access left out the lower half of the RTX 5070 reads 0 in 20 of
20 runs (exact in 20 of 20 with it): the first test here that fails
without that barrier.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The startup warning on hosts without 64-lane waves still said every
console wave64 compute program that reads other lanes is dropped, and its
literal carried a run of spaces from a lost line continuation. It now
says such programs run as two 32-lane waves where there is a form for
them, and that the rest do not translate.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Cases for the ds_bpermute_b32 lowering of the commit before, each lane
checked on an RTX 5070 (two 32-lane waves) and a Radeon iGPU (one
64-lane wave): EXEC over part of each half, two console waves per group,
groups of 48 and 32 threads (a source lane that is not there reads 0),
and beside a v_readlane across the halves, which takes the console flow
on a host without 64-lane waves.

Also formats that commit's new lines for this crate's line width, and
the plan now lists ds_bpermute as an in-half read; ds_permute stays
open.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
In the console flow on a host without 64-lane waves, a whole-wave section
that leaves a float sum, minimum or maximum stopped with "a
floating-point whole-wave operation across 32-lane halves". Each half's
result now crosses as its bits, like the integer ones: minimum and
maximum through FMin / FMax, a sum as the two halves' sums added last,
and a prefix sum in the upper half adds the lower half's total. Groups of
exactly 64 threads, as for integers.

A sum's additions are in one more order than the console's and the host
wave's own, so its last bits may differ, as they already may in one host
wave.

Tests (hand-assembled, each lane checked on an RTX 5070 and a Radeon
iGPU): the lane ids as floats, their sum, maximum (in the upper half) and
minimum (in the lower half) with identities 0.0, -inf and +inf, a sum
over a mask that straddles the halves, and an inclusive prefix sum.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The wave64 plan had per-console-wave arrival counters with a bounded wait
for groups of more than 64 threads. A wait is met only if the partner
half runs meanwhile, which D3D12 does not promise and an RTX 5070 does not
do in the LDS tests, so that plan is dropped. For programs without LDS,
each console wave becomes a host group of its own (64 threads, the
dispatch's x count multiplied), which is the console flow as it is.
Groups that share LDS stay open, with the candidates named.

The group sizes and counts come from an offline translate over a local
copy of the title's shaders; no program content is in the document.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A v_cndmask_b32 whose selector derives from neither EXEC nor a compare (a
constant, a number built from scalars) stopped with "a select on an
untracked mask". In compute the lane can test its own bit of such a mask
by its console lane, as guards on such masks already do: the select now
takes the lane's bit from the structure's other masks, and a program
with such a select declares the console's wave size like the ones that
guard on them. Other stages are unchanged.

The high dword of a wave64 mask held as a number was found only when one
instruction wrote both dwords; written by two (s_mov_b32 each), lanes 32
to 63 tested the low dword's bits. The structure pass now records the
pair a mask's reader takes, and that is used where no single writer
exists. This applied to guards on such masks too.

Test (hand-assembled, each lane checked on an RTX 5070 and a Radeon
iGPU): a select on a mask of two constants and on one with a bit that
depends on the group, as a wave64 and as a wave32 program, in groups of
64 and 32 threads.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A loop-carried EXEC phi can depend on a latch phi that is not otherwise used. Discover deferred inputs before emitting mask phis, including inputs discovered while walking the deferred worklist. Extend the authored lane-read loop fixture by adding a second predecessor of the latch.
The test of the commit before dispatched on WARP only, which has no
32-lane waves, so it checked emission alone. It now runs like the other
lane-read loop test: emitted for each hardware adapter's waves,
validated, dispatched, and every lane compared (lane t stores t + 40).
Exact on an RTX 5070 (two 32-lane waves) and a Radeon iGPU; without the
structure change it stops with "a lane-mask join of an untracked mask".

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Two defects found with a contributor's fixture (a waterfall loop over
lane classes with a whole-wave section inside, reported on #439).

A mask copied dword by dword (EXEC restored with two s_mov_b32) is held
as a number, and that number is known only as the mask's own dword. In
the console flow the lowering followed that in a circle until the stack
ran out, which takes the process with it. It now stops with "an opaque
lane mask".

On a host that runs the console's wave size, a program with a lane read
in a divergent branch took the console flow only if it had no whole-wave
section, so one with both stopped with "a lane mask holding lanes
elsewhere read as data" there while a 32-lane host ran it. The rule
counted the lane reads sections make themselves; it now looks for a lane
read or write outside the sections and lets sections be, which the
console flow lowers as wave operations like the per-lane form. Such
programs fall back to the per-lane form as before if the console flow
cannot lower them.

Tests (hand-assembled): a lane read in a branch beside a whole-wave sum,
each lane checked on an RTX 5070 and a Radeon iGPU; and a mask copied
dword by dword, which overflowed the stack before and stops now.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A compute program with a numeric select declared the console's wave size
whether or not anything read the select's result. On a host without
64-lane waves that refused a wave64 program in a group of more than 64
threads only for a select nothing consumes, where it translated before
selects on numeric masks were lowered.

The ordinary lowering now runs first. Only when it stops on a select
with an untracked mask is the program lowered again with numeric selects
counted among the masks held as numbers.

From r4tedx/VIctory#5 (MichaelSmithAI). Picked onto shader/console-flow-lds
by r4.: the selector scan iterates every instruction here (the tester
tree's `live()` filter is another PR's), and the new lines are formatted
for this crate.
The in-half form cannot read the high word of a numeric mask. Let an unused select drop out and use the existing full-wave retry when its result is needed. Exercise both cases alongside a live swizzle and DPP read.
Keep the host wave target and console-flow lowering while bringing in per-lane waterfall resource tracking. Use the structured program for resource tracking in translation and tests, and prefer proved per-lane descriptor reads before the general console read-first-lane path.
The comment on the console flow's SCC said both write the old EXEC to
their scalar destination. Only saveexec does; wrexec writes the new EXEC
to both, so either write names the mask SCC tests.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
# Conflicts:
#	crates/victory-shader/src/emit/split_tests.rs
Lane t stays in the loop for t + 1 iterations and a scalar counts the
wave's iterations: 64. With the console flow branching on the saved EXEC
(fixed in 2466184) the loop ran once more with no lane in it and the
count was 65, on an RTX 5070 in the console flow. The program reads a
lane, so hosts with 64-lane waves run it in the console flow too (exact
on a Radeon iGPU).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
# Conflicts:
#	crates/victory-shader/src/emit/split_tests.rs
Main lowers a descriptor each lane holds by the path it took
(Source::LanePhi, #566) as a DXIL phi over the edges into the join. In
the console flow every lane reaches the join by the edge the wave took,
so the phi gave every lane that edge's descriptor, silently: the joined
if/else program of the waterfall tests, lowered in the console flow,
sampled the second texture in all 32 lanes where lanes 0-15 hold the
first (RTX 5070; the module passes dxil.dll).

The console flow now stops with its own reason there. A program that
takes the console flow only for its lane reads keeps the per-lane form
where that translates; one that needs it for the host's wave size stops
with the reason.

Found on the testers' branch, where #566 and the console flow first met.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A program with a named lane read and branches its lanes take differently
asks for the console flow on every host. With a descriptor joined per
lane the console flow refuses it (b623fd3), and emit keeps the per-lane
form: checked for any host, a 32-lane host and a 32-64 one, each module
validated by dxil.dll when present.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The host driver compiles pipelines on our worker threads. On an RTX 5080
(driver 32.0.16.1692) NVIDIA's compiler (nvgpucomp64.dll) recursed past
the default 2 MB stack while creating a world compute pipeline
(c7d7a6283fad3cd6): "thread 'victory-pipelines-4' has overflowed its
stack", 0xc00000fd, then the pipeline was refused with E_OUTOFMEMORY and
its dispatches dropped. A 64 MB stack is reserved address space, committed
only as the compiler uses it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Clippy (chunks_exact_to_as_chunks, an error under -D warnings in CI)
on the test carried in 1f53745. No change in what it checks.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The GPU tests walk every hardware adapter and expect each to take the
console's wave-size-dependent programs in one form or the other. An
integrated GPU with narrower waves (an Intel UHD reporting 16-16 was
reported on #439) runs none of them: the translator refuses, correctly,
and 30 tests failed there for expecting a pipeline. The list now leaves
such an adapter out, by its wave range, as it already left out the
software renderer by name. An adapter no SM 6.6 device can be made on
stays listed, for its user to skip as before.

Checked on an RTX 5070 (32-32) and a Radeon iGPU (32-64): both still
listed, each_adapter_gets_what_it_runs and two split tests exact. Not
checked on a 16-lane adapter (none here).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The tests that walk every hardware adapter (split_tests, the lane-read
loop tests, each_adapter_gets_what_it_runs) opened each one by name, so
neither VICTORY_ADAPTER nor VICTORY_WARP=1 kept them off a card: a run
meant for the software renderer still dispatched on every GPU in the
machine.

The adapter list now honours them. VICTORY_TEST_ADAPTERS=<part of a
name>[,<part>...] lists only the adapters whose description holds one
of the parts; without it VICTORY_ADAPTER=<part> does the same, so one
setting keeps a whole shader test run on one adapter; VICTORY_WARP=1
lists none. An adapter that is left out is not opened at all.

Checked on a machine with an RTX 5070 and a Radeon iGPU, with two of
these tests: VICTORY_ADAPTER=Radeon and VICTORY_TEST_ADAPTERS=radeon
run on the Radeon only; VICTORY_WARP=1 and a name that matches nothing
run on no adapter.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Conflicts were where main's write marks (`emit::Options`, `emit_with`,
`translate_with`, `Parts::view_marks`) and its warm-up (`translate
--cache`, `host_shader` returning whether the entry was cached) met the
branch's `Target`:

- emit: `Options` gains `target` (default `Target::ANY`), so main's
  `emit_with` and `translate_with` keep their signatures; `emit(..,
  target)` and `translate_for(c, target)` stay as they were and fill it
  in. `Parts` has both `target` and `view_marks`. Main's retry with
  `structure::killing` is kept as it is.
- shader cache: `host_shader(container, target)` translates with main's
  write marks for `target` and keeps main's (result, cached) pair; the
  branch's key function is renamed `host_key`, since main now has a
  `key` for the build.
- `translate --cache` (new on main) asks `shader_cache::host_target()`,
  which is what a run's `pipeline::translate` uses, so warm entries are
  keyed as the run looks them up; `--cache` refuses `--host-lanes`.
- `translate` (the census) passes its target with main's `view_marks:
  true`; `--pipelines` documents both the host's wave sizes and main's
  pipeline library.
- victory-gpu `Host` keeps both `target` and main's `heap_atomics64`.
- The `Parts` and `emit` call sites main added (the `fuses_fmad` probe
  in `emit/host.rs` and tests in bvh, memory, semantics, stride,
  synthetic, valu and `emit::tests`) pass `Target::ANY`.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Main's newer lowering is kept as it is around the console flow: the
waterfall loop's `v_readfirstlane_b32` and the spilled-SGPR
`v_readlane_b32` keep their arms before the console-flow ones, the
helper-lane read stays in the per-lane `v_readfirstlane_b32`, and
`lane_bit_of`, `mask_number`, the heap and view guards and the write
marks are untouched. Resolutions worth knowing:

- `mask_dword`: the console flow's exchanged ballot comes first, then
  the split form's refusal, then main's `mask_number` for masks holding
  lanes elsewhere (per-lane form only: in the console flow every lane is
  at the block that writes the mask).
- `emit`: one `parts(st, res, console_cf)` closure serves the per-lane
  pass, the `CONSOLE_FLOW` retry with `structure_console`, and main's
  retry with `structure::killing` (pixel discards; never both).
- `structure`: `structure_as(program, helpers, console)` behind
  `structure`, `killing` and `structure_console`; `Structured` has both
  `execs` and main's `restored` / `discards`.
- Test host: `Host::new` takes `VICTORY_ADAPTER` first, else main's
  first adapter that is a GPU (so a machine without one still skips);
  `adapters()` and `Host::on` keep their own hardware test.
- Main's per-lane reasoning that does not hold where the wave takes the
  branches is switched off in the console flow: `never_taken` and the
  branch conditions `live_edges` collects (a lane comes along an edge
  whatever its own condition is, and SGPRs are the wave's). The console
  flow fills phis as it did before the merge.
- Main's 16-bit whole-wave section (`Shape::Half`) reduces over the host
  wave and reads lane `hi` of it: refused in a program split in halves,
  as the other reductions are.
- The `Parts` sites main added pass `console_cf: false`.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Main's `v_cndmask_b32` now takes masks that derive from neither EXEC nor
a compare (`Structured::other`, inline constants) and tests the lane's
bit of the number. In a wave64 program run as two 32-lane waves without
the console flow, `lane_bit` has only the host lane: lanes 32..63 would
test the low word. Guards and branch conditions on such masks already
keep a program out of that form, a select's mask does not, so the merged
code reached `lane_bit`'s debug assertion (and, without assertions, the
wrong bits).

`lane_bit` now returns the refusal instead of asserting. The select then
has no result, and the program stops with that reason if the result is
used.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings main (940d32f), the two lower levels' merges of it, and the
console-flow branch's adapter filter for the every-adapter tests
(d8921a5), which this branch did not have yet.

- `emit`: the `parts` closure takes `per_lane_only` too. A program that
  stops with `CONSOLE_FLOW` is lowered from `structure_console`, and
  falls back to the per-lane form (`per_lane_only`) with the console
  flow's reason when that fails, as before; main's retry with
  `structure::killing` stays a separate arm.
- `Structured::others` is dropped for main's `Structured::other`, which
  is the same map (masks that derive from neither EXEC nor a VALU
  result): the console flow's mask joins read `other`.
- The `Parts` sites main added pass `per_lane_only: false`.
- `split_tests`: this branch's tests, then the lower level's new
  `selects_on_numeric_masks_are_refused_in_halves`.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A castable list naming a format the host does not have is refused whole,
and the texture is then made without castable formats. vkd3d-proton
(D3D12 on Vulkan, under Wine and Proton) has no
`R10G10B10_XR_BIAS_A2_UNORM`, one of the 4-byte formats `castable` lists,
so there every colour texture of that element lost its list, and title
textures of one memory in other formats got their own host textures,
bridged by copies.

`make_texture` now keeps the formats the host reports support for
(`CheckFeatureSupport`, asked once per format). A host that has every
format, as Windows drivers do, keeps the same lists.

New test: a render target with unordered views is castable to the formats
of its element the host has. Under vkd3d-proton it fails before this
change, and `draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view`
passes after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings main (940d32f) through the three lower levels' merges, and the
adapter filter for the every-adapter tests (d8921a5).

- `v_cndmask_b32`: main takes selectors from `Structured::other` and
  inline constants; this branch defers a select on a mask held as a
  number until its result is used. Together: a uniform selector (main's
  `s_cselect` case) needs no lanes and is lowered as on main; a constant
  lane set or a number built from scalars tests the console lane's bit
  where there are console lanes outside the in-half form, and is
  deferred (`UNTRACKED_SELECT`, then the pass with console lanes) in
  compute otherwise. The numeric-select pass counts inline constant
  selectors as masks held as numbers too. Other stages keep main's
  refusals.
- `ds_bpermute_b32`: one arm, main's (its 16-bit offset, `lane_bit_of`),
  gathering within the reader's 32-lane half as this branch lowers it
  (RDNA 2). In wave32 programs that is what main did; in wave64 ones main
  gathered across the whole wave. The form decision keeps treating it as
  an in-half read.
- `Structured::others` is main's `Structured::other`; `pairs` reads it.
- The group barrier before an LDS access in the console flow also
  precedes main's byte and half accesses.
- `split_tests`: the lower level's constant-mask select test becomes
  `selects_on_constant_masks_beside_in_half_reads`: here such a program
  takes the console flow on a host without 64-lane waves instead of
  stopping.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A compute program's image_sample or image_sample_b has no valid DXIL
form yet: the module fails validation with "an operation that is
incompatible with the shader stage" (#201). Drivers take such a module
in the per-lane form. In the console flow in two 32-lane halves the
same module also carries group barriers inside its branches and loops,
and a title run on an RTX 4070 lost its device in a submission of two
of them (ptfx_CS_lightAtlas_Sprite and _Trail, reported on #233 from
fxceless/victory-gta6@e9765a7). That is the best-supported reading,
not a proven cause.

On a host without 64-lane waves such a program now stops, by name,
with "an implicit-derivative sample in the console flow on a host
without 64-lane waves". The per-lane form and hosts with 64-lane waves
are unchanged.

Offline over the title's shader pack (local title data, CPU only,
counts only; 32-lane host): exactly 12 compute programs change, all from
"emitted, fails validation" to this refusal; none that validates is
lost. Both programs named in the report and the one tied to an earlier
RTX 3080 report are among them. None of the 12 ran on a 32-lane card
before this stack.

Test (CPU only, no device): emit::tests::
implicit_samples_stop_the_console_flow_in_halves; it fails with the
guard disabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wave64 program that restores EXEC dword by dword from a mask
(s_mov_b32 exec_lo, s12; s_mov_b32 exec_hi, s13) leaves the structure
pass holding the mask as a number that is known only as the mask's own
dword. With console lanes the lowering followed that in a circle until
the stack ran out, which ends the whole process: a translator run, or
the runtime translating a title's shader. Reproduced at this level after
the merge with main 940d32f with the test below (stack overflow).

The opaque-mask arm now stops with "an opaque lane mask" when it meets
the mask it is already reading, as #439 has done since f12df1e. Test
taken from there: a_mask_copied_dword_by_dword_stops_instead_of_recursing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The copied-mask recursion guard that came with it (7147671) is the one
this branch has had since f12df1e: its field, initialiser and test are
kept once, as they were here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
vkd3d-proton's DXIL conversion keeps one back edge per loop header, as
DXC's code has. With several, the others stay in the header's forward
predecessors and form a cycle, and in programs with wave shuffles its
dominator search then recursed without end: the thread overflowed its
stack and, under Wine, hung. The ray-tracing shadow passes do this once
they translate. The back edges of a header with several now go through
one new block that joins their phi values.

(cherry picked from commit d48ec767ba)
The console flow's nested loops leave an inner loop's latch straight to
the outer loop's header: one block that branches back to two headers.
dxil-spirv keeps one back edge per block and takes the other for a
forward edge. In a program with WaveReadLaneAt its shuffle pass
(flatten_subgroup_shuffles) analyses the CFG before anything rewrites
extra back edges, and its loop-exit search (LoopMergeTracer) recurses
over that cycle without end: the pipeline thread overflows its stack, or
with a large stack eats memory until the process dies (fdd56d97a806bcca
on #439, which adds the lane reads; seen natively, 40 GB in 40 s).

single_latches (#1885, one back edge per header) now also sends such a
block's edge to the outer header through a new block of its own, so the
block stays the inner loop's exiting latch, as in DXC's loops. The
write-time fold of empty latches no longer folds one into a block that
already branches back, which would undo that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: GPT-6.2 Sol (Codex) <[email protected]>
Co-Authored-By: GPT-6.2 Sol (Codex) <[email protected]>
Co-Authored-By: GPT-6.2 Sol (Codex) <[email protected]>
Co-Authored-By: GPT-6.2 Sol (Codex) <[email protected]>
Co-Authored-By: GPT-6.2 Sol (Codex) <[email protected]>
Co-Authored-By: GPT-6.2 Sol (Codex) <[email protected]>
Co-Authored-By: GPT-6.2 Sol (Codex) <[email protected]>
80f5663 took SGPR spills out of the lane reads that ask for the console's
wave size, so a compute program whose only lane reads and writes are
spills lost WaveSize on every host, Target::ANY included, where main
gives the console's wave size and emulates the lane writes. Keep main's
per-lane form there: on a host that runs the console's wave size, any
v_readlane/v_writelane still asks for it. On a 32-lane host spills stay
per-lane with no wave size, and the console flow still skips them.

The test now wants WaveSize(64) on ANY and none on 32-32, both from the
first (per-lane) pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings d5f8f2c (SGPR spills keep main's wave size where the host runs
it). `whole` keeps this branch's ds_bpermute_b32 exception beside
#320's named_lane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The title asks for 1 245 184 descriptor slots, more than the 1 000 000 a host
heap holds, and it walks them in increasing order. "Log when the high-water
mark moves" is therefore one line per distinct slot: 199 846 of the first
200 000 lines of a run, ~8 000 a second, on the thread recording the frame.

That was the whole of the first frame's stall:

    before   310 932 lines in the run, first frame 21 433 ms
    after        231 lines in the run, first frame     33 ms

Same build, same warm caches (926 MB pipeline library, 1 347 MB shader cache),
same 150 s window. What the line said - that slots above the host heap's count
are not mirrored - is what the one line now says.

The underlying problem is not this change: 245 184 title slots can never be
mirrored because they exceed the tier-2 heap limit, which needs either several
host heaps with the index arithmetic adjusted or the views above 1 M placed
elsewhere. That is why the first world frames get null views.

cargo test --workspace --locked; both clippy configurations with -D warnings;
cargo xtask policy.
# Conflicts:
#	crates/victory-gpu/src/descriptor/host.rs
In the user-data loop, a dword numbered `ROOT_VIEW_OFFSET` (4) was taken
for a root view's offset without asking whether the parameter was a root
descriptor at all. Root constants with five or more dwords have a real
dword 4; it was looked up as a root view, none was found, and the draw or
dispatch was refused ("a root view's offset: no root view, or outside
title buffers") with no log line. The ray-tracing builder's dispatches
were among the casualties.

Ask `u.root == RootType::Descriptor` too, through a helper beside
`is_root_view`, so a root constant's dword 4 goes to the title's user data
as the value it is.

The test pins the predicate: descriptor dword 4 is an offset, constants
and table dword 4 are not.
A UAV read as float and also used by an atomic needs two handles: an
atomic on the float handle is invalid SPIR-V after conversion
("AtomicOr/AtomicUMax: expected Result Type to be integer scalar type")
and crashes NVIDIA's compiler in vkCreateComputePipelines.

#177 added the element type to the `handles` key. main has since added
`entry_handles` and `join_handles`, which had the same problem; they are
keyed by both property words now as well. Includes #177's test, with
`view_marks` added for the current `Parts`.

Co-authored-by: Ortomanic <[email protected]>
Co-authored-by: gingertonik <[email protected]>
Translated shaders clamp view indices below HEAP_VIEWS (2^21) and read
the null buffer views two below it, which assumes a host heap that large.
NVIDIA caps shader-visible view heaps at 1,000,000: the heap fell back
to the cap with 2^16 dynamic slots, no room for the null buffer views
("no room for the null buffer views"), title slots past its end, and
indices up to 2^21 - 1 that read past the heap. On a Windows 10 machine
with an NVIDIA card the device was removed (DXGI_ERROR_INVALID_CALL)
about a minute in, still loading.

Whether the host takes a heap of HEAP_VIEWS is now asked once, before
the first translation and the first heap (probe_view_limit). A host
that does not lowers the view limit to its cap (set_view_heap_limit):
shaders clamp below it and read the null buffer views two below it, and
the heap is made at the cap with the full 2^18 dynamic range (2^16 ran
out in the world there), room for 8,192 copy view pairs, the null views
and a last null slot at its top, and the title's slots below them
(721,469; the title's highest index seen is about 720,000). The limit is
part of the shader cache key.

On that machine the heap and title-memory tests (dynamic slots,
lists_share_a_table) now pass; hosts that take HEAP_VIEWS are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTeDQ6Kc6DEkgPbAww8
Review of #2461: the limit was probed only by victory-gpu (shader cache
and runtime heaps), so emit::host, which the shader tests and
`translate --pipelines` use, still made heaps of HEAP_VIEWS on a capped
device (E_INVALIDARG on an RTX 5090 in
stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,
the device for a heap of HEAP_VIEWS and, if refused where 1,000,000 is
taken, sets the view limit to that, as the runtime does. Shaders
translated before the first Host::new keep the limit they were made with.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTeDQ6Kc6DEkgPbAww8
Review of #2461: translating before Host::new probed the device's heap
limit made the shader's fallback the null SRV of a 2^21 heap (2,097,150)
while the heap made on an NVIDIA device had it at 999,998. The test now
builds its shader after the host is made and checks that the fallback
slot is the dispatch heap's null SRV. Verified on an RTX 5080 Laptop
GPU: the check fails with the old order and passes with this one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
Keep the existing title slot budget and reserve the top three slots from the runtime range. Use the remaining space for dynamic tables and host copy pairs.

Refs Marvisak/VIctory#2461
The title's acceleration-structure builder (`XboxBvhBuilder.dll`) builds
and refits the ray-tracing structures in title memory every frame through
some fifty compute dispatches. A dispatch without a host pipeline is
dropped on its own (`State::dispatch`, `execute_indirect`), and some of
the builder's lack one for a long time or for good: refused on hosts of
32-lane waves (they ask for 64-lane waves), not translated, or still being
made. The stages that do run then work on data the missing ones never
wrote, and write the result into title memory. On fxceless/victory-fork,
where this happened, the builder wrote garbage bounds that crashed the
title; that fork's rule is the one taken here.

Its dispatches now run only in frames where every pipeline the builder
has created has its host pipeline; otherwise none run, and the structures
keep what they held. The decision is made once per frame, so a frame
never runs part of the builder. Its pipelines are known by origin: bytecode
in the builder's image, or a return address in it on the stack when the
pipeline is created (`run` passes the DLL's range as it maps it, at start
and when the title loads it). They are started at once, so no frame's
wait budget holds the builder back.

New tests (no game data):
- `pipeline::builder::tests::the_builder_runs_only_with_every_pipeline_made`
- `pipeline::builder::tests::builder_pipelines_are_known_by_their_origin`
- `pipeline::tests::builder_dispatches_wait_for_every_builder_pipeline`:
  a compute pipeline created from bytecode in the registered image is the
  builder's, is started at once, is refused (no shader container), and
  holds back builder dispatches; another pipeline is not held back.
* pr-2723-new:
  Shader: key every heap handle cache by element type (#177 on main)

# Conflicts:
#	crates/victory-shader/src/emit/lower.rs
* pr-1129-new:
  GPU: pipeline workers get a 64 MB stack for the driver's compiler

# Conflicts:
#	crates/victory-gpu/src/pipeline/make.rs
* pr-1548-new:
  GPU: test middle-range capped view heaps keep every title slot
  GPU: preserve full DYNAMIC descriptor range when host view heap is capped at PORTABLE_VIEWS
Cross-builds the test binaries with clang-cl, lld-link and an xwin splat
and runs them in a Wine prefix under target/. --vkd3d-proton puts that
folder's D3D12 in the prefix instead of Wine's own. The loader's
end-to-end test cannot start cargo inside Wine, so its fixture is built
beforehand and named by VICTORY_HLE_PROBE.
Library paths go through CARGO_ENCODED_RUSTFLAGS and include paths are
shell-quoted for cc (CC_SHELL_ESCAPED_FLAGS), so a path with spaces is
no longer split.
#233 at 691ff20 (stacked on #223 at 0d20521), resolved as #2651's merge
commit 9bb79e3 resolves it against main 13f91ca, applied 3-way onto this
branch; #1922 and #2651's own commit are not taken (they refuse every wave64
mesh program on a 32-lane host).

Conflicts with current main:
- emit/host.rs: main's shared WARP device and create_device() take #233's
  adapter choice (VICTORY_ADAPTER, Host::on) as an optional adapter; Host
  keeps main's warp flag, gains #233's adapters() and target().
- main.rs: translate::run takes main's NonZeroUsize jobs and #233's
  --host-lanes.
- Tests main added since (census, crosslane, memory, synthetic, lower,
  resource, draw) pass Target::ANY and console_cf: false.
With #2723 and #233, emit/lower.rs grew to 544,476 bytes, past the asset
policy's 512 KiB per-file limit (main's own is 520,563; #2723 alone takes it
to 524,570). Its test module moves, unchanged but for rustfmt's layout, to
emit/lower_tests.rs, still a child module of `lower` (`#[path]`), so it
keeps its access to the private items it tests.
* origin/main:
  GPU: a null shader view has no alias source
* pr-1548-6b72:
  gpu: fix capped HostHeap comment, MIN_DYNAMIC branch, and reserve CAPPED_PAIRS
Under Wine, D3DCompile is Wine's d3dcompiler_47 (vkd3d-shader HLSL): it
has no methods on writable byte address buffers (E5005 'Load' is not
defined on RWByteAddressBuffer) and ignores a [RootSignature] attribute,
so the code holds no root signature to make. Every run-time shader of
ours failed there: the argument clamp ("no argument clamp: indirect
execution dropped", every indirect draw and dispatch then dropped as
not bounded), the depth twin's 16-bit conversion ("no depth
conversion"), and the tests' own shaders.

A new module, compute, compiles a shader and serializes its root
signature in Rust from the parameters the host binds. The clamp keeps
main's design (one group, tiles of 64, groupshared costs charged in
order, the list's budget, the record's rest copied) with the title's
records a StructuredBuffer<uint> (t0) and the clamped records and the
budget RWStructuredBuffer<uint> (u0, u1), indexed in words: bound()
already refuses addresses and strides not multiples of 4. Its root
signature is b0 (4 constants), SRV t0, UAV u1, UAV u0, as bound()
binds them. The depth conversion indexes its scratch buffer in words
(footprint offsets and pitches are multiples of 4) with b0 (8
constants) and UAV u0. Test shaders lose their RootSignature
attributes the same way.

A new test checks every word the clamp writes for draws, indexed
draws, dispatches, mesh dispatches, records past the budget and the
budget spent.

The approach is Mumogg's (#1279: structured buffers indexed in words,
the root signature serialized beside the shader), ported to main's
rewritten clamp and extended to the depth conversion.
wip/main-base's marked-UAV, placed-view and depth-twin rebind tests
compile their shaders with a [RootSignature] attribute Wine's compiler
ignores, and the marked write ORs its page bit through a byte address
buffer method it lacks. Their root signatures are made with
crate::compute from what the tests bind, and the bitmap is a
RWStructuredBuffer<uint> indexed in words.
From pr-320 (d5f8f2c), on top of #233 already in this base. By r4tedx (r4.);
lane reads in the console flow, constant-started mask joins, and SGPR
spills kept on the per-lane path.

Conflicts:
- lower.rs fill_phis: main's join (BVH numeric masks, edges no mask lane
  takes) kept; #320's console-flow `st.other` masks are looked up with the
  tracked masks before main's numeric fallback.
- lower.rs tests: kept in lower_tests.rs (the policy's size limit);
  #320's `per_lane_only: false` added there and to main's newer tests'
  `Parts` (crosslane, memory, synthetic).
From pr-439 (3fab5a1), stacked on #320 merged just before. By r4tedx (r4.),
with @Raxstreams (whole-wave integer scans across the halves,
ds_bpermute_b32 in half), @ifBars (loop-carried console mask joins) and
MichaelSmithAI (numeric selects only when used): single-wave LDS ordered by a
group barrier before each access in the console flow, whole-wave reductions
and prefix sums across the two 32-lane waves, selects on masks held as
numbers, specific refusal reasons, and `translate --validate` module
summaries.

Conflicts:
- lower.rs helpers: main's scalar_def/sgpr_operand/scalar_constant and
  #439's `numeric` both kept.
- lower.rs ds_bpermute_b32: main already lowers it in the reader's 32-lane
  half (same lane arithmetic as #439's); main's form kept. #439's
  classification of it as an in-half read (not a whole-wave permute) is
  merged in.
- lower.rs tests: kept in lower_tests.rs; #439's new select_tests module
  goes to lower_select_tests.rs (a `#[path]` child of `lower`, unchanged),
  keeping lower.rs under the policy's 512 KiB limit.
Main's a_scalar_result_needs_no_exec (889b871) lowers a v_readlane in a
branch lanes take differently through `lower` directly. Since #320 such a
program asks for the console flow (CONSOLE_FLOW), which `emit` follows and
the helper did not, so the test failed after the merge. `lowers` now
follows emit's chain (console flow, else the per-lane form only), and the
test also pins the per-lane form it was written for.
A latch that branches back to both its loop's header and the outer loop's
makes dxil-spirv recurse until its stack runs out when the shader also
reads other lanes (HansKristian-Work/dxil-spirv#380; the dxil-spirv that
GE-Proton's vkd3d-proton pins has it): pipeline creation never returns.
The outer back edge now leaves through a latch of its own that counts the
outer loop's iteration, and the writer no longer folds an empty outer
latch into a block that already branches back (it keeps the block's own
back edge, else the one to its innermost header).

Over shaders.rpf for 32-lane hosts the emitted counts are unchanged; 9
programs change (the four InstanceCulling batch shaders, three
ShallowWaterSim, WaterSimMgr's UpdateDynamicFoam, an IrradianceCache
filter), the 9 that had such blocks (35 before, none after). The four
InstanceCulling pipelines are now created on GE-Proton11-14's
vkd3d-proton.
From pr-2118 (af8b9ad), by @0xkn0wh3r3. Builder dispatches (pipelines
created from XboxBvhBuilder.dll's code or bytecode) run only in frames
where every builder pipeline has its host pipeline; otherwise none run.

Why here: with #439, two builder programs (28918b71, caa78b8c) translate
on 32-lane hosts while five others (14394a32 among them) are still
refused, so the builder ran in part. A host submission holding it then
never completed (the GPU submission thread sat in Host::execute's fence
wait in both crash dumps), the title's frame heartbeat stopped, and its
30-second hang watchdog crashed it on purpose (+0x23cf683, a store to 0).

No conflicts.
Resolutions:
- emit/host.rs: main's shared WARP device, WARP lock and from_device
  (#244) with #439's adapter list and Host::on; create_device takes the
  adapter Host::on found.
- emit/lower.rs: main's #573 ds_bpermute_b32 form (half base only in a
  native wave64); main's scalar_def helpers and uniform_join next to
  #439's numeric and console_read_lane; the lane-mask join takes #439's
  console-flow masks (`other`) and main's number/no-mask arms, with
  #439's lane_bit returning a Result.
- apps/victory main.rs: main's NonZeroUsize jobs with #439's host_lanes.
- Tests from main pass #439's new arguments (emit's Target,
  Parts::target/console_cf/per_lane_only, Options::target);
  a_scalar_result_needs_no_exec lowers the per-lane form (per_lane_only),
  since a v_readlane past a per-lane branch now asks for the console flow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bitcode.rs: main moved block folding into Module::plan. This branch's
rule sits there now: an empty latch is not folded into a block that
already branches back (branches_back over plan's edges), and
single_latches/successors follow the edges plan writes (Module::term, so
a constant branch's dead edge is not counted).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With #439 merged into main 63bcca4, lower.rs grew to 559,370 bytes, past
the asset policy's 524,288-byte limit (xtask repository_passes_policy).
Its inline test module moves to its own file unchanged (dedented only);
lower.rs is now 506,198 bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* pr-2703:
  GPU: a root constant's dword 4 is a value, not a view offset (#2699)
* pr-2101:
  GPU: castable formats the host has
Every store through a heap view sets its page's bit in the write-mark
bitmap, and every heap-direct texture read its slot's read mark: a load of
the bitmap word, and an atomic OR where the bit is clear. The bitmap is in
system memory (the CPU reads and clears it after each submission), so on
the GPU each of those loads crosses the bus, once per lane. Most lanes of a
wave write the same 64 KiB page or read the same slot.

Lanes whose bit equals the first active lane's now leave the load and the
atomic to that lane (`waveReadLaneFirst`, `waveIsFirstLane`). In pixel
shaders the leading lane is the first that is no helper (a helper's writes
are dropped): the lowest lane index among non-helpers, by `waveActiveOp`
min, and `waveReadLaneAt` of it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A pixel wave of helpers only had no non-helper lane, so the minimum key was
u32::MAX and waveReadLaneAt read past the wave. A helper's key is now its
lane with bit 30 set: the minimum is the first non-helper, or a helper that
no lane matches as leader, at a lane index that exists (bit 30 masked off).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
open() made the empty library from an empty slice, whose pointer is
not null. vkd3d-proton (Wine) refuses a blob pointer with no bytes
(d3d12_pipeline_library_init: `!blob_length && blob` is E_INVALIDARG),
so under Wine no host pipeline library was made ("no host pipeline
library: pipelines are not kept"), also after a rejected blob; the
library tests failed with "an empty library". The empty library is now
asked for with a null blob, which D3D12 takes as well.
- DXIL compute shader translation injects `cs_spread_prologue` to remap
  console GroupId(0) cleanly to `eff_x = gx + gz * row` and early-return
  on surplus groups `eff_x >= asked_x`.
- Pure `spread_groups` decomposes dispatches with `x > 65,535` and `z == 1`
  into rows across `z` up to 65,535 groups.
- Direct dispatches populate root constants at `DISPATCH_SLOT` and dispatch
  remapped dimensions.
- Indirect dispatches integrate with `315cea1` argument buffers: `indirect::bound`
  clamps and formats 20-byte spread records `[row, asked_x, gx, gy, gz]` into
  the list's own argument buffer and executes via `host_spread_signature`.
- Unit tests verify translated remap, early exit on surplus groups, clamp
  multi-record spread splitting, and command signature layouts.

# Conflicts:
#	crates/victory-gpu/src/draw.rs
#	crates/victory-shader/src/emit/synthetic_tests.rs
ExecuteCommandLists no longer waits for the host GPU. A submission's
lists go to the host queue with a Signal of the host fence, and the
title's call returns; the submission completes later (what shaders
wrote goes back to title memory, then the lists' work after them and
bottom-of-pipe writes, then the title fences its queue signalled behind
it). A completion thread completes each submission once the GPU has run
it, so a title's fence moves and its waits end with no call of its own,
as on the console. A title that keeps frames in flight now gets them:
it records the next frame while the GPU runs the last.

What still needs a submission done first completes it first, waiting
without the submission lock:
- a submission whose completion writes title memory or reads the marks
  bitmaps (copy-backs, write and read marks, title memory through page
  tables, work after its lists, bottom-of-pipe writes) completes before
  the next is prepared, whose refreshes read title memory;
- title copies and work that write title memory on the CPU for the GPU's
  timeline wait for everything before them;
- the upload list waits for its last run, and a host list for its own.
So only submissions without such writes overlap for now
(docs/submission-overlap.md, phase 3, would lift that with
per-submission snapshots and bitmaps).

- A queue's Signal behind work in flight is owed by the queue's last
  submission and set when it completes, in order.
- A blocking fence wait (SetEventOnCompletion with no event) now blocks
  until the value is reached instead of failing.
- Present copies into the swap chain with a ring of three lists and does
  not wait for the frame; a resize, multi-plane composition and
  diagnostics read-backs still wait for what they need.
- Host textures given up and resources retired while work is in flight
  are released after the next submission completes.
- A list reset while a queue still runs it keeps what it owned until its
  host list is reset, not as work after the list.
- VICTORY_GPU_OVERLAP=0 waits for each submission as before; per-list
  timing and listed capture frames do too.

Tests: a submission held at a GPU gate returns, and its fence and its
copy into a title buffer move only once it has completed; tests that read
results after ExecuteCommandLists now wait for a fence as a title does.
Measured in the world on an RTX 2080 (1,000,000-view cap), `main` +
#2460 #2461 #2464 and local work, 10 minutes each from a save that
loads into the world: with 65,533 dynamic slots the host ran out of
them and dropped draws (512 and more, and root views); with this PR's
layout before (721,469 title slots, 262,144 dynamic) none were dropped,
and no draw read a title slot past the kept ones (523,715 left out, all
for_draw=false). Back to that layout until a scene needs more title
slots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
Every list the conformance title's frame records binds the views'
bitmaps (its shaders mark the views they read), so each submission was
completed before the next was prepared and the title's ExecuteCommandLists
still waited for the GPU (23 of 25 ms a frame).

Only write marks need that: taken by an earlier submission's completion
while a later one still writes, they would go back early and be lost to
it. Writes through tables and root views are declared per list, so a list
marks writes only through the heap's views. A list counts as heavy for
marks only with heap indexing; write marks are taken only at the
completion of a heavy (or waited-for) submission. Read marks are taken by
any completion that bound them: taken early, they only make views early.

A present no longer waits for its frame, and with two swap chain buffers
the queue stalled until the shown one was let go (the frame rate stayed
at about 31). Three let the next frame be drawn meanwhile.

Waits for submissions in flight count in the frame-rate line's GPU wait.
The once-a-frame eviction pass clears every read mark of the views'
bitmaps (`shadow::reads_since`), which it ran after the previous
submission's completion had taken them (`shadow::take_reads`). With that
submission still in flight, its marks were cleared before it completed:
a null view only it reads would never be made. The pass now takes them
first, as the completion would, and makes their views.

The bitmaps' safety notes say which marks are taken while a submission
may still set more (read marks: a later call takes them) and which only
with none in flight (write marks, page read marks).
From review:
- A present no longer waits for its copy, so the planes it copies or
  composes (and the back buffer) are kept on the present list until it
  has run: the title may release or give up a presented texture
  meanwhile.
- The views' read marks are taken as atomics (a load, then a swap or an
  and), not through a `&mut [u32]` over memory a submission still in
  flight ORs into: no data race, and no mark set between the read and the
  clear is lost.
- Held queue work is pumped after submissions complete on any thread, not
  only on the completion thread: a value written or a fence signalled by a
  submission that a present, an execute or the next submission completed
  no longer waits for the title's next call or the 2 ms timer.
From triage:
- Submissions are waited for by default, as before; VICTORY_GPU_OVERLAP=1
  lets the title's submissions complete after they return. The swap chain
  keeps two buffers unless overlap is on. Tests run with it on (unless it
  is set to 0): theirs are the paths it adds, and our own lists take the
  waited path.
- The GPU's ORs into the read-mark bitmap are not atomic with the CPU's
  operations, so the CPU now clears read marks only with no submission
  that marks reads in flight: a completion takes the forgotten slots'
  clears only then (else a later one does), and the eviction pass, which
  clears every mark, runs only then; once a frame, the submission it is
  due before completes those first. Reads alone stay safe while a
  submission marks: what is not seen yet is seen by a later call.
- The module doc no longer points to a design document.
The once-a-frame wait for submissions that mark reads, before the
eviction pass clears the marks, fell on the first submission of each
frame: the present's, which then waited for the whole frame it shows
(41 fps where 60 held). It now falls on the title's first submission of
the frame instead.
A completion releasing held work (Why::Completed, index 6) indexed past
the frame line's six counts: the next present panicked, overlap on or
off, since any completion pumps held work. The counts and their names
come from Why::ALL now, checked at compile time to hold every reason at
its own index.
From review:
- The present list kept the swap chain's back buffer until the list was
  next reset, so ResizeBuffers found a reference held and failed
  (overlap on or off; compositor_failure_presents_primary_in_the_same_frame
  at its retry). The swap chain keeps its buffers, and a resize completes
  every list first: only the frame's planes are kept now.
- `Host::finish` flagged its completion first, so another thread's pump
  could take the flag before this completion's writes and fences landed,
  and this completion's own pump find it taken: held work waiting on it
  slept until the next call or the timer. The flag is set last (Release)
  and taken with AcqRel.
- Pipeline library messages the host gives for a library blob it rejects
  (another adapter or driver, damage) are no longer stored by the debug
  info queue: `pipeline::library` expects them and opens an empty library.
  With completions later on another thread, one left there from the
  library tests was found by another test's check for errors.
* pr-2312:
  GPU, Shaders: spread compute dispatches past 65,535 groups in x across z (fixes #2256)
  update readme
  GPU: the depth bounds test reaches the host (#158)

# Conflicts:
#	crates/victory-gpu/src/draw.rs
#	crates/victory-gpu/src/indirect.rs
A one-list host submission is timed with VICTORY_GPU_TIMING but was excluded from gpu_times. Read the fps line counters in the five-second block so it covers the same frames as GPU timing.
Review of #2461 (fuzeofficlal): under the debug layer the probe's heap of
`HEAP_VIEWS` slots logs an error at start on a capped host. Where the
runtime and driver report `MaxViewDescriptorHeapSize` (D3D12 options 19)
of at least 1,000,000 (the size every binding tier takes), that size is
the limit, and no heap is tried; otherwise the probe runs as before. The
same in victory-shader's test device.

Test: descriptor::host::tests::a_reported_view_heap_size_is_the_limit (the
limit is the reported size where there is one, and a heap of the limit is
made).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
Each indirect execution had a clamp of its own: a wait for all earlier
work, a compute dispatch, another wait, then the draw, about 5,100 times a
world frame. With the switch, an indirect draw opens a window: one clamp
pass recorded where the single clamp would be, reading a table the CPU
fills while recording. The indirect draws after it that store to no
buffer add their records to that table and read them clamped from the
window's part of the argument buffer, with no pass and no barrier of
their own. The pass clamps in draw order and charges the list's budget in
that order, as the single clamps did.

A window ends at any draw, dispatch or unordered-access clear other than
a joining indirect draw, at an indirect dispatch, at an indirect draw
whose shaders may store, at work a host library records and at the list's
end; a draw opens a new one when the table, the bytes or the records are
full or its arguments lie in a host copy the pass has no view of.

Off by default; the clamp shader is the host's own, so the translator's
source hash and the shader cache stay as they are. Counters per frame in
the copy statistics line (diagnostics).
With overlap on, a queue waiting on another queue's fence or memory value
waits until that submission has completed, which at PresentX it often has
not: imjustprism's run of the title logged work held at the present about
5.5k times. PresentX did not wait behind that work, so the frame could be
shown before its last held work ran.

A PresentX on a queue that holds work is now held there as well, as an
action run in its place once the work before it has gone to the host GPU.
The planes' states are taken at the call, as before. Without overlap a
present still runs at once, as on main. The frame line counts queued
presents.
Regression test for the case reported on Marvisak/VIctory#3197 together
with #2996 (5385cc6).
The window's pass carried its own copy of the mesh bounds; a change to
the single clamp's rule (Marvisak/VIctory#2996, 5385cc6) left the window
on the old one and dropped mesh groups (reported on #3197). Both shaders
now take the rule from one HLSL function.
The window's mesh rule divergence fixed in bdc4167 was found and integrated
first by Andrew (d16ae7d) on Marvisak/VIctory#3197.

Co-authored-by: Andrew <[email protected]>
* pr-2958:
  Shaders: an all-helper wave reads its mark lead at a lane that exists
  Shaders: one lane of a wave sets a mark its wave shares
Test-only: lower #2958's marks with the leader election disabled and compare the written bitmap word for word with the coalesced path, on hardware and WARP, including preselected bits, divergent branches and both console-wave shapes.
* pr-2634:
  victory-gpu: say once, not per slot, that the title's heap outgrew the host's
* pr-3120:
  GPU: with overlap, a present waits behind the work its queue holds
  GPU: a present list does not hold the back buffer; completions are flagged once done
  GPU: the frame line counts every reason held work is released by
  GPU: a present's submission does not wait for the frame to clear read marks
  GPU: overlap only with VICTORY_GPU_OVERLAP=1; read marks cleared with none marking in flight
  GPU: a present keeps its frame's textures; read marks taken atomically; held work runs after any completion
  GPU: eviction takes read marks of submissions in flight first
  GPU: marks of views read alone let submissions overlap; three swap chain buffers
  GPU: the title's submissions return before the host GPU has run them
A draw whose pipeline is still being made is dropped and leaves its
targets as they were. When it is the draw that writes a presented image
(Grand Theft Auto VI's final upscale, PS_TAA2_SpatialUpscaleWithDithering),
that back buffer still holds the frame drawn into it two presents ago, and
the window alternates between two old frames. On a cold driver cache the
world's first frame wants ~1,900 new pipelines; the upscale's was made 41 s
after its first use, and frames 1300-1346 alternated black and dim.

Such a draw now puts its pipeline at the head of the workers' queue
(make::hurry), and a present of an image it left unwritten is not shown:
the window keeps the last frame shown (crate::shown), for at most 10 s
(HOLD_LIMIT). Past that the frames are shown as they come, and the log
names the pipelines waited for, so a pipeline that never arrives (a dead
worker, a hung driver compile) cannot freeze the window. Refused pipelines
do not count at all. VICTORY_SHOW_UNWRITTEN=1 shows those frames as before.
With #3353 a dropped draw into the presented image holds the frame and
puts its pipeline first. A dropped pass further back still leaves the
image wrong: in Grand Theft Auto VI's world on a cold driver cache the
final upscale was made at once, but the world stayed black for ~50 s
until the compute pass resolving the lighting (CS_RaytracingResolve) was
made: it waited 47 s in the queue behind ~1,900 pipelines first used in
the same frame, and took 6 s once a worker had it.

While pipelines are queued, each frame now notes what each pass that runs
reads and writes (the views its code uses through tables, its targets)
and what the dropped ones would have written: their targets, and the
unordered views their code names through tables, read from the
container's own resource records (no translation needed). At the
present, a walk back from the presented images through the passes that
ran finds the dropped passes whose writes they read, and the nearest
eight go to the head of the workers' queue (crate::feeds). Once a
hurried pass runs, a later frame's walk goes on behind it.

The walk must not take the world's content: reads are kept per pass, not
per pipeline (a blit used by many passes would join all their inputs),
and a resource with more than four dropped writers (depth, a geometry
buffer, filled by hundreds of draws) is not followed to them. Without
these a round put 666 mesh pipelines first, pushed back 103 that the
queue would have made within 15 s, and the world went dark again.

The first 64 pipelines a run hurries are listed in first-pipelines.txt
beside the early list; the next run starts them ahead of the other early
starts, during loading.
* eval/overlap2:
  GPU: with overlap, a present waits behind the work its queue holds
  GPU: a present list does not hold the back buffer; completions are flagged once done
  GPU: the frame line counts every reason held work is released by
  GPU: a present's submission does not wait for the frame to clear read marks
  GPU: overlap only with VICTORY_GPU_OVERLAP=1; read marks cleared with none marking in flight
  GPU: a present keeps its frame's textures; read marks taken atomically; held work runs after any completion
  GPU: eviction takes read marks of submissions in flight first
  GPU: marks of views read alone let submissions overlap; three swap chain buffers
  GPU: the title's submissions return before the host GPU has run them
* eval/2461:
  GPU and shaders: a host's reported view heap size is the limit, before any heap is tried
  Revert "GPU: preserve title slots on capped view heaps"
  GPU: preserve title slots on capped view heaps
  Shader tests: the heap-buffer null-view test translates after the host's probe
  Shaders: the shader crate's own host lowers the view limit on a device that caps its heaps
  GPU and shaders: a host that caps its view heaps gets heaps at its cap, and shaders clamp to it
Conflicts were the moved shader host helpers, the PR's `mod tests` file
layout and the `Target` paths in the test files.
* eval/2634:
  victory-gpu: say once, not per slot, that the title's heap outgrew the host's
Unions: `pipeline.rs` keeps the BVH builder's `held_back` and the new
`feeds`/`shown` helpers; `draw.rs`'s indirect drop checks `held_back`
first and notes `not_made(kind == DISPATCH)`; `make.rs` is the same
resolution as eval/2309-hurry's (sides identical there).
Conflict: the GPU timing guard in `Host::submit`. Kept #3120's counter
(`submitted.value`) and took the PR's `if timing()` guard in place of
`if groups.len() > 1`.
Review of #3378 (fuzeofficlal): three bugs in the hooks that note what a
frame's passes read and write.

State::not_made read a table UAV with `table + offset * 4` computed
directly and handed to crate::descriptor::view, unlike table_entry and
tables, which check self.heap_of first: a title binding a null root table
(Root::Table(0)) with a non-zero table offset dereferenced a bogus
address and crashed the child with 0xC0000005. The handle is now a
checked_add that a bound heap must hold, so a null, stale or out-of-heap
table names nothing. A null descriptor names nothing either.

A null view (resource 0) made a phantom hub: a pass that bound a null SRV
joined every pass that bound a null UAV, so an unrelated dropped pass
whose writes nothing presented reads was pulled to the head of the
queue. `feeds` now ignores 0 in reads, writes and targets, at the pass
and in the graph.

Graph::ran noted a pass that wrote nothing, which no walk can reach: its
reads grew past NOTES_MAX while notes stayed put (10,000 writeless
passes, notes 0), for a title that stops presenting while pipelines are
queued. It now returns at once, as Graph::dropped did, and excludes
null descriptors from its counts.
* fix/hurry-feeders:
  GPU: a dropped pass reads only descriptors a bound heap holds
Review of #3378 (fuzeofficlal): three bugs in the hooks that note what a
frame's passes read and write.

State::not_made read a table UAV with `table + offset * 4` computed
directly and handed to crate::descriptor::view, unlike table_entry and
tables, which check self.heap_of first: a title binding a null root table
(Root::Table(0)) with a non-zero table offset dereferenced a bogus
address and crashed the child with 0xC0000005. The handle is now a
checked_add that a bound heap must hold, so a null, stale or out-of-heap
table names nothing. A null descriptor names nothing either.

A null view (resource 0) made a phantom hub: a pass that bound a null SRV
joined every pass that bound a null UAV, so an unrelated dropped pass
whose writes nothing presented reads was pulled to the head of the
queue. `feeds` now ignores 0 in reads, writes and targets, at the pass
and in the graph.

Graph::ran noted a pass that wrote nothing, which no walk can reach: its
reads grew past NOTES_MAX while notes stayed put (10,000 writeless
passes, notes 0), for a title that stops presenting while pipelines are
queued. It now returns at once, as Graph::dropped did, and excludes
null descriptors from its counts.
The #2309 merge gave `heap_direct_texture_reads_mark_their_heap_index`'s
`Parts` the `target`/`console_cf`/`per_lane_only` fields twice (its side
and the PR's, both edited around #2958's `view_marks: true`); the test
target did not compile until they were one.
`feeds::Graph::ran` counts its notes without collecting the filtered
reads and writes; the amended commit replaces the version merged from
a123c31e, so its side is taken whole.
PR head fc39e73f (survey head fc39e73f60, unchanged). Conflicts: host.rs
(2), shadow.rs (1), all resolved keeping both intents:

* host.rs `Deferred`: our `held` (keep_until_reset) and the PR's
  `vram_bitmaps`/`vram_probes` are separate fields; both kept.
* host.rs `Host::run`: our removal check ("lists timed on their own ran
  here") and the PR's VRAM readback block are separate work; both kept,
  ours first. The PR's trailing `let gpu = prepared.elapsed()` is
  dropped: our tree moved that timing into `finish()`
  (`record.prepared.elapsed()`), so the binding would be unused.
* shadow.rs: our `read_marks` and the PR's `has_vram_bitmaps`,
  `sync_bitmaps_pre/post`, `vram_marked_reads` are separate items; both
  kept.

Adaptation git could not see: the PR's `upload_vram_copies` /
`readback_vram_copies` / `run_copy_list` thread a `&mut u64` ahead of our
`Submitted` struct (#3120 overlap), and the value they bumped was only
ever passed as `Some(_)`; `run_copy_list` now takes `wait: bool` and the
counters are gone, so the copy lists never touch the title fence's
`Submitted::value`.

Semantic conflict: the PR's two new memory.rs tests (written against the
older one-argument `pipeline(source)`) now call the four-argument helper
as `pipeline(WRITE, D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 2, 5)`, the same
shape as the existing WRITE tests.

No new switches: VRAM placement is unconditional when the device is not
UMA.
PR head cb7347b8 (survey head cb7347b817, unchanged). One conflict in
shadow.rs, two new tests appended at the same spot before the shared
`unregister(p, p as u64); }` tail: #3312's
`vram_marked_view_writes_go_back_to_title` (ours) and the PR's
`overlapping_snapshots_never_recopy_and_cross_segment_copy_back`. Both
kept, each with its own closing brace; the shared tail closes the PR's
test. No semantic change: they exercise different paths (VRAM readback
on Host::execute vs. `writing`/`copy_back` bookkeeping).

No new switches.
PR head 586102fb. One conflict, the shadow.rs test block: our #3312
`vram_marked_view_writes_go_back_to_title` and #3318
`overlapping_snapshots_never_recopy_and_cross_segment_copy_back` sit
where the PR appends `parallel_marked_pages_go_back_and_retake_guards`.
All three kept (our two take their own closing brace, the shared tail
closes the PR's).

The code side merges clean: the PR turns `copy_back_marked_with`'s own
`vec![0u8; n]` per page into a borrow of the caller's buffer, and
`copy_back_marks` keeps one pooled PAGE buffer per worker. Without #2848
there is no `Back`, so this is where the per-page allocation goes away
for good rather than being replaced twice.
PR head c673921c. Same five conflicts and the same resolutions as the
A-chain and B2-chain steps; `host.rs` and `indirect.rs` are byte-identical
to `eval/perfE`'s after the merge, and `draw.rs` differs from it only by
#2848's stack user data, which this chain does not carry (verified with
`git diff eval/perfE eval/perfE3`).
#2472's batch clamp read its budget through RWByteAddressBuffer::Load and
declared its root signature in a [RootSignature] attribute. Wine's
D3DCompile refuses the first (E5005) and ignores the second, so on Wine
batch_clamp() was None and every hoisted clamp fell back to a single one
('no batched argument clamp: falling back to inline'). As crate::compute
(#2969, after #1279): the budget is a RWStructuredBuffer<uint> and the root
signature is made in Rust (make_with), as record_prelude binds it.

Test: every_clamp_compiles_without_a_root_signature_attribute (no device).
PR head 0c997d40 (with bdc4167c's shared mesh group rule and dff6c005's
test). Conflicts in draw.rs, external.rs, host.rs, indirect.rs; copystat.rs
merged cleanly.

Resolution, in `execute_indirect`: #2472's hoist first (a draw in the
list's non-writing prefix goes to the prelude); otherwise, with the switch
on and a pipeline that does not store, the draw joins or opens a window;
otherwise the single clamp, `bound(.., spread)`, which ends any open window
first. `HoistedClamps::kept` replaces the window branch's `hoisted`. The
single clamp keeps E3's Rust-built root signature (`make_with`) and its
spread flag; the PR's `mesh_groups!` rule is shared by it and the window.

The window shader is left as the PR has it (`[RootSignature]`, budget
through `RWByteAddressBuffer::Load`), built by the PR's `compile`, now over
`crate::compute::compile`. Wine's compiler rejects it; the next commit
fixes that.
#3197's window pass had the batched clamp's two Wine problems (52622595):
its budget read through `RWByteAddressBuffer::Load`, which Wine's
D3DCompile (vkd3d-shader) rejects with E5005, and its root signature in a
`[RootSignature]` attribute Wine's ignores. So `window_clamp()` returned
`None` there and every windowed draw fell back to a single clamp.

The budget is a `RWStructuredBuffer<uint>`, as in the single and batched
clamps, and the root signature is built in Rust (`make_with`) in the order
`open` binds: t0..t3 the sources, t4 the table, u1 the budget, u0 the
records. The tests' store shader is ported the same way, and the PR's
root-signature-from-blob `compile` goes, unused.

`every_clamp_compiles_without_a_root_signature_attribute` now covers the
window shader too (D3DCompile only, no device; passes under Wine).
A draw joined #2472's hoisted prefix or #3197's window only if its
pipeline had no view marks at all (`marks`, `view_marks`). But marks come
in two kinds. A write mark is set beside a store or atomic through an
unordered buffer view from the heap, and such a view is a table's, the
heap's own or a root UAV's, so a stage that writes marks has one of those
write flags anyway. A read mark is a bit in our own bitmap (u1 in the
memory space), a host buffer that is never title memory and so never an
argument or count buffer. The G-buffer's pixel shaders read-mark the
textures they take from the heap and store nothing, yet every one of their
indirect draws was clamped on its own.

One predicate, `may_write_arguments`, decides both batches, from each
stage's write flags: table UAVs (`used`), heap UAVs (`heap_writes`), root
UAVs as root descriptors or as their heap views (`ROOT_UAV_VIEW`), and
title memory (`memory`, `memory_writes`, the page table and its bitmap).
It replaces `pipeline_writes_uav` and `may_store`; marks are no longer
among them. `clamp_route` is that rule's one decision for an indirect
execution: a dispatch or a writer is clamped on its own whatever the
prelude has room for and whatever the window switch says, and its own
clamp ends any open window first; anything else is hoisted if the prelude
takes it, and otherwise joins a window.

Diagnostics: the clamp line of the copy report is logged whatever the
window switch, with the indirect draws hoisted to preludes and those of the
hoisted and windowed that have read marks (the ones this rule lets in).

Tests (CPU, no device): a_stage_that_only_read_marks_may_join_a_clamp_batch,
a_table_uav_store_ends_a_clamp_batch, a_heap_store_ends_a_clamp_batch,
a_root_uav_ends_a_clamp_batch, title_memory_ends_a_clamp_batch,
a_read_marking_draw_may_join_a_window_and_the_writer_ends_it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 15:01:41 +00:00
Author
Owner

@⁠ColorMeBoom on GitHub · 2026-11-27 16:28 UTC · original

The CI failure is WARP's wave size, not the change. Your head d4e44ed merged onto main 63bcca4, RX 5700 XT (RDNA1, 32–64 lanes):

  • Hardware: wave_coalesced_marks_equal_per_lane_marks_on_the_gpu passes: "hardware: coalesced marks and results equal the per-lane ones" for all four wave64/coalesced variants. WARP prints no 32-lane waves; skipped.
  • VICTORY_WARP=1 (what the CI runner has): both adapters print no 32-lane waves; skipped, then memory_tests.rs:1220 panics with neither hardware nor WARP SM 6.6 device available. That's the CI failure, not a wrong result.

The fix is the same one valu_tests::run_cases_on uses for a wave of 32 (and that I proposed for the same failure on #2920): remember the wave-size skip, and accept it in the final assert.

let (mut ran, mut wave_skipped) = (0, false);
// ...
if !host.target().runs(32) {
    eprintln!("{label}: no 32-lane waves; skipped");
    wave_skipped = true;
    continue;
}
// ...
assert!(ran > 0 || wave_skipped, "neither hardware nor WARP SM 6.6 device available");

AI use: Claude Code (Claude Opus 5.5).

**@⁠ColorMeBoom** on GitHub · 2026-11-27 16:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3531#issuecomment-7223302008) **The CI failure is WARP's wave size, not the change.** Your head `d4e44ed` merged onto `main` `63bcca4`, RX 5700 XT (RDNA1, 32–64 lanes): - Hardware: `wave_coalesced_marks_equal_per_lane_marks_on_the_gpu` passes: "hardware: coalesced marks and results equal the per-lane ones" for all four wave64/coalesced variants. WARP prints `no 32-lane waves; skipped`. - `VICTORY_WARP=1` (what the CI runner has): both adapters print `no 32-lane waves; skipped`, then `memory_tests.rs:1220` panics with `neither hardware nor WARP SM 6.6 device available`. That's the [CI failure](https://github.com/Marvisak/VIctory/actions/runs/46020682387), not a wrong result. The fix is the same one `valu_tests::run_cases_on` uses for a wave of 32 (and that I proposed for the same failure on #2920): remember the wave-size skip, and accept it in the final assert. ```rust let (mut ran, mut wave_skipped) = (0, false); // ... if !host.target().runs(32) { eprintln!("{label}: no 32-lane waves; skipped"); wave_skipped = true; continue; } // ... assert!(ran > 0 || wave_skipped, "neither hardware nor WARP SM 6.6 device available"); ``` AI use: Claude Code (Claude Opus 5.5).
WARP and 64-lane-only hardware skip the test for their wave size; the final assert now accepts that skip instead of reporting no device (suggested by @ColorMeBoom).
Author
Owner

@⁠neonbyte1 on GitHub · 2026-11-27 16:39 UTC · original

@⁠ColorMeBoom thanks, that's exactly it, and thanks for running it on RDNA1 hardware. Taken as you proposed in 869abe58: the wave-size skip is remembered and the final assert accepts it. I checked it with clippy (-D warnings) and formatting; the test itself only runs on a 32-lane adapter here, so the WARP case is your CI run's to confirm.

For reviewers: this test isn't part of the read-mark rule. It comes from the stack this draft sits on (#2958's coalesced marks, compared with per-lane marks), which is why it shows up in this PR's diff against main. The change to review stays the last functional commit, d4e44ed5 (draw.rs, copystat.rs).

AI-assisted (Claude); measured on my machine, no game data shared.

**@⁠neonbyte1** on GitHub · 2026-11-27 16:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/3531#issuecomment-7223511488) @⁠ColorMeBoom thanks, that's exactly it, and thanks for running it on RDNA1 hardware. Taken as you proposed in `869abe58`: the wave-size skip is remembered and the final assert accepts it. I checked it with clippy (`-D warnings`) and formatting; the test itself only runs on a 32-lane adapter here, so the WARP case is your CI run's to confirm. For reviewers: this test isn't part of the read-mark rule. It comes from the stack this draft sits on (#2958's coalesced marks, compared with per-lane marks), which is why it shows up in this PR's diff against `main`. The change to review stays the last functional commit, `d4e44ed5` (`draw.rs`, `copystat.rs`). _AI-assisted (Claude); measured on my machine, no game data shared._
Author
Owner

@⁠ColorMeBoom on GitHub · 2026-11-27 17:09 UTC · original

@⁠neonbyte1 confirmed at 869abe5, merged onto main 63bcca4:

  • VICTORY_WARP=1 (CI's case): wave_coalesced_marks_equal_per_lane_marks_on_the_gpu passes, with both adapters printing no 32-lane waves; skipped.
  • RX 5700 XT: still passes, "coalesced marks and results equal the per-lane ones", with WARP skipped.
  • The PR's CI run on 869abe5 is green.

AI use: Claude Code (Claude Opus 5.5).

**@⁠ColorMeBoom** on GitHub · 2026-11-27 17:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/3531#issuecomment-7224097244) @⁠neonbyte1 confirmed at `869abe5`, merged onto `main` `63bcca4`: - `VICTORY_WARP=1` (CI's case): `wave_coalesced_marks_equal_per_lane_marks_on_the_gpu` **passes**, with both adapters printing `no 32-lane waves; skipped`. - RX 5700 XT: still passes, "coalesced marks and results equal the per-lane ones", with WARP skipped. - The PR's [CI run](https://github.com/Marvisak/VIctory/actions/runs/46035344529/job/140629214466) on `869abe5` is green. AI use: Claude Code (Claude Opus 5.5).
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/3531/head:github-bot/gh-3531'
git switch 'github-bot/gh-3531'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3531'
git switch 'github-bot/gh-3531'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3531'
git switch 'github-bot/gh-3531'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3531'
git switch 'main'
git merge --squash 'github-bot/gh-3531'
git switch 'main'
git merge --ff-only 'github-bot/gh-3531'
git switch 'main'
git merge 'github-bot/gh-3531'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3531
No description provided.