backend: pin the format/vertex-format/blend/root-args value rules with unit tests #483

Manually merged
github merged 1 commit from github-bot/gh-479 into main 2026-11-28 01:36:52 +00:00 AGit
Owner

@⁠AnastasisKon on GitHub · 2026-11-27 21:59 UTC · original
AnastasisKon:vibe/backend-value-rules-tests-4f9c68 → main · +220 −0 · 3 files · 1 commits · merged 2026-11-28 01:35 UTC

What this changes

Refs #480.

crates/victory-backend/src/resources.rs decides how a console texture description becomes host values, and backend.rs decides the argument-buffer layout of RootArgs. Neither had a single test, and every one of those rules is a value the GPU host then trusts — a block size or a root-view padding that drifts silently changes what the host allocates or appends.

Two new test-only modules, declared under cfg(test) so the build hash is unchanged:

  • backend_tests.rs: root constants appended little-endian; an address padded to the next 8 bytes then appended as a 64-bit little-endian GPU address; an address on an empty buffer being just the address.
  • resources_tests.rs: Format::block() for the single-texel formats and every BC1/2/4/6H/7 variant (signed and sRGB); which formats are integer and which are depth; TextureDesc::d2's defaults; VertexFormat::byte_size; Blend::second_source.

No behaviour change, no new dependencies, no game data.

How it was tested

  • cargo test -p victory-backend: 10 passed, 0 failed (the new modules included).
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: no warnings on this tree, with victory-backend re-checked after touching the new files.
  • cargo xtask policy: 398 files ok.
  • Ran the game: not needed (test-only).

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 tests pin what the code already does
  • New diagnostics are behind a VICTORY_* variable and documented: none added
**@⁠AnastasisKon** on GitHub · 2026-11-27 21:59 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/479) `AnastasisKon:vibe/backend-value-rules-tests-4f9c68` → `main` · +220 −0 · 3 files · 1 commits · merged 2026-11-28 01:35 UTC ## What this changes Refs #480. `crates/victory-backend/src/resources.rs` decides how a console texture description becomes host values, and `backend.rs` decides the argument-buffer layout of `RootArgs`. Neither had a single test, and every one of those rules is a value the GPU host then trusts — a block size or a root-view padding that drifts silently changes what the host allocates or appends. Two new test-only modules, declared under `cfg(test)` so the build hash is unchanged: - `backend_tests.rs`: root constants appended little-endian; an address padded to the next 8 bytes then appended as a 64-bit little-endian GPU address; an address on an empty buffer being just the address. - `resources_tests.rs`: `Format::block()` for the single-texel formats and every BC1/2/4/6H/7 variant (signed and sRGB); which formats are integer and which are depth; `TextureDesc::d2`'s defaults; `VertexFormat::byte_size`; `Blend::second_source`. No behaviour change, no new dependencies, no game data. ## How it was tested - [x] `cargo test -p victory-backend`: 10 passed, 0 failed (the new modules included). - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`: no warnings on this tree, with `victory-backend` re-checked after touching the new files. - [x] `cargo xtask policy`: 398 files ok. - [ ] Ran the game: not needed (test-only). ## 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 tests pin what the code already does - [x] New diagnostics are behind a `VICTORY_*` variable and documented: none added
resources.rs decides how a console texture description becomes host values
(Format::block, is_integer, is_depth, TextureDesc::d2's defaults,
VertexFormat::byte_size, Blend::second_source) and backend.rs decides the
argument-buffer layout of RootArgs; neither had a test, and the GPU host
trusts both. Add backend_tests.rs and resources_tests.rs, declared under
cfg(test) so the build hash is unchanged.

Refs #476
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:59:39 +00:00
github-bot referenced this pull request from a commit 2026-11-28 00:42:29 +00:00
github manually merged commit 40a134c358 into main 2026-11-28 01:36:52 +00:00
Author
Owner

@⁠Olima34 on GitHub · 2026-11-28 01:35 UTC · original · approved these changes

Check report (helping the maintainer clear the queue):

  • CI: check and macos-scripts green on the current head.
  • Read: the whole diff (tests only). It pins the backend's format, vertex-format, blend and root-argument value rules in two new test modules.
  • Local check: current main (226645f9) merged with this PR and the other test/docs/tools PRs we're landing in this batch (#401 #403 #426 #471 #475 #479 #483 #485 #490 #493 #498 #502 #509 #515). On it, the victory-gpu (arm64), victory-shader, victory-backend, victory-metal and victory tests pass, as do the macOS script tests (rustup-path.sh, run-summary-compare.sh, run-summary.sh --self-test), Windows clippy (-D warnings) and cargo xtask policy. One victory-gpu run in four failed main's own multi_mip_array_and_placed_depth_twins_preserve_all_subresources_and_remirror_immediately. That test also flakes on main alone, so it isn't from this batch.
  • Not checked: no game run (the maintainer asked us to work on GitHub only).

Thanks @⁠AnastasisKon!

**@⁠Olima34** on GitHub · 2026-11-28 01:35 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/479#pullrequestreview-6094922095) · **approved these changes** Check report (helping the maintainer clear the queue): - **CI:** `check` and `macos-scripts` green on the current head. - **Read:** the whole diff (tests only). It pins the backend's format, vertex-format, blend and root-argument value rules in two new test modules. - **Local check:** current main (226645f9) merged with this PR and the other test/docs/tools PRs we're landing in this batch (#401 #403 #426 #471 #475 #479 #483 #485 #490 #493 #498 #502 #509 #515). On it, the `victory-gpu` (arm64), `victory-shader`, `victory-backend`, `victory-metal` and `victory` tests pass, as do the macOS script tests (`rustup-path.sh`, `run-summary-compare.sh`, `run-summary.sh --self-test`), Windows clippy (`-D warnings`) and `cargo xtask policy`. One `victory-gpu` run in four failed main's own `multi_mip_array_and_placed_depth_twins_preserve_all_subresources_and_remirror_immediately`. That test also flakes on main alone, so it isn't from this batch. - **Not checked:** no game run (the maintainer asked us to work on GitHub only). Thanks @⁠AnastasisKon!
This discussion has been locked. Commenting is limited to contributors.
No description provided.