[Contribution] Drop-In Zero-Copy GPU BCPack Decoder for d3d12_xs / IDStorageQueueX (bcpack_gpu.dll, MIT/Apache-2.0) #53

Open
opened 2026-11-26 19:57:03 +00:00 by github-bot · 0 comments
Owner

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

Hi team,

To help unblock DirectStorage (IDStorageQueueX) / d3d12_xs asset streaming without burning CPU cores on BCPack MDU rANS decompression, I built a clean-room, MIT OR Apache-2.0 licensed GPU Compute BCPack decompressor packaged as a drop-in C-ABI DLL + HLSL SM 6.6 / SPIR-V shaders:

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

  • Zero-Copy ID3D12Device Sharing (include/bcpack_gpu.h):
    BcPackContext* ctx = bcpack_gpu_create_from_device(d3d12_device, NULL, 2048, 8388608, 96u * 1024u * 1024u);
    uint64_t fence = 0;
    BcPackDecodeToTexture2D(ctx, stream, stream_len, num_blocks,
                            BCPACK_FORMAT_BC1, BCPACK_SWIZZLE_GFX10_64KB_D,
                            width_blocks, height_blocks, dst_tex2d, mip_idx, 0, 0, &fence);
    direct_queue->Wait((ID3D12Fence*)BcPackGetDirectFence(ctx), fence);
    
    Supports both raw buffer output (BcPackDecodeToBuffer) and direct 2D texture mip upload (BcPackDecodeToTexture2D, with automatic 256B RowPitch padding on small mips) — zero CPU readback.
  • Performance: Zero-barrier Wave32 kernels reaching 11.33 GB/s BC1 (282× vs 1T CPU), 6.02 GB/s equiv 16-lane BC7 rANS (32/32 lanes active), and fused AMD Gfx10 SW_64KB_D/SW_4KB_S detile at 432.6 GB/s (0.144 ms / 64 MiB).
  • Descriptor Heap Limit Fix: Reference SM 6.6 ResourceDescriptorHeap[] pager (1.25M virtual → 262K physical slots in 0.064 ms, 0 mismatches) to avoid NVIDIA's ~1M shader-visible heap cap.

Feel free to drop bcpack_gpu.dll straight into your DirectStorage hooks or cherry-pick the HLSL shaders!

**@⁠POMXARK** on GitHub · 2026-11-25 19:28 UTC · [original](https://github.com/Freminet/ScarlettX/issues/53) Hi team, To help unblock DirectStorage (`IDStorageQueueX`) / `d3d12_xs` asset streaming without burning CPU cores on BCPack MDU rANS decompression, I built a **clean-room, `MIT OR Apache-2.0` licensed GPU Compute BCPack decompressor** packaged as a drop-in C-ABI DLL + HLSL SM 6.6 / SPIR-V shaders: - **Repository:** https://github.com/POMXARK/bcpack-gpu-hlsl - **Prebuilt SDK (`v0.10.0`):** https://github.com/POMXARK/bcpack-gpu-hlsl/releases/tag/v0.10.0 (`bcpack-gpu-sdk-v0.10.0-win64.zip`) - **Architecture & C-ABI Contract:** [`docs/AI_ARCHITECTURE.md`](https://github.com/POMXARK/bcpack-gpu-hlsl/blob/main/docs/AI_ARCHITECTURE.md) ### Highlights (`19/19 PASS` Bit-Exact on RTX 5080, DX12 Debug Layer Clean) - **Zero-Copy `ID3D12Device` Sharing (`include/bcpack_gpu.h`):** ```c BcPackContext* ctx = bcpack_gpu_create_from_device(d3d12_device, NULL, 2048, 8388608, 96u * 1024u * 1024u); uint64_t fence = 0; BcPackDecodeToTexture2D(ctx, stream, stream_len, num_blocks, BCPACK_FORMAT_BC1, BCPACK_SWIZZLE_GFX10_64KB_D, width_blocks, height_blocks, dst_tex2d, mip_idx, 0, 0, &fence); direct_queue->Wait((ID3D12Fence*)BcPackGetDirectFence(ctx), fence); ``` Supports both raw buffer output (`BcPackDecodeToBuffer`) and direct 2D texture mip upload (`BcPackDecodeToTexture2D`, with automatic 256B RowPitch padding on small mips) — **zero CPU readback**. - **Performance:** Zero-barrier Wave32 kernels reaching **11.33 GB/s** BC1 (**282×** vs 1T CPU), **6.02 GB/s equiv** 16-lane BC7 rANS (`32/32` lanes active), and fused AMD Gfx10 `SW_64KB_D`/`SW_4KB_S` detile at **432.6 GB/s** (`0.144 ms` / `64 MiB`). - **Descriptor Heap Limit Fix:** Reference SM 6.6 `ResourceDescriptorHeap[]` pager (`1.25M` virtual → `262K` physical slots in `0.064 ms`, `0` mismatches) to avoid NVIDIA's ~1M shader-visible heap cap. Feel free to drop `bcpack_gpu.dll` straight into your DirectStorage hooks or cherry-pick the HLSL shaders!
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:57:03 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.