native: tell signed from unsigned BC6H #129

Merged
Olima34 merged 1 commit from upstream-pr/129 into main 2026-11-26 18:09:23 +00:00
Olima34 commented 2026-11-26 18:00:05 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T18:00:05Z.


BC6H textures on the native host decoded with the wrong signedness, and the signed format was missing.

Evidence. Tester log #123 (M4 Air, Series S): a title texture format the host does not represent format=96 w=512 h=512 (DXGI 96 = BC6H_SF16). And descriptors.rs mapped DXGI 95 (BC6H_UF16, unsigned) to MTLPixelFormat::BC6H_RGBFloat (150), which is Metal's signed BC6H. Unsigned is BC6H_RGBUfloat (151). Both values are checked in objc2-metal 0.3.2 MTLPixelFormat.rs.

What.

  • The backend's Format::Bc6h is now documented as unsigned (UF16), and a new Bc6hSigned (SF16) is added. Both are 16-byte 4×4 blocks.
  • victory-metal maps Bc6h → BC6H_RGBUfloat and Bc6hSigned → BC6H_RGBFloat.
  • native/descriptors.rs maps 95 → Bc6h and 96 → Bc6hSigned.
  • victory-formats already gives DXGI 94..=99 16-byte blocks, so detiling 96 needs no change. BC6H_TYPELESS (94) stays unmapped, like the other typeless BC formats.

Tests.

  • victory-metal sample_bc6h_unsigned_and_signed: one mode-11 block per format (one region, 10-bit endpoints, untransformed; endpoint 0 = (0x100, 0x300, 0), every index 0), sampled on the GPU.
    • The expected values follow Microsoft's "BC6H Format" decoding rules and DirectXTex's reference decoder (Unquantize, FinishUnquantize), cited in the test: UF16 gives (1807/2^18, 323.75, 0), and SF16 gives (1567/1024, −1567/1024, 0), since 0x300 is −256 in 10-bit two's complement.
    • With the old mapping it fails: Bc6h decodes to [1.5302734, −1.5302734, 0] instead of [0.0068932, 323.75, 0].
  • sample_bc1_and_create_every_bc_format now also creates Bc6hSigned.
  • victory-gpu descriptors::tests::bc6h_keeps_its_signedness checks the 95 and 96 mapping and the element size.

victory-gpu and victory-metal tests (arm64), Windows clippy and cargo xtask policy pass. Not checked in game.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6632437485 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/129). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-26T18:00:05Z. --- BC6H textures on the native host decoded with the wrong signedness, and the signed format was missing. **Evidence.** Tester log #123 (M4 Air, Series S): `a title texture format the host does not represent format=96 w=512 h=512` (DXGI 96 = BC6H_SF16). And `descriptors.rs` mapped DXGI 95 (BC6H_UF16, unsigned) to `MTLPixelFormat::BC6H_RGBFloat` (150), which is Metal's **signed** BC6H. Unsigned is `BC6H_RGBUfloat` (151). Both values are checked in objc2-metal 0.3.2 `MTLPixelFormat.rs`. **What.** - The backend's `Format::Bc6h` is now documented as unsigned (UF16), and a new `Bc6hSigned` (SF16) is added. Both are 16-byte 4×4 blocks. - victory-metal maps `Bc6h` → `BC6H_RGBUfloat` and `Bc6hSigned` → `BC6H_RGBFloat`. - `native/descriptors.rs` maps 95 → `Bc6h` and 96 → `Bc6hSigned`. - victory-formats already gives DXGI 94..=99 16-byte blocks, so detiling 96 needs no change. BC6H_TYPELESS (94) stays unmapped, like the other typeless BC formats. **Tests.** - victory-metal `sample_bc6h_unsigned_and_signed`: one mode-11 block per format (one region, 10-bit endpoints, untransformed; endpoint 0 = (0x100, 0x300, 0), every index 0), sampled on the GPU. - The expected values follow Microsoft's "BC6H Format" decoding rules and DirectXTex's reference decoder (`Unquantize`, `FinishUnquantize`), cited in the test: UF16 gives (1807/2^18, 323.75, 0), and SF16 gives (1567/1024, −1567/1024, 0), since 0x300 is −256 in 10-bit two's complement. - With the old mapping it fails: `Bc6h` decodes to [1.5302734, −1.5302734, 0] instead of [0.0068932, 323.75, 0]. - `sample_bc1_and_create_every_bc_format` now also creates `Bc6hSigned`. - victory-gpu `descriptors::tests::bc6h_keeps_its_signedness` checks the 95 and 96 mapping and the element size. victory-gpu and victory-metal tests (arm64), Windows clippy and `cargo xtask policy` pass. Not checked in game.
LakshanSivakumar commented 2026-11-26 18:10:02 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T18:10:02Z.


Merged, thanks. Unsigned BC6H now decodes correctly, and DXGI 96 maps to the signed format.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7200130416 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/129#issuecomment-7200130416). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T18:10:02Z. --- Merged, thanks. Unsigned BC6H now decodes correctly, and DXGI 96 maps to the signed format.
Sign in to join this conversation.
No reviewers
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!129
No description provided.