wint_diff: model v_mbcnt/v_writelane operands and validate masks, pairs, op_sel, and arity (WINT-DIFF-REF-VALIDATION) #1913
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1913
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/wint-diff-ref-validation"
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?
Pull request successfully merged and closed
Claimed in #1608 as
WINT-DIFF-REF-VALIDATION(https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7167118909).What and why
tools/wint_diff.py's whole-wave integer VALU reference interpreter had two semantic shortcuts and accepted malformed operands silently (or raised rawValueError/KeyError/IndexError/TypeErrorinstead ofRefError):v_mbcnt_lo_u32_b32/v_mbcnt_hi_u32_b32semantics (step): previously hardcoded to write[min(lane, 32)]/[v0 + max(0, lane - 32)]unconditionally intov0, ignoring the destination VGPR, bitmasksrc0, addendsrc1, andEXEC. Both now computepopcount(src0 & mask_below_lane) + src1into the named destination VGPR for active lanes only (cross-checked againstrdna2spirv.py).v_writelane_b32semantics (step): previously indexedv[args[0][1:]][int(args[2])] = st.sget(args[1]), rejecting inline constants (7), crashing on SGPR lane selectors (s5) or out-of-wave lane indices (32in wave32), and accepting SGPR destinations. It now evaluates scalar/immediatesrc0andsrc1, wraps lane selection modst.wave, and validates a VGPR destination.op_sel, and arity validation (State,step):s_mov_b32now rejects VGPR destinations/sources and wave32exec_hi.State.mask/State.set_maskenforce wave-matching mask operands (sN/vcc_loin wave32,s[N:N+1]/vccin wave64) and consecutive pairs.v_cmp_*/v_cmpx_*reject unknown compare predicates withRefErrorinstead ofKeyError.CARRYrequires 5 operands for_ci_forms and 4 otherwise (previously a missing carry-in silently defaulted to0).MAD64validates consecutive VGPR pairsv[N:N+1],OPS16validatesop_sellength (nsrc + 1), and all VGPR destinations reject non-VGPR tokens instead of stripping character 0.Verification (Windows 11 x64, Python 3.12.10, no GPU / no game data)
origin/mainb0f3d39)python -I tests/test_wint_diff.pytools/wint_diff.py(negative control)python -I tools/wint_diff.py --self-testpython -m compileall -q tools/wint_diff.py tests/test_wint_diff.pypython -I scripts/check_no_game_data.py tools/wint_diff.py tests/test_wint_diff.pygit diff --checkAI-assisted: yes. Synthetic unit tests only; no game data, no GPU required.
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
python -m pytest -q tests/test_wint_diff.py:(AI-assisted test run; output checked by hand.)
#1913 | head
395bbc12a1b14b82cd47dc8c6ac418ebabc13190|python3 -I tests/test_wint_diff.py -v| red: 31 run, 23 failures, 10 errors | green: 31 passed | Red → greenThe reference-model tests exercise operand/EXEC handling, lane operations and validation, including hardware-oracle error paths. The test file passed in full after merging.
Copied the PR tests onto clean main
4a54aedcb6b66525e0c9f72a6ea10263337c9141for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.Merged, thank you @ShotTechOp! This PR (wint_diff: model v_mbcnt/v_writelane operands and validate masks, pairs, op_sel, and arity (WINT-DIFF-REF-VALIDATION)) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.