RFC: Opt-in DX12 Async Compute BCPack (All 6 Formats: BC1/BC3/BC4/BC5/BC6H/BC7) + NVIDIA Descriptor Paging via bcpack-gpu-sdk v0.13.0 #1199

Open
opened 2026-11-26 03:59:21 +00:00 by github-bot · 1 comment
Owner

@⁠POMXARK on GitHub · 2026-11-25 23:44 UTC · original

Hi fxceless/victory-fork maintainers,

I would like to propose integrating bcpack-gpu-sdk (v0.13.0, MIT OR Apache-2.0) to offload DirectStorage BCPack decompression from the CPU to GPU Async Compute across all 6 BCPack formats (BC1, BC3, BC4, BC5, BC6H Modes 1–14, BC7 Modes 0–7), and also discuss a complementary NVIDIA descriptor paging follow-up for victory-gpu.

Why this helps victory-fork

  • Currently crates/victory-hle/src/modules/dstorage.rs:968 decodes every BCPack request on the CPU via bcpack::decode(bc, &source, out, tables).
  • Under heavy world streaming, CPU BCPack + Gfx10 detiling competes with game/HLE threads and requires large staging buffers in system RAM before upload.
  • Moving BCPack entropy decode (rANS) + block rebuild onto D3D12 Async Compute removes CPU decompression cost while keeping the path completely opt-in and bit-exact against victory_formats::bcpack::decode.

Phase 1: Ready & Verified Prototype Today

I tested an opt-in prototype patch against fxceless/victory-fork commit 32b31f7 using bcpack-gpu-sdk v0.13.0:

  • Patch Gist: https://gist.github.com/POMXARK/893728e7dfd75072a2afd346166a6f7d
  • Feature & runtime gating: Completely behind --features gpu-bcpack and VICTORY_GPU_BCPACK=1 (zero impact on default builds or default runtime behavior).
  • Clean licensing (MIT OR Apache-2.0): bcpack-gpu-sdk ships compiled DXIL + Vulkan 1.3 SPIR-V compute kernels only, without embedding proprietary tables; victory-hle feeds BCPack reference tables (TABLES_BIN) at runtime via bcpack_gpu_set_{bc1,bc6h,bc7}_tables (or falls back cleanly to CPU bcpack::decode when unavailable).
  • Verification on Windows 11 (NVIDIA RTX 5080):
    • cargo check -p victory-hle -p victory --features gpu-bcpack -> exit 0 (0 warnings in victory-hle and victory).
    • cargo test --release -p victory-hle --features gpu-bcpack gpu_bcpack_matches_victory_cpu -- --nocapture -> test result: ok. 1 passed; 0 failed (TEST_RC=0):
      • 12/12 bit-exact cases (0 byte mismatches vs victory_formats::bcpack::decode) across all 6 formats (BC1, BC3, BC4, BC5, BC6H, BC7) × both [no-ref] and [full-ref+dict] modes.

Note: Phase 1 uses BcPackDecodeAsync in crates/victory-hle/src/modules/dstorage.rs:968 and still copies decoded BC blocks back into out so existing dstorage / victory-gpu contracts stay unchanged.

Proposed Follow-Ups

  1. Zero-copy GPU->GPU path in victory-gpu (bcpack_gpu_create_from_device + BcPackDecodeToTexture2D):
    Attach directly to victory-gpu's ID3D12Device / Async Compute queue and decode straight into GPU resources / staging textures via fence sync, eliminating the CPU readback hop in dstorage.rs (also relevant for staging concurrency such as #1157).
  2. NVIDIA descriptor heap paging (VirtualDescriptorPager) in crates/victory-gpu/src/descriptor/host.rs:
    Right now crates/victory-gpu/src/descriptor/host.rs:795 sets const PORTABLE_VIEWS: u32 = 1_000_000;, constrained by NVIDIA's ~1M CBV_SRV_UAV D3D12 hardware heap limit (whereas AMD/console workloads assume larger flat view heaps). A lightweight VirtualDescriptorPager mapping virtual guest descriptor indices into a 1M physical pool (with LRU eviction + victory-shader indirection or on-demand fault/rebind) could help NVIDIA stability without breaking AMD's direct indexing.
  3. Cross-backend note: bcpack-gpu-sdk v0.13.0 also ships 14 Vulkan 1.3 SPIR-V compute kernels alongside DXIL if a Vulkan/Linux compute path is ever useful.

Questions for Maintainers

  1. Would you be open to a PR starting with the Phase 1 opt-in gpu-bcpack feature (using the release crate or prebuilt bcpack_gpu.dll from v0.13.0), and do you prefer keeping CPU bcpack::decode readback compatibility first or moving straight to zero-copy hooks in victory-gpu?
  2. Is there active work or an existing design preference for handling NVIDIA's PORTABLE_VIEWS = 1_000_000 limit in crates/victory-gpu/src/descriptor/host.rs:795 before I prototype a VirtualDescriptorPager against fxceless/victory-fork?
**@⁠POMXARK** on GitHub · 2026-11-25 23:44 UTC · [original](https://github.com/fxceless/victory-fork/issues/1199) Hi `fxceless/victory-fork` maintainers, I would like to propose integrating [`bcpack-gpu-sdk`](https://github.com/POMXARK/bcpack-gpu-sdk) (`v0.13.0`, `MIT OR Apache-2.0`) to offload DirectStorage BCPack decompression from the CPU to GPU Async Compute across all 6 BCPack formats (`BC1`, `BC3`, `BC4`, `BC5`, `BC6H` Modes 1–14, `BC7` Modes 0–7), and also discuss a complementary NVIDIA descriptor paging follow-up for `victory-gpu`. ## Why this helps `victory-fork` - Currently `crates/victory-hle/src/modules/dstorage.rs:968` decodes every BCPack request on the CPU via `bcpack::decode(bc, &source, out, tables)`. - Under heavy world streaming, CPU BCPack + Gfx10 detiling competes with game/HLE threads and requires large staging buffers in system RAM before upload. - Moving BCPack entropy decode (`rANS`) + block rebuild onto D3D12 Async Compute removes CPU decompression cost while keeping the path completely opt-in and bit-exact against `victory_formats::bcpack::decode`. ## Phase 1: Ready & Verified Prototype Today I tested an opt-in prototype patch against `fxceless/victory-fork` commit `32b31f7` using [`bcpack-gpu-sdk` `v0.13.0`](https://github.com/POMXARK/bcpack-gpu-sdk/releases/tag/v0.13.0): - **Patch Gist:** https://gist.github.com/POMXARK/893728e7dfd75072a2afd346166a6f7d - **Feature & runtime gating:** Completely behind `--features gpu-bcpack` and `VICTORY_GPU_BCPACK=1` (zero impact on default builds or default runtime behavior). - **Clean licensing (`MIT OR Apache-2.0`):** `bcpack-gpu-sdk` ships compiled DXIL + Vulkan 1.3 SPIR-V compute kernels only, without embedding proprietary tables; `victory-hle` feeds BCPack reference tables (`TABLES_BIN`) at runtime via `bcpack_gpu_set_{bc1,bc6h,bc7}_tables` (or falls back cleanly to CPU `bcpack::decode` when unavailable). - **Verification on Windows 11 (NVIDIA RTX 5080):** - `cargo check -p victory-hle -p victory --features gpu-bcpack` -> exit `0` (0 warnings in `victory-hle` and `victory`). - `cargo test --release -p victory-hle --features gpu-bcpack gpu_bcpack_matches_victory_cpu -- --nocapture` -> `test result: ok. 1 passed; 0 failed` (`TEST_RC=0`): - **12/12 bit-exact cases (`0 byte mismatches` vs `victory_formats::bcpack::decode`)** across all 6 formats (`BC1`, `BC3`, `BC4`, `BC5`, `BC6H`, `BC7`) × both `[no-ref]` and `[full-ref+dict]` modes. Note: Phase 1 uses `BcPackDecodeAsync` in `crates/victory-hle/src/modules/dstorage.rs:968` and still copies decoded BC blocks back into `out` so existing `dstorage` / `victory-gpu` contracts stay unchanged. ## Proposed Follow-Ups 1. **Zero-copy GPU->GPU path in `victory-gpu` (`bcpack_gpu_create_from_device` + `BcPackDecodeToTexture2D`):** Attach directly to `victory-gpu`'s `ID3D12Device` / Async Compute queue and decode straight into GPU resources / staging textures via fence sync, eliminating the CPU readback hop in `dstorage.rs` (also relevant for staging concurrency such as #1157). 2. **NVIDIA descriptor heap paging (`VirtualDescriptorPager`) in `crates/victory-gpu/src/descriptor/host.rs`:** Right now `crates/victory-gpu/src/descriptor/host.rs:795` sets `const PORTABLE_VIEWS: u32 = 1_000_000;`, constrained by NVIDIA's ~1M `CBV_SRV_UAV` D3D12 hardware heap limit (whereas AMD/console workloads assume larger flat view heaps). A lightweight `VirtualDescriptorPager` mapping virtual guest descriptor indices into a 1M physical pool (with LRU eviction + `victory-shader` indirection or on-demand fault/rebind) could help NVIDIA stability without breaking AMD's direct indexing. 3. **Cross-backend note:** `bcpack-gpu-sdk v0.13.0` also ships 14 Vulkan 1.3 SPIR-V compute kernels alongside DXIL if a Vulkan/Linux compute path is ever useful. ## Questions for Maintainers 1. Would you be open to a PR starting with the **Phase 1 opt-in `gpu-bcpack` feature** (using the release crate or prebuilt `bcpack_gpu.dll` from `v0.13.0`), and do you prefer keeping CPU `bcpack::decode` readback compatibility first or moving straight to zero-copy hooks in `victory-gpu`? 2. Is there active work or an existing design preference for handling NVIDIA's `PORTABLE_VIEWS = 1_000_000` limit in `crates/victory-gpu/src/descriptor/host.rs:795` before I prototype a `VirtualDescriptorPager` against `fxceless/victory-fork`?
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:21 +00:00
Author
Owner

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

Follow-up on item 2 above (PORTABLE_VIEWS = 1_000_000):

I put together an opt-in (VICTORY_VIEW_PAGER=1) VirtualDescriptorPager + SLOT_VIEW_MAP (t252) prototype against main (006c353) and verified it on Windows 11 (NVIDIA RTX 5080):

  • Prototype Gist: https://gist.github.com/POMXARK/9150099d85799c7db4120ede217283ed (8 files across victory-shader and victory-gpu, off by default)
  • Design summary:
    • victory-shader: adds SLOT_VIEW_MAP (t252 in ROOT_CBV_SPACE, 1 << 21 dwords), set_view_heap_paged/view_heap_paged (included in translation_fingerprint()), and remaps only RootType::ResourceHeap view-heap indices in emit/lower.rs (heap_index, fetched_index). SLOT_STRIDES stays indexed by virtual slot, while RootType::Table, SamplerHeap, and USER_MEMORY_BASE remain untouched.
    • victory-gpu: adds descriptor/pager.rs (VirtualDescriptorPager with clock second-chance eviction), partitions a capped heap into [0..direct), [direct..dynamic_base), DYNAMIC ([dynamic_base..null_slot)), and null_slot = 999_999, allocates the 8 MiB view_map upload buffer in HostHeap, routes mirror / mirror_copied / mirror_copied_page / texture_slot_made_from past count, and binds t252 in pipeline/host.rs and draw.rs.
  • Verification on RTX 5080:
    • cargo check --workspace -> exit 0 (0 new warnings)
    • cargo test -p victory-shader -> 218 passed; 0 failed; 3 ignored, including dxil.dll-validated emit::lower::tests::paged_resource_heap_emits_valid_dxil_with_view_map_srv
    • cargo test -p victory-gpu descriptor:: -> 33 passed; 0 failed, including 3 descriptor::pager::tests unit tests and real D3D12 descriptor::host::tests::paged_host_heap_maps_slots_past_portable_views_on_d3d12 (mapping virtual slots 800_000, 1_200_000, and 1_507_328..1_507_330 into a PORTABLE_VIEWS heap with eviction reset to 999_999 and disjoint DYNAMIC slots).
**@⁠POMXARK** on GitHub · 2026-11-26 00:50 UTC · [original](https://github.com/fxceless/victory-fork/issues/1199#issuecomment-7179160079) Follow-up on item 2 above (`PORTABLE_VIEWS = 1_000_000`): I put together an opt-in (`VICTORY_VIEW_PAGER=1`) `VirtualDescriptorPager` + `SLOT_VIEW_MAP` (`t252`) prototype against `main` (`006c353`) and verified it on Windows 11 (NVIDIA RTX 5080): - **Prototype Gist:** https://gist.github.com/POMXARK/9150099d85799c7db4120ede217283ed (8 files across `victory-shader` and `victory-gpu`, off by default) - **Design summary:** - `victory-shader`: adds `SLOT_VIEW_MAP` (`t252` in `ROOT_CBV_SPACE`, `1 << 21` dwords), `set_view_heap_paged`/`view_heap_paged` (included in `translation_fingerprint()`), and remaps only `RootType::ResourceHeap` view-heap indices in `emit/lower.rs` (`heap_index`, `fetched_index`). `SLOT_STRIDES` stays indexed by virtual slot, while `RootType::Table`, `SamplerHeap`, and `USER_MEMORY_BASE` remain untouched. - `victory-gpu`: adds `descriptor/pager.rs` (`VirtualDescriptorPager` with clock second-chance eviction), partitions a capped heap into `[0..direct)`, `[direct..dynamic_base)`, `DYNAMIC` (`[dynamic_base..null_slot)`), and `null_slot = 999_999`, allocates the 8 MiB `view_map` upload buffer in `HostHeap`, routes `mirror` / `mirror_copied` / `mirror_copied_page` / `texture_slot_made_from` past `count`, and binds `t252` in `pipeline/host.rs` and `draw.rs`. - **Verification on RTX 5080:** - `cargo check --workspace` -> exit `0` (0 new warnings) - `cargo test -p victory-shader` -> `218 passed; 0 failed; 3 ignored`, including `dxil.dll`-validated `emit::lower::tests::paged_resource_heap_emits_valid_dxil_with_view_map_srv` - `cargo test -p victory-gpu descriptor::` -> `33 passed; 0 failed`, including 3 `descriptor::pager::tests` unit tests and real D3D12 `descriptor::host::tests::paged_host_heap_maps_slots_past_portable_views_on_d3d12` (mapping virtual slots `800_000`, `1_200_000`, and `1_507_328..1_507_330` into a `PORTABLE_VIEWS` heap with eviction reset to `999_999` and disjoint `DYNAMIC` slots).
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/fxceless--victory-fork#1199
No description provided.