Shaders: compute selects and carry-ins on a lane mask held as data (F… #1787

Closed
WhiteDragonul wants to merge 1 commit from upstream-pr/1788 into main
WhiteDragonul commented 2026-11-24 22:38:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by WhiteDragonul on 2026-11-24T22:38:19Z.


…IND-6)

v_cndmask_b32 and the v_add/sub_co_ci carry-ins took their mask only from what structurisation recorded, so a mask the program holds as a number (a root constant, the result of scalar arithmetic) stopped the program with "a select on an untracked mask" or "a carry-in from an untracked mask". In compute, where lane n is console lane n, the lane now tests its own bit of the dwords the instruction reads (both in wave64); such a select fixes the console's wave size like other masks read as numbers. Pixel, vertex and mesh programs still refuse it.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6592819926 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1788). Originally posted by [WhiteDragonul](https://github.com/WhiteDragonul) on 2026-11-24T22:38:19Z. --- …IND-6) v_cndmask_b32 and the v_add/sub_co_ci carry-ins took their mask only from what structurisation recorded, so a mask the program holds as a number (a root constant, the result of scalar arithmetic) stopped the program with "a select on an untracked mask" or "a carry-in from an untracked mask". In compute, where lane n is console lane n, the lane now tests its own bit of the dwords the instruction reads (both in wave64); such a select fixes the console's wave size like other masks read as numbers. Pixel, vertex and mesh programs still refuse it.
catminou4 commented 2026-11-24 23:05:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:04:15Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae), cargo test -p victory-shader --locked → 120 passed, 0 failed. GPU execution tests (valu_tests/host) are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.

Selects and carry-ins computed on a lane mask held as data (FP… path): selects_on_a_number + select_mask + mask_data_layout/numeric_mask_select — mask-as-data layout mirrors the earlier mask work (#1407/#1420). +2 tests.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048809821 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1788#pullrequestreview-6048809821). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:04:15Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae), cargo test -p victory-shader --locked → 120 passed, 0 failed. GPU execution tests (valu_tests/host) are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests. Selects and carry-ins computed on a lane mask held as data (FP… path): selects_on_a_number + select_mask + mask_data_layout/numeric_mask_select — mask-as-data layout mirrors the earlier mask work (#1407/#1420). +2 tests.
upipibi commented 2026-11-24 23:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T22:39:13Z.


A case this leaves refused, from reading the diff (not run). select_mask handles Operand::Scalar: SGPR masks, and null as all-false. An inline-constant mask (0 = 128, -1 = 193, the other integers 129-208) is a separate Operand variant in gfx10/fields.rs, so it still returns untracked. XCL's per-lane form had the same gap for v_cndmask_b32 and the _co_ci carry-ins with inline 0 / -1 / null masks; xcl-dev/xcl#1864 fixes it there. A constant is the same mask in every lane, so its bit per lane needs no console-lane condition: bit n of the sign-extended 64-bit value, so -1 is all lanes and 0 none.

AI-assisted (Claude Code). No game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146486225 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1788#issuecomment-7146486225). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T22:39:13Z. --- A case this leaves refused, from reading the diff (not run). `select_mask` handles `Operand::Scalar`: SGPR masks, and `null` as all-false. An inline-constant mask (`0` = 128, `-1` = 193, the other integers 129-208) is a separate `Operand` variant in `gfx10/fields.rs`, so it still returns `untracked`. XCL's per-lane form had the same gap for `v_cndmask_b32` and the `_co_ci` carry-ins with inline `0` / `-1` / `null` masks; xcl-dev/xcl#1864 fixes it there. A constant is the same mask in every lane, so its bit per lane needs no console-lane condition: bit n of the sign-extended 64-bit value, so `-1` is all lanes and `0` none. AI-assisted (Claude Code). No game files.
upipibi commented 2026-11-24 23:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T22:41:13Z.


On NVIDIA: RTX 3070 8 GB, driver 616.56, Windows 11, debug, ae6e932 (on main 70564ae).

  • compute_selects_on_a_lane_mask_held_as_data and compute_carries_in_from_a_lane_mask_held_as_data: pass, 2 of 2 runs.
  • cargo test -p victory-shader --locked: 208 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA heap-cap failures on main (a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, a_heap_buffer_read_by_element_takes_the_views_stride, gathers_at_a_level_match_the_hardware), not this PR.

AI-assisted (Claude Code). Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146525202 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1788#issuecomment-7146525202). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T22:41:13Z. --- On NVIDIA: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `ae6e932` (on `main` `70564ae`). - `compute_selects_on_a_lane_mask_held_as_data` and `compute_carries_in_from_a_lane_mask_held_as_data`: pass, 2 of 2 runs. - `cargo test -p victory-shader --locked`: 208 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA heap-cap failures on `main` (`a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `a_heap_buffer_read_by_element_takes_the_views_stride`, `gathers_at_a_level_match_the_hardware`), not this PR. AI-assisted (Claude Code). Synthetic tests only.
DesertGamer commented 2026-11-24 23:06:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-24T22:55:59Z.


VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146814427 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1788#issuecomment-7146814427). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-24T22:55:59Z. --- ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
upstream-sync closed this pull request 2026-11-25 00:06:03 +00:00
rminzao commented 2026-11-25 00:06:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rminzao on 2026-11-24T23:09:14Z.


wave64: a mask whose hi dword was rewritten still picks up the old compare

select_mask looks the mask up by its lo dword alone (self.x.st.masks.get(&lo)). In wave64, a sequence like

v_cmp_*        s[2:3], ...
s_mov_b32      s3, 0
v_cndmask_b32  v0, v1, v2, s[2:3]

still finds the compare's mask, so lanes 32-63 use the compare's bits instead of 0 and pick the wrong source. Structurisation files the mixed (lo, new hi) pair under other, not masks.

StructureState::mask_bits(lo, Some(hi)) (structure.rs:404) already does the exact-pair lookup. Using it here (and in selects_on_a_number) would send a mismatched pair down the new numeric path, which is correct in compute. The lookup by lo alone predates this PR, but the doc comment ("a scalar operation may have written either alone") suggests this PR means to cover it.

The new tests only check that lowering succeeds and wave_ops is set, not which dword or bit a lane reads, so a swapped lo/hi or a lane >= 32 would still pass.

Static review (AI-assisted), read against main at 70564ae; nothing was run on a GPU.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147074596 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1788#issuecomment-7147074596). Originally posted by [rminzao](https://github.com/rminzao) on 2026-11-24T23:09:14Z. --- **wave64: a mask whose hi dword was rewritten still picks up the old compare** `select_mask` looks the mask up by its lo dword alone (`self.x.st.masks.get(&lo)`). In wave64, a sequence like ``` v_cmp_* s[2:3], ... s_mov_b32 s3, 0 v_cndmask_b32 v0, v1, v2, s[2:3] ``` still finds the compare's mask, so lanes 32-63 use the compare's bits instead of 0 and pick the wrong source. Structurisation files the mixed (lo, new hi) pair under `other`, not `masks`. `StructureState::mask_bits(lo, Some(hi))` (`structure.rs:404`) already does the exact-pair lookup. Using it here (and in `selects_on_a_number`) would send a mismatched pair down the new numeric path, which is correct in compute. The lookup by lo alone predates this PR, but the doc comment ("a scalar operation may have written either alone") suggests this PR means to cover it. The new tests only check that lowering succeeds and `wave_ops` is set, not which dword or bit a lane reads, so a swapped lo/hi or a lane >= 32 would still pass. _Static review (AI-assisted), read against `main` at 70564ae; nothing was run on a GPU._

Pull request closed

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
Marvisak/VIctory!1787
No description provided.