Preserve guest-wave shader state and reclaim idle host memory under pressure #479

Open
github-bot wants to merge 33 commits from github-bot/gh-479 into main AGit
Owner

@⁠JoeY54 on GitHub · 2026-11-27 23:14 UTC · original
JoeY54:fix/shader-memory-correctness → main · +800 −61 · 12 files · 4 commits · open

Standalone first-lane reads, inactive WRITELANE destinations and loop-carried masks can produce incorrect synthetic readbacks. After a submission spike, idle host lists and fetch buffers also retain peak capacity under memory pressure. This adds guest-wave state corrections and pressure-only reclamation with synthetic regression coverage.

Integrated upstream main 64d4931b3dd90305134512b805fc98f04119fb6e; latest tested source b2a3dabad7daf0e7ba3943a0ace2515e487c25dd.

Existing prerequisites, original authors retained: #108; #112 including #111; #116 including #70; #71; #73; #425. Several were closed without merging; that is not represented as author approval. Most of the aggregate diff is their oracle/benchmark and prerequisite work. The report pins every head and separates our new commits. Newly landed upstream allocator/prelude and shader changes are retained; the pressure path reuses upstream's idle-age helper. No competing CI implementation is introduced.

New work preserves guest-wave first-lane reads, single-wave divergent state, inactive WRITELANE updates and mask phis through uniform loops. Under pressure it retires old GPU-complete lists while retaining recent lists and a warm reserve, and shrinks oversized fetch buffers between completed copy/merge operations after a two-second cooldown. VICTORY_IDLE_RECLAIM=0 is a diagnostic opt-out. Branch-state helpers are extracted to satisfy the existing source-size policy.

Current validation: Windows 11, RTX 5090 / driver 621.24, Rust 1.98.1; original synthetic fixtures and serial/exclusive GPU tests.

  • Full default workspace: 1095 passed, 0 failed, 52 ignored, including 300 shader tests; nested child results excluded from totals.
  • Both Clippy configurations passed after integration; final helper extraction also passes all-targets/all-features Clippy. Asset policy: 294 files pass.
  • Unfiltered oracle on the integrated implementation: 1199 semantic comparisons match, 1 ambiguous equal-input SCC case not checked; no differences/refusals in these two seeds.
  • Relay/synchronous strict pressure and two-burst complete readbacks pass. Idle lists fall from 68 to19 and64 to16, and fetch buffers from32 to16 MiB. This is not an FPS claim or a return-to-warm-footprint claim.
  • The final all-features workspace run was cancelled at the owner's request to reduce cost. It is not claimed as complete. Further optional queued compatibility checks were cancelled. Historical earlier-revision results are separated in the report.

Sanitized report with exact revisions, commands, controls and limitations.

Strict joins, legacy denormal expectations, unsupported instructions and broader multi-wave behavior retain the documented limitations. The newly landed optional allocator-trimming switch has not had a separate completed compatibility run. No real-game validation, new binary/table data, private management history or raw machine logs are included.

AI-assisted by OpenAI Codex; submitted by JoeY54.

**@⁠JoeY54** on GitHub · 2026-11-27 23:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/479) `JoeY54:fix/shader-memory-correctness` → `main` · +800 −61 · 12 files · 4 commits · open Standalone first-lane reads, inactive WRITELANE destinations and loop-carried masks can produce incorrect synthetic readbacks. After a submission spike, idle host lists and fetch buffers also retain peak capacity under memory pressure. This adds guest-wave state corrections and pressure-only reclamation with synthetic regression coverage. Integrated upstream main `64d4931b3dd90305134512b805fc98f04119fb6e`; latest tested source `b2a3dabad7daf0e7ba3943a0ace2515e487c25dd`. **Existing prerequisites, original authors retained:** #108; #112 including #111; #116 including #70; #71; #73; #425. Several were closed without merging; that is not represented as author approval. Most of the aggregate diff is their oracle/benchmark and prerequisite work. The report pins every head and separates our new commits. Newly landed upstream allocator/prelude and shader changes are retained; the pressure path reuses upstream's idle-age helper. No competing CI implementation is introduced. New work preserves guest-wave first-lane reads, single-wave divergent state, inactive WRITELANE updates and mask phis through uniform loops. Under pressure it retires old GPU-complete lists while retaining recent lists and a warm reserve, and shrinks oversized fetch buffers between completed copy/merge operations after a two-second cooldown. `VICTORY_IDLE_RECLAIM=0` is a diagnostic opt-out. Branch-state helpers are extracted to satisfy the existing source-size policy. **Current validation:** Windows 11, RTX 5090 / driver 621.24, Rust 1.98.1; original synthetic fixtures and serial/exclusive GPU tests. - Full default workspace: **1095 passed, 0 failed, 52 ignored**, including 300 shader tests; nested child results excluded from totals. - Both Clippy configurations passed after integration; final helper extraction also passes all-targets/all-features Clippy. Asset policy: **294 files pass**. - Unfiltered oracle on the integrated implementation: **1199 semantic comparisons match**, 1 ambiguous equal-input SCC case not checked; no differences/refusals in these two seeds. - Relay/synchronous strict pressure and two-burst complete readbacks pass. Idle lists fall from 68 to19 and64 to16, and fetch buffers from32 to16 MiB. This is not an FPS claim or a return-to-warm-footprint claim. - **The final all-features workspace run was cancelled at the owner's request to reduce cost. It is not claimed as complete.** Further optional queued compatibility checks were cancelled. Historical earlier-revision results are separated in the report. [Sanitized report with exact revisions, commands, controls and limitations](https://github.com/JoeY54/VIctory-NVIDIA-contrib/blob/7ecdb53697695d7d3f008e2bbd725842a1cc159f/docs/shader-memory-validation.md). Strict joins, legacy denormal expectations, unsupported instructions and broader multi-wave behavior retain the documented limitations. The newly landed optional allocator-trimming switch has not had a separate completed compatibility run. No real-game validation, new binary/table data, private management history or raw machine logs are included. AI-assisted by OpenAI Codex; submitted by JoeY54.
s_min_{i,u}32 and s_max_{i,u}32 set SCC when S0 is chosen (S0 < S1 for min,
S0 > S1 for max). The lowering returned no SCC, so the generic D != 0 was
used: s_cselect or s_cbranch_scc after a min/max took the wrong side
whenever the result was nonzero but S1 was chosen (or zero with S0 chosen).
Marvisak/VIctory's lowering already does this.

v_readlane_b32 and v_writelane_b32 take the lane from S1[4:0] (wave32) or
S1[5:0] (wave64). A select past the wave read 0 or wrote no lane here; it
now wraps as on the console. Lanes that are host lanes (pixel/vertex
programs with a computed lane) are unchanged.

Both were found by differential testing of the translator against an
independent RDNA2 interpreter on the GPU.

Ported from avatarmanz/VIctory-7900XTX#404. No version bump here: the shader cache is keyed by the build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
v_readlane_b32 / v_writelane_b32 with a constant lane: ir::build and unspill now see
the lane modulo the wave (S1[4:0] in wave32, S1[5:0] in wave64), so the spill tracker
takes lanes 36 and 4 of a wave32 program for the one slot they are on the console.
The lowering already wrapped the lane; unspill, which runs before it, did not.

Found by UwUCammie in the review of #404, and done the same way in
jtrudeau1530/VIctory-7900XTX#38. Test: ir::tests::
a_constant_lane_past_the_wave_is_its_lane_modulo_the_wave (wave32 aliases, wave64
does not; it fails without the change).

Ported from avatarmanz/VIctory-7900XTX#404.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Random compute programs (integer VALU and SALU arithmetic, lane compares,
lane-divergent if/else under EXEC, uniform ifs and loops on SCC, cross-lane
reads and writes) are encoded to GFX10 machine code, translated by the
production path (spill::build, structure, resource::track, io::raise,
emit_with_retries), run on the host GPU and compared lane by lane with an
interpreter that shares nothing with the translator (not the decoder, the
IR or the lowering). The encoder is checked against the decoder's
instruction names, so a mismatch means the translation, not the encoding.
Failing programs are minimized and printed as a listing.

Wave64 runs on a host of 32-lane waves (TEST_HOST_WAVE), once with exact
translations only (VICTORY_WAVE_LOCAL=idiom) and once as the default.

Default tests: the encoder round trip and the interpreter on known cases
(no GPU needed). The fuzzer is #[ignore]d:
  cargo test -p victory-shader --lib oracle -- --ignored --nocapture --test-threads=1
with VICTORY_ORACLE_RUNS (200), VICTORY_ORACLE_SEED (1), VICTORY_ORACLE_OUT
(report file) and VICTORY_ORACLE_AVOID (leave out known bug classes).
Without an SM 6.6 hardware device it skips.

Ported from avatarmanz/VIctory-7900XTX#403.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On the console a wave runs both sides of a lane-divergent branch once, with
EXEC narrowed; an SGPR (or SCC) written inside is one value for the whole
wave afterwards. Lowered as per-lane control flow, the write only happens on
the lanes that took the branch, so after the join the "scalar" differs per
lane (lanes that skipped the branch keep the old value). Example:

  v_cmp_gt_u32 vcc, s0, v3 ; s_and_saveexec ... ; s_mov_b32 s27, s19 ;
  s_or_b32 exec ... ; (read s27 in every lane)

lower::scalar_splits finds the lane branches whose region writes a scalar
that a block after the join reads with different values on the paths
(following s_mov copies), and emit() takes exactly those branches
wave-wide through the existing widen() (structure_wide), as the console
does. Everything else keeps its per-lane form. widen() takes those
branches as a seed and adds any that structure_wide's result still has.

Compute programs only. A console wave64 on a host of 32-lane waves needs
group barriers for this, so there it applies only with VICTORY_WAVE_WIDE=1
(as widen() already did). VICTORY_SCALAR_SPLITS=0 turns it off; it is part of the shader cache key
(victory-gpu shader_cache.rs) like the other switches that pick a form.
VICTORY_WAVE_WIDE is read through lower::wave_wide_on(), which tests can
turn on per thread instead of changing the environment.

Test: oracle_scalars_written_in_lane_branches_reach_every_lane, 9 shapes
(then/else/both write, a copy of an older scalar, nested, SCC, readfirstlane
and readlane in the branch, a branch in a uniform loop), for all, some and
no lanes on the thread id and on a hash, masks as data or not, wave32 and
wave64. It fails at 26 places without the change. It needs an SM 6.6
hardware device and skips otherwise.

Not tested in the game: how often such shaders occur and what changes on
screen is unknown.

Here widen() also takes `scalar_splits`: the first probe passes true, the
fallbacks lower::scalar_splits_on(), so VICTORY_SCALAR_SPLITS=0 reaches every caller
(the review fix of #405; test widen_takes_scalar_splits_only_when_asked). This fork's
widen() keeps its own parameters (active-lane loops, groups of several console waves).

Ported from avatarmanz/VIctory-7900XTX#405. No version bump here: the shader cache is keyed by the build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ignored tests memory_bench_steady_state and memory_bench_pressure_lets_idle_go: lists, copies,
submissions, fences and windows through the title-facing methods, with title memory from a
write-watched VirtualAlloc allocator; per-class bytes from the existing counters and private
bytes, flat over 240 frames; idle memory let go when little RAM is said to be free.

A port of the bench made for avatarmanz/VIctory-7900XTX. Here the free RAM said for the test
(host::FREE_RAM_SAID) also reaches crate::residency, whose pressure is on by default on this
fork; the bench reads the process's memory itself (copystat is diagnostics-only here);
pool::memory joins shadow::memory/windows and texture::memory/let_go under
cfg(any(test, feature = "diagnostics")); list::with_state is pub(crate).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A host list kept every scratch chunk it took until its reset, and a list that has run is reset
only after the bury lag (16 submissions on a PC of 32 GB or less, 64 above). In the relay mode
the launcher sets (VICTORY_RELAY=2) the memory bench, at only 8 lists a frame, had 42 landed
lists holding 130.5 MB of 4 MiB chunks.

At landing, after its read-backs and next to release_tables(), a list now hands its chunks to
the spare pool (HostList::release_scratch). The card has read them for the last time. Chunks
the pool does not take stay with the list and are freed at its reset as before, so nothing is
freed earlier than it was. Only with shared chunks (VICTORY_SCRATCH_POOL); off with
VICTORY_SCRATCH_AT_LANDING=0.

Memory bench, RTX 4070 Ti, same build, switch off/on, VICTORY_RELAY=2 VICTORY_RELAY_COPY=1:
- private bytes 591.3 -> 466.6 MB
- scratch of landed lists 130.5 -> 0 MB
- upload bytes made 184.2 -> 62.8 MB
- without the relay unchanged (387 MB)

The steady-state test now asserts that landed lists keep no scratch. A port of the change
made for avatarmanz/VIctory-7900XTX.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A console wave64 compute program that runs as two host waves of 32
("halves") numbers its lanes through console_thread (thread_id does).
console_lane and lane_bit still read the host lane index unless
exchange is set. A 64-bit mask read as a number, such as a select on
an SGPR pair, then gave lanes 32-63 the bits of the low dword: their
host lane is 0-31, so the test `lane < 32` always picked the low dword.

Use the console lane in both places when halves is set, as exchange
already does.
On RDNA2 a compare (v_cmp_* writing VCC, or an SGPR pair in VOP3 form)
that runs while EXEC is narrowed writes 0 into the result bits of the
lanes EXEC leaves out. The console's wave runs a lane-divergent
branch's region when any lane needs it, so after the join every lane
sees the region's mask: its own bit is 0 where it skipped, and read as
data the mask is the region's number. The per-lane lowering joined the
mask lane by lane: a lane that skipped the region kept its old mask, as
its bit (v_cndmask) and as the number (s_mov/v_mov of vcc_lo, built per
incoming edge). Found by the RDNA2 oracle (class 5). A port of the fix
made for avatarmanz/VIctory-7900XTX.

- lower.rs: CompareJoins::skipped finds a join that mixes a compare's
  mask written in a per-lane branch's region (also through joins inside
  the region) with the old mask the branch's other lanes bring past it.
  In compute programs, when such a join is read, the lowering names the
  region's blocks and stops with LANE_MASK. A join counts as read as
  lane bits, unless every lane that skipped brings 0 already, or as
  data, also through a join it is made of. emit()'s existing LANE_MASK
  retry (widen, structure_wide; widen's own rounds as well) then takes
  those branches wave-wide, as the console does. Active lanes and
  v_cmpx's EXEC are unchanged.
- mod.rs: where the branches cannot be taken wave-wide, the program is
  lowered again with these joins per lane (with_per_lane_compare_joins),
  as before.
- A console wave64 on 32-lane host waves needs group barriers for
  wave-wide branches: there only with VICTORY_WAVE_WIDE=1, read through
  lower::wave_wide_on(), which a test turns on for its own thread
  (THREAD_WAVE_WIDE; the same code as in #73). VICTORY_WAVE_WIDE=0
  turns it off. Not in the local-wave forms. The default wave-wide form
  of the listed scene kernels is left as it was.
- In a form with wave-wide branches, the joins a read SGPR join is made
  of are read too. Otherwise a mask joined twice is the zero of the
  VICTORY_STRICT_JOINS shortcut. The per-lane form is unchanged.
- No version bump: the shader cache is keyed by the translator's
  sources.

Tests (RTX 4070 Ti, wave64 as two 32-lane host waves):
- oracle_compares_in_lane_branches_zero_the_lanes_left_out: a compare
  in then, in else, in a nested branch, in a uniform loop in the branch
  and in a branch in a uniform loop. VCC is read inside the branch and
  after the join through v_cndmask and as data (s_mov). Each shape runs
  for all/some/no lanes, on the thread id and on a hash, with masks as
  data or not, in wave32 and wave64 (140 cases). 42 differ without the
  change (all five shapes); none with it. 7 wave32 cases of the nested
  shape with masks as data are refused before and after (a lane mask
  holding lanes elsewhere read as data where not every lane runs: this
  fork has no retry that lowers it as a number); the test counts that
  refusal and fails on any other. In wave64 the shape passes.
- cargo test -p victory-shader: 291 passed, 0 failed. clippy
  --all-targets -D warnings, also with --all-features.
- oracle_fuzz, 300 programs per wave size, programs that differ before
  -> after (seed 2, seed 4):
  wave32: 122 -> 104, 98 -> 91 (the same with VICTORY_WAVE_WIDE=1)
  wave64 default: unchanged (exact/default 69/83, 70/93)
  wave64 VICTORY_WAVE_WIDE=1: 92 -> 84, 100 -> 85
  other known classes left out (VICTORY_ORACLE_AVOID=salu_in_branch,
  minmax_scc,lane_range,writelane_inactive): wave32 33 -> 2, 21 -> 3;
  wave64 with VICTORY_WAVE_WIDE=1 15 -> 3, 14 -> 2. Those last ten
  match the oracle with VICTORY_STRICT_JOINS=1.
  No program differs that did not before, no differing program gained
  a register, and the refusals are the same.

Not tested: in the game, AMD hardware, the cost of the wave-wide
branches. Carry-outs and SALU writes of a mask in a lane branch are not
covered. Wave64 on 32-lane hosts without VICTORY_WAVE_WIDE=1 keeps the
per-lane form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI on main stopped at its first step (clippy, 40+ findings), so the
diagnostics clippy and the tests never ran. Locally all three steps of
.github/workflows/ci.yml now pass.

Tests: two indirect budget tests still assumed VICTORY_INDIRECT_REST on,
which 545f890 turned off by default.
- host_list_budget_starts_empty_at_each_submission: the big records now
  fill the budget exactly, so the small record after them runs empty with
  REST on or off and the test still shows that no budget carries over.
- warp_batch_charges_every_execution: the expected spend follows the REST
  rule in force (a job that does not fit takes nothing without REST).
Both pass with VICTORY_INDIRECT_REST unset and =1.

Clippy:
- mechanical: is_multiple_of, shift precedence, sort_by_key with Reverse,
  hex digit groups, contains_key, annotated transmutes, mem::take,
  from_ref, a same-type cast, an if with identical branches;
- host/indirects.rs and placed_filler_twins are only used by the
  diagnostics build and are only compiled there;
- removed the never-used `batched` in make_from and the never-read
  depth_written field; Touch::Title is only built by tests, marked so;
- book.rs: the heap that keeps the descriptor alive is a named field;
- ResourceDesc::from_level(&self) renamed levels_from;
- allowed with a reason: two 8-argument functions, the Late enum (boxing
  a flight would allocate per flight) and the CLI Command enum;
- apps/victory: default_paths moved above the test module; the match on
  a block in play.rs binds the block first.

No change in what the game runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
AI-assisted-by: OpenAI Codex
AI-assisted-by: OpenAI Codex
AI-assisted-by: OpenAI Codex
AI-assisted-by: OpenAI Codex
AI-assisted-by: OpenAI Codex
Include readfirstlane in cross-half detection. Select exact scalar and compare-join lowering for a single complete guest-wave group while keeping multi-wave groups opt-in. Widen branches containing writelane and bypass its EXEC destination guard. Add synthetic oracle regressions for all three cases.

AI-assisted-by: OpenAI Codex
AI-assisted-by: OpenAI Codex
Six loop-mask cases reproduce the pre-fix failure. Preserve waterfall lowering and groups fitting one host wave. Full shader suite: 299 passed, 0 failed, 5 ignored; unfiltered seed 2 now matches.

AI-assisted-by: OpenAI Codex
Retain recent lists and a warm reserve. Resize fetch buffers only between completed copy/merge operations, with a two-second capacity cooldown and VICTORY_IDLE_RECLAIM=0 diagnostic opt-out. Add a two-burst byte-readback regression that forces reallocation.

AI-assisted-by: OpenAI Codex
The reclamation regression must reset the cached pressure state between rounds and inspect fetch capacity before later steady frames can retire it. Keep the forced-growth and complete byte comparisons.

AI-assisted-by: OpenAI Codex
Record pinned prerequisites, distinct test revisions, 1074 default and1127 all-feature passes, unfiltered oracle results and matched reclamation controls. No private logs or binary data.

AI-assisted-by: OpenAI Codex
Merge64d4931; retain upstream age-based list trimming and allocator/prelude reuse alongside pressure-only reclamation. Preserve loop-branch, LDS, compare and scalar-branch lowering. Pushed before revalidation at owner request; previous report results are explicitly limited to prior revisions.

AI-assisted-by: OpenAI Codex
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 23:17:41 +00:00
Keep pressure-only warm reserve and trim accounting. Two upstream64 modulo checks use equivalent is_multiple_of expressions. Full merged-tree validation remains pending.

AI-assisted-by: OpenAI Codex
Move compare-join and scalar-split helpers unchanged apart from module visibility. All-feature workspace Clippy and asset policy pass after upstream integration.

AI-assisted-by: OpenAI Codex
Default workspace1095 passed,0 failed,52 ignored. Preserve exact historical revisions; do not claim the cancelled all-feature matrix or optional compatibility queue completed.

AI-assisted-by: OpenAI Codex
Merge upstream main 8fc22547c8 into the
shader/memory branch. The only conflict was in crates/victory-shader/src/ir.rs,
where this branch (6f4813c) and upstream (a12e0ae) each add one test right
after build_words(); both tests are kept unchanged. The non-test code merges
as is: lane_wrapped_fields() and unspill's 256-entry scalar table both stay.

Upstream already carries #108 (c1d8179) and #425 (9b712a6) with the same
changes as this branch's 245cb85 and 7331b07, so those merge as no-ops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main (8fc2254) fails both Clippy steps. victory-hle's gameinput uses
Some(vk).filter(|_| i < scripted_keys) (clippy::some_filter, from e68f48a);
it is now (i < scripted_keys).then_some(vk), the same value since vk has no
side effects. A victory-shader test helper bound its result to `l` only to
return it (clippy::let_and_return, from feb90ad); it now returns the
expression. main's third finding, shadow.rs `turns % 16 == 0`, is already
`is_multiple_of` on this branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠JoeY54 on GitHub · 2026-11-28 03:37 UTC · original

Merged current main (8fc2254) into this branch as 82ae878, so the PR merges cleanly again. Also fixed the two Clippy lints main's own CI stops on, in a7b233d.

  • One conflict, in crates/victory-shader/src/ir.rs. This branch (6f4813c) and main (a12e0ae) each added a test at the same spot after build_words(). Both tests are kept as they were, and the non-test changes merge unchanged: lane_wrapped_fields() and the 256-entry used table in unspill.

  • main already contains #108 (c1d8179) and #425 (9b712a6), with the same changes as this branch's 245cb85 and 7331b07. Those merge to nothing, so the remaining diff against main is this PR's own work plus the two lint fixes below: 16 files, +3830/−32.

  • One interaction to point out: main's new emit() retry without the loop step now wraps this PR's scalar-split logic, which runs inside emit_once(). Some wave64 compute loop programs may translate on the first try and never reach the retry.

  • main's CI is red at 8fc2254, in its Clippy step. --keep-going shows two lints, both from recent main commits: clippy::some_filter in victory-hle gameinput.rs (from e68f48a), now (i < scripted_keys).then_some(vk), which is the same value because vk has no side effects; and clippy::let_and_return in a victory-shader test helper (from feb90ad). main's third finding, the shadow.rs turns % 16, was already is_multiple_of on this branch.

Checks on a7b233d (RTX 5090, Windows, toolchain 1.98.1):

  • cargo clippy --workspace --all-targets --locked -- -D warnings: pass
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass
  • cargo test --workspace --locked -- --test-threads=1: 1133 passed, 0 failed, 53 ignored. victory-shader alone: 303 passed, 6 ignored. The nested HLE child run is not counted.

Not rerun: the all-features test suite, the ignored oracle fuzzing and memory-bench runs, and the D3D12 debug layer.

AI-assisted (Claude Code).

**@⁠JoeY54** on GitHub · 2026-11-28 03:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/479#issuecomment-7233225260) Merged current `main` (`8fc2254`) into this branch as `82ae878`, so the PR merges cleanly again. Also fixed the two Clippy lints `main`'s own CI stops on, in `a7b233d`. - One conflict, in `crates/victory-shader/src/ir.rs`. This branch (`6f4813c`) and `main` (`a12e0ae`) each added a test at the same spot after `build_words()`. Both tests are kept as they were, and the non-test changes merge unchanged: `lane_wrapped_fields()` and the 256-entry `used` table in `unspill`. - `main` already contains #108 (`c1d8179`) and #425 (`9b712a6`), with the same changes as this branch's `245cb85` and `7331b07`. Those merge to nothing, so the remaining diff against `main` is this PR's own work plus the two lint fixes below: 16 files, +3830/−32. - One interaction to point out: `main`'s new `emit()` retry without the loop step now wraps this PR's scalar-split logic, which runs inside `emit_once()`. Some wave64 compute loop programs may translate on the first try and never reach the retry. - `main`'s CI is red at `8fc2254`, in its Clippy step. `--keep-going` shows two lints, both from recent `main` commits: `clippy::some_filter` in `victory-hle` `gameinput.rs` (from `e68f48a`), now `(i < scripted_keys).then_some(vk)`, which is the same value because `vk` has no side effects; and `clippy::let_and_return` in a `victory-shader` test helper (from `feb90ad`). `main`'s third finding, the `shadow.rs` `turns % 16`, was already `is_multiple_of` on this branch. Checks on `a7b233d` (RTX 5090, Windows, toolchain 1.98.1): - `cargo clippy --workspace --all-targets --locked -- -D warnings`: pass - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: pass - `cargo test --workspace --locked -- --test-threads=1`: 1133 passed, 0 failed, 53 ignored. `victory-shader` alone: 303 passed, 6 ignored. The nested HLE child run is not counted. Not rerun: the all-features test suite, the ignored oracle fuzzing and memory-bench runs, and the D3D12 debug layer. AI-assisted (Claude Code).
Conflicts resolved by keeping both sides:
- host.rs: idle reclaim (trim_idle) and main's trim_spare_uploads, both
  under the pressure branch.
- shader_cache.rs: VICTORY_SCALAR_SPLITS and main's
  VICTORY_WATER_VOLUME_PORTALS both in the cache key.
- emit/mod.rs: main's defrag (with_half_meets) around widen, with this
  branch's scalar-splits argument.
- wave64_tests.rs: main's new widen call gets the scalar-splits argument
  (None, as before the switch).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict resolved: main moved the shader cache key's switches into the
KEYED list; VICTORY_SCALAR_SPLITS, which this branch adds, is in it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main's every_switch_of_the_translator_is_in_the_key reads the switches
from the translator's sources; this branch's differential fuzzer
(oracle_tests.rs) reads VICTORY_ORACLE_RUNS, _SEED, _AVOID and _OUT, which
only steer the test. They go with the other test switches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
53867f6 narrowed the rule that made every v_readfirstlane_b32 need the
console's wave size to groups over 32 threads. main has since dropped
v_readfirstlane_b32 from that rule altogether: on a host of 32-lane waves
its halves lowering gives each host half the console wave's first lane
(lane 0 of the lower half when every lane runs, an exchange otherwise).
With this branch merged, the narrowed rule put it back for groups over 32,
and wave64 compute programs with shared memory and a group barrier in a
per-lane branch needed 64 lanes again: on a 32-lane host they no longer
translated ("no wave32 lowering for this wave64 program") and their draws
were dropped. Eight such programs of a title's character passes are
translated again, to the same DXIL as main's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts:
- shader_cache.rs: main's new keyed switch and this branch's
  VICTORY_SCALAR_SPLITS are both in KEYED (34 names).
- lower.rs: main and this branch fixed the min/max SCC (whether S0 was
  chosen) the same way; main's form is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit acb18301a5. The oracle
(oracle_standalone_firstlane_uses_the_whole_guest_wave) shows main's
lowering without it gives the upper host half its own first lane: the
rule is needed for correctness. The next commit keeps it and handles the
programs it would leave untranslated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A first-lane read in a group over 32 threads needs the console's whole
wave (53867f6; main's lowering gives the upper host half its own first
lane otherwise, see oracle_standalone_firstlane_uses_the_whole_guest_wave).
On a host of 32-lane waves that keeps some wave64 compute programs at 64
lanes, where shared memory and a group barrier in a branch a lane takes on
its own leave no form: "no wave32 lowering for this wave64 program", and
their draws are dropped (eight programs of a title's character passes,
whose characters then drew without bodies).

emit_once's last fallback for such a refused program now translates it
once more with first-lane reads per host wave (with_first_lane_per_host_wave),
after the wave-wide form and the LDS last resort. Only programs that would
otherwise be dropped change; a first-lane read keeps the whole console
wave wherever that translates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-29 08:27 UTC · original

A note on this one: an earlier version was merged for v2026.11.29.01 and then taken back out before the release. Together with other pull requests merged at the same time, its shader-translator changes (compares in lane branches, scalars across lane-divergent branches, lane wrapping) made trees and foliage flicker and vanish in play; the same build with the translator from before this PR did not. The revert is a1fe8350 on main. Nothing is wrong with the PR on its own (it was clean alone), so it stays open and we will bring it back once the interaction is understood. Thank you for the work.

**@⁠trustno1-coder** on GitHub · 2026-11-29 08:27 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/479#issuecomment-7253120116) A note on this one: an earlier version was merged for v2026.11.29.01 and then taken back out before the release. Together with other pull requests merged at the same time, its shader-translator changes (compares in lane branches, scalars across lane-divergent branches, lane wrapping) made trees and foliage flicker and vanish in play; the same build with the translator from before this PR did not. The revert is a1fe8350 on main. Nothing is wrong with the PR on its own (it was clean alone), so it stays open and we will bring it back once the interaction is understood. Thank you for the work.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/host/membench.rs
  • crates/victory-gpu/src/list.rs
  • crates/victory-gpu/src/residency.rs
  • crates/victory-gpu/src/shader_cache.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/mod.rs
  • crates/victory-shader/src/emit/wave64_tests.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/479/head:github-bot/gh-479'
git switch 'github-bot/gh-479'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-479'
git switch 'github-bot/gh-479'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-479'
git switch 'github-bot/gh-479'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-479'
git switch 'main'
git merge --squash 'github-bot/gh-479'
git switch 'main'
git merge --ff-only 'github-bot/gh-479'
git switch 'main'
git merge 'github-bot/gh-479'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!479
No description provided.