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

Manually merged
github merged 1 commit from gh-pr/1529/head into gh-pr/1529/base 2026-11-26 23:14:28 +00:00
Owner

@⁠RenzoWit35 on GitHub · 2026-11-24 13:43 UTC · original
RenzoWit35:tooling/scan-shader-stage-names → main · +47 −8 · 2 files · 1 commits · merged 2026-11-24 14:14 UTC

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.

**@⁠RenzoWit35** on GitHub · 2026-11-24 13:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1529) `RenzoWit35:tooling/scan-shader-stage-names` → `main` · +47 −8 · 2 files · 1 commits · merged 2026-11-24 14:14 UTC ## 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.
detect_shader_stage tested substrings of the lowercased path, so words
such as loops_cs, bumps_vs and tex_cs_ps5 were reported as pixel, and a
relative cs/ directory was missed. Match ps/cs/vs as whole tokens split
on _ . - and the long stage names as whole directory components. When a
path carries tags of several stages, pixel wins over compute over vertex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:14:26 +00:00
github manually merged commit 8045169e74 into gh-pr/1529/base 2026-11-26 23:14:28 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.