shader: add deterministic corpus report #1032

Merged
lambirou merged 2 commits from upstream-pr/1039 into main 2026-11-23 23:29:43 +00:00
lambirou commented 2026-11-23 22:29:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-23T22:29:20Z.


Change

Add tools/shader_corpus_report.py, a deterministic offline report over the existing shader
archive framing, plus a synthetic-frame test registered in the Linux Python job.

The report separates and labels:

  • a record: one accepted named DEFLATE/DXBC occurrence;
  • a program: one distinct SHA-256 of the complete decoded DXBC container;
  • a stream: one distinct native-code SHA-256 within one stage;
  • a cache program: one decoded PS/9 cache entry, kept as a separate population.

All nine known stages are always present, including zero rows, and unknown stage kinds are listed
separately. JSON and Markdown include record/program/stream counts, native bytes, code dwords,
rejections by reason, optional decode results and the top unsupported forms. Without a decoder,
decode.status is not_run and no LLVM is required.

The native-code path now calls extract_native_rdna2_code directly. None still means absent
or refused native code, but an unexpected exception propagates to main, which prints a
diagnostic and exits 1 without writing a report.

Verification

  • out\pe-env\Scripts\python.exe -B tests\shader_corpus_report_check.py
    • Observed: Ran 8 tests ... OK, exit 0.
  • Positive fixture: 5 records, 4 programs, 3 streams; pixel 3/2/1, compute 1/1/1,
    vertex 1/1/1; six stages at zero. The injected form v_foo_f32_e32 blocks one stream and
    three records.
  • Negative control: a truncated container increments container_framing while accepted counts
    stay unchanged; a repeated run is byte-identical. An empty archive exits 1 without a report.
  • Unexpected extractor failure: a patched extract_native_rdna2_code raises, and the report
    raises instead of counting a record without native code. A patched build_document in
    main returns 1 with the diagnostic and writes no output.
  • The test rejects absolute paths and record names in both outputs, and checks one final newline.
  • Two CLI runs on the synthetic fixture are byte-identical:
    • report.json: 3,902 bytes, SHA-256 6787ec4ebc502875dfb68f982a700e972f0ca856e23ecc21a605546b9e6de4a3
    • report.md: 1,133 bytes, SHA-256 b79e17581050f8dbe51682bb18dafd9b4fa86ce67c41d7b0c2bbc7e986f22547
  • out\pe-env\Scripts\python.exe -B tests\docs_links_check.py: Self-test passed.,
    Checked 13 Markdown files and 229 links., exit 0.
  • git diff --check origin/main...HEAD: clean.
  • Tests not run: LLVM decoding, HLSL translation, DXC validation, GPU, CMake and CTest. No real
    archive was used; every input is synthetic.

Evidence and follow-up

  • Branch shader/corpus-report, head 8285b10, based on a4e7651. Two commits:
    0e32626 adds the report and fixture; 8285b10 addresses the review by removing the broad
    exception conversion and registering the check.
  • The envelope is xbox2windows.report/1, with generated_by, inputs,
    sections.shader_corpus and attachments: []. This is the same envelope used by the XCL-01
    report; the tools share a JSON contract, not Python imports.
  • The parser reuses resource_inventory.scene_records and
    extract_shaders.extract_native_rdna2_code; the cache population reuses
    shader_census.cache_index. Acceptance rules are not forked.
  • The check is registered in the existing Linux Python job and the AGENTS list.
  • Provenance: no XCL code, table or output was copied or used. The report shape follows the
    Xbox2Windows backlog and the XCL-01 envelope contract.
  • Follow-up: expose the decoder over the existing LLVM/translator path, record translated modules
    and validation failures, and attach the XCL-01 import-routing section as an optional opaque
    fragment. Records that need the bounded FSSM span or the two-output rule from
    pixel_aot.container_code currently appear in records_without_native; this is visible in
    the report and is the next extraction follow-up.
  • The diff is larger than the 400-line guide because the test builds the archive, DXBC, DXIL and
    native-code framing from bytes. It remains one behavior. README and docs are untouched.
  • No game files, dumps, shader bytes, title paths or secrets are included.

Checklist

  • One reviewable behavior: deterministic shader corpus report.
  • Positive test, truncated-container control and unexpected-failure control.
  • Linux Python job and AGENTS list updated.
  • No public capability claim without a fixture.
  • No game files, dumps, logs or secrets.
  • Provenance checked; no XCL code used.
  • AI-assisted (Codex).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6570144243 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1039). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-23T22:29:20Z. --- ## Change Add `tools/shader_corpus_report.py`, a deterministic offline report over the existing shader archive framing, plus a synthetic-frame test registered in the Linux Python job. The report separates and labels: - a **record**: one accepted named DEFLATE/DXBC occurrence; - a **program**: one distinct SHA-256 of the complete decoded DXBC container; - a **stream**: one distinct native-code SHA-256 within one stage; - a **cache program**: one decoded PS/9 cache entry, kept as a separate population. All nine known stages are always present, including zero rows, and unknown stage kinds are listed separately. JSON and Markdown include record/program/stream counts, native bytes, code dwords, rejections by reason, optional decode results and the top unsupported forms. Without a decoder, `decode.status` is `not_run` and no LLVM is required. The native-code path now calls `extract_native_rdna2_code` directly. `None` still means absent or refused native code, but an unexpected exception propagates to `main`, which prints a diagnostic and exits 1 without writing a report. ## Verification - `out\pe-env\Scripts\python.exe -B tests\shader_corpus_report_check.py` - Observed: `Ran 8 tests ... OK`, exit 0. - Positive fixture: 5 records, 4 programs, 3 streams; pixel `3/2/1`, compute `1/1/1`, vertex `1/1/1`; six stages at zero. The injected form `v_foo_f32_e32` blocks one stream and three records. - Negative control: a truncated container increments `container_framing` while accepted counts stay unchanged; a repeated run is byte-identical. An empty archive exits 1 without a report. - Unexpected extractor failure: a patched `extract_native_rdna2_code` raises, and the report raises instead of counting a record without native code. A patched `build_document` in `main` returns 1 with the diagnostic and writes no output. - The test rejects absolute paths and record names in both outputs, and checks one final newline. - Two CLI runs on the synthetic fixture are byte-identical: - `report.json`: 3,902 bytes, SHA-256 `6787ec4ebc502875dfb68f982a700e972f0ca856e23ecc21a605546b9e6de4a3` - `report.md`: 1,133 bytes, SHA-256 `b79e17581050f8dbe51682bb18dafd9b4fa86ce67c41d7b0c2bbc7e986f22547` - `out\pe-env\Scripts\python.exe -B tests\docs_links_check.py`: `Self-test passed.`, `Checked 13 Markdown files and 229 links.`, exit 0. - `git diff --check origin/main...HEAD`: clean. - Tests not run: LLVM decoding, HLSL translation, DXC validation, GPU, CMake and CTest. No real archive was used; every input is synthetic. ## Evidence and follow-up - Branch `shader/corpus-report`, head `8285b10`, based on `a4e7651`. Two commits: `0e32626` adds the report and fixture; `8285b10` addresses the review by removing the broad exception conversion and registering the check. - The envelope is `xbox2windows.report/1`, with `generated_by`, `inputs`, `sections.shader_corpus` and `attachments: []`. This is the same envelope used by the XCL-01 report; the tools share a JSON contract, not Python imports. - The parser reuses `resource_inventory.scene_records` and `extract_shaders.extract_native_rdna2_code`; the cache population reuses `shader_census.cache_index`. Acceptance rules are not forked. - The check is registered in the existing Linux Python job and the AGENTS list. - Provenance: no XCL code, table or output was copied or used. The report shape follows the Xbox2Windows backlog and the XCL-01 envelope contract. - Follow-up: expose the decoder over the existing LLVM/translator path, record translated modules and validation failures, and attach the XCL-01 import-routing section as an optional opaque fragment. Records that need the bounded FSSM span or the two-output rule from `pixel_aot.container_code` currently appear in `records_without_native`; this is visible in the report and is the next extraction follow-up. - The diff is larger than the 400-line guide because the test builds the archive, DXBC, DXIL and native-code framing from bytes. It remains one behavior. README and docs are untouched. - No game files, dumps, shader bytes, title paths or secrets are included. ## Checklist - [x] One reviewable behavior: deterministic shader corpus report. - [x] Positive test, truncated-container control and unexpected-failure control. - [x] Linux Python job and AGENTS list updated. - [x] No public capability claim without a fixture. - [x] No game files, dumps, logs or secrets. - [x] Provenance checked; no XCL code used. - [x] AI-assisted (Codex).
upstream-sync closed this pull request 2026-11-24 06:45:58 +00:00
R0Y00 commented 2026-11-24 06:49:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:35:32Z.


The record / full-container / native-stream split and decode.status=not_run are useful. Please register the synthetic test in the existing Linux Python job in this PR. Also remove the broad exception-to-no-native conversion around extract_native_rdna2_code: the existing parser already returns None for absent/refused native code. An unexpected exception should fail the report with a diagnostic rather than silently count as a record without native code. Keep the 5/4/3 and truncated-container controls.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115944831 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1039#issuecomment-7115944831). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T22:35:32Z. --- The record / full-container / native-stream split and `decode.status=not_run` are useful. Please register the synthetic test in the existing Linux Python job in this PR. Also remove the broad exception-to-no-native conversion around `extract_native_rdna2_code`: the existing parser already returns None for absent/refused native code. An unexpected exception should fail the report with a diagnostic rather than silently count as a record without native code. Keep the 5/4/3 and truncated-container controls.
lambirou commented 2026-11-24 06:49:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-23T22:53:41Z.


Addressed in c63eb83. The broad exception-to-no-native conversion is removed: extract_native_rdna2_code is called directly, None still means absent or refused native code, and an unexpected exception now propagates out of build_document. main prints "shader corpus: unexpected failure: : " and returns 1 without writing a report. Added the propagation and main-diagnostic tests (8 tests total); the 5/4/3 and truncated-container controls are unchanged. The check is registered in the Linux Python job and the AGENTS list.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7116306853 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1039#issuecomment-7116306853). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-23T22:53:41Z. --- Addressed in c63eb83. The broad exception-to-no-native conversion is removed: extract_native_rdna2_code is called directly, None still means absent or refused native code, and an unexpected exception now propagates out of build_document. main prints "shader corpus: unexpected failure: <type>: <message>" and returns 1 without writing a report. Added the propagation and main-diagnostic tests (8 tests total); the 5/4/3 and truncated-container controls are unchanged. The check is registered in the Linux Python job and the AGENTS list.
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!1032
No description provided.