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

Open
opened 2026-11-27 21:59:37 +00:00 by github-bot · 4 comments
Owner

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

What

crates/victory-backend/src/resources.rs and backend.rs decide how a console texture description becomes host values: Format::block() (texel or 4x4 block sizes), is_integer/is_depth, TextureDesc::d2 defaults, VertexFormat::byte_size, Blend::second_source, and RootArgs appending root constants little-endian and root views padded to an 8-byte boundary before a 64-bit GPU address. None of it has tests, and every one of those rules is a value the GPU host then trusts.

What this pins

  • block sizes for the single-texel formats and for every BC1/2/4/6H/7 variant, signed and sRGB;
  • which formats count as integer and which as depth;
  • TextureDesc::d2 defaults and VertexFormat::byte_size for the formats the title uses;
  • Blend::second_source for the factor/op pairs that read it;
  • RootArgs: constants appended little-endian, an address padded to 8 bytes then appended as a 64-bit little-endian address, and an address on an empty buffer being just the address.

Test-only: no behaviour change, no new dependencies.

How it was tested

  • cargo test -p victory-backend (new unit tests)
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo xtask policy
  • Game run: not needed.
**@⁠AnastasisKon** on GitHub · 2026-11-27 21:57 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/476) ## What `crates/victory-backend/src/resources.rs` and `backend.rs` decide how a console texture description becomes host values: `Format::block()` (texel or 4x4 block sizes), `is_integer`/`is_depth`, `TextureDesc::d2` defaults, `VertexFormat::byte_size`, `Blend::second_source`, and `RootArgs` appending root constants little-endian and root views padded to an 8-byte boundary before a 64-bit GPU address. None of it has tests, and every one of those rules is a value the GPU host then trusts. ## What this pins - block sizes for the single-texel formats and for every BC1/2/4/6H/7 variant, signed and sRGB; - which formats count as integer and which as depth; - `TextureDesc::d2` defaults and `VertexFormat::byte_size` for the formats the title uses; - `Blend::second_source` for the factor/op pairs that read it; - `RootArgs`: constants appended little-endian, an address padded to 8 bytes then appended as a 64-bit little-endian address, and an address on an empty buffer being just the address. Test-only: no behaviour change, no new dependencies. ## How it was tested - `cargo test -p victory-backend` (new unit tests) - `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` - `cargo xtask policy` - Game run: not needed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:59:37 +00:00
Author
Owner

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

/claim

**@⁠AnastasisKon** on GitHub · 2026-11-27 21:58 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/476#issuecomment-7228916119) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-27 21:58 UTC · original

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

**@⁠github-actions[bot]** on GitHub · 2026-11-27 21:58 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/476#issuecomment-7228918459) Claimed by @⁠AnastasisKon. Open a draft pull request with `Refs #476` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 12:44 UTC · original

/release - done without a PR: on branch vibe/backend-value-rules-tests-4f9c68, in my fork's main. The format, vertex-format, blend and root-arg value rules are pinned by format_block_is_one_texel_or_a_4x4_block, format_integer_and_depth_flags, default_color_state_blends_nothing_and_writes_everything and blend_second_source_reads_only_the_src1_factors.

**@⁠AnastasisKon** on GitHub · 2026-11-28 12:44 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/476#issuecomment-7239432472) /release - done without a PR: on branch `vibe/backend-value-rules-tests-4f9c68`, in my fork's `main`. The format, vertex-format, blend and root-arg value rules are pinned by `format_block_is_one_texel_or_a_4x4_block`, `format_integer_and_depth_flags`, `default_color_state_blends_nothing_and_writes_everything` and `blend_second_source_reads_only_the_src1_factors`.
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 12:44 UTC · original

Released. This issue is free to claim.

**@⁠github-actions[bot]** on GitHub · 2026-11-28 12:44 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/476#issuecomment-7239434244) Released. This issue is free to claim.
This discussion has been locked. Commenting is limited to contributors.
No description provided.