[Contribution] Clean-Room GPU BCPack Decoder (DX12 Zero-Copy C-ABI + Vulkan 1.3 SPIR-V) & 1.25M Descriptor Paging (MIT/Apache-2.0) #63

Open
opened 2026-11-26 19:11:31 +00:00 by github-bot · 2 comments
Owner

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

Hi team,

Congrats on the awesome bring-up progress! Since OpenScarlett targets both D3D12 and Vulkan 1.4 (and C++20 runtime shims without a Rust dependency), I wanted to share a clean-room, MIT OR Apache-2.0 licensed GPU BCPack (MDU rANS) decompressor + Virtual Descriptor Pager you can either link directly via C-ABI or embed as HLSL/SPIR-V kernels:

What Fits OpenScarlett's D3D12 & Vulkan Pipeline

  1. Zero-Copy Shared-Device & Direct Texture2D C-ABI (bcpack_gpu.dll + include/bcpack_gpu.h):
    • Pass your existing ID3D12Device* (+ optional compute queue) to bcpack_gpu_create_from_device(...).
    • Call BcPackDecodeToBuffer(...) or BcPackDecodeToTexture2D(...) to decode linear BC1 / fused AMD Gfx10 SW_64KB_D / SW_4KB_S (432.6 GB/s) / 16-lane BC7 rANS directly into caller GPU resources (including auto 256B RowPitch padding for small mips) and wait purely on GPU via direct_queue->Wait((ID3D12Fence*)BcPackGetDirectFence(ctx), fence).
  2. Official Precompiled Vulkan 1.3 SPIR-V Compute Kernels (shaders/spirv/*.spv, shaders/compile_spirv.sh):
    • Compiled with Microsoft DirectXShaderCompiler v1.9.2609 (-spirv -fspv-target-env=vulkan1.3 -T cs_6_6 -E CSMain -O3): bcpack_decode.spv, bcpack_bc7_rans.spv, bc16_pack.spv, gfx10_detile.spv, hiz_build.spv, crowd_skin.spv, and bindless_paging.spv (note: enable VK_EXT_subgroup_size_control for Wave32 on 64-wide GPUs).
  3. Virtual Descriptor Paging Reference (src/descriptor_paging.rs, shaders/bindless_paging.hlsl):
    • Solves NVIDIA's ~1M shader-visible descriptor heap limit by paging 1,250,000 virtual descriptor IDs onto 262,144 physical slots via CopyDescriptorsSimple in 0.064 ms (0 mismatches).
  4. Verified on RTX 5080 (19/19 PASS, DX12 Debug Layer clean — 0 errors): 11.33 GB/s BC1 (282× vs 1T CPU) and 6.02 GB/s equiv on 16-lane BC7 rANS (100% Wave32 = 32/32 lanes), plus DXC -O3 WaveActiveBallot workaround documented in AI_ARCHITECTURE.md.

Let me know if you'd like any adjustments for OpenScarlett's CMake/build integration!

**@⁠POMXARK** on GitHub · 2026-11-25 19:28 UTC · [original](https://github.com/californiaAlmonds/OpenScarlett/issues/63) Hi team, Congrats on the awesome bring-up progress! Since OpenScarlett targets both **D3D12** and **Vulkan 1.4** (and C++20 runtime shims without a Rust dependency), I wanted to share a **clean-room, `MIT OR Apache-2.0` licensed GPU BCPack (MDU rANS) decompressor + Virtual Descriptor Pager** you can either link directly via C-ABI or embed as HLSL/SPIR-V kernels: - **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`) - **Machine-Readable Architecture & Invariants:** [`docs/AI_ARCHITECTURE.md`](https://github.com/POMXARK/bcpack-gpu-hlsl/blob/main/docs/AI_ARCHITECTURE.md) ### What Fits OpenScarlett's D3D12 & Vulkan Pipeline 1. **Zero-Copy Shared-Device & Direct Texture2D C-ABI (`bcpack_gpu.dll` + `include/bcpack_gpu.h`):** - Pass your existing `ID3D12Device*` (+ optional compute queue) to `bcpack_gpu_create_from_device(...)`. - Call `BcPackDecodeToBuffer(...)` or `BcPackDecodeToTexture2D(...)` to decode linear `BC1` / fused AMD Gfx10 `SW_64KB_D` / `SW_4KB_S` (`432.6 GB/s`) / 16-lane `BC7` rANS **directly into caller GPU resources** (including auto 256B RowPitch padding for small mips) and wait purely on GPU via `direct_queue->Wait((ID3D12Fence*)BcPackGetDirectFence(ctx), fence)`. 2. **Official Precompiled Vulkan 1.3 SPIR-V Compute Kernels (`shaders/spirv/*.spv`, `shaders/compile_spirv.sh`):** - Compiled with Microsoft `DirectXShaderCompiler v1.9.2609` (`-spirv -fspv-target-env=vulkan1.3 -T cs_6_6 -E CSMain -O3`): `bcpack_decode.spv`, `bcpack_bc7_rans.spv`, `bc16_pack.spv`, `gfx10_detile.spv`, `hiz_build.spv`, `crowd_skin.spv`, and `bindless_paging.spv` (note: enable `VK_EXT_subgroup_size_control` for Wave32 on 64-wide GPUs). 3. **Virtual Descriptor Paging Reference (`src/descriptor_paging.rs`, `shaders/bindless_paging.hlsl`):** - Solves NVIDIA's ~1M `shader-visible` descriptor heap limit by paging `1,250,000` virtual descriptor IDs onto `262,144` physical slots via `CopyDescriptorsSimple` in `0.064 ms` (`0` mismatches). 4. **Verified on RTX 5080 (`19/19 PASS`, DX12 Debug Layer clean — 0 errors):** **11.33 GB/s** BC1 (**282×** vs 1T CPU) and **6.02 GB/s equiv** on 16-lane BC7 rANS (100% Wave32 = `32/32` lanes), plus DXC `-O3` `WaveActiveBallot` workaround documented in `AI_ARCHITECTURE.md`. Let me know if you'd like any adjustments for OpenScarlett's CMake/build integration!
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:11:31 +00:00
Author
Owner

@⁠californiaAlmonds on GitHub · 2026-11-26 07:44 UTC · original

Thank you so much @⁠POMXARK for sharing this — a clean-room MIT/Apache-2.0 GPU BCPack (MDU rANS + fused GFX10 detiling) decoder with zero-copy D3D12/Vulkan SPIR-V kernels and a 1.25M virtual descriptor pager is genuinely very useful for OpenScarlett! Both fast GPU-side texture decompression during heavy world streaming and virtual descriptor paging for large bindless heaps fit our roadmap closely. We are wrapping up our current active bring-up tasks right now, and we will begin testing and evaluating integration as soon as those are complete!

**@⁠californiaAlmonds** on GitHub · 2026-11-26 07:44 UTC · [original](https://github.com/californiaAlmonds/OpenScarlett/issues/63#issuecomment-7185787616) Thank you so much @⁠POMXARK for sharing this — a clean-room MIT/Apache-2.0 GPU BCPack (MDU rANS + fused GFX10 detiling) decoder with zero-copy D3D12/Vulkan SPIR-V kernels and a 1.25M virtual descriptor pager is genuinely very useful for OpenScarlett! Both fast GPU-side texture decompression during heavy world streaming and virtual descriptor paging for large bindless heaps fit our roadmap closely. We are wrapping up our current active bring-up tasks right now, and we will begin testing and evaluating integration as soon as those are complete!
Author
Owner

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

Glad to hear it fits the roadmap @⁠californiaAlmonds! Take your time finishing up the bring-up tasks — no rush at all.

Quick heads-up for whenever you're ready to test: I just pushed bcpack-gpu-sdk v0.14.1 (https://github.com/POMXARK/bcpack-gpu-sdk/releases/tag/v0.14.1) with a couple of important updates since the initial release:

  1. Recompiled Vulkan 1.3 SPIR-V & DXIL (bcpack_decode.{spv,dxil}): Added BC1 lane 1 index-reference prediction matching bcpack-rs#11, plus restricted BC7 channel rotation strictly to modes 4 and 5 (bcpack_bc7_rebuild.{spv,dxil}).
  2. Mixed-format C-ABI batching (BcPackDecodeBatch): Batches heterogeneous BC1/BC3/BC4/BC5/BC6H/BC7 chunks by pipeline family with automatic sub-batching (42.7x faster than looping single-chunk BcPackDecodeAsync calls on RTX 5080).
  3. Zero-copy BcPackDecodeToTexture2D scaling: Removed the hardcoded 16 MiB row_pad_default cap so 4K+ row-padded subresources scale cleanly with context capacity.

Happy to help wire up a small VK_EXT_subgroup_size_control or C-ABI smoke hook whenever OpenScarlett gets to it.

**@⁠POMXARK** on GitHub · 2026-11-26 11:54 UTC · [original](https://github.com/californiaAlmonds/OpenScarlett/issues/63#issuecomment-7191326125) Glad to hear it fits the roadmap @⁠californiaAlmonds! Take your time finishing up the bring-up tasks — no rush at all. Quick heads-up for whenever you're ready to test: I just pushed **`bcpack-gpu-sdk v0.14.1`** (https://github.com/POMXARK/bcpack-gpu-sdk/releases/tag/v0.14.1) with a couple of important updates since the initial release: 1. **Recompiled Vulkan 1.3 SPIR-V & DXIL (`bcpack_decode.{spv,dxil}`):** Added `BC1` `lane 1` index-reference prediction matching `bcpack-rs#11`, plus restricted `BC7` channel rotation strictly to modes `4` and `5` (`bcpack_bc7_rebuild.{spv,dxil}`). 2. **Mixed-format C-ABI batching (`BcPackDecodeBatch`):** Batches heterogeneous `BC1/BC3/BC4/BC5/BC6H/BC7` chunks by pipeline family with automatic sub-batching (`42.7x` faster than looping single-chunk `BcPackDecodeAsync` calls on RTX 5080). 3. **Zero-copy `BcPackDecodeToTexture2D` scaling:** Removed the hardcoded `16 MiB` `row_pad_default` cap so `4K+` row-padded subresources scale cleanly with context capacity. Happy to help wire up a small `VK_EXT_subgroup_size_control` or C-ABI smoke hook whenever `OpenScarlett` gets to it.
This discussion has been locked. Commenting is limited to contributors.
No description provided.