Skip to content

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

Draft
neonbyte1 wants to merge 166 commits into
Marvisak:mainfrom
neonbyte1:pr/clamp-read-mark-rule
Draft

neonbyte1 wants to merge 166 commits into
Marvisak:mainfrom
neonbyte1:pr/clamp-read-mark-rule

Conversation

@neonbyte1

Copy link
Copy Markdown

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 (GPU: hoist and batch indirect argument clamps into the list prelude #2472), else joins a
    window
    when VICTORY_CLAMP_WINDOW=1 (GPU: clamp consecutive indirect draws in one pass (VICTORY_CLAMP_WINDOW, opt-in) #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

r4tedx and others added 30 commits November 24, 2026 11:20
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
`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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 Marvisak#189 and Marvisak#192, which both get this right.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 Marvisak#192, which has the same result on both adapters.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…the console flow

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
(Marvisak#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 <noreply@anthropic.com>
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 Marvisak#233 that tried Marvisak#269's programs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 Marvisak#233 of pipelines created from modules that
fail validation.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 Marvisak#233: modules that fail validation with that
message and still create pipelines, 20 of them new with Marvisak#320, which I
cannot reproduce with hand-assembled programs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 Marvisak#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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…d masks

Two defects found with a contributor's fixture (a waterfall loop over
lane classes with a whole-wave section inside, reported on Marvisak#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 <noreply@anthropic.com>
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#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.
danielibabet and others added 20 commits November 26, 2026 22:13
* 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
…into eval/perf

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 Marvisak#3120's counter
(`submitted.value`) and took the PR's `if timing()` guard in place of
`if groups.len() > 1`.
Review of Marvisak#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 Marvisak#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 Marvisak#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 Marvisak#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
a123c31, so its side is taken whole.
PR head fc39e73 (survey head fc39e73, 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 (Marvisak#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.
…py-back)

PR head cb7347b (survey head cb7347b, unchanged). One conflict in
shadow.rs, two new tests appended at the same spot before the shared
`unregister(p, p as u64); }` tail: Marvisak#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.
… without Marvisak#2848

PR head 586102f. One conflict, the shadow.rs test block: our Marvisak#3312
`vram_marked_view_writes_go_back_to_title` and Marvisak#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 Marvisak#2848
there is no `Back`, so this is where the per-page allocation goes away
for good rather than being replaced twice.
PR head c673921. 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
Marvisak#2848's stack user data, which this chain does not carry (verified with
`git diff eval/perfE eval/perfE3`).
Marvisak#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
(Marvisak#2969, after Marvisak#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).
…amp-windows

PR head 0c997d4 (with bdc4167's shared mesh group rule and dff6c00's
test). Conflicts in draw.rs, external.rs, host.rs, indirect.rs; copystat.rs
merged cleanly.

Resolution, in `execute_indirect`: Marvisak#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.
Marvisak#3197's window pass had the batched clamp's two Wine problems (5262259):
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 Marvisak#2472's hoisted prefix or Marvisak#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.
@ColorMeBoom

ColorMeBoom commented Nov 27, 2026 •

Copy link
Copy Markdown

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).

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).
@neonbyte1

Copy link
Copy Markdown
Author

@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.

@ColorMeBoom

Copy link
Copy Markdown

@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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.