shader: inventory candidate programs for a named SGD5 effect #315

Manually merged
github merged 2 commits from gh-pr/315/head into gh-pr/315/base 2026-11-26 21:42:24 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-21 21:49 UTC · original
Vonsek:codex/material-effect-evidence → main · +354 −0 · 6 files · 2 commits · merged 2026-11-21 21:59 UTC

Change

Fixes #307. Given an independently located SGD5 group, its program-array offset, and one named effect record, report each referenced program in stored order. The JSON includes the stored group, group-local index, program name, DXIL shader kind and decoded-container SHA-256. Repeated names can identify different containers. The stored VS group can include a mesh shader.

Verification

Tested on Windows with Python 3.12.10 at a08f34d9b8d3aa15642d151c038156f6f3bfd9e1.

  • python -B tests/sgd5_effects_check.py -v passed both test methods. The CLI test initially failed because the command was missing. A subsequent regression claimed a second effect while the selected record occupied the entire remaining group. It was accepted before the count check accounted for the selected span and rejected afterward.
  • cmake --fresh --preset dev -DINTAKE_PYTHON=<worktree-python> and ctest --preset dev --no-tests=error -R "^(sgd5_effect_candidates|docs_links)$" -V passed. The documentation check covered 67 links in 10 files.
  • python -B tools/sgd5_effects.py archive.bin EFFECT --group GROUP_START GROUP_END --arrays ARRAY_OFFSET --record EFFECT_START EFFECT_END on two independently located local effects reported 5 and 81 candidates, including 2 and 41 pixel candidates respectively. All pixel ordinals and container digests agreed with a separate decode.

Evidence and follow-up

The tests generate their SGD5 records, raw-DEFLATE wrappers and minimal DXBC/DXIL headers from repository-licensed Python source. Controls cover duplicate names across and within groups, reversed candidate order, neighboring records, an out-of-group index, truncated framing and a byte budget verified before payload access. An instrumented reader limits individual reads to seven bytes and rejects reads from an unselected compressed payload.

Effect bounds and the table offset come from the caller. The parser treats the intervening technique/state bytes as opaque. Determining which candidate a draw selects still requires pass-selection evidence. README entry · CLI and sample measurements · Public SGD5 program table · Related SGD2 effect layout

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.

AI-assisted contribution.

**@⁠Vonsek** on GitHub · 2026-11-21 21:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/315) `Vonsek:codex/material-effect-evidence` → `main` · +354 −0 · 6 files · 2 commits · merged 2026-11-21 21:59 UTC ## Change Fixes #307. Given an independently located SGD5 group, its program-array offset, and one named effect record, report each referenced program in stored order. The JSON includes the stored group, group-local index, program name, DXIL shader kind and decoded-container SHA-256. Repeated names can identify different containers. The stored VS group can include a mesh shader. ## Verification Tested on Windows with Python 3.12.10 at `a08f34d9b8d3aa15642d151c038156f6f3bfd9e1`. - `python -B tests/sgd5_effects_check.py -v` passed both test methods. The CLI test initially failed because the command was missing. A subsequent regression claimed a second effect while the selected record occupied the entire remaining group. It was accepted before the count check accounted for the selected span and rejected afterward. - `cmake --fresh --preset dev -DINTAKE_PYTHON=<worktree-python>` and `ctest --preset dev --no-tests=error -R "^(sgd5_effect_candidates|docs_links)$" -V` passed. The documentation check covered 67 links in 10 files. - `python -B tools/sgd5_effects.py archive.bin EFFECT --group GROUP_START GROUP_END --arrays ARRAY_OFFSET --record EFFECT_START EFFECT_END` on two independently located local effects reported 5 and 81 candidates, including 2 and 41 pixel candidates respectively. All pixel ordinals and container digests agreed with a separate decode. ## Evidence and follow-up The tests generate their SGD5 records, raw-DEFLATE wrappers and minimal DXBC/DXIL headers from repository-licensed Python source. Controls cover duplicate names across and within groups, reversed candidate order, neighboring records, an out-of-group index, truncated framing and a byte budget verified before payload access. An instrumented reader limits individual reads to seven bytes and rejects reads from an unselected compressed payload. Effect bounds and the table offset come from the caller. The parser treats the intervening technique/state bytes as opaque. Determining which candidate a draw selects still requires pass-selection evidence. [README entry](https://github.com/Vonsek/Xbox2Windows/blob/a08f34d9b8d3aa15642d151c038156f6f3bfd9e1/README.md#choose-an-experiment) · [CLI and sample measurements](https://github.com/Vonsek/Xbox2Windows/blob/a08f34d9b8d3aa15642d151c038156f6f3bfd9e1/docs/experiments.md#candidate-programs-for-a-named-sgd5-effect) · [Public SGD5 program table](https://github.com/rpatty-dev/PercyStar/blob/1b710c5349ef1911d94092f19173e9813dfb300c/src/sgd5.rs#L208-L238) · [Related SGD2 effect layout](https://github.com/Kalmarv/rage-engine-formats/blob/91e5abb68476709fac80f256bc64f928c6fc2d19/src/sgd2.rs#L20-L32) ## 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. AI-assisted contribution.
The same program name can occur in several groups. Resolve the effect's stage-local indices so a contributor can compare candidate identities while keeping runtime pass selection an open question.
A program can end before its enclosing part. Check its declared payload and word extents independently while retaining the full container digest and support for console payloads.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:42:22 +00:00
github manually merged commit dc21141ee0 into gh-pr/315/base 2026-11-26 21:42:24 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 21:49 UTC · original · edited 2026-11-21 21:54 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T21:54:55.551670Z a08f34d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 21:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/315#issuecomment-7069749914) · edited 2026-11-21 21:54 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"a08f34d9b8d3aa15642d151c038156f6f3bfd9e1","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T21:54:55.551670Z">2026-11-21T21:54:55.551670Z</relative-time> | `a08f34d` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 21:54 UTC · original

P2 Badge Allow DXIL parts to extend beyond the declared program

For a DXIL part containing trailing padding or extension data after the program's declared SizeInUint32 extent, this equality check rejects the candidate and aborts the entire effect inventory. The existing resource_inventory.dxil_program and dxil_retarget.unpack_dxil_program validators allow 4 * words <= len(program). Appending four bytes to the synthetic DXIL part while updating its part/container extents is accepted by both shared validators but rejected here. Validate that the declared program fits inside the part rather than requiring it to occupy the whole part.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 21:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/315#discussion_r4655179478) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Allow DXIL parts to extend beyond the declared program** For a DXIL part containing trailing padding or extension data after the program's declared `SizeInUint32` extent, this equality check rejects the candidate and aborts the entire effect inventory. The existing `resource_inventory.dxil_program` and `dxil_retarget.unpack_dxil_program` validators allow `4 * words <= len(program)`. Appending four bytes to the synthetic DXIL part while updating its part/container extents is accepted by both shared validators but rejected here. Validate that the declared program fits inside the part rather than requiring it to occupy the whole part. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠Vonsek on GitHub · 2026-11-21 21:56 UTC · original

Reproduced on a08f34d with an eight-word program inside a nine-word DXIL part. Both resource_inventory.dxil_program and dxil_retarget.unpack_dxil_program accepted it while the effect inventory rejected it. Commit dc21141 checks the payload end against the declared program end and the program end against the part end. The padded case now retains its full-container digest. Declaring seven words truncates the payload and ten words overruns the part; both are rejected. The two local effect runs still report 5 and 81 candidates, including 2 and 41 pixel programs with independently matching digests. Their framed payloads use a different signature from desktop LLVM bitcode, so the inventory validates their extents without requiring that signature. Direct Python (three tests) and the focused CTest run passed.

**@⁠Vonsek** on GitHub · 2026-11-21 21:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/315#discussion_r4655189750) Reproduced on a08f34d with an eight-word program inside a nine-word DXIL part. Both resource_inventory.dxil_program and dxil_retarget.unpack_dxil_program accepted it while the effect inventory rejected it. Commit dc21141 checks the payload end against the declared program end and the program end against the part end. The padded case now retains its full-container digest. Declaring seven words truncates the payload and ten words overruns the part; both are rejected. The two local effect runs still report 5 and 81 candidates, including 2 and 41 pixel programs with independently matching digests. Their framed payloads use a different signature from desktop LLVM bitcode, so the inventory validates their extents without requiring that signature. Direct Python (three tests) and the focused CTest run passed.
Author
Owner

@⁠Vonsek on GitHub · 2026-11-21 22:00 UTC · original

@⁠codex review

Please recheck dc21141ee0, including the padded DXIL part and its two adjacent size controls. All three CI jobs passed.

**@⁠Vonsek** on GitHub · 2026-11-21 22:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/315#issuecomment-7069871687) @⁠codex review Please recheck dc21141ee0567c25745439a6c0840a3c1b1d572e, including the padded DXIL part and its two adjacent size controls. All three CI jobs passed.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 21:54 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a08f34d9b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 21:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/315#pullrequestreview-6008446659) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `a08f34d9b8` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
This discussion has been locked. Commenting is limited to contributors.
No description provided.