gpu(native): give B8G8R8A8_UNORM_SRGB a host texture #65

Merged
ShadyUnderLight merged 1 commit from upstream-pr/65 into main 2026-11-26 13:26:49 +00:00
ShadyUnderLight commented 2026-11-26 12:49:45 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ShadyUnderLight on 2026-11-26T12:49:45Z.


Summary

A windowed run that got past the menus named one more texture format the host could not make: DXGI 91, B8G8R8A8_UNORM_SRGB, a 1024x512 sampled texture. Views of it got no host texture, so every draw that sampled it read nothing. This maps it to Metal's BGRA8Unorm_sRGB.

Problem

  • descriptors::format mapped 87 (B8G8R8A8_UNORM) but not 91, its _SRGB sibling, so TextureInfo::desc returned None, Textures::realize refused the texture, and draws that sampled it read nothing.
  • The log line, from a 200 s windowed run at the world load: a title texture format the host does not represent (first of this format) format=91 w=1024 h=512 flags=3145728.
  • It is neither a render target nor a UAV: 0x300000 has none of bits 0, 1 and 2 set.

Fix

  • Add Format::Bgra8UnormSrgb with a 1x4 block; it is not an integer format.
  • Map DXGI 91 to it, and to MTLPixelFormat::BGRA8Unorm_sRGB (the linear-view map already turns that into BGRA8Unorm).
  • Add the row to the format table in docs/native-host.md.

Tests

bgra8_srgb_has_a_host_format fails on main (format(91) is None) and asserts the exact variant and that it is not an integer format. DXGI 91 is added to host_formats_have_the_title_formats_element_size, which compares the host format's block against resource::element.

Verification

  • cargo test -p victory-gpu bgra8_srgb_has_a_host_format — ok.
  • cargo test -p victory-gpu (native arm64) — 146 passed, 0 failed, 1 ignored.
  • cargo test -p victory-metal — 12 passed, 0 failed.
  • cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings — clean.
  • cargo clippy -p victory-gpu -p victory-backend --all-targets -- -D warnings — the only errors are the two pre-existing unnecessary_cast findings in crates/victory-metal/src/present.rs:126,144; the same two appear on unmodified origin/main.
  • cargo xtask policy — asset policy: 365 files ok.

Windowed 200 s runs, same game and machine, one on origin/main and one with this change:

format=91 warning pipeline binds end of run
origin/main (594aa04) present 1923 0xc0000005 at image+0x1d75a9
this branch absent 1803 0xc0000005 at image+0x55e56f8

Both runs reach the world load (about 1900 pipeline binds, 700 compute) and then fault inside title code, at different addresses. A third run, on the same unmodified main, ended in a different failure: kIOGPUCommandBufferCallbackErrorHang. The world load is unstable independently of this change; the mapping removes the missing-format warning and nothing else. No claim is made about the black world: about 200 of the 698 compute pipelines the world load binds are refused (65 of them for an FSPX root type the translator does not handle), so their dispatches are dropped.

Risk

  • Adds one format; sampling applies the sRGB decode as D3D does.
  • Formats the host already mapped are unchanged.

Notes

All English. Found by reading the log of the first windowed run that got past the menus; headless runs never reach this content. No game data in the repo.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6627006969 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/65). Originally posted by [ShadyUnderLight](https://github.com/ShadyUnderLight) on 2026-11-26T12:49:45Z. --- ## Summary A windowed run that got past the menus named one more texture format the host could not make: DXGI 91, `B8G8R8A8_UNORM_SRGB`, a 1024x512 sampled texture. Views of it got no host texture, so every draw that sampled it read nothing. This maps it to Metal's `BGRA8Unorm_sRGB`. ## Problem - `descriptors::format` mapped 87 (`B8G8R8A8_UNORM`) but not 91, its `_SRGB` sibling, so `TextureInfo::desc` returned `None`, `Textures::realize` refused the texture, and draws that sampled it read nothing. - The log line, from a 200 s windowed run at the world load: `a title texture format the host does not represent (first of this format) format=91 w=1024 h=512 flags=3145728`. - It is neither a render target nor a UAV: `0x300000` has none of bits 0, 1 and 2 set. ## Fix - Add `Format::Bgra8UnormSrgb` with a 1x4 block; it is not an integer format. - Map DXGI 91 to it, and to `MTLPixelFormat::BGRA8Unorm_sRGB` (the linear-view map already turns that into `BGRA8Unorm`). - Add the row to the format table in `docs/native-host.md`. ## Tests `bgra8_srgb_has_a_host_format` fails on main (`format(91)` is `None`) and asserts the exact variant and that it is not an integer format. DXGI 91 is added to `host_formats_have_the_title_formats_element_size`, which compares the host format's block against `resource::element`. ## Verification - `cargo test -p victory-gpu bgra8_srgb_has_a_host_format` — ok. - `cargo test -p victory-gpu` (native arm64) — 146 passed, 0 failed, 1 ignored. - `cargo test -p victory-metal` — 12 passed, 0 failed. - `cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings` — clean. - `cargo clippy -p victory-gpu -p victory-backend --all-targets -- -D warnings` — the only errors are the two pre-existing `unnecessary_cast` findings in `crates/victory-metal/src/present.rs:126,144`; the same two appear on unmodified `origin/main`. - `cargo xtask policy` — `asset policy: 365 files ok`. Windowed 200 s runs, same game and machine, one on `origin/main` and one with this change: | | `format=91` warning | pipeline binds | end of run | |---|---|---|---| | `origin/main` (594aa04) | present | 1923 | `0xc0000005 at image+0x1d75a9` | | this branch | **absent** | 1803 | `0xc0000005 at image+0x55e56f8` | Both runs reach the world load (about 1900 pipeline binds, 700 compute) and then fault inside title code, at different addresses. A third run, on the same unmodified main, ended in a different failure: `kIOGPUCommandBufferCallbackErrorHang`. The world load is unstable independently of this change; the mapping removes the missing-format warning and nothing else. No claim is made about the black world: about 200 of the 698 compute pipelines the world load binds are refused (65 of them for an FSPX root type the translator does not handle), so their dispatches are dropped. ## Risk - Adds one format; sampling applies the sRGB decode as D3D does. - Formats the host already mapped are unchanged. ## Notes All English. Found by reading the log of the first windowed run that got past the menus; headless runs never reach this content. No game data in the repo.
LakshanSivakumar commented 2026-11-26 13:26:46 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T13:26:46Z.

Review: APPROVED


Clean mapping for DXGI 91 (B8G8R8A8_UNORM_SRGB) -> Format::Bgra8UnormSrgb -> MTLPixelFormat::BGRA8Unorm_sRGB (with view_without_srgb already mapping BGRA8Unorm_sRGB -> BGRA8Unorm), matching 1x4 block size, unit tests, and docs/native-host.md update. CI is green; merging.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6074929322 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/65#pullrequestreview-6074929322). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T13:26:46Z. **Review:** APPROVED --- Clean mapping for DXGI 91 (`B8G8R8A8_UNORM_SRGB`) -> `Format::Bgra8UnormSrgb` -> `MTLPixelFormat::BGRA8Unorm_sRGB` (with `view_without_srgb` already mapping `BGRA8Unorm_sRGB` -> `BGRA8Unorm`), matching 1x4 block size, unit tests, and `docs/native-host.md` update. CI is green; merging.
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!65
No description provided.