shader: admit per-lane binary32 VALU forms in pixel_aot masked-region bodies #975
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#975
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@MasterDomino on GitHub · 2026-11-23 19:24 UTC · original
Problem
After #957, the masked region in
tools/pixel_aot.pyopens withs_and_saveexec_b64or with thes_mov_b64exec save plus VOPC_e32v_cmpx. Its body (REGION_ALU) still admits onlyv_mov_b32and binary32add/sub/subrev/mul/min/max, and that is what blocks almost every real region.I proposed this as a next stage in #932 before that issue closed. This is the same proposal as its own task.
Measured on one local input (the 12,101 PS records from #932; aggregates only). It counts the regions #957 accepts structurally: save + f32/i32/u32
_e32v_cmpx+ restore of the same pair. That is 10,827 regions in 3,719 records. Regions that contain a further branch are left out, since nesting is a separate stage.REGION_ALUA record also needs everything outside its regions to translate, so these count regions, not translatable shaders.
Proposal
Admit to the region body, under both openers, the per-lane binary32 forms
lower()already handles outside regions, in the encodings measured in real regions:v_fmac_f32_e32,v_mac_f32_e32v_mul_legacy_f32_e32and_e64v_cvt_f32_ubyte0..3_e32v_rcp_f32_e32,v_rsq_f32_e32,v_sqrt_f32_e32v_fma_f32,v_mad_f32,v_med3_f32That is 14 forms. Each lowers exactly as outside a region. The only translator change is the
REGION_ALUpattern, so the existing per-instruction check still refuses any body instruction that changes more than VGPRs.The restore-time select discards a false lane's speculated value, including an out-of-domain infinity or NaN from
rcp/rsq/sqrt. The accumulator forms read their destination, so a destination still conditional from an earlier region rejects, as reads already do.Other encodings, other operations and scalar instructions stay refused.
Alternatives
s_mov_b32,s_waitcnt, scalar loads), the next most common blockers. They run regardless of EXEC but are skipped with the region bys_cbranch_execz, so they need their own definition. That's a later stage.lower()supports. That is broader than measured need, and each form would need its own speculation argument.Verification
I have an implementation ready, and will link it here as a PR.
Translation controls. Every form under both openers, with exactly one merge of the rewritten register; twelve other forms and encodings refused; the conditional accumulator read refused; a chained region.
Binary. An LLVM 15 gfx1013 round trip of each program.
Draws (
pixel_aot_region_body_warp/_hardware). One program per form rewrites a channel inside av_cmpxregion on mixed, full and empty masks, with exact inner values.rcp/rsqrt/sqrtresults are rounded after the region with +0.5 and floor. A reference that applies the body to every lane must mismatch.I checked for an existing issue or pull request for this change.
I did not include game files, dumps, distribution links or credentials.
AI-assisted.
@MasterDomino on GitHub · 2026-11-23 19:25 UTC · original
Implementation: #976. The translation controls and LLVM 15 round trip pass locally, and all 14 draw shaders compile with DXC; the WARP draws run first in the PR's CI.
AI-assisted.