shader: lower nested control-flow descriptors and immediate sampler phis #739
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!739
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-739"
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?
@powplusplus on GitHub · 2026-11-25 06:06 UTC · original
powplusplus:shader/control-flow-descriptors→main· +608 −250 · 2 files · 3 commits · openSummary
Eliminates all 40 remaining
emit: a descriptor chosen by control flowfailures acrossshaders.rpf(reaching 100% of mesh shaders emitted):resource::Tracer::phi):Tracer::meet, storingNonefor dead edges inSource::Phi { block, args: Vec<Option<Source>> }and unwrapping a single liveConstantor non-dynamicBuiltsource directly.Phi/Selectdescriptors (emit/lower.rs):descriptor_phihelper withuniform_heap_index, handling arbitrarily nestedSource::PhiandSource::Selectover heap-indexed descriptors.const_sampler_choiceandconst_sampler_indexto dispatch image sampling andcalculateLODacross distinct immediate constant samplers chosen by control flow (Phi/Select).Verification
cargo test -p victory-shader --lib(173 passed, 0 failed, including newdead_incoming_phi_edge_is_skipped_for_scalar_descriptoranddescriptor_chosen_by_control_flow_and_constant_sampler_phi_lowertests).victory-shader -- -D warnings) and workspace check clean on8dd30ab.shaders.rpfcensus (26,084 programs):14,164 -> 14,201 / 14,247(+37, 0 lost)8,762 -> 8,765 / 8,765(+3, 100% of mesh programs emitted)2,672 -> 2,672 / 2,682(0 lost)emit: a descriptor chosen by control flow:40 -> 0@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 06:07 UTC · original · edited 2026-11-25 06:19 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
49bb897ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@Flyander on GitHub · 2026-11-25 06:55 UTC · original
I reproduced both P1 cases on this head and opened a focused follow-up against this feature branch: https://github.com/powplusplus/victory-fork/pull/1
It restores the safe direct
Loadedsource for a one-live-edgeResourceHeapphi and hoists matching join-local sampler selects so their SCC is only used after the join. The sampler regression test panicked withforward reference outside a phibefore the fix and now passes; the generated pipeline also creates on the RTX 5070 Ti.Validation on the follow-up: shader lib tests 216 passed, 0 failed, 3 ignored; Clippy is clean. WARP still rejects this synthetic pipeline with
E_INVALIDARG; that limitation is recorded in the follow-up description.@MKmajster on GitHub · 2026-11-25 11:53 UTC · original
Tested on a combined tree, offline: it clears the whole "descriptor chosen by control flow" class there. Two spots need care if this lands together with #353 or #386.
Tree.
skornuta/victory-forkmain(this repo's310c6ebplus ZSlayerHQnext), with the LooperSalty/victory lot that carries #353 and #386, plus #188, #258 and #806 of this repo, then this PR (49bb897).Offline,
victory translate --listover the title's shader pack (26,084 programs, all reach IR; counts are refusals at emission). "Before" is the tree without #806, this PR and #215; "after" has all three, so the split per PR is my reading of the reasons, not measured one by one:cargo test -p victory-shader --lib: 238 passed, 0 failed, 3 ignored (235 on the tree before the three PRs).Two conflicts, and how I resolved them:
sampler_slot. This PR's version keeps one static sampler per set of words and makes it a comparison sampler if any use compares. #386 (in the LooperSalty lot) gives a sampler used both ways two slots, because the DXIL validator wants the kinds to match, and changessamplersto(words, comparison)pairs. I kept your call sites and moved #386's two-slot logic intosampler_slot, including thecmp_samplersbit being cleared for the non-comparison slot.sampleLevelLOD fromtexels. This PR computesLog(texels) * LOG2_E, asmaindoes today. #353 changes that line toLog(texels)alone, because DXILLog(opcode 23) is already base 2. On the merged tree I kept #353's version inside this PR's newtail_argsstructure. Whichever of the two lands second will hit this line.Not verified: a game run with this tree. The numbers above are the offline pack and the unit tests only.
AI-assisted (Claude Code). No game data attached.
@ -1345,0 +1361,4 @@| Source::Built {address: Address { dynamic: None, .. },..}@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 06:19 UTC · original
For a statically addressed
ResourceHeapdescriptor with one live edge and a non-descriptor on a dead EXECZ skip edge, the oldanywhere()fallback returnedSource::Loadeddirectly. This whitelist instead leaves the load inside a one-live-armSource::Phi, butslot_stride()returnsNonefor phis. Consequently,smem()loses its stride-based SRV/CBV dispatch and unconditionally annotates the heap entry as a CBV and callscbufferLoadLegacy, even when the entry is a buffer SRV. This breaks previously supported buffer reads. Preserve the safe direct-loaded case, or make the stride/type lookup follow the new phi.Useful? React with 👍 / 👎.
@ -6099,0 +6228,4 @@let idx = match arg {Some(arg) => {let here = std::mem::replace(&mut self.cur, at);let idx = self.const_sampler_index(arg, cmp, slots);@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 06:19 UTC · original
When one immediate-sampler word comes from a control-flow phi and another is chosen by
s_cselectafter that join,Tracer::phi()produces phi arguments containing selects whose SCC is defined in the join block. Switchingself.curto the predecessor here emits those selects before their SCC definition, violating dominance. A two-arm sampler phi followed by a join-local compare/select andimage_sample_lzreproduces a panic inModule::write()withforward reference outside a phi; the parent returned an unsupported-translation error instead. Factor post-join selects outside the phi, or otherwise ensure their conditions dominate the insertion block.Useful? React with 👍 / 👎.
@Flyander on GitHub · 2026-11-25 06:16 UTC · original · reviewed
I locally added the sampler-choice GPU regression from #718 to this branch and ran it on the RTX 5070 Ti and WARP. The selected wrap/clamp sampler produced the expected texel in both cases. With that test registered,
cargo test -p victory-shader --lib --locked --no-fail-fast -- --test-threads=4passed (217 passed, 0 failed, 3 ignored), andcargo clippy -p victory-shader --all-targets --locked -- -D warningswas clean.The current
descriptor_chosen_by_control_flow_and_constant_sampler_phi_lowertest checks emission, while this render test checks the result reaches the target correctly. I recommend keeping that coverage with this implementation, since #739 is the path replacing #718. In a separate local experiment, mergingdx.types.ResRetas an aggregate phi caused WARP to remove the device (0x887A0005); the per-channelf32merges in this branch passed.@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 06:19 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
49bb897967ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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.Merge
Merge the changes and update on Forgejo.