tooling: the shader scan reports an unbound entry register as a translator rejection (bare KeyError) #1314
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#1314
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@MasterDomino on GitHub · 2026-11-24 07:41 UTC · original
tools/scan_unsupported_shaders.pyreports a record as "opcodes recognized, translator rejected" wheneverpixel_aot.lower()raises. On one local input, 10,861 of 12,101 records reach that verdict through a bareKeyError. The cause is an entry register that the scanner never binds, not an instruction the translator refuses. The recorded reason is just the register name,'s9'. The scan therefore cannot show what actually blocks the translator.Setup
upstream/mainatf9710f64, Windows 11 (build 26300), Python 3.13.1, LLVM 15.0.7LLVM-C.dll.tools/extract_shaders.py --stage pixel --format native. Aggregates only.python -B tools/scan_unsupported_shaders.py --llvm <LLVM-C.dll> --output-dir <out> <records>What the scanner does
analyze_shader_instructionscallslower()with the same arguments for every record:texture_sgpr=20,interp_sgpr=24,sampler=[1, 2, 3, 4]and no constant bindings. It storesstr(e)for any exception.lower()reads an unbound register with a plainscalar[src]/vector[src]lookup, so the stored reason is the bare key.Measured (
lower_errorinshader_scan_report.json)KeyErroron an SGPR ('s9'10,112,'s11'263,'s17'159,'s12'98,'s15'70, others 46)KeyErroron a VGPR ('v3'108, others 5)32-bit execution mask save requires a validated wave32 guest profileUnexpected sample count or missing color exportUnresolved constant buffer bindingValueError(writelane,comprexport, ds_swizzle, unbound pixel input at a conversion, …)Here is where the unbound register is first read, using LLVM 15 disassembly of the same records with the scanner's arguments. Of the 10,785 records that raise a bare
KeyErrorthere:s_mov_b32 sN, sN(a copy of an entry SGPR): 10,334s_mov_b32 m0, sN: 323v_mov_b32_e32 vN, vN: 107The scanner and LLVM counts differ slightly because the scanner disassembles with
disasm_rdna2.Experiment, not a proposal. As a local hypothesis check, I patched
TrackedScalar.__getitem__to return an opaque value for any unbound SGPR. With that patch, the first rejections are:Unresolved constant buffer bindingUnbound pixel input vNatv_cvt_u32_f32_e32Unbound texture descriptor offsetKeyErroron a VGPRSo even past the entry copy, almost every record stops on a missing binding contract rather than on an instruction. Without per-record bindings, the scan's translator column mostly measures the harness.
Proposed change (one small PR)
pixel_aot.lower(): report an unbound entry register as aValueErrorthat names the register and the instruction, e.g.Unbound scalar input s9 at instruction N: <instruction>. This matches the existingUnbound pixel input vN at …messages. One way is a single translation ofKeyErrorat the per-instruction dispatch, which covers every handler without touching them one by one. The CLI already catchesKeyErrorand would print the clearer message. Two checks intests/pixel_aot_check.pycurrently assert the bare key (('v20',)for thev_mac_legacyaccumulator and('s9',)for an unbound table register). They would assert the new message instead. Both still require a refusal, and the new assertions are stricter.scan_unsupported_shaders.py: keep the per-recordlower_error, but add a summary field that separatesunbound entry register(no binding contract supplied) from real translator rejections. The Markdown report would then state that the translator column only covers records whose bindings the scan supplies. No change to the opcode coverage columns.Out of scope here: inferring each record's real binding contract (descriptor tables, interpolation base, constant buffers). That needs data the extractor does not carry yet. If you prefer, part 2 could wait until such a contract exists, and part 1 could go alone.
@R0Y00, is this worth doing, and should both parts go in one PR or two? I can take it once you confirm.
Limits
AI-assisted.
@R0Y00 on GitHub · 2026-11-24 07:57 UTC · original
Please take this as one focused diagnostics PR. Give missing scalar and vector operand reads a structured diagnostic with the register and instruction (and the byte offset when available), then have the scanner count that diagnostic separately while retaining the per-record reason. Keep unexpected lookup errors distinguishable so an internal bug does not get reported as a missing binding. A small source-built check should distinguish an unbound SGPR, an unbound VGPR, an unsupported opcode, and a bound sample that still translates. Keep the opcode column as-is and describe the acceptance totals as conditional on the bindings supplied by the scan.
@MasterDomino on GitHub · 2026-11-24 08:02 UTC · original
Claiming this as one diagnostics PR: a structured missing-operand diagnostic for scalar and vector reads (register, instruction, byte offset when available), unexpected lookup errors kept distinguishable, the scanner counting it separately with the per-record reason kept, a source-built check (unbound SGPR, unbound VGPR, unsupported opcode, bound sample that translates), opcode column unchanged and acceptance totals described as conditional on the scan's bindings. I'll link the PR here.
AI-assisted.
@MasterDomino on GitHub · 2026-11-24 08:28 UTC · original
PR: #1337.
UnboundOperand(aValueError) names the bank, register, instruction and byte offset; other missing keys stayKeyErrorand the scan counts them as unexpected errors. On the local input every verdict is unchanged; the 10,861 bare-key rejections now split into 10,748 unbound scalar and 113 unbound vector operands, leaving 1,240 real rejections.AI-assisted.