victory: pin shader::sources (SGD5 records + raw DXBC scan) with unit tests #472

Closed
github-bot wants to merge 1 commit from github-bot/gh-468 into main AGit
Owner

@⁠AnastasisKon on GitHub · 2026-11-27 21:34 UTC · original
AnastasisKon:vibe/shader-sources-tests-4f9c68 → main · +173 −0 · 1 files · 1 commits · closed without merging

What this changes

Refs #469.

apps/victory/src/shader.rs's sources() is the entry point behind victory shader and the pre-build, and nothing held it in place. Six unit tests over synthetic bytes pin what the survey and pre-build counts rest on:

  • empty and non-shader input has no sources, and the SGD5 magic alone is no record;
  • a container stored as is is found at its offset (@0x4) and bytes() returns those bytes;
  • a magic whose header claims more bytes than the file holds, and a magic with no header behind it, are skipped;
  • a packed record found by marker is listed as Source::Packed, its label carries offset and name (@0x2a PS_main_Wrapped), kind is what the object holds, and bytes() unpacks to the container's bytes;
  • a record whose stream is no deflate is still listed, so a run can report it corrupt, and bytes() is None;
  • an SGD5 file yields both its packed records and the containers stored as is, in that order, the second of which Container::parse accepts.

Test-only: a hand-built 0x20-byte DXBC header and a one-block stored-deflate record. No game data, no new dependencies.

How it was tested

  • cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: all pass (victory 19, victory-hle 327 + native_probe 17, victory-loader 29).
  • cargo test -p victory -p victory-hle -p xtask on the arm64 host: all pass (14 / 144 + 2 / 6).
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: no warnings.
  • cargo xtask policy: 398 files ok.
  • Ran the game: not needed (test-only).

The tests are known to bite: dropping the Container::parse filter in sources() fails a_magic_whose_container_does_not_parse_is_skipped.

cargo test -p victory-gpu on this Mac: 402 passed, 10 failed, every one of them at dlopen /usr/local/lib/libmetalirconverter.dylib (Apple's Metal Shader Converter is not installed here; #382's wrapper fails fast for the same reason). Unrelated to this change, which touches no GPU code.

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md: none added; the record layout the fixtures use is sgd5.rs's documented one
  • New diagnostics are behind a VICTORY_* variable and documented: none added
**@⁠AnastasisKon** on GitHub · 2026-11-27 21:34 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/468) `AnastasisKon:vibe/shader-sources-tests-4f9c68` → `main` · +173 −0 · 1 files · 1 commits · closed without merging ## What this changes Refs #469. `apps/victory/src/shader.rs`'s `sources()` is the entry point behind `victory shader` and the pre-build, and nothing held it in place. Six unit tests over synthetic bytes pin what the survey and pre-build counts rest on: - empty and non-shader input has no sources, and the SGD5 magic alone is no record; - a container stored as is is found at its offset (`@0x4`) and `bytes()` returns those bytes; - a magic whose header claims more bytes than the file holds, and a magic with no header behind it, are skipped; - a packed record found by marker is listed as `Source::Packed`, its label carries offset and name (`@0x2a PS_main_Wrapped`), `kind` is what the object holds, and `bytes()` unpacks to the container's bytes; - a record whose stream is no deflate is still listed, so a run can report it corrupt, and `bytes()` is `None`; - an SGD5 file yields both its packed records and the containers stored as is, in that order, the second of which `Container::parse` accepts. Test-only: a hand-built 0x20-byte DXBC header and a one-block stored-deflate record. No game data, no new dependencies. ## How it was tested - [x] `cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory`: all pass (victory 19, victory-hle 327 + native_probe 17, victory-loader 29). - [x] `cargo test -p victory -p victory-hle -p xtask` on the arm64 host: all pass (14 / 144 + 2 / 6). - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`: no warnings. - [x] `cargo xtask policy`: 398 files ok. - [ ] Ran the game: not needed (test-only). The tests are known to bite: dropping the `Container::parse` filter in `sources()` fails `a_magic_whose_container_does_not_parse_is_skipped`. `cargo test -p victory-gpu` on this Mac: 402 passed, 10 failed, every one of them at `dlopen /usr/local/lib/libmetalirconverter.dylib` (Apple's Metal Shader Converter is not installed here; #382's wrapper fails fast for the same reason). Unrelated to this change, which touches no GPU code. ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md: none added; the record layout the fixtures use is `sgd5.rs`'s documented one - [x] New diagnostics are behind a `VICTORY_*` variable and documented: none added
`sources()` is what `victory shader` and the pre-build count from: an SGD5
file's packed records, plus every raw `DXBC` container whose `Container::parse`
accepts it. Nothing held it in place.

Six tests over synthetic bytes (a hand-built 0x20-byte DXBC header and a
one-block stored-deflate record, no game data): empty and non-shader input has
no sources; a container stored as is is found at its offset and labelled with
it; a magic whose size disagrees with the file, or with no header behind it, is
skipped; a packed record is listed by its offset and name and unpacks to the
container's bytes; a record whose stream is no deflate is still listed for the
corrupt-record report but has no bytes; and an SGD5 file yields its records
first, then the containers stored as is.

Refs #465
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:37:54 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-27 21:37 UTC · original

Duplicate of #471: two sessions of the same account picked up #469 and both opened a PR for it. #471 (branch vibe/shader-sources-tests-1705ac) is the one being kept — it covers the same cases plus the bare-magic ones — so I'm closing this one as superseded. The branch is left untouched; reopen if you'd rather keep this one instead.

**@⁠AnastasisKon** on GitHub · 2026-11-27 21:37 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/468#issuecomment-7228618552) Duplicate of #471: two sessions of the same account picked up #469 and both opened a PR for it. #471 (branch vibe/shader-sources-tests-1705ac) is the one being kept — it covers the same cases plus the bare-magic ones — so I'm closing this one as superseded. The branch is left untouched; reopen if you'd rather keep this one instead.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-27 21:38 UTC · original

Superseded by #471 (same issue #469, same author; one change per issue).

**@⁠AnastasisKon** on GitHub · 2026-11-27 21:38 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/468#issuecomment-7228618863) Superseded by #471 (same issue #469, same author; one change per issue).
github-bot closed this pull request 2026-11-27 21:43:28 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.