Shaders: immediate samplers chosen by control flow #1008
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1008
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1008/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ThiagoAlexsander on GitHub · 2026-11-24 14:56 UTC · original
ThiagoAlexsander:shader/sampler-choice→main· +337 −68 · 3 files · 1 commits · closed without mergingA uniform branch that leaves one of two constant sampler descriptors in the same SGPRs was refused with
a descriptor chosen by control flow: the join (Source::Phiinhandle) only took heap loads. In the title's programs the two choices differ only in their address modes (wrap, or clamp to the last texel), for example inPS_TexturedDeferred,PS_TexturedLit_8and the terrain mesh programsMST_DS_TerrainTransform.Change
E_INVALIDARGon the hardware device and on WARP, thoughdxil.dllaccepts the module). So the join cannot index them as an HLSL sampler array would.sampler_choice: for a sampler phi whose every edge is a constant, one static-sampler handle per distinct choice, and the choice's position as ani32phi at the join. It is uniform, as the edge is.sample,sampleBias,sampleLevel,sampleGrad,sampleCmp*,textureGather,calculateLOD) runs once per handle, and the newpickedselects each channel by that position. With one handle nothing changes: the match arms now name their op and it is emitted after the match, with the same arguments.immediate_sampler, unchanged.Results
victory translate --validateover the title's files (mainffe310eagainst this branch, Windows SDKdxil.dll10.0.26100), compared program by program:maina descriptor chosen by control flow39 programs gain (36 pixel, 3 mesh), and none lose. One
PS_PuddleDetectvariant now stops later, ata cross-lane operation outside compute(#599 territory). The remaininga descriptor chosen by control flowis a compute program whose heap-loaded descriptor goes through two nested joins, a separate case.Testing
emit::sampler_tests: a hand-written wave32 compute program whose group id picks between the two samplers with a uniform branch, then samples a 2×1 texture past its right edge. It is lowered, validated bydxil.dll, and run on the hardware device (RTX 5080) and WARP. Group 0 reads the first texel (wrap) and group 1 the last (clamp). Onmainboth tests fail at lowering.cargo test --workspace --locked: 344 passed, 0 failed, 6 ignored (342 onmainplus the two new tests).cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: clean.rustfmt --edition 2024 --check: no new hunks (the three inlower.rs's tests and one inmod.rsare onmaintoo).cargo xtask policy: 155 files ok.No game data is in the test or the change.
AI use: Claude Code (Claude Opus 5.5) found the case with the census, wrote the change and the tests, and ran everything above. I reviewed the diff and the results.
🤖 Generated with Claude Code
@Zipettte on GitHub · 2026-11-24 15:12 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
7101c98:cargo test -p victory-shaderpasses, 122 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 00:30 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.An immediate sampler picked by a uniform branch is in main (emit/lower.rs handle(), Source::Phi of two constants: samples with both and selects by the edge taken; sampler_choices).
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed