tooling: name unbound operand reads in pixel_aot and count them separately in the shader scan #1330
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1337"
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 MasterDomino on 2026-11-24T08:28:55Z.
Fixes #1314
pixel_aot.lower()reported a read of a register it holds no value for as a bareKeyError('s9'). The shader scan stored that as a translator rejection.lower()now raises a named diagnostic for these reads, and the scan counts it separately from real rejections. Translation results are unchanged: the same programs are accepted, and every refusal is still a refusal.Behaviour
Following the scope on #1314:
tools/pixel_aot.py:UnboundOperand(ValueError)carriesbank(scalarorvector),register,index(0-based instruction number),offset(byte offset whenlower()receives(offset, text)pairs, otherwiseNone) andinstruction. Example message:Unbound scalar operand s9 at instruction 2 (byte offset 0x8): s_mov_b32 m0, s9. The trackers raise it from__missing__, so every handler is covered and no handler changed. The loop records the current instruction on both trackers and clears it after the last one.Which reads count:
s0–s105,vccandv0–v255, read inside an instruction. Any other missing key in the register state stays a plainKeyError, for examples106,ttmp0, a VGPR name in the scalar state, a non-string key, or a read outside an instruction. Lookups in every other dict are unchanged. So an internal lookup bug is not reported as a missing binding.Why
ValueError: this matches the existingUnbound pixel input vN at …refusals. Every caller that handled the oldKeyErroralso catchesValueError: thepixel_aotCLI, andmust_rejectin the tests.lower()itself has noexceptclause. The CLI now prints the full message instead of's9'.tools/scan_unsupported_shaders.py:lower_error(the per-record reason) andlower_statusare unchanged. New per-record fields:lower_error_kind:unbound_operand,translator_rejection(any otherValueError) orunexpected_error(any other exception, a bareKeyErrorincluded).lower_error_type: the exception class name.lower_unbound: the structured diagnostic.The summary adds
translator_rejections_by_causeandtranslator_bindings. The Markdown report, the console summary and thePROGRESS.mdnotes state that the acceptance and rejection totals hold only under the scan's fixed bindings: texture tables20, interpolation bases24, sampler words 1 2 3 4, no constant buffers. Opcode columns and verdict categories are unchanged.Tests
tests/pixel_aot_check.py(no arguments), newcheck_unbound_operand_diagnostics, source-built on a single-sample program bound the way the scan binds it:s_mov_b32 m0, s9), as plain strings and as(offset, text)pairs with the byte offset;v_mov_b32_e32 v2, v3);ValueError(Unsupported instruction 1: …);KeyError;s105,vccandv255are diagnosed.('v20',)for thev_mac_legacyaccumulator,('s9',)for an unbound table register) now require the full diagnostic: bank, register, instruction index, offset, text and message. Both still require a refusal.tests/rdna2_tools_check.py, newtest_unbound_operand_counted_separately: the scanner on the same four programs. It checks per-record kind, register and kept reason, and that the unbound records stayopcode_recognized_translator_rejectedwith empty opcode columns. A patchedlowerraisingKeyError('s9')must count asunexpected_error, not unbound. It also checks the summary split,translator_bindingsand the Markdown lines.Every pure-Python check listed in
AGENTS.mdalso passes.Negative control: with
tools/pixel_aot.pyandtools/scan_unsupported_shaders.pyrestored to main, and the new tests kept:Inventory change, reason only
One local input (12,101 PS records, the same population as #711), scanned with
tools/scan_unsupported_shaders.py --llvm <LLVM-C.dll>. Base8cbb4c03against this branch. Aggregates only.lower_statusare identical.top_unsupported_opcodesandunsupported_by_categoryare identical too. Onlylower_errorchanged, in exactly the 10,861 records whose base reason was the bare key, and in each one the new diagnostic names the same register.s910,112,s11263,s17159,s1298,s1570, other SGPRs 46;v3108, other VGPRs 5.s_mov_b32 sN, sN10,410,s_mov_b32 m0, sN323,v_mov_b32_e32 vN, vN107, other 21.byte_offsetisNonefor these records. The CLI path passes(offset, text)pairs and gets the offset.8cbb4c03, 801 of the unbound-scalar records also contain unrecognized opcodes, so they stay in that column.0f09ca93, which includes #1322 (permlane decoding), a re-scan of the branch gives the same causes: 10,748 unbound scalar, 113 unbound vector, 1,240 other rejections, 0 unexpected. Only the opcode columns move, as #1322 reported. 11,887 records are recognized-but-rejected (10,559 unbound scalar, 113 unbound vector, 1,215 other), and 214 contain unrecognized opcodes (189 unbound scalar, 25 other). 45 unique opcodes remain unsupported.Unexpected sample count or missing color export: 315;Unresolved constant buffer binding: 53;Unsupported instruction: 29;Unbound pixel input vN at v_cvt_*refusals: 13;ds_swizzle_b32whole-quad source: 4.Limits
Environment
Windows 11 26H2 (build 26300), Python 3.13.1, LLVM 15.0.7 (
LLVM-C.dll,llvm-mc,llvm-objcopy).AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:54:46Z.
Review: COMMENTED
Technical peer review at commit
012e142a545b0ce0844e6cbbb3b83ec04d74af9c(LGTM, no blocking findings):Code audit:
tools/pixel_aot.py:UnboundOperand(ValueError)is raised viaTrackedVector.__missing__/TrackedScalar.__missing__only whensite is not None(inside the instruction lowering loop) and the key matchesVECTOR_OPERAND(v0-v255) orSCALAR_OPERAND(s0-s105,vcc). Outside the loop (site = None) or for non-register keys, missing lookups still raiseKeyError, preventing internal translator bugs from being misclassified as missing bindings.tools/scan_unsupported_shaders.py:SCAN_BINDINGSandlower_rejection_causescleanly separateunbound_scalar_operand,unbound_vector_operand,translator_rejection(otherValueError), andunexpected_error(non-ValueError, e.g. bareKeyError) in both JSON and Markdown reports, without alteringcompatibility_categoryortranslator_accepted.tests/pixel_aot_check.py&tests/rdna2_tools_check.py:expect_unbound_operandandtest_unbound_operand_counted_separatelyverify exact attributes, formatted error messages, and report aggregation including the mockedKeyErrornegative control.Checks:
tests/docs_links_check.py(16 Markdown files, 294 links) passed;tests/bidi_controls_check.py(1108 files) passed;tests/pixel_aot_check.pypassed;tests/rdna2_tools_check.py(139 tests, 18 skipped) passed;git diff --checkclean.--preset dev,offscreen_check):rdna2_tools_check(4.35s) +pixel_aot_warp(14.85s) 2/2 passed./O2(--preset release,offscreen_check):rdna2_tools_check(4.49s) +pixel_aot_warp(15.53s) 2/2 passed.tests/form_coverage_check.pypassed (38.76s).Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T08:40:43Z.
The structured exception and unexpected KeyError control both work, and the local Python checks pass. Please adjust the report's two cause labels. A missing register during lowering can also be an undefined operand later in the program, so “entry binding not supplied by the scan” is more specific than UnboundOperand proves. Label these as unbound scalar/vector operands under the scanned inputs. Keep the existing explanatory note about fixed entry bindings separate from the per-record classification. The opcode column can stay unchanged.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:29:56Z.
Review: COMMENTED
Re-verification at commit
90a707ef5c44dc33dc7d4efffdff98f23386b36e(LGTM, no blocking findings):Delta audit (
012e142a..90a707ef):tools/scan_unsupported_shaders.py&tests/rdna2_tools_check.py: relabeled the Markdown cause lines toUnbound scalar operand under the scanned inputs/Unbound vector operand under the scanned inputs, updated comments accordingly, and kept the fixed-binding note separate without altering per-record fields or counts.Checks:
docs_links_check.py(16 Markdown files, 294 links),bidi_controls_check.py(1108 files),pixel_aot_check.py,rdna2_tools_check.py(139 tests, 18 skipped), andform_coverage_check.pyall passed;git diff --checkclean.--preset dev,offscreen_check):rdna2_tools_check(4.38s) +pixel_aot_warp(15.09s) — 2/2 passed (15.16s)./O2(--preset release,offscreen_check):rdna2_tools_check(4.26s) +pixel_aot_warp(15.14s) — 2/2 passed (15.20s).tests/form_coverage_check.pypassed (39.17s).Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T09:08:24Z.
Relabelled in
90a707ef: the Markdown causes now readUnbound scalar operand under the scanned inputs/Unbound vector operand under the scanned inputs, the code comments no longer call these missing entry bindings, and the fixed-binding note stands on its own (the "needs a binding contract" sentence is gone). Per-record fields, counts and the opcode column are unchanged.rdna2_tools_check.py(with LLVM 15 and without) and thepixel_aot_check.pycontrols pass; the branch still merges cleanly with main after #1328.AI-assisted.