shader: name where a gfx2hlsl translation failed in its .fail #2356

Merged
pigalot merged 2 commits from upstream-pr/2364 into main 2026-11-25 14:18:54 +00:00
pigalot commented 2026-11-25 13:40:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-25T13:40:51Z.


Change

Two kinds of .fail reason don't say where to look:

  • An unexpected translator error (translator error: TypeError: ...) now ends with the function, file name and line that raised it, for example (in scalar_select, gfx2hlsl.py line 1234).
  • An operand refusal (operand '-v30') doesn't say which lowering refused it. The translation loop now records the instruction on the refusal, and the graphics and compute .fail writers append it: operand '-v30' in v_and_b32_e64.

The exception message itself is unchanged, so Pipeline, --refusals and anything else that groups refusals by message see the same text as before. Only the .fail file and the translate_to result 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.
  • Negative control: with tools/startup/gfx2hlsl.py reverted, python -B tests/startup_gfx2hlsl_watch_check.py fails.
  • The _hardware variants were not run on this branch.

Evidence and follow-up

tests/startup_gfx2hlsl_watch_check.py gains two cases, built in the test from source text: the existing injected ZeroDivisionError now checks the location, and a synthetic graphics pair whose pixel shader uses -v30 on v_and_b32_e64 checks that translate_to and .fail name the instruction while Pipeline still raises operand '-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.md describes the new suffixes; docs/experiments.md notes that the census reason omits them.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

This change was AI-assisted: written with Claude Code, and the checks above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6605810190 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2364). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-25T13:40:51Z. --- ## Change Two kinds of `.fail` reason don't say where to look: - An unexpected translator error (`translator error: TypeError: ...`) now ends with the function, file name and line that raised it, for example `(in scalar_select, gfx2hlsl.py line 1234)`. - An operand refusal (`operand '-v30'`) doesn't say which lowering refused it. The translation loop now records the instruction on the refusal, and the graphics and compute `.fail` writers append it: `operand '-v30' in v_and_b32_e64`. The exception message itself is unchanged, so `Pipeline`, `--refusals` and anything else that groups refusals by message see the same text as before. Only the `.fail` file and the `translate_to` result 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. - Negative control: with `tools/startup/gfx2hlsl.py` reverted, `python -B tests/startup_gfx2hlsl_watch_check.py` fails. - The `_hardware` variants were not run on this branch. ## Evidence and follow-up `tests/startup_gfx2hlsl_watch_check.py` gains two cases, built in the test from source text: the existing injected `ZeroDivisionError` now checks the location, and a synthetic graphics pair whose pixel shader uses `-v30` on `v_and_b32_e64` checks that `translate_to` and `.fail` name the instruction while `Pipeline` still raises `operand '-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.md` describes the new suffixes; `docs/experiments.md` notes that the census reason omits them. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. This change was AI-assisted: written with Claude Code, and the checks above were run locally.
tedin7 commented 2026-11-25 14:05:03 +00:00 (Migrated from github.com)

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

  • .fail writers in translate_to and translate_compute both go through the new fail_reason(). The exception text is untouched, so Pipeline and --refusals grouping see the same message (the new test asserts this).
  • triage_run.classify_shader_reason matches operand\b at the start of the first line and never copies the text, so the added in <instr> suffix and the (in fn, file line N) suffix do not split its buckets.
  • CI on this head: Linux checks, Windows build/test and gfx1013 fixtures pass. Mergeable. Title and body are neutral.
  • No shader or HLSL output changes (only .fail text), so no Windows GPU run was needed.

Commands run locally (Linux, on the PR head)

  • python3 -B tests/startup_gfx2hlsl_watch_check.py: passed
  • python3 -B tests/startup_gfx2hlsl_refusals_check.py: passed
  • python3 -B tests/startup_triage_run_check.py: 0 failed
  • python3 tests/docs_links_check.py: 18 files, 451 links, passed
  • python3 tests/bidi_controls_check.py: passed
  • git diff --check origin/main...HEAD: clean
  • Mutation: removed the text += ' in %s' % reason.instruction line in fail_reason. startup_gfx2hlsl_watch_check.py failed (operand refusal .fail: got operand '-v30', want ... in v_and_b32_e64). Reverted with git checkout -- ..

Nits (non-blocking)

  • tools/startup/gfx2hlsl.py (translation loop, ~line 1483): the instruction is only recorded when refusals is None. That is the path that reaches .fail, so it is fine today. If another caller later surfaces a refusal from the refusals list path, it will have no suffix.
  • translate_one suffix 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 in gfx2hlsl.py could be more useful.
  • The translator-error test regex pins startup_gfx2hlsl_watch_check\.py, which breaks if the file is renamed. Harmless.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6058741713 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2364#pullrequestreview-6058741713). Originally posted by [tedin7](https://github.com/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** - `.fail` writers in `translate_to` and `translate_compute` both go through the new `fail_reason()`. The exception text is untouched, so `Pipeline` and `--refusals` grouping see the same message (the new test asserts this). - `triage_run.classify_shader_reason` matches `operand\b` at the start of the first line and never copies the text, so the added ` in <instr>` suffix and the `(in fn, file line N)` suffix do not split its buckets. - CI on this head: Linux checks, Windows build/test and gfx1013 fixtures pass. Mergeable. Title and body are neutral. - No shader or HLSL output changes (only `.fail` text), so no Windows GPU run was needed. **Commands run locally (Linux, on the PR head)** - `python3 -B tests/startup_gfx2hlsl_watch_check.py`: passed - `python3 -B tests/startup_gfx2hlsl_refusals_check.py`: passed - `python3 -B tests/startup_triage_run_check.py`: 0 failed - `python3 tests/docs_links_check.py`: 18 files, 451 links, passed - `python3 tests/bidi_controls_check.py`: passed - `git diff --check origin/main...HEAD`: clean - Mutation: removed the `text += ' in %s' % reason.instruction` line in `fail_reason`. `startup_gfx2hlsl_watch_check.py` failed (`operand refusal .fail: got operand '-v30'`, want `... in v_and_b32_e64`). Reverted with `git checkout -- .`. **Nits (non-blocking)** - `tools/startup/gfx2hlsl.py` (translation loop, ~line 1483): the instruction is only recorded when `refusals is None`. That is the path that reaches `.fail`, so it is fine today. If another caller later surfaces a refusal from the `refusals` list path, it will have no suffix. - `translate_one` suffix 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 in `gfx2hlsl.py` could be more useful. - The translator-error test regex pins `startup_gfx2hlsl_watch_check\.py`, which breaks if the file is renamed. Harmless. AI-assisted; commands listed were executed locally.
ChazY11 commented 2026-11-25 14:05:13 +00:00 (Migrated from github.com)

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

out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_watch_check.py
translation pass interrupted, retrying: a worker was terminated abruptly
startup_gfx2hlsl_watch_check passed        exit 0
mutation result
text += ' in %s' % reason.instruction removed caught
the startswith('operand ') condition replaced with if False caught
reason.instruction = name replaced with pass caught
the traceback suffix removed caught

The 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 .fail file 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 .fail text 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 the
change — but (in <function>, <basename> line <n>) makes the key depend on a line number. Reordering unrelated code in gfx2hlsl.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 the
format is consumed by a report is the moment it becomes expensive to change.

2. reason.instruction = name attaches an attribute to the exception under if not hasattr(...). Setting an attribute on Unsupported survives
re-raising only while the same object travels; anything that reconstructs the exception (raise Unsupported(str(e)), which the handler_error path or a
retry 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 path
where 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7164384756 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2364#issuecomment-7164384756). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T13:51:11Z. --- ## Four mutations, all caught — and the two-part structure is the right one ```powershell out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_watch_check.py translation pass interrupted, retrying: a worker was terminated abruptly startup_gfx2hlsl_watch_check passed exit 0 ``` | mutation | result | |---|---| | `text += ' in %s' % reason.instruction` removed | **caught** | | the `startswith('operand ')` condition replaced with `if False` | **caught** | | `reason.instruction = name` replaced with `pass` | **caught** | | the traceback suffix removed | **caught** | The 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 `.fail` file 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 `.fail` text 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 the change — but `(in <function>, <basename> line <n>)` makes the key depend on a line number. Reordering unrelated code in `gfx2hlsl.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 the format is consumed by a report is the moment it becomes expensive to change. **2. `reason.instruction = name` attaches an attribute to the exception under `if not hasattr(...)`.** Setting an attribute on `Unsupported` survives re-raising only while the same object travels; anything that reconstructs the exception (`raise Unsupported(str(e))`, which the `handler_error` path or a retry 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 path where 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.
pigalot commented 2026-11-25 14:05:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-25T14:04:15Z.


Thanks, both of you. Pushed e255825f.

  • Library frames (tedin7's second nit): the location now skips standard-library frames and falls back to the last frame. A new case in the watch check raises inside json.loads and must be located at its caller. With the old last-frame rule that case fails (library error located at its caller: got False).
  • Pinned file name (tedin7's third nit): the regex takes the name from __file__.
  • Refusals path (tedin7's first nit): left as is. Only the refusals is None path reaches a .fail; if another caller starts reporting from the refusals list, recording the instruction there belongs with that change.
  • Line number in the key (ChazY11, 1): nothing groups by the full .fail text today. --refusals counts the exception message, which this PR leaves unchanged, and triage_run.classify_shader_reason matches 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.
  • Rebuilt exception (ChazY11, 2): 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 .fail said before this PR. The one rebuild I found, in ComputePipeline.__init__, wraps a thread-group ValueError before any instruction runs.

Commands on e255825f (Windows 11 26200):

  • python -B tests/startup_gfx2hlsl_watch_check.py: passed
  • ctest --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 links
  • git diff --check: clean

Still open: nothing from this PR.

AI-assisted: written with Claude Code; the commands above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7164711137 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2364#issuecomment-7164711137). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-25T14:04:15Z. --- Thanks, both of you. Pushed e255825f. - **Library frames (tedin7's second nit):** the location now skips standard-library frames and falls back to the last frame. A new case in the watch check raises inside `json.loads` and must be located at its caller. With the old last-frame rule that case fails (`library error located at its caller: got False`). - **Pinned file name (tedin7's third nit):** the regex takes the name from `__file__`. - **Refusals path (tedin7's first nit):** left as is. Only the `refusals is None` path reaches a `.fail`; if another caller starts reporting from the `refusals` list, recording the instruction there belongs with that change. - **Line number in the key (ChazY11, 1):** nothing groups by the full `.fail` text today. `--refusals` counts the exception message, which this PR leaves unchanged, and `triage_run.classify_shader_reason` matches 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. - **Rebuilt exception (ChazY11, 2):** `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 `.fail` said before this PR. The one rebuild I found, in `ComputePipeline.__init__`, wraps a thread-group `ValueError` before any instruction runs. Commands on e255825f (Windows 11 26200): - `python -B tests/startup_gfx2hlsl_watch_check.py`: passed - `ctest --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 links - `git diff --check`: clean Still open: nothing from this PR. AI-assisted: written with Claude Code; the commands above were run locally.
upstream-sync closed this pull request 2026-11-25 15:01:45 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2356
No description provided.