Shaders, second round: geometry programs as geometry shaders, loops as the console runs them, lighter wave64 forms, dispatches past 65,535 groups in x (stacked on #854) #993

Open
github-bot wants to merge 36 commits from github-bot/gh-993 into main AGit
Owner

@⁠PiloteCode on GitHub · 2026-11-25 15:20 UTC · original
PiloteCode:pr/shaders2 → main · +9443 −1665 · 50 files · 36 commits · open

Stacked on #854. The branch is #854's head (0751197e) with main (0b0074e0) merged in, which had no conflict. The 25 commits after that merge are this PR's. Once #854 is in, only they remain. The first one is the clippy fix for main that our other open PRs also start with (shadow.rs, manual_is_multiple_of).

Offline census over the title's whole shader pack (victory translate --validate --list, VICTORY_HOST_MAX_WAVE=32, CPU only: translation and DXIL validation, no pipelines, as the card was reserved): 25,948 of 25,953 programs translate and validate, against 25,682 with #854 alone.

Stage #854, pass / fail This PR, pass / fail
Compute 2,729 / 5 2,729 / 5
Mesh 8,694 / 71 8,765 / 0
Pixel and vertex 14,259 / 0 14,259 / 0
Geometry 0 / 195 195 / 0
All 25,682 / 271 25,948 / 5

The 71 mesh programs pass in the form they take when drawn without a pixel program (below); #854 links them with their pixel program for the pipelines that have one. The five left are shadow-mask trace programs (a descriptor read only as data). Our ray-tracing PR, stacked on this one, makes four of them translate.

What changes

Geometry programs translate as geometry shaders (geometry.rs, emit/rings.rs, native.rs, pipeline/host.rs)

The title's 195 geometry programs (all GS_VoxelizeGeneric variants) stopped at resource tracking: their first load reads the console driver's table that user data 0 and 1 point at.

How the console runs such a program: in one hardware stage, after the ES half of its vertex program. It reads its triangle's vertices from LDS at the offsets in v0 and v1 (16 bits each), writes the vertices it emits to its lane's slot of the GS-VS ring (also in LDS), and sends a GS message for each emit and cut. The stage data gives the ring's layout (StageIo::Gs).

How the host runs it now:

  • The ES half runs as the vertex program it is: the container's VS program, the other compilation of the same HLSL.
  • The program runs as a geometry shader with one invocation per primitive (crate::geometry, emit/rings.rs). The address of each LDS access is followed to the input vertex and dword it reads, or to the emitted vertex and dword it writes:
    • a ring read is that input's loadInput;
    • a ring write is kept as that vertex's output;
    • the n-th emit stores vertex n's outputs and emits it.
  • The load from the driver's table only places the ring, so its value is never needed (resource::DRIVER).
  • The prologue that narrows EXEC to the wave's GS threads keeps every lane (NativeProgram::patched_code).
  • The primitive id (v2) is the host's.
  • Refused: an invocation id (v3, instancing), vertices 4 and 5 (adjacency), another stream, and emits in branches.

A title pipeline with a geometry stage was refused before ("only vertex, mesh, pixel and compute stages are translated"). It now gets a host pipeline: the vertex program, the geometry program and the pixel program, each stage's user data and views bound as the others are. The geometry stage comes last, so the pixel stage keeps its place.

Offline, all 195 translate and validate, and the DXIL of every other program is unchanged by this commit. Their pipelines, between a stub vertex and pixel shader, build on WARP. No run so far drew with a geometry stage.

#854 links each of the 71 oversized mesh programs with the pixel program of its pipeline. A pipeline without a pixel program, as the title makes for depth, still got the invalid translation: the runs so far bound 143 mesh programs alone 14,576 times.

link_mesh_alone translates such a program again without its outputs of arbitrary semantics, which only a pixel program reads. Position, clip and cull distances stay, and it fits. The runtime makes those pipelines with it. The census checks that form of the 71, since its stub pixel program reads nothing: all 71 validate and get a pipeline (RTX 5090). VICTORY_MESH_LINK=0 turns this form off too.

Loops (emit/loops.rs, emit/regions.rs, emit/trip.rs, lower.rs)

  • A helper lane of a pixel program is its own first lane. The console runs a pixel program's helper lanes as lanes of EXEC (the program starts with s_wqm), so a waterfall loop over descriptors serves a helper lane in a pass of its own. The host's wave operations leave helper lanes out (SM 6.6) and give them undefined results. A helper lane whose value no other lane held never met it as the first lane. It went round the translated loop to the iteration limit, sampling each pass, and left with nothing computed, which its quad's derivatives then read. The character skin and cloth program (94d281151ca58b4f) samples its material layers in nine such nested loops.

    • A first-lane read in a pixel program now gives a helper lane its own value, and every heap handle of such a program is non-uniform.
    • Test: on the RTX 5090 the helper lane's count was 0 (never served) before and 1 now; WARP agrees.
    • VICTORY_HELPER_OWN=0 turns it off, for an A/B on screen.
  • A loop whose code fixes its count runs to its end, whatever the limit. The limit is for loops whose end the data decides. A loop has a fixed count when its exit is a scalar counter that:

    • starts at a constant;
    • moves by a constant step each pass;
    • is compared with a constant, at its bottom, or at its top with a jump back.

    Such a loop now runs as often as the console's, up to 65,536 passes. The environment BRDF integration tables (PS_IntegrateEnvBRDF and its Beckmann and thin-film variants) integrate 1,024 samples a texel in six loops of 256 or 512 passes. At the pixel limit of 128, every one of the 65,536 texels of each table stopped at a half or a quarter of its samples (loop notes, opening cutscene). Every specular reflection reads those tables.

  • A loop each lane leaves on its own is not code every lane runs. Where two host waves run one console wave of 64 lanes, they exchange first lanes, masks and LDS order through group barriers, and only in blocks every lane runs. A waterfall loop in one block was taken for such code and got two host waves' exchange: four group barriers a pass, which lanes that had left met at other barriers.

    • In the projected-decal classification (1f1fbd86759b3da2), lanes then never met their descriptor and ran to the compute limit of 4,096 passes, losing their loads.
    • A loop that a lane branch leaves is now part of that branch's region.
    • Of the 1,085 compute programs seen in the title's runs, two translate differently.
  • A loop closed by a jump leaves at its exit at the limit. Such a loop has its exit test elsewhere in its body. At the limit, its jump back could only end the lane: a pixel discarded, a mesh or compute lane stopped before its writes. Its exit tests now take the limit too, so a lane at the limit leaves there and goes on with the program. A lane whose way round passes no exit test still ends.

  • A vertex or mesh program with a root UAV declares UAVs at every stage (ShaderFlags bit 16). With loop notes on, the validator refused 62 of 801 such programs of a run.

  • Diagnostics.

    • Loop limits per stage: pixel 128, vertex and mesh 256, compute 4,096, ray tracing 1,024, as before. VICTORY_SHADER_LOOP_LIMIT takes one number, or stage:n pairs.
    • VICTORY_LOOP_NOTES=1: each lane that reaches a loop's limit adds one to that loop's record in a root UAV of ours, and the log names the loops whose counts grew, every five seconds (crate::loop_notes).
  • The limits themselves stay. With them raised to 1,024 / 4,096 / 65,536, the notes named loops that never end, for example a cascade search that reads its count as 0, and a decal resolve's walk.

Wave64 programs on 32-lane GPUs (emit/split.rs, emit/guarded.rs, emit/forms.rs)

  • Allocation-only programs run as two host waves of their own (VICTORY_WAVE_SPLIT=0 turns it off). Some console wave64 programs use their wave-wide values only as the allocation idiom uses them: each wave's first lane reserves its count on a shared counter, and every lane takes the base plus its rank. Such a program is exact with each host wave on its own: the same records, reserved by each half in another order. Before, a program that the exchange form also translated took that form: two host waves meeting at two group barriers for each first-lane read, mask and sum.
    • CS_Primary_RegisterAllocationRequests (33 group barriers in 681 host instructions) took 3.7 ms of card time per dispatch in the opening cutscene, 2.8 ms a frame: the most of any wave64 program.
    • The idiom check now also follows a guarded write that reuses a register: a reader that cannot see the lanes outside the guard keeps the write's kind (split::read_inside_only).
    • Offline (CPU census, the same build with the switch off): 40 of the 160 exchange-form programs take the local form, and 5 of the 70 paired programs. No other program changes. The 5 paired ones go from 48,501 to 19,039 host instructions.
  • The paired form reads a guarded write without its select where only lanes inside the guard read it (VICTORY_WAVE_RAW=0 turns it off). In the paired form every per-lane branch is the wave's, so a guarded write is select(guard, new, old). That was about a sixth of the paired programs' host code, each select keeping the register's old value alive. A lane that reads the register under a guard that implies the writer's guard reads the computed value. This holds only for its own registers: a DPP source, lane read or write, swizzle or permute reads other lanes. Offline, only the 69 paired programs change: host instructions 2,303,768 -> 1,617,871 (-30 %), guard selects 360,668 -> 124,509.
  • The census names the form each console wave64 compute program takes on a 32-lane host (form= with VICTORY_SHADER_CENSUS).

Dispatches of more than 65,535 groups in x run whole (lower.rs, shader.rs, draw.rs, indirect.rs)

One host dispatch runs at most 65,535 groups in a dimension; the console runs more. The screen-probe final gather of the indirect diffuse light asks for up to 2 x 57,600 = 115,200 groups in x: one group per 8x8 tile of each of its two layers at 2560x1440. The clamp of indirect records cut such a record to 65,535, so the tiles past that point never ran. This showed as blocks along the bottom of the picture, and on a head lit by the window as a washed-out orange light with a vertical seam.

  • Translator. A compute program's group id in x adds a user-data dword the host computes, USER_GROUP_BASE (RootType::Other(0x104)). Programs with a spilled user-data table do not ask for it: their root signatures are close to the host's 64 dwords.
  • Direct dispatches of more than 65,535 groups in x run as several, each told its first group by a root constant.
  • Indirect dispatches of such programs are clamped as split dispatches, a kind of the clamp's own (indirect::SPLIT_DISPATCH):
    • each record becomes four records of the base and the counts, at most 65,535 groups in x each (262,140 in all);
    • they run through a command signature that sets the base and dispatches;
    • the records past a count buffer's count come out empty, and every record runs.
  • Diagnostics. A program whose indirect dispatch asks for more groups than run is named.

In our tree, in the save's gameplay (the cell window, the same static view): before, about 0.8 records a frame were cut, blue and white blocks lined the bottom edge, and the hair took the washed-out light. After, 166 frame lines asked for more than 65,535 groups, none was cut, the bottom edge was clean and the hair was lit as the rest of the room. That tree clamped into a ring of the list's (not in main). Here the split is written onto main's clamp program and scratch buffer: the same records and signature, tested on WARP.

Switches

Switch Default Effect
VICTORY_WAVE_SPLIT on =0: allocation-only wave64 programs take the forms they took before
VICTORY_WAVE_RAW on =0: the paired form selects every guarded write, as before
VICTORY_HELPER_OWN on =0: helper lanes read the host wave's first lane, as before
VICTORY_MESH_LINK on =0 now also turns off the system-values-only form of oversized mesh programs drawn alone
VICTORY_SHADER_LOOP_LIMIT stage limits one number for every stage, or pixel:<n>,vertex:<n>,compute:<n>,trace:<n>
VICTORY_LOOP_NOTES=1 off count the lanes that reach a loop's limit (a root UAV of ours in every program with a counted loop)

Every VICTORY_* switch the translator reads is part of the shader cache key.

Tested

The branch was checked as it is (its head merged with main already). The card was reserved for other work, so the tests ran on the software adapter:

  • cargo test -p victory-shader -- --test-threads=1 with VICTORY_WARP=1: 259 passed, 5 failed, 2 ignored. The same five fail on #854's head merged with main (237 passed, 5 failed), all on the software adapter (WARP refuses the pipelines of the first four, E_INVALIDARG, and reads another lane count in the fifth): ds_min_max_f32_order_floats_and_return_the_old_value, lds_subtractions_get_a_pipeline_and_stay_atomic, v_permlane16_and_x16_read_the_lanes_their_selectors_pick, whole_wave_f64_sum_and_cvt_f32_f64 and a_lane_mask_joined_with_a_number_is_read_as_the_number_it_is. Tests that need the card's 32-lane waves run on WARP here; they passed on the RTX 5090 when they went in.
  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1 with VICTORY_D3D12_WARP=1: 186 passed, 1 failed, 6 ignored. The failure, depth_bounds_pipeline_loads_and_filters_draws, fails the same way on #854's head merged with main (185 passed): WARP does not reject the pixels outside the depth bounds.
  • cargo test -p victory: 1 passed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo build --release -p victory, cargo build --profile diag -p victory --features diagnostics and cargo xtask policy pass.

New tests:

  • the geometry rings of a program of the console's form, the refusals, the prologue, the primitive id, and that program drawn between a pass-through vertex and pixel shader (WARP);
  • helper lanes in a waterfall (quad permute of a pixel's own count);
  • the fixed-count analysis (bottom and top tests, counts the data bounds), and a compute loop of 5,000 passes;
  • a waterfall's block is not every lane's, while a scalar loop around a lane branch still is;
  • a loop closed by a jump goes on at the limit;
  • a vertex program writing the notes' UAV validates;
  • the local form of an allocation that reuses its count register, with its counter and records against the console's;
  • raw reads of guarded writes in the paired form, against the console's 64 lanes;
  • a compute program's group id in x asks for the base, and in y it does not;
  • on WARP, a record of 100,000 groups runs each group from 0 to 99,999 once through the split records, and a record past the count runs none.

Earlier, all of these changes ran in our tree on the RTX 5090, with our layer work: its general test (an opening cutscene run and gameplay runs from a save) had no device loss, no refused pipeline and no exception.

Overlaps with open pull requests

  • #834 splits indirect dispatches past 65,535 groups in x with a second execution, up to 131,070. It adds the same user-data word, under the same name and code (USER_GROUP_BASE, RootType::Other(0x104)), to the group id in x. Here one execution of split records runs up to 262,140 groups, and direct dispatches are split too. The translator parts are nearly the same; whichever goes in second keeps one.
  • #646 uses the same code, RootType::Other(0x104), for another word (USER_DISPATCH_THREADS). With both, one of the two needs another code. Our ray-tracing PR (stacked on this one) does thread counts with 0x105.
  • #895 keeps helper lanes out of first-lane reads with IsHelperLane, and adds quad reads. Here a helper lane reads its own value in a pixel program's first-lane reads.
  • #832 (a divergent loop's re-entry into its branch's region) is close to "a loop each lane leaves on its own".
  • #683 gives compute programs a loop limit of their own. Here every stage has its own limit, and fixed-count loops ignore the limits.
  • #871 prunes the unread varyings of oversized mesh pairs; #854 links them.
  • #592 and #779 change which form wave64 programs take on 32-lane hosts in other ways.

Not tested

  • A run of this exact branch in the title: the card was reserved. Earlier runs of our tree had these changes.
  • A draw with a geometry stage: no run has made one. The pipelines build on WARP.
  • GPUs with 64-lane waves (AMD), where the wave64 forms here are not taken; Intel; Linux/Proton.
**@⁠PiloteCode** on GitHub · 2026-11-25 15:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/993) `PiloteCode:pr/shaders2` → `main` · +9443 −1665 · 50 files · 36 commits · open **Stacked on #854.** The branch is #854's head (`0751197e`) with `main` (`0b0074e0`) merged in, which had no conflict. The 25 commits after that merge are this PR's. Once #854 is in, only they remain. The first one is the clippy fix for `main` that our other open PRs also start with (`shadow.rs`, `manual_is_multiple_of`). Offline census over the title's whole shader pack (`victory translate --validate --list`, `VICTORY_HOST_MAX_WAVE=32`, CPU only: translation and DXIL validation, no pipelines, as the card was reserved): 25,948 of 25,953 programs translate and validate, against 25,682 with #854 alone. | Stage | #854, pass / fail | This PR, pass / fail | |---|---|---| | Compute | 2,729 / 5 | 2,729 / 5 | | Mesh | 8,694 / 71 | 8,765 / 0 | | Pixel and vertex | 14,259 / 0 | 14,259 / 0 | | Geometry | 0 / 195 | 195 / 0 | | **All** | **25,682 / 271** | **25,948 / 5** | The 71 mesh programs pass in the form they take when drawn without a pixel program (below); #854 links them with their pixel program for the pipelines that have one. The five left are shadow-mask trace programs (a descriptor read only as data). Our ray-tracing PR, stacked on this one, makes four of them translate. ## What changes ### Geometry programs translate as geometry shaders (`geometry.rs`, `emit/rings.rs`, `native.rs`, `pipeline/host.rs`) The title's 195 geometry programs (all `GS_VoxelizeGeneric` variants) stopped at resource tracking: their first load reads the console driver's table that user data 0 and 1 point at. How the console runs such a program: in one hardware stage, after the ES half of its vertex program. It reads its triangle's vertices from LDS at the offsets in v0 and v1 (16 bits each), writes the vertices it emits to its lane's slot of the GS-VS ring (also in LDS), and sends a GS message for each emit and cut. The stage data gives the ring's layout (`StageIo::Gs`). How the host runs it now: - The ES half runs as the vertex program it is: the container's VS program, the other compilation of the same HLSL. - The program runs as a geometry shader with one invocation per primitive (`crate::geometry`, `emit/rings.rs`). The address of each LDS access is followed to the input vertex and dword it reads, or to the emitted vertex and dword it writes: - a ring read is that input's `loadInput`; - a ring write is kept as that vertex's output; - the n-th emit stores vertex n's outputs and emits it. - The load from the driver's table only places the ring, so its value is never needed (`resource::DRIVER`). - The prologue that narrows EXEC to the wave's GS threads keeps every lane (`NativeProgram::patched_code`). - The primitive id (v2) is the host's. - Refused: an invocation id (v3, instancing), vertices 4 and 5 (adjacency), another stream, and emits in branches. A title pipeline with a geometry stage was refused before ("only vertex, mesh, pixel and compute stages are translated"). It now gets a host pipeline: the vertex program, the geometry program and the pixel program, each stage's user data and views bound as the others are. The geometry stage comes last, so the pixel stage keeps its place. Offline, all 195 translate and validate, and the DXIL of every other program is unchanged by this commit. Their pipelines, between a stub vertex and pixel shader, build on WARP. No run so far drew with a geometry stage. ### A mesh program over 32 KiB drawn without a pixel program keeps only its system values (`emit/link.rs`, `pipeline/host.rs`) #854 links each of the 71 oversized mesh programs with the pixel program of its pipeline. A pipeline without a pixel program, as the title makes for depth, still got the invalid translation: the runs so far bound 143 mesh programs alone 14,576 times. `link_mesh_alone` translates such a program again without its outputs of arbitrary semantics, which only a pixel program reads. Position, clip and cull distances stay, and it fits. The runtime makes those pipelines with it. The census checks that form of the 71, since its stub pixel program reads nothing: all 71 validate and get a pipeline (RTX 5090). `VICTORY_MESH_LINK=0` turns this form off too. ### Loops (`emit/loops.rs`, `emit/regions.rs`, `emit/trip.rs`, `lower.rs`) - **A helper lane of a pixel program is its own first lane.** The console runs a pixel program's helper lanes as lanes of EXEC (the program starts with `s_wqm`), so a waterfall loop over descriptors serves a helper lane in a pass of its own. The host's wave operations leave helper lanes out (SM 6.6) and give them undefined results. A helper lane whose value no other lane held never met it as the first lane. It went round the translated loop to the iteration limit, sampling each pass, and left with nothing computed, which its quad's derivatives then read. The character skin and cloth program (`94d281151ca58b4f`) samples its material layers in nine such nested loops. - A first-lane read in a pixel program now gives a helper lane its own value, and every heap handle of such a program is non-uniform. - Test: on the RTX 5090 the helper lane's count was 0 (never served) before and 1 now; WARP agrees. - `VICTORY_HELPER_OWN=0` turns it off, for an A/B on screen. - **A loop whose code fixes its count runs to its end, whatever the limit.** The limit is for loops whose end the data decides. A loop has a fixed count when its exit is a scalar counter that: - starts at a constant; - moves by a constant step each pass; - is compared with a constant, at its bottom, or at its top with a jump back. Such a loop now runs as often as the console's, up to 65,536 passes. The environment BRDF integration tables (`PS_IntegrateEnvBRDF` and its Beckmann and thin-film variants) integrate 1,024 samples a texel in six loops of 256 or 512 passes. At the pixel limit of 128, every one of the 65,536 texels of each table stopped at a half or a quarter of its samples (loop notes, opening cutscene). Every specular reflection reads those tables. - **A loop each lane leaves on its own is not code every lane runs.** Where two host waves run one console wave of 64 lanes, they exchange first lanes, masks and LDS order through group barriers, and only in blocks every lane runs. A waterfall loop in one block was taken for such code and got two host waves' exchange: four group barriers a pass, which lanes that had left met at other barriers. - In the projected-decal classification (`1f1fbd86759b3da2`), lanes then never met their descriptor and ran to the compute limit of 4,096 passes, losing their loads. - A loop that a lane branch leaves is now part of that branch's region. - Of the 1,085 compute programs seen in the title's runs, two translate differently. - **A loop closed by a jump leaves at its exit at the limit.** Such a loop has its exit test elsewhere in its body. At the limit, its jump back could only end the lane: a pixel discarded, a mesh or compute lane stopped before its writes. Its exit tests now take the limit too, so a lane at the limit leaves there and goes on with the program. A lane whose way round passes no exit test still ends. - **A vertex or mesh program with a root UAV declares UAVs at every stage** (ShaderFlags bit 16). With loop notes on, the validator refused 62 of 801 such programs of a run. - **Diagnostics.** - Loop limits per stage: pixel 128, vertex and mesh 256, compute 4,096, ray tracing 1,024, as before. `VICTORY_SHADER_LOOP_LIMIT` takes one number, or `stage:n` pairs. - `VICTORY_LOOP_NOTES=1`: each lane that reaches a loop's limit adds one to that loop's record in a root UAV of ours, and the log names the loops whose counts grew, every five seconds (`crate::loop_notes`). - The limits themselves stay. With them raised to 1,024 / 4,096 / 65,536, the notes named loops that never end, for example a cascade search that reads its count as 0, and a decal resolve's walk. ### Wave64 programs on 32-lane GPUs (`emit/split.rs`, `emit/guarded.rs`, `emit/forms.rs`) - **Allocation-only programs run as two host waves of their own** (`VICTORY_WAVE_SPLIT=0` turns it off). Some console wave64 programs use their wave-wide values only as the allocation idiom uses them: each wave's first lane reserves its count on a shared counter, and every lane takes the base plus its rank. Such a program is exact with each host wave on its own: the same records, reserved by each half in another order. Before, a program that the exchange form also translated took that form: two host waves meeting at two group barriers for each first-lane read, mask and sum. - `CS_Primary_RegisterAllocationRequests` (33 group barriers in 681 host instructions) took 3.7 ms of card time per dispatch in the opening cutscene, 2.8 ms a frame: the most of any wave64 program. - The idiom check now also follows a guarded write that reuses a register: a reader that cannot see the lanes outside the guard keeps the write's kind (`split::read_inside_only`). - Offline (CPU census, the same build with the switch off): 40 of the 160 exchange-form programs take the local form, and 5 of the 70 paired programs. No other program changes. The 5 paired ones go from 48,501 to 19,039 host instructions. - **The paired form reads a guarded write without its select where only lanes inside the guard read it** (`VICTORY_WAVE_RAW=0` turns it off). In the paired form every per-lane branch is the wave's, so a guarded write is `select(guard, new, old)`. That was about a sixth of the paired programs' host code, each select keeping the register's old value alive. A lane that reads the register under a guard that implies the writer's guard reads the computed value. This holds only for its own registers: a DPP source, lane read or write, swizzle or permute reads other lanes. Offline, only the 69 paired programs change: host instructions 2,303,768 -> 1,617,871 (-30 %), guard selects 360,668 -> 124,509. - **The census names the form** each console wave64 compute program takes on a 32-lane host (`form=` with `VICTORY_SHADER_CENSUS`). ### Dispatches of more than 65,535 groups in x run whole (`lower.rs`, `shader.rs`, `draw.rs`, `indirect.rs`) One host dispatch runs at most 65,535 groups in a dimension; the console runs more. The screen-probe final gather of the indirect diffuse light asks for up to 2 x 57,600 = 115,200 groups in x: one group per 8x8 tile of each of its two layers at 2560x1440. The clamp of indirect records cut such a record to 65,535, so the tiles past that point never ran. This showed as blocks along the bottom of the picture, and on a head lit by the window as a washed-out orange light with a vertical seam. - **Translator.** A compute program's group id in x adds a user-data dword the host computes, `USER_GROUP_BASE` (`RootType::Other(0x104)`). Programs with a spilled user-data table do not ask for it: their root signatures are close to the host's 64 dwords. - **Direct dispatches** of more than 65,535 groups in x run as several, each told its first group by a root constant. - **Indirect dispatches** of such programs are clamped as split dispatches, a kind of the clamp's own (`indirect::SPLIT_DISPATCH`): - each record becomes four records of the base and the counts, at most 65,535 groups in x each (262,140 in all); - they run through a command signature that sets the base and dispatches; - the records past a count buffer's count come out empty, and every record runs. - **Diagnostics.** A program whose indirect dispatch asks for more groups than run is named. In our tree, in the save's gameplay (the cell window, the same static view): before, about 0.8 records a frame were cut, blue and white blocks lined the bottom edge, and the hair took the washed-out light. After, 166 frame lines asked for more than 65,535 groups, none was cut, the bottom edge was clean and the hair was lit as the rest of the room. That tree clamped into a ring of the list's (not in `main`). Here the split is written onto `main`'s clamp program and scratch buffer: the same records and signature, tested on WARP. ## Switches | Switch | Default | Effect | |---|---|---| | `VICTORY_WAVE_SPLIT` | on | `=0`: allocation-only wave64 programs take the forms they took before | | `VICTORY_WAVE_RAW` | on | `=0`: the paired form selects every guarded write, as before | | `VICTORY_HELPER_OWN` | on | `=0`: helper lanes read the host wave's first lane, as before | | `VICTORY_MESH_LINK` | on | `=0` now also turns off the system-values-only form of oversized mesh programs drawn alone | | `VICTORY_SHADER_LOOP_LIMIT` | stage limits | one number for every stage, or `pixel:<n>,vertex:<n>,compute:<n>,trace:<n>` | | `VICTORY_LOOP_NOTES=1` | off | count the lanes that reach a loop's limit (a root UAV of ours in every program with a counted loop) | Every `VICTORY_*` switch the translator reads is part of the shader cache key. ## Tested The branch was checked as it is (its head merged with `main` already). The card was reserved for other work, so the tests ran on the software adapter: - `cargo test -p victory-shader -- --test-threads=1` with `VICTORY_WARP=1`: 259 passed, 5 failed, 2 ignored. The same five fail on #854's head merged with `main` (237 passed, 5 failed), all on the software adapter (WARP refuses the pipelines of the first four, E_INVALIDARG, and reads another lane count in the fifth): `ds_min_max_f32_order_floats_and_return_the_old_value`, `lds_subtractions_get_a_pipeline_and_stay_atomic`, `v_permlane16_and_x16_read_the_lanes_their_selectors_pick`, `whole_wave_f64_sum_and_cvt_f32_f64` and `a_lane_mask_joined_with_a_number_is_read_as_the_number_it_is`. Tests that need the card's 32-lane waves run on WARP here; they passed on the RTX 5090 when they went in. - `cargo test -p victory-gpu --features diagnostics -- --test-threads=1` with `VICTORY_D3D12_WARP=1`: 186 passed, 1 failed, 6 ignored. The failure, `depth_bounds_pipeline_loads_and_filters_draws`, fails the same way on #854's head merged with `main` (185 passed): WARP does not reject the pixels outside the depth bounds. - `cargo test -p victory`: 1 passed. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `cargo build --release -p victory`, `cargo build --profile diag -p victory --features diagnostics` and `cargo xtask policy` pass. New tests: - the geometry rings of a program of the console's form, the refusals, the prologue, the primitive id, and that program drawn between a pass-through vertex and pixel shader (WARP); - helper lanes in a waterfall (quad permute of a pixel's own count); - the fixed-count analysis (bottom and top tests, counts the data bounds), and a compute loop of 5,000 passes; - a waterfall's block is not every lane's, while a scalar loop around a lane branch still is; - a loop closed by a jump goes on at the limit; - a vertex program writing the notes' UAV validates; - the local form of an allocation that reuses its count register, with its counter and records against the console's; - raw reads of guarded writes in the paired form, against the console's 64 lanes; - a compute program's group id in x asks for the base, and in y it does not; - on WARP, a record of 100,000 groups runs each group from 0 to 99,999 once through the split records, and a record past the count runs none. Earlier, all of these changes ran in our tree on the RTX 5090, with our layer work: its general test (an opening cutscene run and gameplay runs from a save) had no device loss, no refused pipeline and no exception. ## Overlaps with open pull requests - **#834** splits indirect dispatches past 65,535 groups in x with a second execution, up to 131,070. It adds the same user-data word, under the same name and code (`USER_GROUP_BASE`, `RootType::Other(0x104)`), to the group id in x. Here one execution of split records runs up to 262,140 groups, and direct dispatches are split too. The translator parts are nearly the same; whichever goes in second keeps one. - **#646** uses the same code, `RootType::Other(0x104)`, for another word (`USER_DISPATCH_THREADS`). With both, one of the two needs another code. Our ray-tracing PR (stacked on this one) does thread counts with `0x105`. - **#895** keeps helper lanes out of first-lane reads with `IsHelperLane`, and adds quad reads. Here a helper lane reads its own value in a pixel program's first-lane reads. - **#832** (a divergent loop's re-entry into its branch's region) is close to "a loop each lane leaves on its own". - **#683** gives compute programs a loop limit of their own. Here every stage has its own limit, and fixed-count loops ignore the limits. - **#871** prunes the unread varyings of oversized mesh pairs; #854 links them. - **#592** and **#779** change which form wave64 programs take on 32-lane hosts in other ways. ## Not tested - A run of this exact branch in the title: the card was reserved. Earlier runs of our tree had these changes. - A draw with a geometry stage: no run has made one. The pipelines build on WARP. - GPUs with 64-lane waves (AMD), where the wave64 forms here are not taken; Intel; Linux/Proton.
`cargo clippy --workspace --all-targets -- -D warnings` (CI) fails on 9376fd6
with this toolchain: unnecessary_sort_by in draw.rs, the bench's
depth_written in indirect.rs never read, and placed_filler_twins unused
without the diagnostics feature. No code changes.
Over the title's shader pack (`victory translate --validate --pipelines`
on an RTX 5090, 32-lane waves), 25,682 of 25,953 programs translate,
validate and get a pipeline, against 25,452 on 9376fd6 (compute 2,729
against 2,695, mesh 8,694 against 8,657, pixel 12,067 against 11,947,
vertex 2,192 against 2,153). Of the 271 left, 195 are the unused voxel
geometry stages and 71 the mesh programs below, valid once linked.

- Wave64 compute programs on 32-lane hosts in a paired form: each console
  wave runs as one host wave, each thread two of its lanes (n and n + 32);
  every per-lane branch is taken by the whole wave with EXEC as each
  lane's guard, and lane reads, permutes, lane masks and reductions take
  both halves through the host wave's own operations. Tried after every
  other form for a program the host refuses (it asks for 64-lane waves)
  or that does not translate: 28 programs (screen-space tracing tiles,
  particles, decal trails, hair shadow masks, alpha resolve, three
  structure-builder programs, a cascade shadow program). Tried before the
  per-half forms that are approximate: 36 programs in which each half-wave
  counted, ORed or elected over its own 32 lanes now run as on the
  console. VICTORY_WAVE_PAIRS=0 turns it off. The allocation idiom also
  takes a base with a multiply-add (three lens-flare scans keep their
  per-half form, which is exact for them).
- Mesh programs whose outputs pass D3D12's 32 KiB as translated alone (71:
  pedestrian, vehicle and prop transforms, 65 to 71 components for 128
  vertices; NVIDIA builds them, the validator refuses them) are
  translated again with the pixel program of the pipeline
  (emit::link_mesh): the mesh program writes only what the pixel program
  reads, which declares only the inputs it reads. pipeline/host.rs makes
  such a pipeline from the linked pair (once per pair, same root signature
  and bindings; VICTORY_MESH_LINK=0 turns it off). `victory translate`
  with VICTORY_PAIRS links and validates pairs as the runtime does: 710
  pairs (each of the 71 with the ten pixel programs that read most of its
  outputs) link, validate and get a pipeline.
- One interpolation mode per signature register (70 programs: a float the
  console declared nointerpolation beside an integer or the front face);
  signature rows in the validator's order (72 programs); a level-of-detail
  query of an array texture leaves the layer undefined.
- An immediate sampler chosen by a uniform branch: the block is copied for
  each way in (ir::split_joins; the terrain programs).
- Pixel programs ordered by primitive (POPS) go past the console's wait and
  use rasterizer-ordered views (ten cut-out programs).
- A 16-bit write over a first interpolation half reads that half as zero
  (eight deferred and decal programs). The write of zero over every first
  half (v_interp_p1_f32, v_interp_p1ll_f16) is left out: with it, 59 pixel
  programs that translated came out changed and none more translated; the
  retry with first-half pairs stays.
- Whole-wave sections that a jump splits are joined into one block (the
  water optical depth program), tried first for a program whose permutes
  no followed section holds; elsewhere the v_permlane16/x16 lowering
  stands.
- 64-bit floats and their wave sums (five water volumetrics programs),
  one implementation of the two that existed (float64.rs): both dwords of
  a sum from one host wave operation (in place of Red64F/ActiveF64, which
  summed each dword on its own), v_add_f64, v_mul_f64, v_cvt_f64_f32, and
  the IEEE v_cvt_f32_f64 on integers. Its unused flush-to-zero twin and
  ignored test are left out.
- Descriptors read only for their size, one implementation of the two
  (descriptor_data.rs): a buffer with a used-resource entry gets the
  title's view, structured where its elements are whole dwords (a raw
  handle of such a view answered 2 records where it holds 9 on the RTX
  5090); VICTORY_DESC_WHY stays.
- A subtraction on group-shared memory (ds_sub, or ds_add of 0 - x) is a
  compare-exchange loop: NVIDIA's compiler refuses the pipeline otherwise
  (E_OUTOFMEMORY; DXC's own InterlockedAdd(g, -x) too). The weather
  particle update gets a pipeline.
- A lane mask parked in two VGPR lanes that also hold single scalars comes
  back as the mask (ir::with_shared_slots; the voxelization program).
- Loops of programs that test rays against tree nodes stop at 1,024
  iterations (the compute limit is 4,096): with the title's builder off, a
  walk follows whatever memory holds. Shadow mask 11.7 -> 2.4 ms a frame
  in timing runs of the opening of the gameplay.

The allocation-idiom check (idiom.rs), descriptors read as data
(descriptor_data.rs) and 64-bit floats (float64.rs) are modules of their
own, so that lower.rs stays under the asset policy's 512 KiB a file.

Tests: each new form is run on the card against what the console's 64
lanes give; the linked signatures, the LDS subtraction loop, the shared
slots, the joined sections and the descriptor sizes have tests of their
own.
The whole pack on an RTX 5090 (32-lane waves): 25,682 of 25,953 programs
translate, validate and get a pipeline, against 25,452 at 9376fd6. All 52
structure-builder programs translate (three in the paired form); switched
on in game runs, the builder crashed the title about 80 s into the
gameplay, so it stays off.
The shader tests' host can now bind a root UAV as a table of one raw view
(`Root::Uav`, and `Root::UavAlias` for a destination that is its source,
as the title rehydrates its structures in place) for a root signature from
`Host::compute_pipeline_bounded`, as the layer binds root UAVs: an access
past the buffer's end is dropped. An unbounded root UAV let random inputs
write past the buffers and remove the device. The views' contents come
back after the heap's UAVs, in the order of the roots.
The limits of translated loops were literals in count_iteration, and the
switch set one limit for every stage. Now they are named per stage
(pixel 128, vertex and mesh 256, compute 4,096, ray tracing 1,024, as
before) and the switch can set one stage alone (`stage:n` pairs) or all
(one number); the shader cache keys on all four. The documentation says
what a lane at the limit does: where the loop branches back on a
condition it leaves the loop and goes on; where it jumps back it leaves
the program (a pixel discards).
With the switch, every program with a counted loop gets a root UAV of
ours (u252, space 1) and each lane that reaches a loop's limit adds one
to that loop's record: the lanes that left the loop and went on, and the
lanes the limit took out of the program, by the loop's first code byte.
The host binds each program a range of one shared buffer of its own at
its first draw and logs the records that grew every five seconds, by
stage and hash. A helper lane of a pixel shader writes nothing, so it is
never counted. Off by default: it adds a root parameter to every
program with a loop. Part of the shader cache key.

First run, the opening cutscene from a new game (8 minutes, 254 programs
with counted loops drawn): only the three environment BRDF integration
programs reached a limit, all 65,536 texels of each table in each of
their six loops; no lane of any program was taken out.
The console runs a pixel program's helper lanes as lanes of EXEC (the
program starts with s_wqm), so a waterfall loop over descriptors serves a
helper lane in a pass of its own, with its own descriptor. The host's
wave operations leave helper lanes out (SM 6.6) and give them undefined
results: a helper lane whose value no other lane of its wave held never
met it as the first lane, went round the translated loop to the iteration
limit (with the loop's samples each pass) and left with what the loop
computes never set, which its quad's derivatives then read. The
character skin and cloth program (94d281151ca58b4f) samples its material
layers in nine such nested loops.

A first-lane read in a pixel program now gives a helper lane its own
value; since scalar code made of such a read may then differ in helper
lanes, every heap handle of such a program is created non-uniform.

Test: a waterfall over each pixel's own number, with the count of the
lane across the quad's x read through a quad permute. On the RTX 5090
the helper lane's count was 0 (never served) before, 1 now; WARP
agrees.
The iteration limit is for loops whose end the data decides (a count
read from memory the host has not got yet). A loop whose exit is a
scalar counter that starts at a constant, moves by a constant step each
pass and is compared with a constant (at its bottom, or at its top with
a jump back) runs as often as the console's, up to 65,536 passes: its
limit becomes its own count.

The title's environment BRDF integration tables (PS_IntegrateEnvBRDF,
the Beckmann and thin-film variants) integrate 1,024 samples a texel,
two or four a pass, in six loops of 256 or 512 passes. At the pixel
limit of 128 every one of the 65,536 texels of each table stopped at a
half or a quarter of its samples (loop notes, opening cutscene), and the
tables, which every specular reflection reads, held a half or a quarter
of their values. Translated now with limits of 256 and 512.

Tests: the count analysis on synthetic loops (bottom and top tests,
four adds a pass, counts the data bounds or that never meet their
constant), and a compute loop of 5,000 passes that runs past the
compute limit on the GPU and WARP.
Where two host waves run one console wave of 64 lanes, they exchange
first lanes, masks and LDS order through group barriers, only in blocks
every lane runs (`all_lane_blocks`): no per-lane branch's region, the
blocks a branch reaches that do not post-dominate it. A loop each lane
leaves on its own (its back edge or a break on the lane's own bit) has
blocks that post-dominate the branch, its own among them, yet only the
lanes that stayed run them again: a waterfall loop in one block was
taken for code every lane runs and got two host waves' exchange of the
first lane, four group barriers a pass, which lanes that had left met
at other barriers. In the projected-decal classification
(CS_ProjDecalReduceClassification_Scalarized, 1f1fbd86759b3da2) lanes
then never met their descriptor and ran to the compute limit of 4,096
passes: 77 lanes in each of five loops, 44, 19 and 1 in three more, in
seven minutes of the gameplay's opening (loop notes); those lanes lost
their loads. A loop a lane branch leaves is now part of that branch's
region (natural loops of the lane exits).

Of the 1,085 compute programs seen in the title's runs, two translate
differently: the decal classification takes each host wave on its own
(approximate: the tile's sums are each half's; the exact paired form is
tried after the approximate ones), and CS_SortRayTiles (a1bf269d5b19f025)
keeps its form with its LDS ordered by group barriers at the loop's
ends. Test: the waterfall's block is not every lane's, a scalar loop
around a lane branch still is.
lower.rs had grown past the asset policy's 512 KiB per file (533,966
bytes; `cargo xtask policy` refused it). The limits by stage, the count
and its test on back edges and the loop notes move to emit/loops.rs, the
regions of lane branches (blocks every lane runs, the natural loops they
leave) to emit/regions.rs, both child modules of the lowering. No change
in what is emitted; lower.rs is 520,593 bytes.
A loop that goes round by jumps back alone has its exit test elsewhere in
its body; at the limit its jump back could only end the lane (a pixel
discarded, a mesh or compute lane stopped before its writes). Its exit
tests now take the limit too, so a lane at the limit leaves there and
goes on with the program, as one does at a branch back; the jump back
still ends a lane whose way round passes no exit test.

With the limits raised to 1,024 / 4,096 / 65,536 (VICTORY_SHADER_LOOP_LIMIT,
loop notes) the opening cutscene lost the card again, 9 minutes in, and
the notes named loops of that kind that never end: PS_Textured_Eight
(b37565055f2f7d3b, 1af4a50c7fb40c97), whose search of its shadow
cascades reads its cascade count as 0 (the count minus one never stops
it), 10,441 pixels taken out at 1,024 (holes in what it draws); and the
projected-decal resolve's walk of its decal bits (c4183d3cbee28e8e, in
the approximate one-host-wave form), 10,381 lanes at 65,536. The limits
stay where they were; the comment records why.

The loop limit's helpers (`limit_of`, the exit test, the search for such
loops) live in emit/loops.rs. Tests: a loop closed by a jump goes on
with s6 at the limit; one whose way round skips its exit still ends the
lane.
With loop notes (VICTORY_LOOP_NOTES=1) every program with a counted loop
binds the notes as a root UAV. A vertex or mesh program that binds a UAV
must say so (ShaderFlags bit 16, SFI0 0x4); without it the validator
refused 62 of the 801 vertex and mesh programs of a game run translated
with notes ("Flags must match usage"); with it they all validate (but
the two whose outputs pass 32 KiB, as without notes). The runtime does
not validate, so the game ran them as they were.

Test: a vertex program writing the notes' UAV validates.
For an A/B of what the fix changes on screen: with the switch at 0, helper
lanes of pixel programs read the host wave's first lane in the title's
first-lane reads again, as before. On by default; part of the shader cache
key (the build script lists every VICTORY_ switch the translator reads).
The opening cutscene run with the limits raised to 1,024 / 4,096 / 65,536
did not lose the card to a long loop: Windows reset it 2.5 s after a
Parsec session ended (09:54:32 disconnect, 09:54:34 "Resetting TDR"), as
in the day's other losses. The limits stay where they are for the reason
the loop notes give: no loop needs more, and the ones that reach them
never end (PS_Textured_Eight's cascade search, the decal resolve).
The clamp of indirect records counts, per list, the compute records that
ask for more groups in x than one dispatch runs (up to 93,648 in the runs
of this morning, cut to 65,535: the rest never run), but not whose they
are. At recording, the arguments are now read where title memory has them
(the card writes them, so this is an earlier frame's copy-back), and the
first record over the limit of each program is logged with its counts.
One host dispatch runs at most 65,535 groups in a dimension; the console
runs more. The title's depth-of-field blur asks for up to 115,200 groups in
x every frame of a defocused shot (2 x 57,600: one group per 8x8 tile of
each of its two layers at 2560x1440; the clamp of indirect records counted
81,064 to 115,200 asked, 0.3 to 3.5 records a frame cut, in the opening's
first minutes), and the clamp cut the record to 65,535: the groups past it
never ran. The tiles of the second layer past that point stayed unblurred,
which shows as blocks: in the kitchen shot the blinds are blurred above a
row and, in that row, left of a column, sharp everywhere after it, the
shape of a tile list in reading order cut after its 65,535th tile.

- Translator: a compute program's group id in x adds a user-data dword the
  host computes, USER_GROUP_BASE (0x104), as the host's other words are
  given (not for programs with a spilled user-data table, whose root
  signature is close to the host's 64 dwords).
- Direct dispatches of more than 65,535 groups in x run as several, each
  told its first group by a root constant.
- Indirect dispatches of such programs are clamped as split dispatches (a
  kind of the clamp's own): each record becomes four records of the base
  and the counts, at most 65,535 groups in x each (up to 262,140 in all),
  run through a command signature that sets the base and dispatches; the
  records past a count buffer's count come out empty, and every one runs.

Tests: on the software adapter, a record of 100,000 groups runs each group
from 0 to 99,999 once and a record past the count runs none; the clamped
records and the budget charged are checked. A compute program reading its
group id in x asks for the base; one reading y does not. The 3,418 shaders
of this morning's runs translate with the change (warm-up, 94 s).
A split dispatch's command signature is cached by the address of the root
signature it was made for (with the root parameter and dword of the group
base). D3D12 does not say that a command signature holds a reference to
its root signature: with the root signature released and another made at
the same address, the cache would hand out a signature made for the first,
and ExecuteIndirect with a command signature of another root signature is
undefined. The cache now keeps the root signature alive with it, so an
address in the cache names one root signature for the whole run. Few root
signatures run split dispatches (the screen-probe final gather's and the
meshlet culling's in the general tests), so nothing much is kept.
A program that counts its groups from a base is named once (info) when
its indirect dispatch asks for more than 65,535 groups in x, and run as
several; one that asks for more than runs even so is still a warning.
It runs nothing whatever its x (one such record, 6,062,079 x 0 x 0, was
named in the opening run of the split dispatches).
With VICTORY_SHADER_CENSUS, `victory translate` now writes `form=` for each
console wave64 compute program translated for a host of 32-lane waves:
paired, local (each host wave on its own), local-any (approximate),
exchange (two host waves meeting at group barriers), halves (two host
waves with nothing to exchange) or wave64 (refused by such a host); empty
for every other program. The lowering names its form, and each program
emitted since the last `emit` is remembered by its DXIL, so the form of
the one `emit` returns is known whatever forms were tried before it.

On integration (9376fd6 merged), the title's wave64 compute programs:
69 paired, 30 local (all the allocation idiom, exact), 160 exchange,
141 halves, none refused.
In the paired form every per-lane branch is the wave's, so EXEC stays a
guard on each vector instruction and a guarded write is
select(guard, new, old): about a sixth of the paired programs' host code
(360,668 of 2,303,768 instructions in the title's 69 paired programs,
against 29,850 selects of that kind in all the other forms of the same
programs), each keeping the register's old value alive.

A lane that reads the register under a guard that implies the writer's
ran the write, so it now reads the value as computed: its own registers
only (not a DPP source, a lane read or write, a swizzle or permute, which
read other lanes), never the old value a write keeps for the lanes
outside its guard. The reader reads the writer's SSA value, so the
writer dominates it and no atom of the writer's guard is defined again in
between: both guards are evaluated on the same lane-mask atoms, and the
implication of the two functions (Bools::meet) holds lane by lane. The
selects nothing reads any more go with the clean-up's dead code.

Offline (CPU census, every program of the title): only the 69 paired
programs change; their host instructions 2,303,768 -> 1,617,871 (-30%),
guard selects 360,668 -> 124,509, joins 151,991 -> 122,297.
VICTORY_WAVE_RAW=0 turns it off. Test: values written and read under the
same guard, a narrower one in the block and in a nested branch, a wider
one after it and by every lane past the branch, floats and an
accumulator, against the console's 64 lanes.
A console wave64 compute program whose wave-wide values are used only as
the allocation idiom uses them (idiom::wave_local: each wave's first lane
reserves its count on a shared counter, every lane takes the base plus
its rank) is exact with each host wave on its own: the same records,
reserved by each half in another order. That form was only tried for
programs no form in two host waves took, so a program the exchange form
also translated took that one: two host waves meeting at two group
barriers for each first-lane read, mask and sum.
CS_Primary_RegisterAllocationRequests (33 group barriers in 681 host
instructions) took 3.7 ms of the card per dispatch in the opening
cutscene, 2.8 ms a frame, the most of any wave64 program; its
irradiance-cache twin 0.5 ms a frame. Where the exchange form translates
a program, the local form is now tried and kept if it translates
(split::local_if_exact).

The idiom check also took every guarded write as mixing the register's
old value (a wave count, say) into the lanes outside its EXEC, read or
not: the light-probe allocations reuse the register that held the count
for the first lane's lane number. Such a write now keeps its kind where
no reader can see those lanes (split::read_inside_only): followed through
the guarded writes that keep it and the joins that take it, every reader
of its own lane reads under a guard that lies, where it stands, inside
the guards written since the old value; a reader of other lanes and a
loop's join count as seeing them, a whole-wave section's select by its
mask, a first-lane read by its own guard (the idiom's shortcut for
first-lane reads).

Offline (CPU census of every program, the same build with the switch
off): 40 of the 160 exchange-form programs take the local form (both
allocation requests, the depth-of-field and trail-map tile
classifications, the depth pyramids, shadow-mask denoises, ray-bin
offsets, the screen-space ray pre-passes, water patch culling, among
them), and 5 of the 70 paired programs (the four temporal resolves that
count frame statistics, and lens_flares CS_ScanMip0, the idiom with a
multiply-add as its three siblings); no other program changes. Their host
instructions: the 5 paired ones 48,501 -> 19,039. VICTORY_WAVE_SPLIT=0 turns both
off. Diagnostics builds: VICTORY_WAVE_PAIRED_OVER_EXCHANGE=1 gives the
remaining exchange-form programs the paired form, to time the two in a
run. Test: an allocation that reuses its count register as the light-probe
requests do takes the local form; on the card its counter and records
against the console's (the paired form's also in the console's order).
The 71 mesh programs whose outputs pass D3D12's 32 KiB as translated
alone (128 vertices of 65 to 71 components) were linked with the pixel
program of their pipeline (link_mesh), but a pipeline without one, as
the title makes for depth (14,576 binds of 143 mesh programs alone in
the runs so far), got the invalid translation as it is. link_mesh_alone
translates such a program again without its outputs of arbitrary
semantics, which only a pixel program reads: position, clip and cull
distances stay, and it fits. The runtime makes those pipelines with it;
the offline census, whose stub pixel program reads nothing, checks that
form of the 71 (all 71 validate and get a pipeline, RTX 5090) and counts
them on its mesh line. None of the 71 was drawn alone in the runs so far:
the two drawn (72da0ba1efaec1e0, 8a621a22094767f3) came with pixel
programs and linked.
The census's 195 geometry programs (all GS_VoxelizeGeneric variants) stopped
at resource tracking: their first load reads the console driver's table that
user data 0 and 1 point at. The console runs such a program in one hardware
stage after the ES half of its vertex program: it reads its triangle's
vertices from LDS at the offsets v0 and v1 hold (16 bits each), writes the
vertices it emits to its lane's slot of the GS-VS ring, also in LDS, and
sends a GS message for each emit and cut. The stage data gives the ring's
layout (vertex count and dwords per vertex, four per register of the output
signature; StageIo::Gs).

The host runs the ES half as the vertex program it is (the container's VS
program, the other compilation of the same HLSL) and the program as a
geometry shader of one invocation per primitive (crate::geometry,
emit/rings.rs): the address of each LDS access is followed to the input
vertex and dword it reads, or the emitted vertex and dword it writes; a
ring read is that input's loadInput, a ring write is kept as that vertex's
output, and the n-th emit stores vertex n's outputs and emits it. The load
from the driver's table only places the ring (resource::DRIVER: its value
is never needed). The prologue that narrows EXEC to the wave's GS threads
keeps every lane (NativeProgram::patched_code). The primitive id (v2) is
the host's; an invocation id (v3, instancing), vertices 4 and 5
(adjacency), another stream or emits in branches are refused.

Offline (32-lane host) all 195 translate and validate (the census's new
geometry line), the DXIL of every other program unchanged; their pipelines
between a stub vertex and pixel shader build on the WARP device (the
card's are left to the general test session). Tests: the rings of a program
of the console's form written for them, the refusals, the prologue, the
primitive id, and that program drawn between a pass-through vertex and
pixel shader (every texel as it writes it; passed on WARP). No run so far
drew with a geometry stage.
A pipeline whose stream has a geometry shader was refused ("only vertex,
mesh, pixel and compute stages are translated") and its draws dropped. Its
geometry program now translates (the commit before): the host pipeline is
the vertex program, the pixel program and the geometry program between
them, its user data and views bound per stage as the others' (stage last,
so the pixel stage keeps its place; no rectangle stage beside it, and none
in a mesh pipeline). Its library entry has a name of its own. The translated
geometry stage brings its used-resource entries like the other stages.

shortcut: not run in the title yet: none of the runs so far (opening
cutscene, gameplay from the user's save) drew with a geometry stage.
Four lines in the summary: the 195 geometry programs run as host geometry
shaders (no run has drawn with one), oversized mesh programs drawn without
a pixel program keep their system values, and the CPU census (25,948 of
25,953 translate and validate; the rest: five ray-trace programs); the
loop fixes; the two wave64 forms; the split of dispatches past 65,535
groups in x. VICTORY_WAVE_SPLIT and VICTORY_WAVE_RAW in the table of
switches, VICTORY_MESH_LINK's alone form, and geometry stages out of what
the shaders lack.
No conflict. Upstream's loads of four dwords a call (VICTORY_SHADER_OPT
bit 64, not in the default) merge into emit/lower.rs, emit/mod.rs and
emit/bitcode/opt.rs beside this branch's forms; lower.rs is 504,469
bytes of the policy's 524,288. The rest of upstream's commits is in
files this branch does not change, but for README.md (additions side by
side) and three lint lines in draw.rs, indirect.rs and resource.rs.
`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c4 with the pinned toolchain (1.98.1), after the two fixes before
this one too: map_entry in fpsbox.rs, collapsible_if in
pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and
with --all-features in draw.rs and watch.rs (twice). No change of
behaviour.
No conflict. Read through where both sides changed the same code:
- indirect.rs: the clamp's source now has upstream's gathered records
  (bit 2 of has_count: a record's place read from a table) and this
  branch's split dispatch (kind 3). Only a windowed draw's record is
  gathered, never a dispatch's, so the two do not meet.
- draw.rs: execute_indirect ends the list's gathering for a dispatch
  before the split clamp, and a direct dispatch split past 65,535 groups
  ends it on entry.
- emit/lower.rs, emit/mod.rs, emit/bitcode/opt.rs: upstream's loads of
  four dwords a call (VICTORY_SHADER_OPT bit 64, not in the default)
  beside this branch's forms; lower.rs is 511,375 bytes of the policy's
  524,288.
- host.rs, shadow.rs, lib.rs, README.md: additions side by side.
`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c4 with the pinned toolchain (1.98.1), after the two fixes before
this one too: map_entry in fpsbox.rs, collapsible_if in
pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and
with --all-features in draw.rs and watch.rs (twice). No change of
behaviour.
The test lowered the program for 64-lane waves only and returned when the
device refused the pipeline, so on a GPU of 32-lane waves it passed with
nothing run on the card (review of #854). It now asks the device how wide its
waves are (D3D12_OPTIONS1) before choosing the form: the console's own 64
lanes where they fit, the paired form on waves of 32, nothing on narrower
waves (the software adapter's 4). The pipeline and the dispatch are then made
on that same device, and a refusal fails the test.

On an RTX 5090 (32-lane waves) the paired form gives the console's tree bit
for bit with 64, 63, 40, 33, 32, 17, 5 and 1 lanes left.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:22 +00:00
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 22:11 UTC · original

Merged main (c36971b) into the branch: a merge commit on top of the commits already here (f2d66cb), then one lint commit. No conflict. The branch still holds #854's head as it was.

Merged without a conflict, and read through where both sides changed the same code:

  • indirect.rs: the clamp's shader now has main's gathered records (a record's place read from a table) and this branch's split dispatch (kind 3). Only a windowed draw's record is gathered, never a dispatch's, so the two do not meet. The tests of both pass.
  • draw.rs: execute_indirect ends the list's gathering for a dispatch before the split clamp, and a direct dispatch split past 65,535 groups ends it on entry.
  • The translator: main's loads of four dwords a call (VICTORY_SHADER_OPT bit 64, not in the default) sit beside this branch's forms. main's new paths are taken only with the bit on, and its test of them passes here. emit/lower.rs is 511,375 bytes of the policy's 524,288.

Added after the merge: one lint commit for main's newer code, the same as on our other open branches: map_entry in fpsbox.rs, collapsible_if in pipeline/library.rs, manual_is_multiple_of in queue.rs, shadow.rs, draw.rs and watch.rs. Without it cargo clippy --workspace --all-targets --locked -- -D warnings fails on c36971b, with or without --all-features.

Checked, the branch as it is (5a6f243), every test on the software adapter:

  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo xtask policy, cargo build --release -p victory and cargo build --profile diag -p victory --features diagnostics: pass.
  • cargo test -p victory-shader -- --test-threads=1 with VICTORY_WARP=1: 260 passed, 5 failed, 2 ignored. The five are the ones the description names; four of them fail on main alone on the software adapter (212 passed, 4 failed, 3 ignored), and the fifth is #854's LDS subtraction test. The one test more than before is main's new one.
  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1 with VICTORY_D3D12_WARP=1: 201 passed, 1 failed, 6 ignored. The failure is depth_bounds_pipeline_loads_and_filters_draws, as on main (200 passed, 1 failed, 6 ignored).
  • cargo test -p victory-hle -- --test-threads=1: 100 + 1 passed, as on main.
  • cargo test -p victory -p victory-loader: passed.
  • The offline census of the description, on the merged release build (victory translate --validate --list, VICTORY_HOST_MAX_WAVE=32, CPU only, no pipelines): 25,948 of 25,953 programs translate and validate. Its list is the same, program for program, as the one taken before the merge: the one line that differs is the example it quotes for the five that fail.
**@⁠PiloteCode** on GitHub · 2026-11-25 22:11 UTC · [original](https://github.com/fxceless/victory-fork/pull/993#issuecomment-7176055375) Merged `main` (`c36971b`) into the branch: a merge commit on top of the commits already here (`f2d66cb`), then one lint commit. No conflict. The branch still holds #854's head as it was. **Merged without a conflict, and read through** where both sides changed the same code: - `indirect.rs`: the clamp's shader now has `main`'s gathered records (a record's place read from a table) and this branch's split dispatch (kind 3). Only a windowed draw's record is gathered, never a dispatch's, so the two do not meet. The tests of both pass. - `draw.rs`: `execute_indirect` ends the list's gathering for a dispatch before the split clamp, and a direct dispatch split past 65,535 groups ends it on entry. - The translator: `main`'s loads of four dwords a call (`VICTORY_SHADER_OPT` bit 64, not in the default) sit beside this branch's forms. `main`'s new paths are taken only with the bit on, and its test of them passes here. `emit/lower.rs` is 511,375 bytes of the policy's 524,288. **Added after the merge:** one lint commit for `main`'s newer code, the same as on our other open branches: `map_entry` in `fpsbox.rs`, `collapsible_if` in `pipeline/library.rs`, `manual_is_multiple_of` in `queue.rs`, `shadow.rs`, `draw.rs` and `watch.rs`. Without it `cargo clippy --workspace --all-targets --locked -- -D warnings` fails on `c36971b`, with or without `--all-features`. **Checked**, the branch as it is (`5a6f243`), every test on the software adapter: - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `cargo xtask policy`, `cargo build --release -p victory` and `cargo build --profile diag -p victory --features diagnostics`: pass. - `cargo test -p victory-shader -- --test-threads=1` with `VICTORY_WARP=1`: 260 passed, 5 failed, 2 ignored. The five are the ones the description names; four of them fail on `main` alone on the software adapter (212 passed, 4 failed, 3 ignored), and the fifth is #854's LDS subtraction test. The one test more than before is `main`'s new one. - `cargo test -p victory-gpu --features diagnostics -- --test-threads=1` with `VICTORY_D3D12_WARP=1`: 201 passed, 1 failed, 6 ignored. The failure is `depth_bounds_pipeline_loads_and_filters_draws`, as on `main` (200 passed, 1 failed, 6 ignored). - `cargo test -p victory-hle -- --test-threads=1`: 100 + 1 passed, as on `main`. - `cargo test -p victory -p victory-loader`: passed. - The offline census of the description, on the merged release build (`victory translate --validate --list`, `VICTORY_HOST_MAX_WAVE=32`, CPU only, no pipelines): 25,948 of 25,953 programs translate and validate. Its list is the same, program for program, as the one taken before the merge: the one line that differs is the example it quotes for the five that fail.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/fpsbox.rs
  • crates/victory-gpu/src/indirect.rs
  • crates/victory-gpu/src/pipeline.rs
  • crates/victory-gpu/src/pipeline/library.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/mod.rs
  • crates/victory-shader/src/emit/shader.rs
  • crates/victory-shader/src/emit/wave64_tests.rs
  • crates/victory-shader/src/ir.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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