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

Open
opened 2026-11-27 21:57:42 +00:00 by AnastasisKon · 4 comments
AnastasisKon commented 2026-11-27 21:57:42 +00:00 (Migrated from github.com)
Contributor

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


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.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6655096377 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/476). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T21:57:42Z. --- ## 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 commented 2026-11-27 21:58:26 +00:00 (Migrated from github.com)
Author
Contributor

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


/claim

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

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


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

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

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


/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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239432472 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/476#issuecomment-7239432472). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:44:19Z. --- /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`.
github-actions[bot] commented 2026-11-28 12:44:28 +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:28Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239434244 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/476#issuecomment-7239434244). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T12:44:28Z. --- 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#476
No description provided.