fix(shader): keep killed pixel lanes in quad and fix wave32 lanes on Wave64 hosts #412

Merged
Androtim merged 1 commit from upstream-pr/412 into main 2026-12-04 00:42:40 +00:00
Androtim commented 2026-12-03 23:45:40 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T23:45:40Z.


Summary

Fixes AMD RDNA 3/4 stippled/disappearing alpha-tested foliage, tree trunks, and per-pixel dither banding on 64-lane host waves:

  1. Per-lane kill-continue demote (VICTORY_KILL_CONTINUE, default on; =0 to disable)

    • In victory-shader, pixel-shader lane branches whose one side ends in a quiet null-export kill block (exp null ... done + s_endpgm) with EXEC provably cleared (Some(Bool::FALSE)) now emit dx.op.discard(kill) and branch unconditionally to the live continuation block instead of exiting early (discard + ret).
    • Requires guards[to][i] == Some(Bool::FALSE) on done Target::Null exports in Lower::kill_end and guards live_ok against !kill_end(b, live) in Lower::exit so live depth-only / Z-prepass / UAV-only exp null done exits are never misclassified as kill blocks.
    • Preserves console s_wqm whole-quad helper-lane semantics so subsequent 2x2 quad swizzles and derivatives read valid computed values rather than undefined registers.
    • Adds VICTORY_KILL_CONTINUE to TRANSLATOR_ENV_KEYS in victory-gpu/src/shader_cache.rs so the shader cache keys on it.
    • Ported from lobomfz/VIctory-xmem (SPDX GPL-3.0, PR #195, commit 837007cfcfc602866f6bb06852f9408c1dc9ce89, merge f7bc339d8a6d7de8b148c20727e622cbc80c0bb0).
  2. Wave32 pixel/vertex lane indices and wide ballots on 64-lane host waves

    • Keeps v_mbcnt_lo lane indices in 0..31 (and makes v_mbcnt_hi a no-op) for wave32 pixel/vertex programs running in 64-lane host waves so per-pixel dither patterns do not saturate at 32 in the upper half of the wave.
    • Promotes s_bcnt1_i32_b32, s_ff1_i32_b32, s_cmp_eq_u32, s_cmp_lg_u32, and ballot-backed v_mbcnt to inspect both dwords of the 64-lane host ballot.
    • Ported from lobomfz/VIctory-xmem (SPDX GPL-3.0, PR #344, commits e5243e48bfeca53a017e276749c1febd56eddc5a and f0fc9905ca1562e3d925a0b6978d1a280110c056, merge 1152b9c24898c87f3274e888582ad5ddbf27d112).
  3. ReBAR VRAM reservation check

    • Verified shadow::card_room_kept() in victory-gpu is already free of the +2.56 GiB phantom ReBAR reservation addressed in ReTerryDavis/ReVIctory (SPDX GPL-3.0, commit 631b2ed4f2c3e41b7115198913c857a9310389c7).

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader -- kill depth_only wave32 (12 passed, including a_killed_pixel_stays_in_its_quad, depth_only_live_null_exit_is_not_discarded, depth_only_alpha_test_inverted_compare_discards_only_killed_lanes, and wave32_pixel_lane_number_and_wide_ballot)
  • cargo +1.98.1-x86_64-pc-windows-gnu check --workspace (clean)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5637150234 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/412). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T23:45:40Z. --- ## Summary Fixes AMD RDNA 3/4 stippled/disappearing alpha-tested foliage, tree trunks, and per-pixel dither banding on 64-lane host waves: 1. **Per-lane kill-continue demote (`VICTORY_KILL_CONTINUE`, default on; `=0` to disable)** - In `victory-shader`, pixel-shader lane branches whose one side ends in a quiet null-export kill block (`exp null ... done` + `s_endpgm`) with `EXEC` provably cleared (`Some(Bool::FALSE)`) now emit `dx.op.discard(kill)` and branch unconditionally to the live continuation block instead of exiting early (`discard` + `ret`). - Requires `guards[to][i] == Some(Bool::FALSE)` on `done` `Target::Null` exports in `Lower::kill_end` and guards `live_ok` against `!kill_end(b, live)` in `Lower::exit` so live depth-only / Z-prepass / UAV-only `exp null done` exits are never misclassified as kill blocks. - Preserves console `s_wqm` whole-quad helper-lane semantics so subsequent 2x2 quad swizzles and derivatives read valid computed values rather than undefined registers. - Adds `VICTORY_KILL_CONTINUE` to `TRANSLATOR_ENV_KEYS` in `victory-gpu/src/shader_cache.rs` so the shader cache keys on it. - Ported from `lobomfz/VIctory-xmem` (SPDX GPL-3.0, PR #195, commit `837007cfcfc602866f6bb06852f9408c1dc9ce89`, merge `f7bc339d8a6d7de8b148c20727e622cbc80c0bb0`). 2. **Wave32 pixel/vertex lane indices and wide ballots on 64-lane host waves** - Keeps `v_mbcnt_lo` lane indices in `0..31` (and makes `v_mbcnt_hi` a no-op) for wave32 pixel/vertex programs running in 64-lane host waves so per-pixel dither patterns do not saturate at 32 in the upper half of the wave. - Promotes `s_bcnt1_i32_b32`, `s_ff1_i32_b32`, `s_cmp_eq_u32`, `s_cmp_lg_u32`, and ballot-backed `v_mbcnt` to inspect both dwords of the 64-lane host ballot. - Ported from `lobomfz/VIctory-xmem` (SPDX GPL-3.0, PR #344, commits `e5243e48bfeca53a017e276749c1febd56eddc5a` and `f0fc9905ca1562e3d925a0b6978d1a280110c056`, merge `1152b9c24898c87f3274e888582ad5ddbf27d112`). 3. **ReBAR VRAM reservation check** - Verified `shadow::card_room_kept()` in `victory-gpu` is already free of the +2.56 GiB phantom ReBAR reservation addressed in `ReTerryDavis/ReVIctory` (SPDX GPL-3.0, commit `631b2ed4f2c3e41b7115198913c857a9310389c7`). ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader -- kill depth_only wave32` (12 passed, including `a_killed_pixel_stays_in_its_quad`, `depth_only_live_null_exit_is_not_discarded`, `depth_only_alpha_test_inverted_compare_discards_only_killed_lanes`, and `wave32_pixel_lane_number_and_wide_ballot`) - `cargo +1.98.1-x86_64-pc-windows-gnu check --workspace` (clean)
Androtim commented 2026-12-04 00:02:24 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T00:02:24Z.


Triage (e9c87557, CI check PASS):

  • Clean, 100% title-neutral 2-part AMD RDNA 3/4 Wave64 shader fix (+529/-24, 3 files, zero opt-in toggles — VICTORY_KILL_CONTINUE is default-on with =0 kill-switch; ports lobomfz/VIctory-xmem #195 & #344).
  • Cache invalidation note for Gate 2 (#282): TRANSLATOR_ENV_KEYS adds VICTORY_KILL_CONTINUE (which is unset by default), so existing SHADER_CACHE_VERSION = 3 disk caches on AMD GPUs will NOT automatically re-translate previously cached pixel/vertex shaders unless SHADER_CACHE_VERSION is also bumped (3 -> 4) or the default key signature changes.
  • Holding auto-merge for Gate 2 Audit (#282) + Gate 3 cold-cache GPU verification (plain---release A/B + --features diagnostics foliage/tree/dither PNGs).
<!-- greyfinch-sync:Androtim/MiniVI:comment:7396296691 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/412#issuecomment-7396296691). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-04T00:02:24Z. --- Triage (`e9c87557`, **CI `check` PASS**): - Clean, 100% title-neutral 2-part AMD RDNA 3/4 Wave64 shader fix (`+529/-24`, 3 files, **zero opt-in toggles** — `VICTORY_KILL_CONTINUE` is default-on with `=0` kill-switch; ports `lobomfz/VIctory-xmem` `#195` & `#344`). - **Cache invalidation note for Gate 2 (`#282`):** `TRANSLATOR_ENV_KEYS` adds `VICTORY_KILL_CONTINUE` (which is unset by default), so existing `SHADER_CACHE_VERSION = 3` disk caches on AMD GPUs will NOT automatically re-translate previously cached pixel/vertex shaders unless `SHADER_CACHE_VERSION` is also bumped (`3 -> 4`) or the default key signature changes. - Holding auto-merge for **Gate 2 Audit (`#282`)** + **Gate 3 cold-cache GPU verification** (plain-`--release` A/B + `--features diagnostics` foliage/tree/dither PNGs).
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Androtim/MiniVI!412
No description provided.