Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"xmem_shim_test_controls", "startup_stub_xcrdapi", "startup_stub_xcrdapi_break_window_control",
"xmem_run_break_readers_check", "xmem_run_break_readers_control", "xmem_cross_call_merge_check",
"xmem_placeholder_split_check", "xmem_map_split_first_check", "startup_dstorage_break_window_check",
"xmem_page_runs_device_check", "linear_buffer_backing_check"
"xmem_page_runs_device_check", "linear_buffer_backing_check",
"bcpack_formats_check", "startup_stub_consumer"
]
},
{ "name": "release", "configurePreset": "release" },
Expand All @@ -47,7 +48,7 @@
"displayName": "Windows pull request smoke tests",
"filter": {
"include": {
"name": "^(desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_shader_cache_key|startup_present_readback|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package)$"
"name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_shader_cache_key|startup_present_readback|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package)$"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The control-flow CPU translator supports [source-built string memory transfers](
| CPU differential fuzz | Generate 20 deterministic leaf functions from seed `0xA902`, translate them, and compare native, default and `/O2` builds over 313 inputs each. | `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V` |
| Script states | Reproduce a parent/child lookup, an ambiguous selection or a damaged sibling link with a synthetic tree. | `ctest --preset dev --no-tests=error -R '^script_(state_literals\|path_links)$' -V` |
| Resource metadata | Check a [relocated resource root](docs/experiments.md#relocated-resource-root) against its block directory and type schema. | `ctest --preset dev --no-tests=error -R '^resource_relocated_root$' -V` |
| Texture recovery | [Decode MDU rANS symbols](docs/experiments.md#decoding-mdu-rans-symbol-streams) using [bcpack-rs by Ahmet Dedeler](https://github.com/Ahmet-Dedeler/bcpack-rs), or check a packed mip tail, a first refill byte, the fields of a generated BC7 block, or a resident mip drawn on the software adapter. [Look up a texture key across archives and inspect a matching descriptor](docs/experiments.md#reading-logical-ranges-and-probing-structured-resources). [Batch export TTPF textures with optional Rust kernels](docs/experiments.md#batch-export-ttpf-textures-to-dds). | `ctest --preset dev --no-tests=error -R '^(bcpack_prefix_and_mip_tail\|bcpack_rans_symbols\|bc7_block_reference\|bc7_draw_warp\|resource_range_controls)$' -V` |
| Texture recovery | [Check standalone BCPack BC1–BC7 reconstruction](docs/experiments/bcpack-standalone.md) or [decode MDU rANS symbols](docs/experiments.md#decoding-mdu-rans-symbol-streams) using [bcpack-rs by Ahmet Dedeler](https://github.com/Ahmet-Dedeler/bcpack-rs), or check a packed mip tail, a first refill byte, the fields of a generated BC7 block, or a resident mip drawn on the software adapter. [Look up a texture key across archives and inspect a matching descriptor](docs/experiments.md#reading-logical-ranges-and-probing-structured-resources). [Batch export TTPF textures with optional Rust kernels](docs/experiments.md#batch-export-ttpf-textures-to-dds). | `ctest --preset dev --no-tests=error -R '^(bcpack_all_formats\|startup_bcpack_storage\|bcpack_prefix_and_mip_tail\|bcpack_rans_symbols\|bc7_block_reference\|bc7_draw_warp\|resource_range_controls)$' -V` |
| Audio metadata | Inventory stream counts, codec IDs and sample rates in a bounded [AWC sound-effect or music bank](docs/experiments.md#awc-sound-effect-format-metadata) with flag word `0xff000001` or `0xff020001`. | `ctest --preset dev --no-tests=error -R '^audio_awc_metadata$' -V` |
| Compute shader recompilation | Translate fixed, indexed and row-pitch raw UAV stores for 1D, 2D and 3D thread groups, including an optional runtime constant buffer, and compare the complete buffer on D3D12. [Bindings and commands](docs/experiments.md#compute-uav-stores-from-a-native-container) · [Bounded gfx1030 DS lane routing](docs/experiments.md#bounded-gfx1030-ds-lane-routing) · [Private gfx1030 LDS access and updates, including 64-bit min/max and xor](docs/experiments.md#private-gfx1030-lds-word-access) | `ctest --preset dev --no-tests=error -R '^compute_store_aot_'` |
| gfx1013 compute DPP16 | Lower `v_or_b32_dpp` with `quad_perm`, and `v_or_b32_dpp`/`v_add_nc_u32_dpp` with `row_shr:1`–`15` with or without `bound_ctrl`, under full row/bank masks; compare source-built fixtures with logical-thread references. Scope and limits: [quad_perm](docs/experiments.md#gfx1013-compute-dpp16-quad-permutation), [row_shr](docs/experiments.md#gfx1013-compute-dpp16-row-shift-right) | `ctest --preset dev --no-tests=error -R '^compute_store_aot_dpp_' -V` |
Expand Down
14 changes: 14 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -12875,6 +12875,20 @@ mapping, archive stream discovery and rendered pixels remain separate work.
The existing prefix probe keeps its diagnostic behavior. No local archive or
texture payload is used by these checks.

### Standalone BCPack block reconstruction

The startup DirectStorage stand-in reconstructs BC1–BC7 packed blocks without an
installed GDK or external table file. BC1's fitted endpoint window and quadrant
masks are removed; BC2 and BC6H now decode rather than report blank success.
See [the standalone implementation notes](experiments/bcpack-standalone.md) for
source provenance, synthetic golden checks, atomic storage tests, and optional
oracle reproduction commands.

```powershell
cmake --build --preset dev --target bcpack_formats_check startup_stub_consumer startup_stub_xcrdapi
ctest --preset dev --no-tests=error -R '^(bcpack_all_formats|startup_bcpack_storage)' -V
```

### BCPack lane decoder paths

The startup storage stand-in decodes BCPack streams with `decode_lanes` in
Expand Down
133 changes: 133 additions & 0 deletions docs/experiments/bcpack-standalone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Standalone BCPack BC1–BC7 reconstruction

`src/startup_stubs/bcpack_decoder.h` reconstructs the seven BC block formats from
complete BCPack streams. BC2 uses fifteen lanes and BC6H uses sixteen. BC1 now
uses independent endpoint/index references and the full 255-entry initial
dictionary. The old fitted BC1 endpoint window and quadrant masks are removed.
BC6H supports all fourteen modes and changes of precision/subset count across
historical references. The output is packed BC blocks, not RGBA pixels.

The DirectStorage stand-in decodes into a temporary buffer and publishes it
only after the complete request succeeds. BC2/BC6H no longer return successful
blank textures. An invalid format or malformed stream fails. Existing file,
memory, outer RFC 1950 zlib and physical-page destination handling applies.
Historical `bcpack-blank` counters remain in the log schema for compatibility;
this decoder does not produce blank-success requests.

## Sources and constants

The entropy decoder and existing BC3/4/5/7 code retain their bcpack-rs and
silicon-rans notices in [THIRD_PARTY_NOTICES.md](../../tools/_bcpack_rans/THIRD_PARTY_NOTICES.md).
The new BC1/2/6H routines are original C++ reconstruction code. Research used
the installed GDK interface, local implementation inspection, and comparisons
with public bcpack-rs and VIctory implementations. This is not a claim of a
strict clean-room process. No GPL implementation or binary table blob was
copied into these files.

`bcpack_tables_extra.inl` contains fixed format dictionaries and rank mappings.
They were reconstructed by sending chosen, entirely synthetic lane streams to
the developer oracle's `BCPackDecompress` API and reading the resulting standard
BC fields. There is no sample fitting, approximation, per-asset lookup or
run-time learning. The recovery tool does not read the DLL's data section.

The BC6H wire descriptors adapt Microsoft's MIT-licensed
[DirectXTex BC6HBC7.cpp](https://github.com/microsoft/DirectXTex/blob/a8e5dbf42909aeeb9fcf9c2ae399ae3c06737379/DirectXTex/BC6HBC7.cpp),
revision `a8e5dbf42909aeeb9fcf9c2ae399ae3c06737379`, SHA-256
`187434fab12351df0f875ae09390981034e8479159a6f4aaaf0904f007182b8a`.
The emitted BCPack blocks use ascending high base-endpoint bits in modes 13/14;
the descriptor generator applies that ordering explicitly. Preserve the
DirectXTex MIT notice when redistributing those descriptors.

Normal builds, tests and runtime DLLs require neither GDK nor BCPack.dll.
The optional oracle target and script below are development tools only. They
require a separately installed developer oracle, which is not redistributed.

## Reproduce the public checks

From an x64 Visual Studio developer PowerShell:

```powershell
. ./tools/dev.ps1
cmake --preset dev
cmake --build --preset dev --target bcpack_formats_check startup_stub_consumer startup_stub_xcrdapi
ctest --preset dev --no-tests=error -R '^(bcpack_all_formats|startup_bcpack_storage)' -V
python -B tests/bcpack_tables_check.py
```

The golden test generates 12,330 synthetic streams from source. It checks all
255 initial references plus the zero predictor, independently selected endpoint
and index references, all fourteen BC6H modes and all 32 partitions. Random
symbol streams cover all seven formats and block counts 2, 17, 255, 256, 257
and 1024, including mode changes and history-ring wrap. BC7 selects all 285
mapped controls. Every supported entropy path must reproduce the same bytes.

Each group is checked against a fixed FNV-1a-64 hash of the independent oracle's
complete output. The expected hashes are not generated by the decoder under
test. A one-byte mutation must fail the golden control. Truncation, wrong output
alignment, nonzero trailing data and invalid formats must fail with zero bytes
reported. An undefined BC6H mode must fail too. The storage test checks full BC2
and BC6H destination bytes against fixed synthetic oracle outputs across
memory/file, raw/zlib and linear/cross-page requests. Missing page grants, unsupported formats and a bad final BC6H mode after
three valid blocks must preserve the destination; a following valid request
must still succeed.

The unchanged `synthetic_11` BC1 input in `startup_stub_consumer.cpp` had 491
wrong bytes in its former 512-byte expected output. Its first eight expected
bytes were `85 31 64 d5 af be ff bf`; the oracle returns
`8d 73 0a 07 ea b8 fa be`. The fixture now checks the oracle's complete 512
bytes, keeping the original input, size and malformed-input controls.

## Optional oracle reproduction

For the original experiment the installed BCPack library reported version
`1.2603.3.0`. Its binaries, private headers and title payloads are not part of
this repository. Supply paths to your own local installation and to the public
DirectXTex source pinned above:

```powershell
cmake --build --preset dev --target bcpack_oracle_bridge
./out/build/dev/bcpack_formats_check.exe --oracle 'C:/path/to/BCPack.dll'
python -B tools/bcpack_recover_constants.py `
--sdk 'C:/path/to/BCPack.dll' `
--bridge out/build/dev/bcpack_oracle_bridge.dll `
--bc6-reference out/DirectXTex/DirectXTex/BC6HBC7.cpp `
--output out/bcpack_tables_extra.inl `
--storage-goldens out/bcpack_storage_goldens.h
python -c "from pathlib import Path; assert Path('src/startup_stubs/bcpack_tables_extra.inl').read_text() == Path('out/bcpack_tables_extra.inl').read_text()"
python -c "from pathlib import Path; assert Path('tests/bcpack_storage_goldens.h').read_text() == Path('out/bcpack_storage_goldens.h').read_text()"
```

The recovery script queries each dictionary entry separately. BC1/2 ranks are
recovered with zero predictors. BC6H's base endpoint uses the sixteen-bit mode;
the other endpoints use modes exposing their complete stored precision. The
generated table file reproduced LF-normalized SHA-256
`181f279bbc84a3e93aa4d44bf6f7c6e522493b3a92538b7209e4b22721a3a12e`.
An oracle change may change output; investigate differences before replacing
goldens or format constants.

## Local comparison and limits

A separate read-only comparison covered 105,845 chunks from 45 local archive
pools, totaling 16,356,958,208 decoded bytes. Every chunk was compared byte for
byte with the installed oracle on the AVX2 path. A distributed sample of 882
chunks also used the reference and scalar paths. There were no byte mismatches
or guard violations. No archive bytes or extracted textures are included here.

| Format | Local archive chunks |
|---|---:|
| BC1 | 100,020 |
| BC2 | 0 |
| BC3 | 35 |
| BC4 | 77 |
| BC5 | 325 |
| BC6H | 268 |
| BC7 | 5,120 |

An additional 312 oracle-compressed synthetic cases across BC1–BC7 matched
byte for byte on all three paths, including random, repeated and historical
blocks and individual BC6H/BC7 modes. Inputs rejected by the oracle compressor
were excluded from that successful-compression count, not called passes.
The public synthetic golden suite supplies BC2 coverage independently of the
local archives. These are packed-block decoding checks, not GPU image or
full-application startup measurements. Finite test coverage cannot establish
correctness for every possible stream.
2 changes: 1 addition & 1 deletion docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -2847,7 +2847,7 @@ These are measured on one executable; treat them as hypotheses for others.
`src/startup_stubs/logical_view_table.h` without a device. It covers the first and last records, one
past the end, handles inside a record or below the heap, missing heap fields, memory that wraps past
the top of the address space, and records crossing the end of a window.
- BCPack DirectStorage requests are decoded for BC7 and BC1 streams into destination memory as single atomic texture payloads; each request decompresses a complete multi-lane rANS chunk directly into its destination buffer and is excluded from chunk continuation caching. Unhandled formats fall back to zero-filled destinations. At process exit, one `x2w-dstorage BCPack summary` line reports request and zero-filled counts for every format 1..15 that was requested. The consumer fixture sends a format 6 request and checks that it succeeds, leaves a zero-filled destination, and appears in both counts; BC1 and BC7 requests must not be counted as zero-filled.
- BCPack DirectStorage requests decode BC1–BC7 complete multi-lane rANS payloads into temporary memory and publish only after success. They are excluded from continuation caching. BC2/BC6H now reconstruct packed blocks; invalid formats and damaged streams fail without publishing blank textures. BC1 uses independent endpoint/index history and exact format dictionaries; the fitted window and quadrant masks have been removed. File and memory sources, outer zlib and physical-page destinations share this path. Historical zero-filled counters remain in the summary log schema but are no longer incremented. [Implementation, synthetic fixtures and oracle reproduction](experiments/bcpack-standalone.md).
- The XG stand-in normally uses desktop copyable footprints. Its opt-in BC7 diagnostic
reports standard GFX10 4 KiB tiled geometry for a single-slice, single-mip, non-MSAA
`BC7_UNORM` 2D texture with an unknown layout, default alignment, and no resource flags.
Expand Down
Loading
Loading