fix(gpu/desc): use transparent alpha (0x00) on RGBA neutral stand-ins to prevent smoke billboard gray quads #420

Merged
Androtim merged 1 commit from upstream-pr/420 into main 2026-12-04 04:02:02 +00:00
Androtim commented 2026-12-04 03:15:45 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T03:15:45Z.


Summary

Fixes translucent gray square quads around smoke/particle emitters (e.g., aircraft engine exhaust plumes) on 8 GB GPUs when RGBA billboard textures are evicted or not yet resident and receive a neutral stand-in SRV from neutral_for().

Root Cause

In crates/victory-gpu/src/descriptor/host.rs, standin_texel(false) returned [0x80, 0x80, 0x80, 0x80] (RGB ≈ 0.502, A ≈ 0.502).

  • For alpha-blended smoke / particle / decal / overlay billboards (BC3, BC7, BC2, R8G8B8A8, B8G8R8A8), A ≈ 0.502 renders 50%-opaque gray square quads (and stacked exhaust plume billboards compound to ~99.9% opaque gray blocks).
  • For alpha-tested cutouts (foliage/leaves/fences with clip(alpha - 0.5)), 0x80 / 255 = 0.50196 >= 0.5 passes the alpha test and renders solid gray square cards.
  • In addition, A8_UNORM, R8_TYPELESS, and R9G9B9E5_SHAREDEXP were not yet excluded from gray_fits() alongside R8_UNORM, BC4_*, and R11G11B10_FLOAT/BC6H_*.

Changes

  1. standin_texel(opaque): Default (!VICTORY_STANDIN_OPAQUE) now uses [0x80, 0x80, 0x80, 0x00] (neutral ~0.502 RGB, transparent 0x00 alpha). VICTORY_STANDIN_OPAQUE=1 continues to opt in to [0x80, 0x80, 0x80, 0xff].
  2. format_without_alpha() + standin_component_mapping(): Non-alpha picture/normal formats (BC5_*, R8G8_*, B8G8R8X8_*, B5G6R5_UNORM) force A = 1.0 via D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1 (6792) on the stand-in SRV, matching real D3D12 hardware semantics while keeping RGB = 0x80 (~0.502).
  3. gray_fits(): Exclude A8_UNORM (alpha-only mask), R8_TYPELESS (single-channel typeless counterpart of R8_UNORM), and R9G9B9E5_SHAREDEXP (HDR shared-exponent float) so they stay null (0,0,0,0).
  4. Unit & D3D12 SRV tests: Expanded neutral_standin_rules_and_texel_formats and a_texture_not_there_yet_has_a_neutral_stand_in to cover all format groups and Shader4ComponentMapping behavior.

Format-by-Format Analysis

Format Family Stand-in Behavior Sampled Value (Default) Impact / Safety
BC3 / BC2 / BC7 / R8G8B8A8 / B8G8R8A8 / R10G10B10A2 / R16G16B16A16_UNORM / B5G5R5A1 / B4G4R4A4 Neutral stand-in, default component mapping (0.502, 0.502, 0.502, 0.0) (or A=1.0 with VICTORY_STANDIN_OPAQUE=1) Smoke/particles/decals/overlays: invisible until resident (fixes gray quads). Opaque albedo & YCbCr: RGB stays 0.502 (neutral gray, no neon green; opaque shaders ignore .a). Cutouts: cleanly discarded until resident instead of solid gray cards.
BC1 (UNORM / SRGB / TYPELESS) Neutral stand-in, default component mapping (0.502, 0.502, 0.502, 0.0) Opaque BC1 albedo: .a ignored, RGB stays neutral gray. 1-bit alpha-tested BC1 foliage: discarded cleanly while streaming instead of solid gray cards.
BC5_UNORM / BC5_TYPELESS / R8G8_UNORM / R8G8_TYPELESS Neutral stand-in, Shader4ComponentMapping forces A = 1.0 (0.502, 0.502, 0.502, 1.0) Tangent-space normal maps & YCbCr chroma: R=0.502, G=0.502 produces flat normal (0,0,1) and neutral chroma; A=1.0 matches real D3D12 hardware semantics for 2-channel formats.
B8G8R8X8_* / B5G6R5_UNORM Neutral stand-in, Shader4ComponentMapping forces A = 1.0 (0.502, 0.502, 0.502, 1.0) RGB-only formats with no alpha channel; matches real D3D12 hardware A=1.0.
R8_UNORM / R8_TYPELESS / A8_UNORM / BC4_UNORM / BC4_TYPELESS Excluded from gray_fits() → null SRV (0.0, 0.0, 0.0, 0.0) Single-channel roughness/wetness/opacity masks stay transparent/zero.
BC6H_* / R11G11B10_FLOAT / R9G9B9E5_SHAREDEXP / R16G16B16A16_FLOAT / R32*_FLOAT Excluded from gray_fits() → null SRV (0.0, 0.0, 0.0, 0.0) HDR lighting/reflection/probe/linear-data textures stay zero.
*_SNORM (BC5_SNORM, BC4_SNORM, R8G8_SNORM, etc.) / D* depth / *_UINT / *_SINT Excluded via gray_fits() / integer_format() → null SRV (0, 0, 0, 0) Signed normals (0.0 = flat), depth, and integer views stay zero.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib descriptor: 109 passed, 0 failed (1 ignored)
  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: asset policy: 365 files ok
  • cargo +1.98.1-x86_64-pc-windows-gnu check --workspace: passed cleanly
<!-- greyfinch-sync:Androtim/MiniVI:issue:5639431492 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/420). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-04T03:15:45Z. --- ## Summary Fixes translucent gray square quads around smoke/particle emitters (e.g., aircraft engine exhaust plumes) on 8 GB GPUs when RGBA billboard textures are evicted or not yet resident and receive a neutral stand-in SRV from `neutral_for()`. ### Root Cause In `crates/victory-gpu/src/descriptor/host.rs`, `standin_texel(false)` returned `[0x80, 0x80, 0x80, 0x80]` (`RGB ≈ 0.502, A ≈ 0.502`). - For **alpha-blended smoke / particle / decal / overlay billboards** (`BC3`, `BC7`, `BC2`, `R8G8B8A8`, `B8G8R8A8`), `A ≈ 0.502` renders 50%-opaque gray square quads (and stacked exhaust plume billboards compound to ~99.9% opaque gray blocks). - For **alpha-tested cutouts** (foliage/leaves/fences with `clip(alpha - 0.5)`), `0x80 / 255 = 0.50196 >= 0.5` passes the alpha test and renders solid gray square cards. - In addition, `A8_UNORM`, `R8_TYPELESS`, and `R9G9B9E5_SHAREDEXP` were not yet excluded from `gray_fits()` alongside `R8_UNORM`, `BC4_*`, and `R11G11B10_FLOAT`/`BC6H_*`. ### Changes 1. **`standin_texel(opaque)`**: Default (`!VICTORY_STANDIN_OPAQUE`) now uses `[0x80, 0x80, 0x80, 0x00]` (neutral `~0.502` RGB, transparent `0x00` alpha). `VICTORY_STANDIN_OPAQUE=1` continues to opt in to `[0x80, 0x80, 0x80, 0xff]`. 2. **`format_without_alpha()` + `standin_component_mapping()`**: Non-alpha picture/normal formats (`BC5_*`, `R8G8_*`, `B8G8R8X8_*`, `B5G6R5_UNORM`) force `A = 1.0` via `D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1` (`6792`) on the stand-in SRV, matching real D3D12 hardware semantics while keeping `RGB = 0x80` (`~0.502`). 3. **`gray_fits()`**: Exclude `A8_UNORM` (alpha-only mask), `R8_TYPELESS` (single-channel typeless counterpart of `R8_UNORM`), and `R9G9B9E5_SHAREDEXP` (HDR shared-exponent float) so they stay null `(0,0,0,0)`. 4. **Unit & D3D12 SRV tests**: Expanded `neutral_standin_rules_and_texel_formats` and `a_texture_not_there_yet_has_a_neutral_stand_in` to cover all format groups and `Shader4ComponentMapping` behavior. --- ## Format-by-Format Analysis | Format Family | Stand-in Behavior | Sampled Value (Default) | Impact / Safety | |---|---|---|---| | **`BC3` / `BC2` / `BC7` / `R8G8B8A8` / `B8G8R8A8` / `R10G10B10A2` / `R16G16B16A16_UNORM` / `B5G5R5A1` / `B4G4R4A4`** | Neutral stand-in, default component mapping | `(0.502, 0.502, 0.502, 0.0)` (or `A=1.0` with `VICTORY_STANDIN_OPAQUE=1`) | **Smoke/particles/decals/overlays**: invisible until resident (fixes gray quads). **Opaque albedo & YCbCr**: RGB stays `0.502` (neutral gray, no neon green; opaque shaders ignore `.a`). **Cutouts**: cleanly discarded until resident instead of solid gray cards. | | **`BC1` (`UNORM` / `SRGB` / `TYPELESS`)** | Neutral stand-in, default component mapping | `(0.502, 0.502, 0.502, 0.0)` | **Opaque `BC1` albedo**: `.a` ignored, RGB stays neutral gray. **1-bit alpha-tested `BC1` foliage**: discarded cleanly while streaming instead of solid gray cards. | | **`BC5_UNORM` / `BC5_TYPELESS` / `R8G8_UNORM` / `R8G8_TYPELESS`** | Neutral stand-in, `Shader4ComponentMapping` forces `A = 1.0` | `(0.502, 0.502, 0.502, 1.0)` | **Tangent-space normal maps & YCbCr chroma**: `R=0.502, G=0.502` produces flat normal `(0,0,1)` and neutral chroma; `A=1.0` matches real D3D12 hardware semantics for 2-channel formats. | | **`B8G8R8X8_*` / `B5G6R5_UNORM`** | Neutral stand-in, `Shader4ComponentMapping` forces `A = 1.0` | `(0.502, 0.502, 0.502, 1.0)` | RGB-only formats with no alpha channel; matches real D3D12 hardware `A=1.0`. | | **`R8_UNORM` / `R8_TYPELESS` / `A8_UNORM` / `BC4_UNORM` / `BC4_TYPELESS`** | Excluded from `gray_fits()` → null SRV | `(0.0, 0.0, 0.0, 0.0)` | Single-channel roughness/wetness/opacity masks stay transparent/zero. | | **`BC6H_*` / `R11G11B10_FLOAT` / `R9G9B9E5_SHAREDEXP` / `R16G16B16A16_FLOAT` / `R32*_FLOAT`** | Excluded from `gray_fits()` → null SRV | `(0.0, 0.0, 0.0, 0.0)` | HDR lighting/reflection/probe/linear-data textures stay zero. | | **`*_SNORM` (`BC5_SNORM`, `BC4_SNORM`, `R8G8_SNORM`, etc.) / `D*` depth / `*_UINT` / `*_SINT`** | Excluded via `gray_fits()` / `integer_format()` → null SRV | `(0, 0, 0, 0)` | Signed normals (`0.0` = flat), depth, and integer views stay zero. | ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib descriptor`: **109 passed, 0 failed** (1 ignored) - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: **asset policy: 365 files ok** - `cargo +1.98.1-x86_64-pc-windows-gnu check --workspace`: **passed cleanly**
Androtim commented 2026-12-04 03:31:52 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T03:31:52Z.


Triage (4bc457cc, CI check PASS):

  • Clean, 100% title-neutral visual fix (+146/-24 in crates/victory-gpu/src/descriptor/host.rs, zero new toggles): switches default neutral stand-ins to [0x80, 0x80, 0x80, 0x00] (hiding unstreamed smoke/particle/decal billboards and alpha-tested cutouts instead of rendering gray squares), forces A = 1.0 via D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1 on non-alpha formats (BC5, R8G8, B8G8R8X8, B5G6R5), and excludes A8_UNORM, R8_TYPELESS, and R9G9B9E5_SHAREDEXP from gray_fits().
  • Holding auto-merge for Gate 2 Audit (#282) + Gate 3 --features diagnostics visual PNG check (verifying gray smoke/foliage quads eliminated with zero regression on solid surfaces).
<!-- greyfinch-sync:Androtim/MiniVI:comment:7400176834 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/420#issuecomment-7400176834). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-04T03:31:52Z. --- Triage (`4bc457cc`, **CI `check` PASS**): - Clean, 100% title-neutral visual fix (`+146/-24` in `crates/victory-gpu/src/descriptor/host.rs`, zero new toggles): switches default neutral stand-ins to `[0x80, 0x80, 0x80, 0x00]` (hiding unstreamed smoke/particle/decal billboards and alpha-tested cutouts instead of rendering gray squares), forces `A = 1.0` via `D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1` on non-alpha formats (`BC5`, `R8G8`, `B8G8R8X8`, `B5G6R5`), and excludes `A8_UNORM`, `R8_TYPELESS`, and `R9G9B9E5_SHAREDEXP` from `gray_fits()`. - Holding auto-merge for **Gate 2 Audit (`#282`)** + **Gate 3 `--features diagnostics` visual PNG check** (verifying gray smoke/foliage quads eliminated with zero regression on solid surfaces).
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
Androtim/MiniVI!420
No description provided.