Shaders: a sampler chosen by control flow between two immediate samplers (40 programs) #718
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!718
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/718/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?
@JRamos1993 on GitHub · 2026-11-25 05:28 UTC · original
JRamos1993:sampler-chosen-by-control-flow→main· +307 −3 · 4 files · 1 commits · closed without mergingPart of #279 (its "a descriptor chosen by control flow" row).
Problem
40 programs of the retail shader pack (37 pixel, 3 mesh) stop with
emit: a descriptor chosen by control flow, so their draws are dropped.In all 40, the sampler is a phi of two immediate samplers: each side of a branch sets the four sampler dwords in SGPRs, and the two sets differ only in dword 0, the address modes.
descriptor_phionly takes heap-index sources (Loaded, or a nestedPhi), so aConstantargument stops it.Two direct fixes do not work:
createHandleFromBindingindexed by a phi of the registers. It validates, but D3D12 refuses the pipeline when the range is covered by two separate static samplers ("The parameter is incorrect").SamplerState s[2] : register(s0)indexed dynamically, with two static samplers ats0ands1, is refused.What
The sample is made through each of the two static samplers, and each result channel is picked by a bit made at the join.
lower:immediate_sampler_pairgives the two handles, plus ani1phi at the join that is set on the edges that chose the second sampler.image, the sample op is emitted as before through the first handle, then once more through the second (Module::call_with). Each extracted channel isselect(bit, second, first).calculateLOD(op 81) does the same.bitcode:Module::call_with, a copy of a call with one argument replaced.a_sampler_chosen_by_control_flow_samples_through_the_chosen_one, a synthetic pixel program:Tested
RTX 5090, driver 621.24, Windows 11,
main310c6eb.victory translate --validate --list:--pipelineson the 40 creates 40 pipelines, 0 refused.cargo test -p victory-shader --locked --no-fail-fast -- --test-threads=4: 215 passed, 0 failed, 3 ignored.cargo clippy -p victory-shader --all-targets --locked -- -D warnings, with and without--all-features: clean.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4: 511 passed, 0 failed, 9 ignored.Not tested
AI use
Claude Code with Claude Opus 5.5 found the failure class on the retail pack, wrote the change and the test, ran the checks above and wrote this. The test uses a synthetic program. The title's shaders were only read on my machine, and nothing from them is in this PR.
@JRamos1993 on GitHub · 2026-11-25 06:08 UTC · original
Closing as a duplicate of #25, which I missed when I checked for existing work (I searched issues, not pull requests). Sorry for the noise.
Same 40 programs: measured on the retail pack against
main310c6eb(RTX 5090,victory translate --validate --list, local DXIL hash on each validated line):mainvalidates the same 40 programs this PR does: 25,382 → 25,422.main's, as with this PR.#25 is the better fix:
Possibly useful for #25:
SamplerState s[2]indexed dynamically.crates/victory-shader/src/emit/sampler_choice_tests.rsonJRamos1993:sampler-chosen-by-control-flow, if a second test is wanted.Pull request closed