tools/shader_meta: fold signed min/max, s_bfe_i32, s_sext_i32, s_pack_* and guard SGPR width #1865
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1865"
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 ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T13:39:05Z.
Claimed in the coordination issue as: SHADER-META-SCALAR-PACK-SEXT-SIGNED-FOLD-AND-WIDTH-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164029615)
What and why
tools/rdna2spirv.pyintools/shader_meta.pyfor signed scalar min/max (s_min_i32,s_max_i32), signed bitfield extraction (s_bfe_i32), 16-bit half packing (s_pack_ll_b32_b16,s_pack_lh_b32_b16,s_pack_hh_b32_b16), and unary sign extension (s_sext_i32_i8,s_sext_i32_i16).s_add_*,s_sub_*,s_addc_u32,s_subb_u32, and binary ALU folding) to require single-SGPR (n == 1) destination and stride-source operands so malformed multi-SGPR operands clear prior state cleanly without attaching bogus constant or stride tags.tests/test_shader_meta.pyandtests/test_shader_meta_operands.py.Tested
python -I tests/test_shader_meta.py -v->Ran 30 tests in 0.200s(OK);python -I tests/test_shader_meta_operands.py -v->Ran 6 tests in 0.000s(OK).upstream/main5e95fa2fwith updated test files copied into detached worktree):test_shader_meta.py->Ran 30 tests in 0.267s(FAILED (failures=17));test_shader_meta_operands.py->Ran 6 tests in 0.001s(FAILED (failures=3)).python -I tests/test_ci_registration.py(Ran 16 tests in 5.029s,OK),python -I tests/test_text_write_line_endings.py(Ran 3 tests in 12.679s,OK),python -I scripts/check_no_game_data.py(exit 0),python -I -m compileall -q(exit 0),git diff --check(exit 0).GPUs tested: n/a (static shader metadata constant folding and operand width validation tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-25T14:03:40Z.
Tested
e0a8694beon Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain71a769d7d(Python shader-metadata tool; no GPU):tests/test_shader_meta.py+tests/test_shader_meta_operands.py: 36 passed, 86 subtests passed at this head.main: 20 failed, 36 passed, 66 subtests — the signed min/max,s_bfe_i32,s_sext_i32,s_pack_*folds and the wide-scalar-destination width guard are new.AI-assisted; synthetic fixtures only, no game data.
Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-25T15:32:11Z.
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
python -m pytest -q tests/test_shader_meta.py tests/test_shader_meta_operands.py:(AI-assisted test run; output checked by hand.)
Imported from ubiquitarianism/leonida. Originally posted by MSedgeMC on 2026-11-25T19:28:52Z.
Review: APPROVED
Verified on the PR branch (clean, 1 commit ahead of main): python3 -m unittest tests.test_shader_meta -> 30 tests OK, including the new cases for signed s_min/s_max, s_bfe_i32 width clamping/sign extension, s_sext_i32_i8/i16, and s_pack_ll/lh/hh constant folding into literal samplers, plus negative cases where an unknown source must not fold. Genuine translator improvement with comprehensive 32-bit edge cases. Python-only, no game data.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:57:49Z.
Red/green: tests/test_shader_meta.py and tests/test_shader_meta_operands.py fail 17 and 3 assertions on main (signed min/max, s_bfe_i32, s_sext_i32, s_pack_* folds, wide SGPR destination guard) and pass with the PR.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
cb7a239ccin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)