Shaders: support multi-way and nested immediate sampler phis #3117

Open
github-bot wants to merge 1 commit from github-bot/gh-3117 into main AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 08:43 UTC · original
fuzeofficlal:feat/shader-multi-way-nested-sampler-phi → main · +607 −135 · 5 files · 1 commits · open

Summary

  • Generalize immediate sampler Source::Phi lowering in crates/victory-shader/src/emit/lower.rs beyond flat two-way [Constant, Constant] pairs to arbitrary multi-way and nested Source::Phi graphs, with cycle protection (active visited set), never_taken edge handling, and comparison-mode (cmp_samplers) preservation.
  • Plan the selector tree before mutating self.samplers or emitting IR so mixed (non-constant) Source::Phi graphs fall back cleanly to the existing heap-index path without side effects.
  • Collapse single unique sampler targets directly to that static sampler handle (zero selector phi); for 2+ unique samplers, emit an i32 selector phi and dispatch via generalized Shader::sampler_choices, Module::chosen, and Module::select_indexed (preserving per-field extract selection on dx.types.ResRet.f32).
  • Add synthetic GPU + WARP end-to-end tests in crates/victory-shader/src/emit/stride_tests.rs covering a 3-way flat immediate sampler phi and a nested immediate sampler phi exercising both regular and comparison sampling.

Verification

  • cargo test -p victory-shader --locked -- sampler --test-threads=1 (RTX 5090 hardware + WARP): 11 passed, 0 failed.
  • VICTORY_WARP=1 cargo test -p victory-shader --locked -- sampler --test-threads=1: 11 passed, 0 failed.
  • cargo test -p victory-shader --locked -- emit::lower::: 33 passed, 0 failed.
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean.
  • cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: clean.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 08:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/3117) `fuzeofficlal:feat/shader-multi-way-nested-sampler-phi` → `main` · +607 −135 · 5 files · 1 commits · open ## Summary - Generalize immediate sampler `Source::Phi` lowering in `crates/victory-shader/src/emit/lower.rs` beyond flat two-way `[Constant, Constant]` pairs to arbitrary multi-way and nested `Source::Phi` graphs, with cycle protection (`active` visited set), `never_taken` edge handling, and comparison-mode (`cmp_samplers`) preservation. - Plan the selector tree before mutating `self.samplers` or emitting IR so mixed (non-constant) `Source::Phi` graphs fall back cleanly to the existing heap-index path without side effects. - Collapse single unique sampler targets directly to that static sampler handle (zero selector phi); for 2+ unique samplers, emit an `i32` selector phi and dispatch via generalized `Shader::sampler_choices`, `Module::chosen`, and `Module::select_indexed` (preserving per-field `extract` selection on `dx.types.ResRet.f32`). - Add synthetic GPU + WARP end-to-end tests in `crates/victory-shader/src/emit/stride_tests.rs` covering a 3-way flat immediate sampler phi and a nested immediate sampler phi exercising both regular and comparison sampling. ## Verification - `cargo test -p victory-shader --locked -- sampler --test-threads=1` (RTX 5090 hardware + WARP): 11 passed, 0 failed. - `VICTORY_WARP=1 cargo test -p victory-shader --locked -- sampler --test-threads=1`: 11 passed, 0 failed. - `cargo test -p victory-shader --locked -- emit::lower::`: 33 passed, 0 failed. - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: clean. - `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings`: clean. - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:46:36 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 08:50 UTC · original · approved these changes

Verified on RTX 5090 & WARP against origin/main (63bcca4):

  • cargo test -p victory-shader --lib emit::stride_tests:: -- --test-threads=1:
    • All 3 sampler-phi tests (a_flat_sampler_phi_selects_among_three_static_samplers, a_nested_sampler_phi_selects_regular_and_comparison_samplers, a_sampler_chosen_by_a_uniform_branch_samples_as_chosen) passed on both RTX 5090 and WARP.
    • 10/10 passed under VICTORY_WARP=1; on RTX 5090, the only 2 failures (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros) reproduce identically on clean origin/main.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly generalizes immediate sampler phis to multi-way and nested phis across both regular and comparison samplers.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 08:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/3117#pullrequestreview-6070973658) · **approved these changes** Verified on RTX 5090 & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib emit::stride_tests:: -- --test-threads=1`: - All 3 sampler-phi tests (`a_flat_sampler_phi_selects_among_three_static_samplers`, `a_nested_sampler_phi_selects_regular_and_comparison_samplers`, `a_sampler_chosen_by_a_uniform_branch_samples_as_chosen`) passed on both RTX 5090 and WARP. - 10/10 passed under `VICTORY_WARP=1`; on RTX 5090, the only 2 failures (`a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`) reproduce identically on clean `origin/main`. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly generalizes immediate sampler phis to multi-way and nested phis across both regular and comparison samplers. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3117'
git switch 'github-bot/gh-3117'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3117'
git switch 'github-bot/gh-3117'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3117'
git switch 'main'
git merge --squash 'github-bot/gh-3117'
git switch 'main'
git merge --ff-only 'github-bot/gh-3117'
git switch 'main'
git merge 'github-bot/gh-3117'
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/Marvisak--VIctory!3117
No description provided.