Skip to content

TEST-608: resolve stored SGD5 technique passes to shader carve offsets - #3036

Merged
ItsNotRexed merged 4 commits into
ItsNotRexed:mainfrom
jeremygold02:feat/sgd5-effect-passes
Nov 22, 2026
Merged

ItsNotRexed merged 4 commits into
ItsNotRexed:mainfrom
jeremygold02:feat/sgd5-effect-passes

Conversation

@jeremygold02

@jeremygold02 jeremygold02 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Implements TEST-608. Coordination claim

Depends on: #2519 (format research). This tool runs independently on current main.

What it does

python -I tools/sgd5_effects.py <path-to-shaders.rpf> prints aggregate counts for each shader database in the Xbox 1.0.2.1 package. Use --list-effects to discover effect names locally and --effect NAME to list the techniques in each matching effect. Add --effect NAME --technique NAME to get the passes stored under that pair and the exact program references for each pass. You can also enter the material hash exported by rpf9dump with --shader-hash HEX and optionally --technique NAME. Repeated names or colliding hashes return every matching effect.

The reader walks the six program groups, verifies the declared effect count, and reaches each technique count by skipping an 80-byte header and four counted tables with row widths 16, 24, 68, and 36 bytes. From the end of the pass table it walks a counted word array, a marker, two length-prefixed byte blocks and a packed entry table. The following string-pool length leads to the next effect. The final cursor must land on the terminal word and zero padding in each database. The reader validates ordinal ranges, string-pool name offsets, pass counts and one-based selectors. Payloads stay in place. The CLI prints JSON and writes no files.

A program's native record offset and its shader_carve index offset can differ. On this package, 24,795 offsets are equal and 1,708 carve offsets are one byte later. The named lookup returns both. All 26,503 reported carve offsets independently matched the carver's existing scan pattern.

Forward traversal coordination claim

Verification

  • Nine synthetic tests pass without the game. They cover duplicate names, both forms of archive offset, database-local ordinals, empty passes, invalid references, header and string-pool lookalikes inside counted data, malformed post-pass fields, incorrect record counts, truncation, hexadecimal material-hash queries and hash collisions.
  • With LEONIDA_GAME_DIR set, the tenth test reproduces 932 effects, 913 effects with named techniques, 25,037 techniques and 28,798 passes across the two databases. Run python -I tests/test_sgd5_effects.py -v to repeat it.
  • Compared the new traversal with the previously reviewed reader (0029eba) for every effect. All 932 effect starts, string-pool starts and effect ends matched. All 25,037 named technique rows, 28,798 passes and 51,535 program references agreed. Both database terminators were reached from the declared record counts. The opaque fields still have unknown meanings.
  • An independent reader using previously measured table locations agreed on all 213 techniques, 217 passes and 404 program references of three vehicle effects. The offset selector from fix(first-light): select same-stage shader variants by archive offset (BUILD-834) #2893 also selected each of two distinct same-name pixel programs using the offsets returned here.
  • A complete pass through the pinned model decoder recovered 3,175 models from data.rpf. Each of their 3,340 material slots resolved to exactly one native effect (18 distinct hashes). Of those slots, 3,339 have an authored pass with both a vertex/mesh program and a pixel program, and the remaining slot has four compute-only passes. Reproduction and compute-prefix comparison
  • All 27 existing tests/test_shader_carve.py tests pass.

AI-assisted. Tested on Windows 11 (build 26200), Python 3.12.10, on an Intel Core Ultra 7 265K. The package reads and synthetic fixtures ran on the CPU. The workstation has an NVIDIA GeForce RTX 5070 (621.01) and integrated Intel Graphics (32.0.101.9150). Which technique the original executable selects during gameplay remains unverified.

Walk both native databases and resolve effect-local pass selections to the exact shader carve offsets. Include synthetic coverage and an opt-in package census for TEST-608.

Refs: ItsNotRexed#2519, ItsNotRexed#2891
Allow a local package owner to identify both names before querying a stored pass. Expose duplicate effect records and technique rows, including effects with no techniques.

Refs: ItsNotRexed#3036
Accept the shader hash emitted by rpf9dump, retain every matching effect, and expose its techniques and stored passes even when it has no named compute program.

Refs: ItsNotRexed#2519, ItsNotRexed#3036
@Jadiac5

Jadiac5 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 0029eba on Windows 11, Python 3.12.10: pass

  • Real-archive run of the new tool: python -I tools/sgd5_effects.py shaders.rpf on my own copy. Exit code 0, empty stderr, about 4.5 s. Same counts at the two earlier heads 2c04cac and 8c0c6be.
  • The totals in the description are reproduced: 932 effects (910 + 22 over the two databases), 913 with named techniques (891 + 22), 25,037 techniques (23,938 + 1,099), 28,798 passes (27,536 + 1,262).
  • python -I tests/test_sgd5_effects.py with LEONIDA_GAME_DIR set: 7 tests OK, including the package test. Without it: 7 tests, 1 skipped, OK.
  • shader_carve.py on the same archive (run for shader_carve: resume scanning past carved deflate payloads #3025) gives 26,503 shaders, the number the description uses for the carve offsets.
  • Not done: the split of 24,795 equal and 1,708 one-byte-later offsets (not in the default output); the named --effect/--technique lookup; the comparison with an independent reader.

AI-assisted (Claude Code).

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on the PR head: python -I tests/test_sgd5_effects.py -> 6 tests: 5 pass, 1 skip; with LEONIDA_GAME_DIR set, 6/6 pass. test_tool_startup 2/2. Against the real 1.0.2.1 package: 932 effects, 913 named, 25,037 techniques, 28,798 passes; all 26,503 program records resolve into the shader_carve index (24,795 at the same offset, 1,708 at +1 byte, matching the body). Selectors are one-based: 3,094 values equal the effect-list length, 0 are out of range. The three measured records from #2519 reproduce exactly (213 techniques / 217 passes / 404 refs; first-pass ordinals 11017/10943, 9143/8925, 9089/8835). No game data or absolute paths. Approve.

Caveat: the offsets are pinned to 1.0.2.1, and the opt-in game-data test is the only path that exercises the real archive.

rafaelpssz added a commit to rafaelpssz/Leonida that referenced this pull request Nov 22, 2026
… the effect census reproduced

With @jeremygold02's tools/sgd5_effects.py (ItsNotRexed#3036, 0029eba) on the same
shaders.rpf: 932 effect records with distinct name hashes, 913 technique
tables, 25,037 techniques and 28,798 passes, and the data.rpf materials'
18 hashes (3,340 slots) each matching exactly one record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow the post-pass tables through the counted string pool and next record. Check both database terminators and keep opaque payload contents out of structural matching.

Refs: ItsNotRexed#2519, ItsNotRexed#3036
rafaelpssz added a commit to rafaelpssz/Leonida that referenced this pull request Nov 22, 2026
…ItsNotRexed#3036 c043996)

The table-location caveat is gone: tests/test_sgd5_effects.py passes
against this package. The u32 after an effect name stays open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rafaelpssz added a commit to rafaelpssz/Leonida that referenced this pull request Nov 22, 2026
… the effect census reproduced

With @jeremygold02's tools/sgd5_effects.py (ItsNotRexed#3036, 0029eba) on the same
shaders.rpf: 932 effect records with distinct name hashes, 913 technique
tables, 25,037 techniques and 28,798 passes, and the data.rpf materials'
18 hashes (3,340 slots) each matching exactly one record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rafaelpssz added a commit to rafaelpssz/Leonida that referenced this pull request Nov 22, 2026
…ItsNotRexed#3036 c043996)

The table-location caveat is gone: tests/test_sgd5_effects.py passes
against this package. The u32 after an effect name stays open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ItsNotRexed
ItsNotRexed merged commit 26b5272 into ItsNotRexed:main Nov 22, 2026
ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
Record the effect-local fixed-function table mapping and the full-corpus discriminator used for PROC-143.

Refs: #2519, #3036, #3047
@jeremygold02
jeremygold02 deleted the feat/sgd5-effect-passes branch November 22, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants