shader: pin unsupported form ranking and decoder result refusals in shader_corpus_report_check #1833

Merged
Asimmimx merged 1 commit from upstream-pr/1840 into main 2026-11-24 20:32:44 +00:00
Asimmimx commented 2026-11-24 19:21:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T19:21:25Z.


Change

tests/shader_corpus_report_check.py gives tools/shader_corpus_report.py a
decoder callback that reports one _e32 form in one stream and always returns
valid counts. The ranking of unsupported forms, the other encoding suffixes and
the refusal of invalid callback results could therefore change without a
failure. I applied 16 single-point mutants to the tool by hand and ran the
existing check after each one. Fifteen survived. This PR adds two tests that
kill 13 of them. The tool is unchanged.

Mutant in tools/shader_corpus_report.py Existing check With the new cases
ranking -blocked_streams -> blocked_streams (ascending) survived killed
ranking -instructions -> instructions (ascending) survived killed
drop the _dpp suffix from _form_parts survived killed
drop the _sdwa suffix from _form_parts survived killed
form token not lowercased survived killed
blank unsupported entry not skipped (continue -> pass) survived killed
form stages sorted alphabetically instead of by stage order survived killed
form_instructions[form] += 1 -> = 1 survived killed
blocked_records counts streams instead of records killed killed
negative instruction count accepted (< 0 -> < -1) survived killed
bool instruction count accepted survived killed
decoded_dwords above the stream's code dwords accepted (<= dwords -> <= dwords + 1) survived killed
callback exceptions caught only as ValueError survived killed
all-failed decode reported as partial instead of failed survived killed
unknown stage kind not counted in unknown_stage_kinds survived survived (not in scope, see below)
decode.streams reported without a decoder survived survived (not in scope, see below)

The new cases use the existing five-record fixture: one pixel stream backing
three records, and one compute and one vertex stream backing one record each.

  • test_unsupported_forms_split_encoding_and_rank returns unsupported text per
    stream: pixel V_ADD_F32_DPP, v_mov_b32_sdwa, s_nop and a blank entry;
    compute v_add_f32_dpp and two v_cmp_eq_u32_e64; vertex v_mov_b32_sdwa.
    The expected rows are:

    1. v_add_f32_dpp (family v_add_f32, dpp), stages pixel then compute,
      2 streams, 3 + 1 = 4 records, 2 instructions. The upper-case pixel entry
      merges with the compute one.
    2. v_mov_b32_sdwa (sdwa), pixel and vertex, 2 streams, 4 records,
      2 instructions. It ties row 1 on streams and instructions and sorts after
      it by name.
    3. v_cmp_eq_u32_e64 (e64), compute, 1 stream, 1 record, 2 instructions.
    4. s_nop (plain), pixel, 1 stream, 3 records, 1 instruction. It ties row
      3 on streams and sorts after it on instructions.

    The blank entry produces no row. The test also checks the first Markdown row.

  • test_invalid_decoder_results_are_failures returns DecodeResult(-1, 2) for
    pixel, DecodeResult(1, 3) for compute (3 decoded dwords from a 2-dword
    stream) and DecodeResult(True, 2) for vertex. All three streams fail, the
    status is failed, the first failures list pixel, vertex and compute in
    stage order with the ValueError text, and no decoded dwords or
    instructions are added. A second callback raises RuntimeError for vertex
    only and gives partial with one RuntimeError: owned callback stop failure
    and 2 + 2 = 4 instructions from the other two streams.

Verification

Based on origin/main at 813045b3c1.
Windows 11 Pro 26300.9974, Python 3.12.10.

> python -B tests/shader_corpus_report_check.py
Ran 10 tests in 0.995s
OK
> python -B tests/docs_links_check.py
Self-test passed.
Checked 18 Markdown files and 369 links.
> python -B tests/bidi_controls_check.py
Self-test passed.
Checked 1320 tracked source, script and build/CI files: no bidirectional controls.

Before this change the check printed Ran 8 tests ... OK. For the negative
control, I ran the check at origin/main and the new check against each
mutant above and recorded the results in the table.

Evidence and follow-up

All inputs are synthetic bytes built in the check. No game files are used.

Two survivors are left for a separate change because they are about other
report fields than the decoder callback:

  • unknown_stage_kinds is never populated by the fixture. A case would need a
    record whose stage kind is outside STAGE_NAMES.
  • The CLI test checks decode.status == "not_run" but not that
    decode.streams is 0 when no decoder is supplied.

The tool is not changed.

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. (No capability or requirement changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589586788 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1840). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T19:21:25Z. --- ## Change `tests/shader_corpus_report_check.py` gives `tools/shader_corpus_report.py` a decoder callback that reports one `_e32` form in one stream and always returns valid counts. The ranking of unsupported forms, the other encoding suffixes and the refusal of invalid callback results could therefore change without a failure. I applied 16 single-point mutants to the tool by hand and ran the existing check after each one. Fifteen survived. This PR adds two tests that kill 13 of them. The tool is unchanged. | Mutant in `tools/shader_corpus_report.py` | Existing check | With the new cases | |---|---|---| | ranking `-blocked_streams` -> `blocked_streams` (ascending) | survived | **killed** | | ranking `-instructions` -> `instructions` (ascending) | survived | **killed** | | drop the `_dpp` suffix from `_form_parts` | survived | **killed** | | drop the `_sdwa` suffix from `_form_parts` | survived | **killed** | | form token not lowercased | survived | **killed** | | blank unsupported entry not skipped (`continue` -> `pass`) | survived | **killed** | | form `stages` sorted alphabetically instead of by stage order | survived | **killed** | | `form_instructions[form] += 1` -> `= 1` | survived | **killed** | | `blocked_records` counts streams instead of records | killed | killed | | negative instruction count accepted (`< 0` -> `< -1`) | survived | **killed** | | `bool` instruction count accepted | survived | **killed** | | `decoded_dwords` above the stream's code dwords accepted (`<= dwords` -> `<= dwords + 1`) | survived | **killed** | | callback exceptions caught only as `ValueError` | survived | **killed** | | all-failed decode reported as `partial` instead of `failed` | survived | **killed** | | unknown stage kind not counted in `unknown_stage_kinds` | survived | survived (not in scope, see below) | | `decode.streams` reported without a decoder | survived | survived (not in scope, see below) | The new cases use the existing five-record fixture: one pixel stream backing three records, and one compute and one vertex stream backing one record each. - `test_unsupported_forms_split_encoding_and_rank` returns unsupported text per stream: pixel `V_ADD_F32_DPP`, `v_mov_b32_sdwa`, `s_nop` and a blank entry; compute `v_add_f32_dpp` and two `v_cmp_eq_u32_e64`; vertex `v_mov_b32_sdwa`. The expected rows are: 1. `v_add_f32_dpp` (family `v_add_f32`, `dpp`), stages pixel then compute, 2 streams, 3 + 1 = 4 records, 2 instructions. The upper-case pixel entry merges with the compute one. 2. `v_mov_b32_sdwa` (`sdwa`), pixel and vertex, 2 streams, 4 records, 2 instructions. It ties row 1 on streams and instructions and sorts after it by name. 3. `v_cmp_eq_u32_e64` (`e64`), compute, 1 stream, 1 record, 2 instructions. 4. `s_nop` (`plain`), pixel, 1 stream, 3 records, 1 instruction. It ties row 3 on streams and sorts after it on instructions. The blank entry produces no row. The test also checks the first Markdown row. - `test_invalid_decoder_results_are_failures` returns `DecodeResult(-1, 2)` for pixel, `DecodeResult(1, 3)` for compute (3 decoded dwords from a 2-dword stream) and `DecodeResult(True, 2)` for vertex. All three streams fail, the status is `failed`, the first failures list pixel, vertex and compute in stage order with the `ValueError` text, and no decoded dwords or instructions are added. A second callback raises `RuntimeError` for vertex only and gives `partial` with one `RuntimeError: owned callback stop` failure and 2 + 2 = 4 instructions from the other two streams. ## Verification Based on `origin/main` at 813045b3c13f7bad20d8577557b621ee869ccbba. Windows 11 Pro 26300.9974, Python 3.12.10. ```text > python -B tests/shader_corpus_report_check.py Ran 10 tests in 0.995s OK > python -B tests/docs_links_check.py Self-test passed. Checked 18 Markdown files and 369 links. > python -B tests/bidi_controls_check.py Self-test passed. Checked 1320 tracked source, script and build/CI files: no bidirectional controls. ``` Before this change the check printed `Ran 8 tests ... OK`. For the negative control, I ran the check at `origin/main` and the new check against each mutant above and recorded the results in the table. ## Evidence and follow-up All inputs are synthetic bytes built in the check. No game files are used. Two survivors are left for a separate change because they are about other report fields than the decoder callback: - `unknown_stage_kinds` is never populated by the fixture. A case would need a record whose stage kind is outside `STAGE_NAMES`. - The CLI test checks `decode.status == "not_run"` but not that `decode.streams` is 0 when no decoder is supplied. The tool is not changed. ## 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. (No capability or requirement changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
tedin7 commented 2026-11-24 20:00:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:35:33Z.

Review: COMMENTED


Reviewed head 6ff393432310143e2ae6b71ee3c1c9b9631e97fe in a clean Linux worktree.

  • git diff --check origin/main...HEAD: clean (rc 0)
  • python -B tests/bidi_controls_check.py: rc 0
  • python -B tests/shader_corpus_report_check.py: rc 0

Local mutations on tools/shader_corpus_report.py (each restored with git checkout -- .). The test failed (rc 1) when I:

  • dropped the decoded_dwords <= dwords bound
  • dropped the negative instructions check
  • dropped the bool rejection
  • removed .lower() on the form name
  • replaced blocked_records with the stream count
  • removed, negated or reordered the secondary and tertiary ranking keys

One mutation survived: swapping the first two ranking keys (instructions before blocked_streams). The fixture rows come out in the same order either way, so the test comment about ranking "by blocked streams, then instructions" is not fully enforced. This is a small coverage gap, not a defect. A row with more instructions but fewer blocked streams would close it.

The new asserts guard real logic: decoder result validation, form merging and encoding split, and ranking. Nothing cosmetic.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046029030 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1840#pullrequestreview-6046029030). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:35:33Z. **Review:** COMMENTED --- Reviewed head `6ff393432310143e2ae6b71ee3c1c9b9631e97fe` in a clean Linux worktree. - `git diff --check origin/main...HEAD`: clean (rc 0) - `python -B tests/bidi_controls_check.py`: rc 0 - `python -B tests/shader_corpus_report_check.py`: rc 0 Local mutations on `tools/shader_corpus_report.py` (each restored with `git checkout -- .`). The test failed (rc 1) when I: - dropped the `decoded_dwords <= dwords` bound - dropped the negative `instructions` check - dropped the bool rejection - removed `.lower()` on the form name - replaced `blocked_records` with the stream count - removed, negated or reordered the secondary and tertiary ranking keys One mutation survived: swapping the first two ranking keys (instructions before blocked_streams). The fixture rows come out in the same order either way, so the test comment about ranking "by blocked streams, then instructions" is not fully enforced. This is a small coverage gap, not a defect. A row with more instructions but fewer blocked streams would close it. The new asserts guard real logic: decoder result validation, form merging and encoding split, and ranking. Nothing cosmetic. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 21:00:54 +00:00
tedin7 commented 2026-11-24 21:00:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:31:12Z.

Review: COMMENTED


Review of head 6ff393432310143e2ae6b71ee3c1c9b9631e97fe (Linux, pure-Python test-only change, no Windows run needed).

No P1, no P2. The new test test_unsupported_forms_split_encoding_and_rank guards real logic in tools/shader_corpus_report.py: decoder result validation, form merging and encoding split, and the ranking.

Commands run:

  • git diff --check origin/main...HEAD: rc=0
  • python3 tests/docs_links_check.py: rc=0
  • python3 tests/bidi_controls_check.py: rc=0
  • python3 -B tests/shader_corpus_report_check.py: rc=0 (OK)

Mutations on tools/shader_corpus_report.py, each restored with git checkout -- .; the test must fail (rc=1) and did:

  • decoded_dwords upper bound dropped (line 177): rc=1
  • negative instructions check dropped (line 174): rc=1
  • secondary ranking key -instructions removed (line 230): rc=1
  • .lower() on the form name removed (line 77): rc=1

Known small gap, as noted in the earlier review: swapping the first two ranking keys is not caught, because the fixture rows come out in the same order. Not a defect.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046895050 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1840#pullrequestreview-6046895050). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T20:31:12Z. **Review:** COMMENTED --- Review of head `6ff393432310143e2ae6b71ee3c1c9b9631e97fe` (Linux, pure-Python test-only change, no Windows run needed). **No P1, no P2.** The new test `test_unsupported_forms_split_encoding_and_rank` guards real logic in tools/shader_corpus_report.py: decoder result validation, form merging and encoding split, and the ranking. Commands run: - `git diff --check origin/main...HEAD`: rc=0 - `python3 tests/docs_links_check.py`: rc=0 - `python3 tests/bidi_controls_check.py`: rc=0 - `python3 -B tests/shader_corpus_report_check.py`: rc=0 (OK) Mutations on tools/shader_corpus_report.py, each restored with `git checkout -- .`; the test must fail (rc=1) and did: - decoded_dwords upper bound dropped (line 177): rc=1 - negative `instructions` check dropped (line 174): rc=1 - secondary ranking key `-instructions` removed (line 230): rc=1 - `.lower()` on the form name removed (line 77): rc=1 Known small gap, as noted in the earlier review: swapping the first two ranking keys is not caught, because the fixture rows come out in the same order. Not a defect. AI-assisted; commands listed were executed locally.
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!1833
No description provided.