shader: lower v_swap_b32 in gfx2hlsl (Part of #1723) #2012
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2012
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2012/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?
@tedin7 on GitHub · 2026-11-24 23:04 UTC · original
tedin7:x2w-pipe-v-swap-b32→main· +222 −0 · 5 files · 2 commits · closed without mergingPart of #1723
What this unblocks: Completes 1 graphics pipeline blocked on v_swap_b32 in gfx2hlsl (replaces closed draft #1796, rebased cleanly on origin/main).
Verification:
AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:04 UTC · original · edited 2026-11-24 23:07 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
242834cℹ️ 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.
@ChazY11 on GitHub · 2026-11-24 23:07 UTC · original
mainalready lowersv_swap_b32, and this branch is 114 commits behindChecked against
mainatf018831b's content (the tree currently intools/startup/gfx2hlsl.py):That is #1995's implementation, already in
main— it arrived with commitf018831b(startup: lower v_swap_b32 in gfx2hlsl), whichgit logshows onmain's history for that file.tests/startup_gfx2hlsl_swap_check.pyis onmainand green:Your branch:
Those deletions are other people's merged work that your branch predates, not something your patch removes — but a merge today would conflict in
CMakeLists.txtandtools/startup/gfx2hlsl.pyand would add a secondtests/startup_gfx2hlsl_swap_check.py(AAon that path when I merged both branches). So it cannot land as is.What your version still adds
Two things that the version on
maindoes not have:v_swap_b32 v5, v5currently emits{ uint t = v5; v5 = v5; v5 = t; }onmain— harmless, but dead code in every shader that contains a self-swap. Skipping it is a real (small) improvement, and it is the only part of this PR that is not already upstream.The other difference goes the other way:
mainmoves the uniformity flag across (uniform = (dst in uniform_v and exec_known, …)), so two uniform registers stay uniform after a swap; your version discards the property for both. That is conservative rather than wrong, but it is a regression against what is onmaintoday.Suggested shape
A one-handler follow-up on current
mainthat adds only thea != bskip, plus one fixture line asserting thatv_swap_b32 v5, v5emits nothing. That would be reviewable in a minute and would not touch the existing check file.I am not asking you to do that — just making sure the duplication is visible before someone spends time resolving it.
Notes
@ChazY11 on GitHub · 2026-11-24 23:10 UTC · original
Correction: my previous comment was wrong —
maindoes not lowerv_swap_b32, and this PR is not a duplicateI claimed
mainalready contained this handler and that your PR duplicated it. That was wrong, and I apologise for the noise. The check Ishould have run, now run three ways against the commit rather than a working tree:
and, for contrast:
origin/mainat66423e45has 75op_*methods onStageand none of them isop_v_swap_b32;tests/startup_gfx2hlsl_swap_check.pyis not inthe tree.
What went wrong on my side: I had your branch checked out earlier in the same session to run
tests/startup_gfx2hlsl_swap_check.py, and mylater greps read that working tree instead of
origin/main. The line numbers I quoted (1304,1318,1322) are real — in your branch. Theconclusion I drew from them was not.
What survives from that comment
Two observations were measured on your branch and do not depend on the mistake:
v_swap_b32 vA, vAemits{ uint swap_tmp = vA; vA = vA; vA = swap_tmp; }with theif a != b:guard removed; your guard is a realimprovement over emitting the dead block.
(it sets each register's flag from the other's), and it is worth deciding on rather than leaving to whichever PR lands.
Both PRs touch the same handler and the same file, so whichever lands second needs a rebase — that part stands.
Notes
@ChazY11 on GitHub · 2026-11-24 23:24 UTC · original
Now it is actually true: #1995 has merged, and this PR is a duplicate against current
mainMy two earlier corrections on this PR said the opposite — that
maindid not lowerv_swap_b32. That was correct at the time and is no longer. Thecurrent state, verified against the commit object:
So the feature is landed with #1995's implementation, and the only thing this PR still adds is the
if a != b:short-circuit:mainemits{ uint t = v5; v5 = v5; v5 = t; }forv_swap_b32 v5, v5.What that short-circuit is worth
It is a genuine (small) improvement — dead code in every shader that contains a self-swap — and it is now the only difference, which makes it a
one-line follow-up rather than a competing implementation. If you want it, a fresh branch on current
mainwith:plus one fixture line asserting that
v_swap_b32 v5, v5emits nothing, would be reviewable in a minute and would not touch the existing check file(which #1995 added with the same name this PR would have used).
Note also that #1995's version keeps the uniformity flag across the swap (
uniform = (dst in uniform_v and exec_known, …)); a rebase of this PRshould preserve that rather than replacing it with an unconditional discard, which is what the current branch does.
On my earlier comments
I got this wrong twice in opposite directions: first claiming the code was on
mainwhen my greps were reading a checked-out branch, thencorrecting to "not on
main" when that was true only for those hours. Both corrections were measured against the right object at the wrong time —a reminder that "is X on main" is a statement about a commit, not about a repository.
Notes
@R0Y00 on GitHub · 2026-11-24 23:30 UTC · original
Thanks for the parallel implementation. JB2WIN separately claimed this row in #1723, and #1995 is now on main. It covers the swap, self-swap, EXEC and uniformity tracking with encoded and mutation controls. Closing the overlapping patch.
Pull request closed