Lower reversed float subtract and vector moves in pixel shaders #143
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/144"
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 bosseurdinternet on 2026-11-21T17:05:01Z.
Change
Adds two instructions the offline gfx1013 pixel translator rejected. Rebased on #121, whose six operations and fixtures are unchanged.
v_subrev_f32(src1 - src0),_e32and_e64, with the existingclampsuffix.v_mov_b32for numeric values. A move copies a sample component, a loaded constant, an earlier result or an inline or literal constant, and emits oneprecise floatstatement. Integer inline constants stay bit patterns, as in the other operands. Moves of barycentrics, interpolated or partial coordinates, packed pairs or descriptor words are rejected, as are moves with a modifier, moves in whole-quad mode and reads before the requireds_waitcnt.image_samplewill still fill is rejected untils_waitcnt vmcnt(0).The
arithmetic()fixture usesv_add_f32andv_mul_f32from #121 next to the two new instructions.Verification
python3 -B tests/pixel_aot_check.py binary llvm-mc llvm-objcopy libLLVM-19.soon Linux with LLVM 19: passes, including the round trip ofarithmetic()beside theshaping()and predicate fixtures already on main. pyflakes is clean on both Python files.v_subrev_f32: operand order asserted on the generated HLSL, wrong arity rejected, and the render case's negative control replaces it withv_sub_f32.v_mov_b32: non-numeric sources, a modifier,clamp, wrong arity, whole-quad mode, a sample read beforevmcnt(0), a constant read beforelgkmcnt(0), and a move into each of the four pending sample destinations are rejected. The same move into a free register, and into a sample destination after the wait, is accepted.llc19 for gfx1013 selectsv_subrev_f32_e32 v0, s0, v0forv - s, and LLVM prints src0 first.pixel_aot_hardwareis not run: there is no D3D12 adapter on my machine.Evidence and follow-up
half_rtzin the test is only correct for non-negative values (current callers pass none), and LLVM prints negated constants asneg(...), which the translator rejects.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T17:17:58Z.
Please rebase on #121 once it lands and keep v_subrev and v_mov with their own controls. For v_mov, cover writing to a register whose prior texture sample is still pending so that the emitted dataflow remains valid.
Imported from R0Y00/Xbox2Windows. Originally posted by bosseurdinternet on 2026-11-21T17:31:26Z.
Thanks for the review. The
v_movpoint is addressed in5cf9cb4, and the branch is rebased onc1a65f0.Move into a pending sample destination. The translator now tracks the destination registers of each
image_sampleuntils_waitcnt vmcnt(0)and rejects av_mov_b32into one of them with "Write overlaps an outstanding sample". Controls incheck_controls, on thearithmetic()fixture:v12tov15before the wait is rejected;v12after the wait is accepted, and the later copy reads the moved constant.Manual mutant, not in CI: with the new check disabled,
check_controlsfails on the first rejected move.The arithmetic branch has the same gap for its destination register. I left it unchanged here to keep this PR to the two instructions; I can send it separately if you want it.
#121. I will rebase onto it once it lands and drop the two shared table entries.
v_subrev_f32andv_mov_b32keep their own controls: operand order and text assertions, wrong arity, non-numeric sources, reads before either wait, whole-quad mode and the pending-destination cases above. The render case's negative control replacesv_subrev_f32withv_sub_f32.Verified here:
tests/pixel_aot_check.py binarywith LLVM 19 and pyflakes. The Windows draw is left to CI.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T17:58:50Z.
Thanks for covering pending sample destinations. #121 has now landed, and GitHub reports a merge conflict on 420f14b. Please reconcile the pixel lowering and fixture lists with #121, retaining its six arithmetic operations as well as your v_subrev/v_mov controls and the predicate fixtures already on main. Then rerun the assembly and WARP checks.
Imported from R0Y00/Xbox2Windows. Originally posted by bosseurdinternet on 2026-11-21T18:03:46Z.
Reconciled with #121 at
7e97af3, rebased onccfa703.ALUtable and the arithmetic pattern keep #121's six operations unchanged. This PR now adds only thesubreventry,|subrevin the pattern, thev_mov_b32branch and the pending-destination tracking. The duplicateaddandmulentries are gone.arithmetic()is added besideshaping()in the exp-spelling loop and incheck_binary, where the four predicate groups and the dual-texture fixtures are unchanged. Incheck_renderthe arithmetic block runs before the existingcurve/shapingloop, which is unchanged.v_subrev_f32andv_mov_b32controls are as before, including the four pending sample destinations.Checks at
7e97af3:tests/pixel_aot_check.py binarypassed.pixel_aot_warppassed, 77 of 77 tests passed.The two commits are squashed into one, and the title and description now describe only
v_subrev_f32andv_mov_b32.AI-assisted (Claude Code).