perf(gpu/hwrt): GPU decode_quant24_vb compute shader in SANITIZE_HLSL (Wave 12A) #432

Merged
Androtim merged 4 commits from upstream-pr/432 into main 2026-12-04 11:52:53 +00:00
Androtim commented 2026-12-04 10:52:27 +00:00 (Migrated from github.com)

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


Summary

Moves console 24-24-16 quantized 3D position vertex buffer decoding (TITLE_QUANT24_VFMT) from the CPU staging loop into a GPU compute shader (decode_quant24_vb) inside SANITIZE_HLSL, reading GPU-resident shadow VBs directly into BLAS work UAV buffers while retaining the CPU decoder as a fail-closed fallback.

Changes

  • crates/victory-gpu/src/hwrt/sanitize.rs:
    • Added decode_quant24_vb compute entry point (cs_5_1, [numthreads(64, 1, 1)]) to SANITIZE_HLSL with its own 10-dword root signature (RS_QUANT24 at b1, leaving clamp_ib/copy_vb root signature RS untouched).
    • Unpacks 24-24-16 packed vertices via ByteAddressBuffer::Load2, applies fused mad(scale, (float)q, bias) across all swizzle modes (0 => [c, b, a], 1 => [b, c, a], default [a, b, c]), and scrubs non-finite / |x| > 1e10 (0x501502F9u) coordinates to quiet NaN (0x7FC00000u) directly into the R32G32B32_FLOAT UAV buffer.
    • Added quant24_root_params and quant24_shadow_eligible helpers enforcing 4-byte VA/stride alignment and full [vb_va, vb_va + vbytes) shadow coverage.
  • crates/victory-gpu/src/hwrt/decoders.rs:
    • Extracted Quant24Header, read_quant24_header, and decode_title_quant24_vb_with_header so CPU header reading/finiteness validation is shared once between the GPU path and CPU fallback.
  • crates/victory-gpu/src/hwrt.rs:
    • Compiled decode_quant24_vb root signature & compute PSO in HwRtManager::new alongside clamp_ib/copy_vb.
    • Added HwRtManager::decode_quant24 chunked via sanitize_chunks, calling Shadow::refresh and list.keep(&sh.buffer), writing directly into work (synchronized by flush_blas_batch UAV -> NON_PIXEL_SHADER_RESOURCE + UAV barrier before BuildRaytracingAccelerationStructure, then restored NON_PIXEL_SHADER_RESOURCE -> UAV).
    • Fails closed to CPU decode_title_quant24_vb_with_header whenever the VB is not shadow-backed, unaligned, out of shadow bounds, or work lease allocation fails.
    • Added GPU quant24 decode telemetry counter (STATS[16]) alongside total quant24 decodes (STATS[8]).

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu -- hwrt: 58 passed, 0 failed
    • Includes FXC cs_5_1 compile checks for all 3 SANITIZE_HLSL entry points, header validation tests, shadow eligibility boundary tests, root constant packing tests, and decode_quant24_vb_gpu_shader_matches_cpu_decoder_bit_exact verifying bit-exact GPU vs CPU output across all swizzle modes, strides, non-16-byte src_bias offsets, 1e10/Inf scrubbing, and 131-vertex multi-group dispatch with trailing sentinel protection under the D3D12 debug layer.
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings: clean (0 warnings)
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean (0 warnings)
  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: asset policy: 368 files ok
<!-- greyfinch-sync:Androtim/MiniVI:issue:5645079895 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/432). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-04T10:52:27Z. --- ## Summary Moves console 24-24-16 quantized 3D position vertex buffer decoding (`TITLE_QUANT24_VFMT`) from the CPU staging loop into a GPU compute shader (`decode_quant24_vb`) inside `SANITIZE_HLSL`, reading GPU-resident shadow VBs directly into BLAS `work` UAV buffers while retaining the CPU decoder as a fail-closed fallback. ### Changes - **`crates/victory-gpu/src/hwrt/sanitize.rs`**: - Added `decode_quant24_vb` compute entry point (`cs_5_1`, `[numthreads(64, 1, 1)]`) to `SANITIZE_HLSL` with its own 10-dword root signature (`RS_QUANT24` at `b1`, leaving `clamp_ib`/`copy_vb` root signature `RS` untouched). - Unpacks 24-24-16 packed vertices via `ByteAddressBuffer::Load2`, applies fused `mad(scale, (float)q, bias)` across all swizzle modes (`0 => [c, b, a]`, `1 => [b, c, a]`, default `[a, b, c]`), and scrubs non-finite / `|x| > 1e10` (`0x501502F9u`) coordinates to quiet NaN (`0x7FC00000u`) directly into the `R32G32B32_FLOAT` UAV buffer. - Added `quant24_root_params` and `quant24_shadow_eligible` helpers enforcing 4-byte VA/stride alignment and full `[vb_va, vb_va + vbytes)` shadow coverage. - **`crates/victory-gpu/src/hwrt/decoders.rs`**: - Extracted `Quant24Header`, `read_quant24_header`, and `decode_title_quant24_vb_with_header` so CPU header reading/finiteness validation is shared once between the GPU path and CPU fallback. - **`crates/victory-gpu/src/hwrt.rs`**: - Compiled `decode_quant24_vb` root signature & compute PSO in `HwRtManager::new` alongside `clamp_ib`/`copy_vb`. - Added `HwRtManager::decode_quant24` chunked via `sanitize_chunks`, calling `Shadow::refresh` and `list.keep(&sh.buffer)`, writing directly into `work` (synchronized by `flush_blas_batch` `UAV -> NON_PIXEL_SHADER_RESOURCE` + UAV barrier before `BuildRaytracingAccelerationStructure`, then restored `NON_PIXEL_SHADER_RESOURCE -> UAV`). - Fails closed to CPU `decode_title_quant24_vb_with_header` whenever the VB is not shadow-backed, unaligned, out of shadow bounds, or `work` lease allocation fails. - Added GPU quant24 decode telemetry counter (`STATS[16]`) alongside total quant24 decodes (`STATS[8]`). ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu -- hwrt`: **58 passed, 0 failed** - Includes FXC `cs_5_1` compile checks for all 3 `SANITIZE_HLSL` entry points, header validation tests, shadow eligibility boundary tests, root constant packing tests, and `decode_quant24_vb_gpu_shader_matches_cpu_decoder_bit_exact` verifying bit-exact GPU vs CPU output across all swizzle modes, strides, non-16-byte `src_bias` offsets, `1e10`/Inf scrubbing, and 131-vertex multi-group dispatch with trailing sentinel protection under the D3D12 debug layer. - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings`: clean (0 warnings) - `cargo +1.98.1-x86_64-pc-windows-gnu clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings`: clean (0 warnings) - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: `asset policy: 368 files ok`
Androtim commented 2026-12-04 11:01:39 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T11:01:39Z.


Triage (5c16e97c, CI check PASS, MERGEABLE):

  • Clean, 100% title-neutral Wave 12A GPU decode_quant24_vb compute shader (+766/-57 across hwrt.rs, hwrt/decoders.rs, hwrt/sanitize.rs, zero new env toggles) moving TITLE_QUANT24_VFMT decoding from CPU staging onto the GPU with fail-closed CPU fallback.
  • Marked triage: needs gpu test — awaiting Gate 2 Audit (#282) + Gate 3 VICTORY_HW_RT=1 GPU verification.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7409525563 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/432#issuecomment-7409525563). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-04T11:01:39Z. --- Triage (`5c16e97c`, **CI `check` PASS**, `MERGEABLE`): - Clean, 100% title-neutral Wave 12A GPU `decode_quant24_vb` compute shader (`+766/-57` across `hwrt.rs`, `hwrt/decoders.rs`, `hwrt/sanitize.rs`, **zero new env toggles**) moving `TITLE_QUANT24_VFMT` decoding from CPU staging onto the GPU with fail-closed CPU fallback. - Marked `triage: needs gpu test` — awaiting Gate 2 Audit (`#282`) + Gate 3 `VICTORY_HW_RT=1` GPU verification.
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!432
No description provided.