shader: lower s_bitcmp0/1_b32 and b64 in bounded mesh lowerers #2436
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2444"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-25T16:59:36Z.
Summary
s_bitcmp0_b32,s_bitcmp1_b32,s_bitcmp0_b64, ands_bitcmp1_b64in the bounded mesh lowerers (tools/mesh_entry_aot.pyandtools/mesh_dynamic_aot.py), addressing thes_bitcmp0_b32refusal (129 of 298 slot-57 programs) reported in the #2413 T2 census.S1[4:0]) and 64-bit (S1[5:0], includings[M:N],exec,vcc, and sign-extended-1) forms per AMD RDNA 2 ISA §9.3 (SOPC), as well as 32-bit constant-bufferDynbit tests feedings_cbranch_scc0/s_cbranch_scc1descriptor joins.Wave.steps()to skip no-destinations_cmp_*ands_bitcmp*ops in theself.writtenpre-scan so comparing a never-written SGPR fails withScalar register sN used before it is written, extendWave.exec_range()dynamic joins to handles_cbranch_scc1, and check all compare operands inRuntimeWave.descriptor_scalar_op()so sampler/texture descriptor words are refused cleanly.tests/mesh_bitcmp_check.py, registermesh_bitcmp_cpuandmesh_bitcmp_draw_{warp,hardware}inCMakeLists.txt, wiretests/mesh_bitcmp_check.pyintopixel-binary(llvm-mc-15) andpython-linuxin.github/workflows/windows.yml, and document the behavior and checks inAGENTS.mdanddocs/experiments.md.Refs #2413, #1998
Verification
b442b57f(upstream/main)a60be126(shader/mesh-bitcmp)10.0.26300.0), DXC1.9.2602.17Microsoft Basic Render Driver(1414:008c), driver10.0.26100.9818, D3D12 debug layer enabledNVIDIA GeForce RTX 5080(10de:2c02), driver32.0.16.2124, D3D12 debug layer enabledCommands and Observed Results
docs_links_check.py: 19 files / 465 links;bidi_controls_check.py: 1725 files;git diff --check: clean).tools/mesh_entry_aot.py): both masking_b64shift by31instead of63(rc=1) and disabling theWave.steps()compare skip (rc=1) failedtests/mesh_bitcmp_check.pyas expected and were reverted cleanly.devCTest: 8 passed, 0 skipped, 0 failed (mesh_dynamic_aot_cpu0.53 s,mesh_lane_spill_cpu0.18 s,mesh_bitcmp_cpu0.41 s,mesh_entry_skipped_scalar_cpu0.19 s,mesh_join_descriptor_hardware3.15 s,mesh_bitcmp_draw_hardware5.80 s,mesh_join_descriptor_warp0.74 s,mesh_bitcmp_draw_warp1.40 s;debug_errors=0 debug_warnings=0).releaseCTest: 3 passed, 0 skipped, 0 failed (mesh_bitcmp_cpu0.41 s,mesh_bitcmp_draw_hardware5.43 s,mesh_bitcmp_draw_warp1.36 s; all drawspixels=1024 mismatches=0,debug_errors=0 debug_warnings=0, inverteds_bitcmp0_b32->s_bitcmp1_b32GPU negative control failed withpixels=1024 mismatches=1024).tests/mesh_bitcmp_check.py binary llvm-mc-15(llvm-mcis not installed on this Windows host); wired into the Ubuntupixel-binaryCI job.s_bitcmp*evaluation and descriptor-join branching inmesh_entry_aot/mesh_dynamic_aot; they do not establish full-game startup or direct slot-57 mesh emission.Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:28:53Z.
Five mutations, all caught — including the two that decide the predicate
Baseline:
mesh s_bitcmp controls passed, exit 0.s_bitcmp{0,1}_b{32,64}lowering inmesh_entry_aot.pys_bitcmp0predicate inverted (==↔!=)1u << bit→~0u)1u << (bit + 1))The first two are the whole instruction:
SCC = (S0[S1] == 0)forbitcmp0and!= 0forbitcmp1, so an inverted comparison and a mask that stops isolating one bit are the two ways to get a silently wrong predicate. Both are pinned, and so is the off-by-one in the index, which is the third.The refusal rows matter for a different reason: this is the same translator-crash class the
gfx2hlslside has been closing — a short or wrong-width operand list must be aValueErrornaming the requirement rather than an index error. Both surface here, so removing either is visible.What I checked beyond the diff
docs/experiments.mdgains the ISA citation (RDNA 2 ISA s9.3 (SOPC)) next to the lowering, which is the right place for it: the bit index width (5 bits forb32, 6 forb64) is the only non-obvious part, and it is exactly what a reader would get wrong.CMakeLists.txt, the LinuxRun Python checkslist,AGENTS.md) is present formesh_bitcmp_check.py, so the new fixture actually runs in CI rather than only locally.One suggestion
The
b64case is the one where the bit index can legitimately exceed 31, and the fixture's controls pass — but I could not find an assertion that pairs a 64-bit source with an index above 31 specifically. If that case is absent, it is the one I would add: it is the only input that distinguishes "index taken modulo 32" from "index used as-is", and the mutation above (bit + 1) was caught by some other case, not necessarily that one.AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:24:00Z.
Review: COMMENTED
Review of head
a60be126(comment only, no merge from me).Findings:
s_bitcmp0/1_b32,s_bitcmp0/1_b64) intools/mesh_entry_aot.pywith different code. This PR also coverstools/mesh_dynamic_aot.pyand theWave.steps()/exec_range()/descriptor_scalar_op()changes, so it is the wider slice. Two PRs for one slice is a design choice, so I leave it to @R0Y00 which one lands (the other then needs a rebase or a close)..github/workflows/windows.yml, so it needs an update with main and a fresh CI run before any merge. The newtests/mesh_bitcmp_check.pylines inpixel-binaryandpython-linuxmust run in that CI run.Not done: no Win2025 run and no mutation run, because the choice between the two PRs comes first.
Commands run:
gh pr view,gh pr list --search s_bitcmp,python3 merge_check.py 2444.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T19:20:54Z.
Routing note: this PR and #2438 (by @triggered02, opened 11 minutes earlier) both add
s_bitcmp0_b32,s_bitcmp1_b32,s_bitcmp0_b64ands_bitcmp1_b64totools/mesh_entry_aot.py, with different code. This PR also coverstools/mesh_dynamic_aot.py.git merge-treeshows the two branches merge without a textual conflict, so both could land and leave two implementations of the same ops.Competing implementations go to the maintainer. @R0Y00, could you pick one, or ask the authors to consolidate (for example, one PR takes
mesh_entry_aot.py, the other only addsmesh_dynamic_aot.py)? I'm not reviewing either for merge until that's decided.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T07:30:20Z.
Review: APPROVED
The merged tree retains the #2438 concrete bitcmp model and its verified branch ordering. The new constant-buffer predicate is allowed only immediately before a supported descriptor join. Unsupported dynamic consumers keep their existing refusal. Windows Release passed all 9 CTests, zero skips, with both WARP and RTX 4060 Laptop draw readback and an inverted-predicate control. The original #2438 checks still pass.