native: tell signed from unsigned BC6H #129

Manually merged
github merged 1 commit from github-bot/gh-129 into main 2026-11-26 18:09:27 +00:00 AGit
Owner

@⁠Olima34 on GitHub · 2026-11-26 18:00 UTC · original
Olima34:fix/native-bc6h-signedness → main · +65 −2 · 5 files · 1 commits · merged 2026-11-26 18:09 UTC

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.

**@⁠Olima34** on GitHub · 2026-11-26 18:00 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/129) `Olima34:fix/native-bc6h-signedness` → `main` · +65 −2 · 5 files · 1 commits · merged 2026-11-26 18:09 UTC 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.
Metal's BC6H_RGBFloat is the signed BC6H and BC6H_RGBUfloat the
unsigned one. The native host mapped DXGI 95 (BC6H_UF16) to the signed
format, so unsigned BC6H textures decoded with the wrong sign and
scale, and had no format for DXGI 96 (BC6H_SF16), which tester log #123
names ("a title texture format the host does not represent format=96").
Format::Bc6h is now the unsigned format (RGBUfloat) and the new
Format::Bc6hSigned the signed one (RGBFloat); 96 maps to it. A GPU test
samples a mode 11 block whose decoded values differ between the two,
derived from the BC6H decoding rules.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:04:10 +00:00
github manually merged commit 48750d00e3 into main 2026-11-26 18:09:27 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 18:10 UTC · original

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

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 18:10 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/129#issuecomment-7200130416) Merged, thanks. Unsigned BC6H now decodes correctly, and DXGI 96 maps to the signed format.
This discussion has been locked. Commenting is limited to contributors.
No description provided.