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

Manually merged
github merged 4 commits from github-bot/gh-432 into gh-pr/432/base 2026-12-04 11:53:23 +00:00 AGit
Owner

@⁠Androtim on GitHub · 2026-12-04 10:52 UTC · original
Androtim:perf/w12a-hwrt-quant24-gpu → main · +884 −61 · 3 files · 4 commits · merged 2026-12-04 11:52 UTC

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** on GitHub · 2026-12-04 10:52 UTC · [original](https://github.com/Androtim/MiniVI/pull/432) `Androtim:perf/w12a-hwrt-quant24-gpu` → `main` · +884 −61 · 3 files · 4 commits · merged 2026-12-04 11:52 UTC ## 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`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 11:03:18 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-04 11:01 UTC · original

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.
**@⁠Androtim** on GitHub · 2026-12-04 11:01 UTC · [original](https://github.com/Androtim/MiniVI/pull/432#issuecomment-7409525563) 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.
github-bot changed target branch from main to gh-pr/432/base 2026-12-04 11:53:20 +00:00
github manually merged commit 4685c66af6 into gh-pr/432/base 2026-12-04 11:53:23 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Androtim--MiniVI!432
No description provided.