[Showcase / Contribution] Clean-Room GPU Compute Backend (DX12 HLSL SM 6.6 + Vulkan 1.3 SPIR-V, 11.33 GB/s BC1 / 6.02 GB/s BC7 rANS) #9

Open
opened 2026-11-26 18:56:06 +00:00 by github-bot · 3 comments
Owner

@⁠POMXARK on GitHub · 2026-11-25 19:28 UTC · original

Hi @⁠Ahmet-Dedeler,

Huge thanks for bcpack-rs and your clear BCPACK_SPEC.md — it served as our bit-exact CPU oracle! Using bcpack-rs + microsoft/silicon-rans, I built an open-source (MIT OR Apache-2.0) GPU Compute decoder & AAA streaming suite in DX12 HLSL SM 6.6 + Vulkan 1.3 SPIR-V + Rust:

Highlights (Bit-Exact 19/19 PASS vs bcpack-rs on RTX 5080, DX12 Debug Layer Clean)

  • BC1 Zero-Barrier Wave32 Kernel (shaders/bcpack_decode.hlsl): Dual-chunk per warp, register-resident 64B stream window, 4-step branchless binary search → 11,327.6 MB/s (282.1× vs 1T CPU) with 0 byte mismatches across monolithic, tiled 4K strips, and full 10-level Mip + Packed Mip Tail (85-block tail).
  • 16-Lane BC7 rANS (shaders/bcpack_bc7_rans.hlsl, 100% Wave32 32/32 lanes): 6,024.0 MB/s equiv (247.1× vs 1T CPU) with 0 symbol mismatches against bcpack::rans::decode_slice.
  • Fused AMD Gfx10 Swizzle -> Linear (shaders/gfx10_detile.hlsl): SW_64KB_D (8B/16B) & SW_4KB_S (8B) at 432.6 GB/s (0.144 ms / 64 MiB).
  • Official Vulkan 1.3 SPIR-V builds (shaders/spirv/*.spv, shaders/compile_spirv.sh): All core compute kernels precompiled with DXC v1.9.2609.
  • DXC 1.8 -O3 Finding: WavePrefixCountBits + WaveActiveCountBits miscompiled stream_pos in split-half Wave32 allocation; solved cleanly via WaveActiveBallot + countbits.

Saw your recent bc5/bc7/bc6h progress in bcpack-rs — would love to align/extend our GPU block-reconstruction pass with your updated CPU decoders if there's interest!

**@⁠POMXARK** on GitHub · 2026-11-25 19:28 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/issues/9) Hi @⁠Ahmet-Dedeler, Huge thanks for `bcpack-rs` and your clear `BCPACK_SPEC.md` — it served as our bit-exact CPU oracle! Using `bcpack-rs` + `microsoft/silicon-rans`, I built an open-source (`MIT OR Apache-2.0`) **GPU Compute decoder & AAA streaming suite** in DX12 HLSL SM 6.6 + Vulkan 1.3 SPIR-V + Rust: - **Repository:** https://github.com/POMXARK/bcpack-gpu-hlsl - **Release `v0.10.0` (Win64 SDK + Demos):** https://github.com/POMXARK/bcpack-gpu-hlsl/releases/tag/v0.10.0 - **Architecture & Workarounds:** [`docs/AI_ARCHITECTURE.md`](https://github.com/POMXARK/bcpack-gpu-hlsl/blob/main/docs/AI_ARCHITECTURE.md) ### Highlights (Bit-Exact `19/19 PASS` vs `bcpack-rs` on RTX 5080, DX12 Debug Layer Clean) - **BC1 Zero-Barrier Wave32 Kernel (`shaders/bcpack_decode.hlsl`):** Dual-chunk per warp, register-resident 64B stream window, 4-step branchless binary search → **11,327.6 MB/s (282.1× vs 1T CPU)** with `0` byte mismatches across monolithic, tiled 4K strips, and full 10-level Mip + Packed Mip Tail (`85`-block tail). - **16-Lane BC7 rANS (`shaders/bcpack_bc7_rans.hlsl`, `100%` Wave32 `32/32` lanes):** **6,024.0 MB/s equiv (247.1× vs 1T CPU)** with `0` symbol mismatches against `bcpack::rans::decode_slice`. - **Fused AMD Gfx10 Swizzle -> Linear (`shaders/gfx10_detile.hlsl`):** `SW_64KB_D` (8B/16B) & `SW_4KB_S` (8B) at **432.6 GB/s** (`0.144 ms` / `64 MiB`). - **Official Vulkan 1.3 SPIR-V builds (`shaders/spirv/*.spv`, `shaders/compile_spirv.sh`):** All core compute kernels precompiled with DXC `v1.9.2609`. - **DXC 1.8 `-O3` Finding:** `WavePrefixCountBits` + `WaveActiveCountBits` miscompiled `stream_pos` in split-half Wave32 allocation; solved cleanly via `WaveActiveBallot` + `countbits`. Saw your recent `bc5`/`bc7`/`bc6h` progress in `bcpack-rs` — would love to align/extend our GPU block-reconstruction pass with your updated CPU decoders if there's interest!
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:56:06 +00:00
Author
Owner

@⁠Ahmet-Dedeler on GitHub · 2026-11-26 02:54 UTC · original

Cool to see it used as an oracle for a GPU decoder, thanks for the credit.

One thing you should know since you checked bit-exactness against bcpack-rs: #10 found that the BC1 assembler ignored lane 1 (the index reference). It's fixed now (#11). On retail data it changes nothing because lane 1 was always 0 there. But if your BC1 kernel matched the old behaviour and you test with streams where lane 1 isn't 0, it would match the bug. Worth rerunning your 19 checks against current master. The rANS decoder also got a big speed-up in #8, with the output unchanged.

**@⁠Ahmet-Dedeler** on GitHub · 2026-11-26 02:54 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/issues/9#issuecomment-7181222444) Cool to see it used as an oracle for a GPU decoder, thanks for the credit. One thing you should know since you checked bit-exactness against bcpack-rs: #10 found that the BC1 assembler ignored lane 1 (the index reference). It's fixed now (#11). On retail data it changes nothing because lane 1 was always 0 there. But if your BC1 kernel matched the old behaviour and you test with streams where lane 1 isn't 0, it would match the bug. Worth rerunning your 19 checks against current master. The rANS decoder also got a big speed-up in #8, with the output unchanged.
Author
Owner

@⁠POMXARK on GitHub · 2026-11-26 11:54 UTC · original

Thanks for the heads-up @⁠Ahmet-Dedeler! Just audited our Wave32 BC1 kernel (shaders/bcpack_decode.hlsl) and confirmed it indeed skipped lane 1 (s1).

Fixed and released in bcpack-gpu-sdk v0.14.1 (https://github.com/POMXARK/bcpack-gpu-sdk/releases/tag/v0.14.1):

  • Added ring_line[2][256] + x = s1 & 255u, d = (x + unzigzag(s0)) & 255u, and branchless 16-pixel SWAR line-position arithmetic (codes_to_lines / add_lines / lines_to_codes, treating pre-start x > block_idx as zero, matching bcpack-rs#11).
  • Bumped our Cargo.toml oracle pin to bcpack-rs master (7b2b421) and recompiled both bcpack_decode.dxil and Vulkan 1.3 spirv/bcpack_decode.spv.
  • Verified on Windows 11 + NVIDIA RTX 5080 (tests/v14_batch_and_tex2d: 5/5 PASS): new bc1_lane1_index_reference_bit_exact test (512 blocks with pre-start and 1..=31 lane 1 index refs) matched CPU bcpack::bc1::decode with 0 byte mismatches (kernel=0.593 ms).

Also noticed the speedup from #8 directly in our CPU comparison (365.87 ms vs 725.26 ms single-thread on 20 MiB) — great work!

**@⁠POMXARK** on GitHub · 2026-11-26 11:54 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/issues/9#issuecomment-7191325286) Thanks for the heads-up @⁠Ahmet-Dedeler! Just audited our Wave32 BC1 kernel (`shaders/bcpack_decode.hlsl`) and confirmed it indeed skipped `lane 1` (`s1`). Fixed and released in **`bcpack-gpu-sdk v0.14.1`** (https://github.com/POMXARK/bcpack-gpu-sdk/releases/tag/v0.14.1): - Added `ring_line[2][256]` + `x = s1 & 255u`, `d = (x + unzigzag(s0)) & 255u`, and branchless 16-pixel SWAR line-position arithmetic (`codes_to_lines` / `add_lines` / `lines_to_codes`, treating pre-start `x > block_idx` as zero, matching `bcpack-rs#11`). - Bumped our `Cargo.toml` oracle pin to `bcpack-rs` master (`7b2b421`) and recompiled both `bcpack_decode.dxil` and Vulkan 1.3 `spirv/bcpack_decode.spv`. - Verified on Windows 11 + NVIDIA RTX 5080 (`tests/v14_batch_and_tex2d`: `5/5 PASS`): new `bc1_lane1_index_reference_bit_exact` test (512 blocks with pre-start and `1..=31` `lane 1` index refs) matched CPU `bcpack::bc1::decode` with **0 byte mismatches** (`kernel=0.593 ms`). Also noticed the speedup from `#8` directly in our CPU comparison (`365.87 ms` vs `725.26 ms` single-thread on `20 MiB`) — great work!
Author
Owner

@⁠Ahmet-Dedeler on GitHub · 2026-11-26 12:06 UTC · original

Nice, that was quick. If you want a regression case for it, bc1_lane1_index_reference in tests/roundtrip.rs is the small one from #10 (second block has to come out as a1 17 5d f0 0a 0a 5f f5). tests/vectors/*.json were re-blessed with lane 1 in, so they work as a check too.

Also, BC3, BC4, BC5 and BC7 decoding is in the CLI now (#12, thanks to brainbudt), with DDS export for all of them. So if you want to line your GPU block rebuild up against the CPU side for those formats, decode-bc3 / decode-bc7 etc. give you per-chunk output to diff against. BC6H isn't done yet.

**@⁠Ahmet-Dedeler** on GitHub · 2026-11-26 12:06 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/issues/9#issuecomment-7191571774) Nice, that was quick. If you want a regression case for it, `bc1_lane1_index_reference` in `tests/roundtrip.rs` is the small one from #10 (second block has to come out as `a1 17 5d f0 0a 0a 5f f5`). `tests/vectors/*.json` were re-blessed with lane 1 in, so they work as a check too. Also, BC3, BC4, BC5 and BC7 decoding is in the CLI now (#12, thanks to brainbudt), with DDS export for all of them. So if you want to line your GPU block rebuild up against the CPU side for those formats, `decode-bc3` / `decode-bc7` etc. give you per-chunk output to diff against. BC6H isn't done yet.
This discussion has been locked. Commenting is limited to contributors.
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/Ahmet-Dedeler--bcpack-rs#9
No description provided.