Shaders: a uniform branch can choose between two immediate samplers (40 programs) #1096

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

@⁠m335671 on GitHub · 2026-11-25 19:22 UTC · original
m335671:port/sampler-choice → main · +70 −5 · 1 files · 1 commits · open

What

On current main, 40 programs fail translation with emit: a descriptor chosen by control flow. In each of them, a uniform branch picks one of two immediate (constant) samplers before an image sample. This ports DexNom's fix from DexNom/VIctory ddb7332 (GPL-3.0, the lower.rs part only):

  • When the sampler is a phi of two constants, the sample is taken with both static samplers and the original derivatives.
  • The result from the edge that supplied the console's sampler is kept, through a phi on the join block.
  • If one side has no host block, the other sampler is used directly.
  • image now takes the sampler and calls image_with_sampler; everything else is unchanged.

The commit also carries DexNom's unit test, a_uniform_branch_can_choose_between_immediate_samplers.

Testing

RTX 4070 12 GB (32-lane waves), driver 32.0.16.2124, Windows 11 Pro 26300.

Offline, VICTORY_HOST_MAX_WAVE=32 victory translate --list --pipelines over the title's whole shader pack, compared program by program by hash:

pipelines created a descriptor chosen by control flow
main d510ee4 25,608 40
this PR 25,648 0
  • All 40 now translate and the driver creates their pipelines. No program that main creates is lost, and no other failure count changes.
  • By name, the 40 are PS_TexturedDeferred (10); PS_TexturedLit_ReflectionMap, PS_TexturedLit_8 and PS_MirrorReflectionTexturedDeferred (7 each); PS_PuddleDetect (6); MST_DS_TerrainTransform (2); and MST_DS_CascadeShadows_PNTriTexture (1).
  • cargo test -p victory-shader immediate_samplers passes.

In the title (diagnostics build, prewarmed cache, checkpoint to the first room, then idle; VICTORY_INDIRECT_WINDOW=1 VICTORY_LEVELS_ON_DEMAND=1 VICTORY_JOIN_PARTS=1 VICTORY_BACK_OWN_VIEW=1 VICTORY_COPY_PLAIN=1 VICTORY_INDIRECT_GATHER=1 VICTORY_CARD_REHASH_RUNS=1, with #1093 at VICTORY_AMBIENT=0.6):

fps ms/frame on the GPU
without this PR 6.61 151 61
with it 6.51 154 63
  • No device removal, 0 refused dynamic slots, and the same 7 wave64 compute pipelines refused as without it.
  • None of the 40 is used in that room: none of their hashes appears in the run's log. So this shows no regression there, but not the picture they fix. They should matter outdoors (terrain, puddles, reflective surfaces), which I haven't reached in a scripted run.

Not tested: scenes that use these programs, other GPUs, and DexNom's integer-target blending change from the same commit (left out here).

Credit: the lowering and its test are DexNom's; this PR only applies them to this tree.

AI use: Claude Code (Claude Opus 5.5) ported the change, ran the checks on my machine and wrote this description.

🤖 Generated with Claude Code

**@⁠m335671** on GitHub · 2026-11-25 19:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/1096) `m335671:port/sampler-choice` → `main` · +70 −5 · 1 files · 1 commits · open ## What On current `main`, 40 programs fail translation with `emit: a descriptor chosen by control flow`. In each of them, a uniform branch picks one of two immediate (constant) samplers before an image sample. This ports DexNom's fix from [DexNom/VIctory](https://github.com/DexNom/VIctory) `ddb7332` (GPL-3.0, the `lower.rs` part only): - When the sampler is a phi of two constants, the sample is taken with both static samplers and the original derivatives. - The result from the edge that supplied the console's sampler is kept, through a phi on the join block. - If one side has no host block, the other sampler is used directly. - `image` now takes the sampler and calls `image_with_sampler`; everything else is unchanged. The commit also carries DexNom's unit test, `a_uniform_branch_can_choose_between_immediate_samplers`. ## Testing RTX 4070 12 GB (32-lane waves), driver 32.0.16.2124, Windows 11 Pro 26300. **Offline**, `VICTORY_HOST_MAX_WAVE=32 victory translate --list --pipelines` over the title's whole shader pack, compared program by program by hash: | | pipelines created | `a descriptor chosen by control flow` | |---|---|---| | `main` `d510ee4` | 25,608 | 40 | | this PR | **25,648** | **0** | - All 40 now translate and the driver creates their pipelines. No program that `main` creates is lost, and no other failure count changes. - By name, the 40 are `PS_TexturedDeferred` (10); `PS_TexturedLit_ReflectionMap`, `PS_TexturedLit_8` and `PS_MirrorReflectionTexturedDeferred` (7 each); `PS_PuddleDetect` (6); `MST_DS_TerrainTransform` (2); and `MST_DS_CascadeShadows_PNTriTexture` (1). - `cargo test -p victory-shader immediate_samplers` passes. **In the title** (diagnostics build, prewarmed cache, checkpoint to the first room, then idle; `VICTORY_INDIRECT_WINDOW=1 VICTORY_LEVELS_ON_DEMAND=1 VICTORY_JOIN_PARTS=1 VICTORY_BACK_OWN_VIEW=1 VICTORY_COPY_PLAIN=1 VICTORY_INDIRECT_GATHER=1 VICTORY_CARD_REHASH_RUNS=1`, with #1093 at `VICTORY_AMBIENT=0.6`): | | fps | ms/frame | on the GPU | |---|---|---|---| | without this PR | 6.61 | 151 | 61 | | with it | 6.51 | 154 | 63 | - No device removal, 0 refused dynamic slots, and the same 7 wave64 compute pipelines refused as without it. - **None of the 40 is used in that room**: none of their hashes appears in the run's log. So this shows no regression there, but not the picture they fix. They should matter outdoors (terrain, puddles, reflective surfaces), which I haven't reached in a scripted run. **Not tested:** scenes that use these programs, other GPUs, and DexNom's integer-target blending change from the same commit (left out here). Credit: the lowering and its test are DexNom's; this PR only applies them to this tree. AI use: Claude Code (Claude Opus 5.5) ported the change, ran the checks on my machine and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Ported from DexNom/VIctory ddb7332 (GPL-3.0): both samples are taken with the
original derivatives, and the texel from the edge that supplied the console's
sampler is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:57:23 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.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/1096/head:github-bot/gh-1096'
git switch 'github-bot/gh-1096'

Merge

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