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

Open
opened 2026-11-27 21:24:38 +00:00 by AnastasisKon · 5 comments
AnastasisKon commented 2026-11-27 21:24:38 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T21:24:38Z.


What

apps/victory/src/shader.rs's sources() is the entry point behind victory shader and the pre-build: it lists an SGD5 file's packed records (sgd5::records) and every raw DXBC container found by magic whose Container::parse accepts it. It has no tests; the survey/prebuild counts rest on its exact behavior.

What this pins

  • empty / non-shader input yields no sources;
  • a raw DXBC at an offset is found with that offset, and a DXBC magic whose container does not parse (truncated size) is skipped;
  • an SGD5 record found by marker is listed as Source::Packed, its label carries offset and name, bytes() returns None for a corrupt (non-deflate) stream, and a well-formed stored-deflate record unpacks to the container bytes;
  • a file that is SGD5 gets both its packed records and any raw containers in the same scan.

Test-only change: synthetic bytes (hand-built DXBC header, hand-built stored-deflate record), no game data, no new dependencies.

How it was tested

  • cargo test -p victory (new unit tests in apps/victory/src/shader.rs)
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo xtask policy
  • Game run: not needed (test-only).
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6654690690 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/465). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T21:24:38Z. --- ## What `apps/victory/src/shader.rs`'s `sources()` is the entry point behind `victory shader` and the pre-build: it lists an SGD5 file's packed records (`sgd5::records`) and every raw `DXBC` container found by magic whose `Container::parse` accepts it. It has no tests; the survey/prebuild counts rest on its exact behavior. ## What this pins - empty / non-shader input yields no sources; - a raw `DXBC` at an offset is found with that offset, and a `DXBC` magic whose container does not parse (truncated size) is skipped; - an SGD5 record found by marker is listed as `Source::Packed`, its label carries offset and name, `bytes()` returns `None` for a corrupt (non-deflate) stream, and a well-formed stored-deflate record unpacks to the container bytes; - a file that is SGD5 gets both its packed records and any raw containers in the same scan. Test-only change: synthetic bytes (hand-built DXBC header, hand-built stored-deflate record), no game data, no new dependencies. ## How it was tested - `cargo test -p victory` (new unit tests in `apps/victory/src/shader.rs`) - `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` - `cargo xtask policy` - Game run: not needed (test-only).
AnastasisKon commented 2026-11-27 21:24:42 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T21:24:42Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7228419394 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/465#issuecomment-7228419394). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T21:24:42Z. --- /claim
github-actions[bot] commented 2026-11-27 21:24:52 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T21:24:52Z.


Claimed by @AnastasisKon. Open a draft pull request with Refs #465 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7228421911 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/465#issuecomment-7228421911). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T21:24:52Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #465` in its description within 24 hours, or the claim expires.
AnastasisKon commented 2026-11-27 21:38:02 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T21:38:02Z.


Work is up in draft PR #467 (branch vibe/shader-sources-tests-1705ac). Note: a second session of this account opened #468 for the same issue; I closed #468 as a duplicate — #467 covers its cases too.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7228619507 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/465#issuecomment-7228619507). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T21:38:02Z. --- Work is up in draft PR #467 (branch vibe/shader-sources-tests-1705ac). Note: a second session of this account opened #468 for the same issue; I closed #468 as a duplicate — #467 covers its cases too.
AnastasisKon commented 2026-11-28 12:43:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:43:53Z.


/release - done without a PR (upstream is paused, so none was opened): the work is on branch vibe/shader-sources-tests-1705ac and is in my fork's main. input_without_shaders_yields_nothing in apps/victory/src/shader.rs now also checks that the SGD5 magic alone is no record and that a "DXBC" with no header behind it is no container (shader.rs:451-455), and an_sgd5_record_is_listed_and_unpacks_to_its_container (shader.rs:507) covers the record path.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239427587 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/465#issuecomment-7239427587). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:43:53Z. --- /release - done without a PR (upstream is paused, so none was opened): the work is on branch `vibe/shader-sources-tests-1705ac` and is in my fork's `main`. `input_without_shaders_yields_nothing` in `apps/victory/src/shader.rs` now also checks that the SGD5 magic alone is no record and that a "DXBC" with no header behind it is no container (`shader.rs:451-455`), and `an_sgd5_record_is_listed_and_unpacks_to_its_container` (`shader.rs:507`) covers the record path.
github-actions[bot] commented 2026-11-28 12:44:03 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T12:44:03Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239429474 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/465#issuecomment-7239429474). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T12:44:03Z. --- Released. This issue is free to claim.
Sign in to join this conversation.
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
LakshanSivakumar/Native-Victory-macOS#465
No description provided.