startup: lower s_bitcmp0_b64 and s_bitcmp1_b64 in gfx2hlsl #2880
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!2880
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2880"
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-26 16:19 UTC · original
R0D4X:feat/gfx2hlsl-s-bitcmp64→main· +441 −0 · 4 files · 1 commits · merged 2026-11-27 04:45 UTCSummary
Lower the 64-bit scalar bit-compare SOPC instructions
s_bitcmp0_b64ands_bitcmp1_b64intools/startup/gfx2hlsl.py:SCC = (S0.u64[S1.u[5:0]] == 0)fors_bitcmp0_b64and== 1fors_bitcmp1_b64. Bit 5 ofS1selects the high vs. low 32-bit word ((idx & 32u) != 0u ? hi : lo), andidx & 31uselects the bit within that word.S0) handling: Supports even-aligned SGPR pairs (s[0:1]..s[104:105]),null(0u, 0u), inline integers-16..64(sign-extended to 64 bits viaStage.i64_words), and 32-bit hex literals (zero-extended to 64 bits).masksandmask_highon either register of an SGPR pair or onS1), VGPRs, single/odd/out-of-range SGPRs, float inline constants,m0/src_sccasS0, and unverifiedsrc_sccasS1. Updatesscc_uniformviaStage.set_scc.Before / After
s_bitcmp0_b64ands_bitcmp1_b64were decoded bytools/disasm_rdna2.pyand handled inpixel_aot/mesh_entry_aot, but refused as unlowered intools/startup/gfx2hlsl.py.ps_5_1+ DXCps_6_0GPU draw verification.Verification
Commit under test:
43b0aa33(based onupstream/mainb505c32b)Environment: Windows 11 x64 (
10.0.26300.9974), MSVC19.44.35230, Windows SDK10.0.26100.0, FXC + DXC1.9.2602.17, D3D12 debug layer enabled.Adapters:
Microsoft Basic Render Driver(1414:008c, driver10.0.26100.9818)NVIDIA GeForce RTX 5080(10de:2c02, driver32.0.16.2124)Commands & observed results:
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_s_bitcmp64' -V-> 3/3 passed, 0 skipped (startup_gfx2hlsl_s_bitcmp64_controls,startup_gfx2hlsl_s_bitcmp64_warp,startup_gfx2hlsl_s_bitcmp64_hardware;debug_errors=0 debug_warnings=0on every draw, negative-control mismatch rejected on both FXC and DXC).ctest --preset release --no-tests=error -R '^startup_gfx2hlsl_s_bitcmp64' --output-on-failure-> 3/3 passed, 0 skipped.ctest --preset dev --no-tests=error -R '^startup_tools_lint$'-> 1/1 passed.docs_links_check.py,bidi_controls_check.py,startup_gfx2hlsl_s_bitcmp_check.py,startup_gfx2hlsl_handler_arity_check.py,startup_gfx2hlsl_scalar_arity_check.py,startup_gfx2hlsl_scalar_table_arity_check.py,startup_gfx2hlsl_scalar_null_check.py,startup_gfx2hlsl_refusals_check.py,git diff --check) -> all passed.tools/startup/gfx2hlsl.py(swap_lo_hi,drop_bit5,drop_vgpr_guard,drop_mask_high,sext_literal) -> 5/5 killed (rc=1) bytests/startup_gfx2hlsl_s_bitcmp64_check.py.Evidence Scope
Verified on synthetic gfx1013 SOPC fixtures decoded via
G.decode()and executed on WARP and NVIDIA GeForce RTX 5080 with FXCps_5_1and DXCps_6_0. This establishes thes_bitcmp0_b64/s_bitcmp1_b64lowering ingfx2hlsl.py; it does not establish full-title execution or frame rate.@RonLogic on GitHub · 2026-11-26 16:40 UTC · original
Independent Windows check at
43b0aa33d647566e04bc952ce0c30f44888ca9c2: the pure-Python controls and directstartup_gfx2hlsl_s_bitcmp64_check.py drawpassed on in-box WARP10.0.26100.10068and RTX 407032.0.16.2124, with both SDK FXC and DXC. The wrong-expectation controls failed as intended, with no debug errors, warnings or skips. Windows build26300.10075, using the existing MSVC Release offscreen runner.@Leyukaka on GitHub · 2026-11-26 21:48 UTC · original
Review of head
43b0aa33, from reading the diff (not run). The lowering of the 64-bit bit test reads as correct:Two test notes, the same pattern as on #2891:
ps_words()loadss4..s6withs_mov_b32of literals, whichStage.scalartracks as('const', value), andS()emits them as hex literals. Every draw expression is therefore constant, for example((0x00000025u & 32u) != 0u ? <hi> : <lo>), and the compiler can fold it. No draw case reads a run-time SGPR. This matters more here becauseeval_scc_exprstrips theusuffixes and evaluates with Python's unbounded integers, so a lowering that relied on more than 32 bits, for example(hi << 32) | lo, would pass the Python grid; only the draw checks that. One case with a non-constants[4:5]/s6would close that.ref_bitcmp64(...)with itself and never patch the handler, so they pass with any lowering. Section 9, which deletes the handlers, is a real control; a patched handler (index masked with 31, high word ignored) asserted to fail would make section 10 one too.Optional follow-up, outside this diff: the calculated-PC check in
gfx2hlsl.py(s_cmpk?_..._[iu]32|s_bitcmp[01]_b32) does not lists_bitcmp[01]_b64. After the GETPC add/addc sequence the SCC is marked unusable until a listed compare rewrites it.s_bitcmp[01]_b64is not listed, so an SCC reader after it (s_cbranch_scc*,s_cselect, ...) is refused with "calculated PC SCC escapes". This is fail-closed, not a miscompile.AI-assisted.
@R0Y00 on GitHub · 2026-11-27 04:44 UTC · original · approved these changes
Reviewed
43b0aa33d647566e04bc952ce0c30f44888ca9c2. The lowering uses index bit 5 to select the word and the low five bits for the intra-word shift. The control suites preserve the lane-mask refusals. I built the clean integration tree with current main50488e1cin Release on Windows 11 26200.9974, then ranctest --preset release --no-tests=error --output-on-failure -R '^startup_gfx2hlsl_s_bitcmp64_'. Its portable, WARP (10.0.26100.9818) and RTX 4060 Laptop (32.0.16.1656) tests all passed. D3D12 debug-layer output showed zero errors or warnings. Required Windows CI passed.