shader: accept 2D/3D and wider thread groups in compute_store_aot #702
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/708"
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 roansystemlabs on 2026-11-22T21:31:40Z.
Change
compute_store_aotaccepted only(1|32|64, 1, 1)thread groups. In the fixed-profile archive rescan indocs/experiments.md, this check is the first CS stop for 1,054 of 2,689 compute records. This PR moves that stop. Refs #701.group_size()reads(x, y, z)from PSV0 and accepts anycs_6_0group: x and y up to 1024, z up to 64, x·y·z up to 1024. The translator emits[numthreads(x,y,z)]unchanged, so an 8×8 group stays 8×8.v1andv2, and only when that group dimension is larger than one. gfx10 compute waves receive the three local IDs in separate VGPRs. In LLVM 15.0.7,SITargetLowering::allocateSpecialEntryInputVGPRsusesv0/v1/v2unlesshasPackedTID()is set.FeaturePackedTIDbelongs to gfx90a, gfx940 and gfx11, andFeatureISAVersion10_1_3does not have it.--group-reg-yand--group-reg-zbind the group-ID SGPRs in the same way as--group-reg. Bindings must be distinct and must differ from the table register.v_lshl_add_u32 vD, s<group A>, log2(size A), v<local A>, for a power-of-two size on axis A.idxenaxis, when every other group dimension is one;idxenand a column axis throughoffen(thev[n:n+1]pair), with the byte offset fromv_lshlrev_b32. The store must fit in one element, and one group's row must fit in the stride.tid.x, …), which the swapped-axis controls need.tests/compute_check.cpp: the store-casegroupsword now carries the Y and Z group counts in bits 8–15 and 16–23. Existing files are unchanged. Single-axis cases still printgroups=N.tools/shader_profile_audit.pypasses the PSV0 size through. For the Y and Z candidates it tries the next one or two SGPRs after the group-X candidate (LLVM allocates group IDs as consecutive system SGPRs in X, Y, Z order, each only when the program reads it). A CPU control checks that a 4×1×8 kernel reading group Z from the SGPR after group X is accepted, and one reading it two SGPRs later is not.The five existing cases produce byte-identical HLSL before and after; I compared them against the old module.
Verification
Commit
b8150d0(rebased on343a3a4). Windows 11 build 26200.9974, D3D12 debug layer enabled, NVIDIA GeForce RTX 3070 (driver 621.01) and WARP (Microsoft Basic Render Driver).shader_metadata_census(from #617) importsshader_profile_auditand is included because this PR changes that module.compute_store_aot_hardwareandcompute_store_aot_warpeach passed 15 full 320-word readbacks withmismatches=0anddebug_errors=0 debug_warnings=0: the 8 existing ones plus 7 new ones. The new readbacks:(tid.x, tid.y)offset:4, stores(tid.z, tid.x)tid.xidxenX (stride 4), storestid.xAn independent per-invocation model in the test supplies the expected words. It does not call the translator. On each adapter, every multi-dimensional shape must also fail for:
That makes 15 expected failures per adapter, all detected. The two
compute_to_pixel_*debug warnings (D3D12 1328, ignored initial state) are pre-existing and outside this change.CPU controls (
controls(), run in both modes) reject:v1read in a group whose Y is one;idxenalone in a 2D group;offenwithoutidxen;Mutation check (local script, not added to the repo): I made 16 single-line mutants of
compute_store_aot.py, each run throughcompute_store_check.py drawon WARP and on the RTX 3070. All 16 were killed. The mutants covered: swapped axes in the HLSL, a flattened 1D group, Y/Z always bound, non-power-of-two sizes, an unchecked local axis, and each removed coverage, row, element, layout, same-axis and duplicate-register check. The rest were relaxed Z or total limits, a dropped column shift, group Y bound as X, and a byte offset from a local ID. A separate review pass added six more mutants on both adapters, all killed (five by the CPU controls before any dispatch, one by the store-address check): Z ignored by the coverage check, the column multiplied instead of shifted, a smaller dispatch shift accepted, every stored index emitted astid.x, theidxen/offenroles swapped, and the audit reading group Z two SGPRs after X (killed only after the audit control above was added).Pure-Python checks from
AGENTS.md, plusdocs_links_check.py: all exit 0.compute_store_check.py binaryneeds LLVM 15 with AMDGPU, which I don't have locally. It ran on the fork's Ubuntu job (LLVM 15) with workflow_dispatch atb8150d0, along with the other binary checks in that job. The job passed: https://github.com/roansystemlabs/Xbox2Windows/actions/runs/45071780235. The other jobs in that run also passed: the Windows build and tests, the Windows /O2 build and the Linux Python checks. This includes the new shapes assembled withllvm-mc-15, decoded throughlibLLVM-15.so.1, and the CLI producing the same HLSL as the line fixtures.GPU load during the runs (
nvidia-smi): 2 % before and after, with about 5.6 GB already in use by other processes on the machine. The tests are short dispatches.Evidence and follow-up
tools/shader_profile_audit.pyon this branch? I expect the 1,054 records to stop at a later instruction, not to pass.v_mad_u32_u24row pitches,v_lshl_add_u32with other operands, bounds checks and branches. Reusing thepixel_aotALU lowering in compute would be a separate design question, and I'd ask on #701 first.--group-regalready is.store lowering. If it would help the rescan, a follow-up could append the first store-profile diagnostic, as the PS rows already do.Checklist
AI-assisted: yes. Code, tests and this description were prepared with an AI coding agent and checked by running the commands above.
Imported from R0Y00/Xbox2Windows. Originally posted by Joacoorandom on 2026-11-22T21:37:11Z.
Independent CPU-only check of
b8150d0c2146dddfbb0664dae56d9b25f3d94e7aon Linux/Python 3.14.4:Result: PASS, including the PR's grid/axis/layout rejection controls and the additional group-size boundaries above. This checks translator acceptance and generated expressions only; I have not independently run the assembler or Windows/D3D12 readback cases, so this is not a GPU validation or merge approval.