startup: lower s_brev_b64 in gfx2hlsl #3029
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!3029
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3029"
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?
@R0D4X on GitHub · 2026-11-27 08:45 UTC · original
R0D4X:feat/gfx2hlsl-s-brev64→main· +414 −0 · 4 files · 1 commits · merged 2026-11-27 12:27 UTCWhat this changes
Adds lowering for the 64-bit scalar bit-reverse SOP1 instruction
s_brev_b64intools/startup/gfx2hlsl.py(already decoded bytools/disasm_rdna2.py, alongside the existing 32-bits_brev_b32).S0into SGPR pairs[D:D+1](D.lo = reversebits(S0.hi),D.hi = reversebits(S0.lo)), leavingSCCunchanged.null, sign-extended inline integers-16..64, zero-extended 32-bit hex literals, and constant-tracked SGPRs). WhenD == S0(s_brev_b64 s[4:5], s[4:5]), emits a scoped temporary so both halves are read before being overwritten, and swaps their tracked uniformity accordingly.masks/mask_highon either half ofDorS0), descriptor-bearing SGPRs, VGPR pairs, single/odd/out-of-range SGPRs, floats,m0, andsrc_scc.Tests added
tests/startup_gfx2hlsl_s_brev64_check.py: SOP1 binary decode viaG.decode(), disjoint and in-place aliasing checks, inline-1sign-extension and0x80000001zero-extension, constant folding, uniformity swap checks, refusal cases, unlowered control, and FXCps_5_1+ DXCps_6_0GPU readback draws (including a negative-control draw).tests/cmake/startup_gfx2hlsl_s_brev64.cmakeandtests/checks/python-linux/startup_gfx2hlsl_s_brev64.txt.Verification
f8b78b2c(onupstream/main3b6c38a8)10.0.26300.9974), MSVC19.44.35230, Windows SDK10.0.26100.0, FXC + DXC1.9.2602.17, D3D12 debug layer enabled1414:008c, driver10.0.26100.9818) and NVIDIA GeForce RTX 5080 (10de:2c02, driver32.0.16.2124)Results:
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_s_brev64|^startup_tools_lint$' -V-> 4/4 passed, 0 skipped (debug_errors=0 debug_warnings=0on all draws)ctest --preset release --no-tests=error -R '^startup_gfx2hlsl_s_brev64'-> 3/3 passed, 0 skippeddocs_links_check.py,bidi_controls_check.py,startup_gfx2hlsl_scalar_brev_fold_check.py, scalar/arity/null/refusal checks,git diff --check) -> all passedgfx2hlsl.py(breaking in-place aliasing, skipping half swap, sign-extending 32-bit literals, droppingmask_highguard, wrong in-place uniformity swap) -> 5/5 caught (rc=1)Scope: Covers synthetic gfx1013 SOP1 fixtures translated by
gfx2hlsl.pyand run on WARP and RTX 5080; does not establish full-title startup or frame rate.@tedin7 on GitHub · 2026-11-27 10:06 UTC · original · reviewed
Review of head
f8b78b2c(comment only).Read the diff of
tools/startup/gfx2hlsl.py(73 lines):op_s_brev_b64swaps and bit-reverses the two halves (D.lo = reverse(S0.hi), D.hi = reverse(S0.lo)), folds constants, uses a scoped temporary when D == S0, and refuses lane masks and non-integer symbolic sources. Immediate sources go through the existingi64_words(decimal strings, so theint(lo[:-1])fold is safe).The PR's check has the real thing a lowering needs:
startup_gfx2hlsl_s_brev64_warp/_hardwaredraw the translated shader and compare the readback with a CPU reference, plus a_controlstest.Ran locally (Linux):
python3 -B tests/startup_gfx2hlsl_s_brev64_check.py(controls): ok.hifor both words: the controls fail ("in-place SGPR pair aliasing (8 cases)").reversebits(hi)into the high word: the controls fail ("disjoint SGPR pair (8 cases)").No defect found. It only lacks a Windows receipt on this head:
ctest -R "startup_gfx2hlsl_s_brev64"(dev + release).AI-assisted; commands listed were executed locally.
@R0Y00 on GitHub · 2026-11-27 12:26 UTC · original · approved these changes
Reviewed
f8b78b2cwithmain1ec2c938(integration tree68aed76a). The two reversed halves, in-place temporary, constant folding and per-half tracking agree with the existing scalar write rules.python -B tests/startup_gfx2hlsl_s_brev64_check.pypassed, and itsdraw <dxc> <offscreen_check> <warp|hardware> <fxc>invocation passed on both adapters with both Debug and Release /O2 renderers. The reused renderer was built from the unchanged renderer source on this base. The source-built wrong-output and invalid-operand controls passed. Windows 11 26200.9974, SDK 10.0.26100, WARP 10.0.26100.9818, RTX 4060 Laptop driver 32.0.16.1656, D3D12 debug layer enabled. Hosted Windows, Linux Python and gfx1013 passed.