shader: accept scratch-base and binary16 rounding-mode s_setreg_imm32_b32 writes in pixel_aot #634
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/640"
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 rasptum on 2026-11-22T17:09:09Z.
Change
pixel_aotcontrol-flow validation already letss_setreg_imm32_b32through, butlower()rejected every form of it. The fixed-profile archive rescan indocs/experiments.mdlists it as the second most common first rejection of the first general profile (2,007 PS records).s_setreg_imm32_b32writes hardware state, so this PR accepts it only where the effect on the lowered program is known, and rejects everything else by name.Accepted:
HW_REG_FLAT_SCR_LOorHW_REG_FLAT_SCR_HIwith any 32-bit immediate. These hold the scratch base address. Onlyscratch_*andflat_*memory instructions ands_getreg_b32can observe it, and none of them is lowered, so the write changes no result. The controls pin that: each of those readers must still be rejected after the write, so a later PR that lowers one of them has to revisit this.hwreg(HW_REG_MODE, 2, 2)with 0 or 3. LLVM'sSIDefines.hnames MODE bits 3:2 the rounding mode shared by binary16 and binary64 results (0 nearest even, 3 toward zero). The lowerer tracks the value as state. Entry is taken as nearest even, which the existingv_cvt_f16_f32,v_pk_*_f16andv_fma_mix*_f16lowerings already assume. While round toward zero is selected, every binary16 or binary64 form is rejected by name exceptv_cvt_f32_f16(exact) andv_cvt_pkrtz_f16_f32(always truncates).Rejected, each with a diagnostic that names the line:
STATUS,TRAPSTS,LDS_ALLOC,GPR_ALLOC,IB_STS,SHADER_CYCLES);s_endpgm;v_cvt_f16_f32,v_pk_*_f16,v_fma_mix*_f16,v_dot2_f32_f16, 16-bit interpolation and any other_f16or_f64form while round toward zero is selected;s_setreg_b32ands_getreg_b32, which stay unsupported.Not done on purpose: a truncating
v_cvt_f16_f32. It did not occur under round toward zero in the input I counted (below), and its overflow result on this hardware is not something I can measure, so it stays rejected instead of guessed.The denormal fields of MODE relate to #312. No write to them occurred in the counted input, and this PR keeps them rejected, so it does not change what #312 and #363 established.
tools/scan_unsupported_shaders.pygets the two matching patterns so its line classifier agrees with the translator.tools/pixel_cb_read.pyalready skippedhwreg(HW_REG_MODE, 2, 2), 0|3and is unchanged.Verification
Environment: Windows 10 Pro 19045, Python 3.13, LLVM 15.0.7 (
clangas assembler,llvm-objcopy,LLVM-C.dll), DXC from Windows SDK 10.0.26100.0. Branch based onb03f754. The round trip, coverage check and WARP draw were rerun after the last rebase; the hardware run and the pure-Python checks were last run a few commits earlier.python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>python -B tests/pixel_aot_check.py draw <dxc> <offscreen_check> warppython -B tests/pixel_aot_check.py draw <dxc> <offscreen_check> hardwarescalarfixture, see belowpython -B tests/form_coverage_check.pyform coverage checks passedAGENTS.mdHardware run: NVIDIA GeForce RTX 3060, driver 32.0.15.9636, debug layer enabled. The run stops at a
pixel_mismatchin the existingscalarfixture (channel 0,expected_bits=3fa0c000 actual_bits=3fa04000). Unmodifiedefecacfstops at the same fixture with the same bits on this adapter, so it is not caused by this PR, and I am not counting the hardware run as a pass. I can open a separate issue with the details if that is useful. The newcheck_mode_register_drawruns before that point and passed on this adapter; run on its own it passes on both WARP and the RTX 3060.The new fixture (
mode_program()):v_cvt_f16_f32narrowings whose truncated results differ, then selects round toward zero again before a second widening and the pack;s_nop 0in place of each of its five writes;pixel_mismatch.Negative controls in
check_mode_register_controls(): 19 rejected register, field and width spellings; six rejected MODE[3:2] values; the four scratch-base readers;s_setreg_b32ands_getreg_b32; a write between export ands_endpgm; dropping the nearest-even restore from the fixture; round toward zero beforev_cvt_f16_f32and beforev_pk_add_f16; seven further_f16and_f64forms under round toward zero. I also checked by hand that addingv_cvt_f16_f32to the exempt list makes the controls fail.tests/form_coverage_check.pynow requires that the fixture recordss_setreg_imm32_b32and that the register forms are not recorded.Evidence and follow-up
Limited observation from one local input, counted with a throwaway script on top of
resource_inventory.scene_records,pixel_aot.container_codeandpixel_aot.disassemble. Counts use linear instruction order, so they are approximate for programs with branches. Of 12,101 PS records, 825 were not decoded by the count.FLAT_SCR_LO = 0,FLAT_SCR_HI = 0x400scratch_*orflat_*instructionhwreg(HW_REG_MODE, 2, 2), 3_f16or_f64form while 3 is selectedhwreg(HW_REG_MODE, 2, 2), 0The scratch-base pair also opens 8,011 of 9,282 MS, 837 of 2,236 VS and 387 of 2,689 CS records, again with no scratch or flat access. MS, VS and CS records only ever write MODE[3:2] = 0.
So the 2,007 first rejections match the scratch-base pair, not a floating-point mode write. What this measures: which writes occur in that input. What stays a hypothesis: that entry holds nearest even (the compiler emitting 3 before 16-bit interpolation and 0 before rounding half operations fits LLVM's mode-register pass, but pipeline state was not observed), and anything about title pipeline state or startup.
Effect on the same input,
python -B tools/shader_profile_audit.py <archive> --llvm <LLVM-C.dll>atefecacfand with this change: accepted records are unchanged (PS 853, MS 2, CS 13 in both runs). This PR does not make any additional record translate. It removes one first rejection and exposes the next one:efecacfunsupported s_setreg_imm32_b32Unresolved constant buffer bindings17s14unsupported s_mov_b32Unbound pixel input v2 at v_cvt_u32_f32_e32No record first stops at one of the new diagnostics. (
efecacfgives 2,011 where the rescan text indocs/experiments.md, measured at an earlier commit, says 2,007; I left that text as the historical measurement.)Follow-ups this does not cover:
v_interp_p1ll_f16andv_interp_p2_f16(the reason the 4,187 records select round toward zero), a truncatingv_cvt_f16_f32once its overflow result can be established, and branches, which most of the affected records contain.Overlap: no open PR mentions
s_setregin its diff. #612, #541, #540 and #528 also add lines to the pattern list intools/scan_unsupported_shaders.py, and #358 edits text next to the scheduling-hint paragraph indocs/experiments.md; both are adjacent-line conflicts at most. #333 listeds_getreg/s_setregas still open in SOPK.Refs #312 (context only; the denormal fields stay rejected).
AI-assisted: written with Claude Code, reviewed and run locally before submitting.
🤖 Generated with Claude Code