tooling: match scan shader stage tags as whole tokens #1522

Merged
RenzoWit35 merged 1 commit from upstream-pr/1529 into main 2026-11-24 14:14:15 +00:00
RenzoWit35 commented 2026-11-24 13:43:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-24T13:43:14Z.


Change

detect_shader_stage in tools/scan_unsupported_shaders.py classified a shader by substring tests on its lowercased path ("ps_" in lower, "_cs" in lower, and so on). Substrings of unrelated words matched, which skews the per-stage breakdown in the scan report. On main:

name main expected
loops_cs.s (contains ps_) pixel compute
shaders/bumps_vs.txt (contains ps_) pixel vertex
tex_cs_ps5.s (contains _ps) pixel compute (see below)
cs/copy.s (directory test needed a leading slash) other compute

The change matches ps, cs and vs only as whole tokens of a path component, where tokens are split on _, . and -. pixel, compute and vertex match only as a whole directory component. Matching stays case insensitive and \ is still read as /. The name shapes that existing tests and callers use keep their classification (shaders/pixel/ps_draw.bin, cs_dispatch.bin, shaders/vertex/vs_main.s, ps_test.bin, unknown_kernel.bin).

Judgement call for the maintainer: when a path carries whole tags of two stages (for example ps_cs_x.s), the first of pixel, compute, vertex wins. That is the order the old code tested, so such names keep their old result. tex_cs_ps5.s is not ambiguous under the token rule: ps5 is a different token from ps, so it classifies as compute. If ps5 should count as a pixel tag, that needs a decision on what the suffix means. I did not find a naming convention for it in the repository and did not invent one.

Behavior changes beyond the four names: a/ps/x.s and ps/x.s now match without a leading slash, and blur.ps.s matches on a . delimiter. Names that only matched through a tag embedded in a word now fall to other or to the stage of their real tag.

Open PRs #1466, #713 and #528 also edit tools/scan_unsupported_shaders.py, in the lowering tables. None of their diffs touches detect_shader_stage, and a test merge of this branch with #1466 is clean.

Verification

Windows 11, Python 3.14.5, base origin/main 1ca0dec1.

python -B tests/rdna2_tools_check.py
  • main plus the new test (original tool file): Ran 141 tests, FAILED (failures=1, skipped=18). The failure is the new test_detect_shader_stage_whole_tokens_only, first assertion loops_cs.s: 'pixel' != 'compute'.
  • With the change: Ran 141 tests, OK (skipped=18).
  • Direct check on main: loops_cs.s pixel, shaders/bumps_vs.txt pixel, tex_cs_ps5.s pixel, cs/copy.s other, blur_cs.s compute.

The 18 skips are the existing LLVM-only tests (no LLVM on this machine). Not run: the other checks in the AGENTS.md list and the C++ and ctest targets; this change touches no lowering or GPU path.

Evidence and follow-up

The new test covers the four misclassified names, controls for each stage (suffix, - and . delimiters, upper case, backslash path, long directory names) and the two-tag precedence rule. docs/experiments.md has no text on stage detection, so no doc change. No game files or dumps; names are synthetic.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6583151560 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1529). Originally posted by [RenzoWit35](https://github.com/RenzoWit35) on 2026-11-24T13:43:14Z. --- ## Change `detect_shader_stage` in `tools/scan_unsupported_shaders.py` classified a shader by substring tests on its lowercased path (`"ps_" in lower`, `"_cs" in lower`, and so on). Substrings of unrelated words matched, which skews the per-stage breakdown in the scan report. On `main`: | name | `main` | expected | |---|---|---| | `loops_cs.s` (contains `ps_`) | pixel | compute | | `shaders/bumps_vs.txt` (contains `ps_`) | pixel | vertex | | `tex_cs_ps5.s` (contains `_ps`) | pixel | compute (see below) | | `cs/copy.s` (directory test needed a leading slash) | other | compute | The change matches `ps`, `cs` and `vs` only as whole tokens of a path component, where tokens are split on `_`, `.` and `-`. `pixel`, `compute` and `vertex` match only as a whole directory component. Matching stays case insensitive and `\` is still read as `/`. The name shapes that existing tests and callers use keep their classification (`shaders/pixel/ps_draw.bin`, `cs_dispatch.bin`, `shaders/vertex/vs_main.s`, `ps_test.bin`, `unknown_kernel.bin`). Judgement call for the maintainer: when a path carries whole tags of two stages (for example `ps_cs_x.s`), the first of pixel, compute, vertex wins. That is the order the old code tested, so such names keep their old result. `tex_cs_ps5.s` is not ambiguous under the token rule: `ps5` is a different token from `ps`, so it classifies as compute. If `ps5` should count as a pixel tag, that needs a decision on what the suffix means. I did not find a naming convention for it in the repository and did not invent one. Behavior changes beyond the four names: `a/ps/x.s` and `ps/x.s` now match without a leading slash, and `blur.ps.s` matches on a `.` delimiter. Names that only matched through a tag embedded in a word now fall to `other` or to the stage of their real tag. Open PRs #1466, #713 and #528 also edit `tools/scan_unsupported_shaders.py`, in the lowering tables. None of their diffs touches `detect_shader_stage`, and a test merge of this branch with #1466 is clean. ## Verification Windows 11, Python 3.14.5, base `origin/main` 1ca0dec1. ``` python -B tests/rdna2_tools_check.py ``` - `main` plus the new test (original tool file): `Ran 141 tests`, `FAILED (failures=1, skipped=18)`. The failure is the new `test_detect_shader_stage_whole_tokens_only`, first assertion `loops_cs.s`: `'pixel' != 'compute'`. - With the change: `Ran 141 tests`, `OK (skipped=18)`. - Direct check on `main`: `loops_cs.s` pixel, `shaders/bumps_vs.txt` pixel, `tex_cs_ps5.s` pixel, `cs/copy.s` other, `blur_cs.s` compute. The 18 skips are the existing LLVM-only tests (no LLVM on this machine). Not run: the other checks in the `AGENTS.md` list and the C++ and ctest targets; this change touches no lowering or GPU path. ## Evidence and follow-up The new test covers the four misclassified names, controls for each stage (suffix, `-` and `.` delimiters, upper case, backslash path, long directory names) and the two-tag precedence rule. `docs/experiments.md` has no text on stage detection, so no doc change. No game files or dumps; names are synthetic. AI-assisted.
upstream-sync closed this pull request 2026-11-24 15:01:52 +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!1522
No description provided.