shader: name where a gfx2hlsl translation failed in its .fail #2356
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2364"
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 pigalot on 2026-11-25T13:40:51Z.
Change
Two kinds of
.failreason don't say where to look:translator error: TypeError: ...) now ends with the function, file name and line that raised it, for example(in scalar_select, gfx2hlsl.py line 1234).operand '-v30') doesn't say which lowering refused it. The translation loop now records the instruction on the refusal, and the graphics and compute.failwriters append it:operand '-v30' in v_and_b32_e64.The exception message itself is unchanged, so
Pipeline,--refusalsand anything else that groups refusals by message see the same text as before. Only the.failfile and thetranslate_toresult gain the suffix. This is an independent diagnostics improvement; no issue tracks it.Verification
On
fe0c822f+ this commit, Windows 11 (26200):ctest --preset dev --no-tests=error -j 8 -R 'gfx2hlsl|pixel_aot_check|rdna2_tools|compute|translator|startup_run|triage|scan_unsupported' -E '_hardware$|startup_audio_': 195 passed.python -B tests/docs_links_check.py: 18 files, 451 links, passed.tools/startup/gfx2hlsl.pyreverted,python -B tests/startup_gfx2hlsl_watch_check.pyfails._hardwarevariants were not run on this branch.Evidence and follow-up
tests/startup_gfx2hlsl_watch_check.pygains two cases, built in the test from source text: the existing injectedZeroDivisionErrornow checks the location, and a synthetic graphics pair whose pixel shader uses-v30onv_and_b32_e64checks thattranslate_toand.failname the instruction whilePipelinestill raisesoperand '-v30'. The line number in the location is whatever the traceback reports; the test checks the format, not a fixed number.Docs:
docs/startup-runtime.mddescribes the new suffixes;docs/experiments.mdnotes that the census reason omits them.Checklist
This change was AI-assisted: written with Claude Code, and the checks above were run locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:45:28Z.
Review: COMMENTED
Review of head
c7552c613d812b1e89ed71b77a2f9fed9b7ae778(comment only).Summary: the change is small, correct for what it claims, and the new tests catch a real regression. No P1, no P2.
Checked
.failwriters intranslate_toandtranslate_computeboth go through the newfail_reason(). The exception text is untouched, soPipelineand--refusalsgrouping see the same message (the new test asserts this).triage_run.classify_shader_reasonmatchesoperand\bat the start of the first line and never copies the text, so the addedin <instr>suffix and the(in fn, file line N)suffix do not split its buckets..failtext), so no Windows GPU run was needed.Commands run locally (Linux, on the PR head)
python3 -B tests/startup_gfx2hlsl_watch_check.py: passedpython3 -B tests/startup_gfx2hlsl_refusals_check.py: passedpython3 -B tests/startup_triage_run_check.py: 0 failedpython3 tests/docs_links_check.py: 18 files, 451 links, passedpython3 tests/bidi_controls_check.py: passedgit diff --check origin/main...HEAD: cleantext += ' in %s' % reason.instructionline infail_reason.startup_gfx2hlsl_watch_check.pyfailed (operand refusal .fail: got operand '-v30', want... in v_and_b32_e64). Reverted withgit checkout -- ..Nits (non-blocking)
tools/startup/gfx2hlsl.py(translation loop, ~line 1483): the instruction is only recorded whenrefusals is None. That is the path that reaches.fail, so it is fine today. If another caller later surfaces a refusal from therefusalslist path, it will have no suffix.translate_onesuffix uses the last traceback frame. If the error is raised inside a stdlib helper, the location points there rather than at gfx2hlsl. Acceptable, but the last frame ingfx2hlsl.pycould be more useful.startup_gfx2hlsl_watch_check\.py, which breaks if the file is renamed. Harmless.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T13:51:11Z.
Four mutations, all caught — and the two-part structure is the right one
text += ' in %s' % reason.instructionremovedstartswith('operand ')condition replaced withif Falsereason.instruction = namereplaced withpassThe fourth is the one I would have expected to slip: a diagnostic suffix is the easiest thing to leave unpinned, because nothing fails when it is missing —
the
.failfile still exists and still has text. Your check distinguishes it, so the location is part of the contract rather than a nicety.Two things worth writing down while the diff is small
1. The
.failtext is now a grouping key, and it gained a moving part. The docstring says grouped reasons point at the fault, which is the point of thechange — but
(in <function>, <basename> line <n>)makes the key depend on a line number. Reordering unrelated code ingfx2hlsl.py— a comment, an import —changes every grouped key for that site, so a census taken before and after a refactor will not compare. If the census is meant to survive that, consider
(in <function>, <basename>)without the line, or put the line in a second field. I am not asking for it in this PR; I am noting it because the moment theformat is consumed by a report is the moment it becomes expensive to change.
2.
reason.instruction = nameattaches an attribute to the exception underif not hasattr(...). Setting an attribute onUnsupportedsurvivesre-raising only while the same object travels; anything that reconstructs the exception (
raise Unsupported(str(e)), which thehandler_errorpath or aretry wrapper could do) drops it, and then
fail_reason()silently returns the old one-line text. The check would still pass, since it exercises the pathwhere the attribute is present. Worth a sentence in the docstring if that is acceptable, or a fallback that keeps the reason usable when the attribute is
gone.
Neither is a blocker and neither is a P1/P2 — the behaviour the PR adds is correct and pinned. I would just rather read those two sentences here than infer them
later from a census diff.
AI-assisted; the check and the four mutations above were run locally on Windows 11 build 26300.9974.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-25T14:04:15Z.
Thanks, both of you. Pushed
e255825f.json.loadsand must be located at its caller. With the old last-frame rule that case fails (library error located at its caller: got False).__file__.refusals is Nonepath reaches a.fail; if another caller starts reporting from therefusalslist, recording the instruction there belongs with that change..failtext today.--refusalscounts the exception message, which this PR leaves unchanged, andtriage_run.classify_shader_reasonmatches the first line by pattern without copying it. Our comment overstated that, so it now says the location is for reading, not a stable key. If a report ever groups by this text, dropping the line there is the right call.fail_reason's docstring now says the instruction is an attribute on the exception, so a refusal raised outside the loop or rebuilt on the way gives the message alone, which is what.failsaid before this PR. The one rebuild I found, inComputePipeline.__init__, wraps a thread-groupValueErrorbefore any instruction runs.Commands on
e255825f(Windows 11 26200):python -B tests/startup_gfx2hlsl_watch_check.py: passedctest --preset dev --no-tests=error -j 8 -R 'gfx2hlsl|pixel_aot_check|rdna2_tools|compute|translator|startup_run|triage|scan_unsupported|lint|style|bidi|docs' -E '_hardware$|startup_audio_': 198 passed, 1 skipped (startup_run_sh, a shell script)python -B tests/docs_links_check.py: 18 files, 451 linksgit diff --check: cleanStill open: nothing from this PR.
AI-assisted: written with Claude Code; the commands above were run locally.