cpu: select BC7 storage ranges from a bounded guest directory #1345

Manually merged
github merged 1 commit from gh-pr/1345/head into gh-pr/1345/base 2026-11-26 22:59:52 +00:00
Owner

@⁠R0Y00 on GitHub · 2026-11-24 08:47 UTC · original
R0Y00:codex/guest-directory-selection → main · +173 −63 · 6 files · 1 commits · merged 2026-11-24 09:05 UTC

Refs #1198 and #870. Follows #1331.

Let the compiler-built guest select both requests from a raw file prefix of up to 64 KiB. It validates the RDS5 directory and both logical pages, binary-searches for each requested record, and computes its source range. Queue creation and submission remain in the existing Windows provider. The guest's lookup function has an explicit PE export so the AOT verifier can identify the leaf function.

The three runners use the same underlying files. The controls distinguish three ways to get the same incorrect first half of the BC7 frame:

  • Opening the alternate file changes the Windows file-object identity. Its directory entries and request ranges match the original file.
  • Selecting the equal-length decoy in the original file reports directory entry 3585.
  • Shifting the correct entry's offset by 896 KiB reports entry 1 but reads the same bytes as entry 3585.

The ordinary two-page batch also selects entry 2 then jumps to entry 3585. Two ETPF metadata sizes change the absolute start of the compressed data. An oversized count, an out-of-file terminal boundary, and an unavailable second page each return 3 before the provider creates the queue. Moving only the first physical offset to EOF returns 6, leaves that page untouched and completes the second request.

Windows 11 build 26200.9974 x64, Release 4f3f79a2, RTX 4060 Laptop GPU 32.0.16.1656 and WARP 10.0.26100.9818. Native PE, mapped PE and AOT: 108 runs, 60 complete RGBA frames, 12 queue EOF controls, 36 pre-enqueue rejections and no capability skips. Existing reader, texture publication and directory queue regressions passed. Documentation checker verified 299 links.

cmake --build --preset release --target archive_directory_lifted pe_map archive_reader_lifted archive_texture_lifted startup_stub_consumer startup_stub_xcrdapi
ctest --preset release --no-tests=error --output-on-failure -R '^(cpu_archive_directory_gpu_(warp|hardware)|cpu_native_archive_reader|cpu_archive_texture_publication|startup_storage_directory_batch)$'

The fixture accepts a whole single-page zlib interval for each requested logical page. Its failure controls leave the separate production offset-source question in #1198 open.

**@⁠R0Y00** on GitHub · 2026-11-24 08:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1345) `R0Y00:codex/guest-directory-selection` → `main` · +173 −63 · 6 files · 1 commits · merged 2026-11-24 09:05 UTC Refs #1198 and #870. Follows #1331. Let the compiler-built guest select both requests from a raw file prefix of up to 64 KiB. It validates the RDS5 directory and both logical pages, binary-searches for each requested record, and computes its source range. Queue creation and submission remain in the existing Windows provider. The guest's lookup function has an explicit PE export so the AOT verifier can identify the leaf function. The three runners use the same underlying files. The controls distinguish three ways to get the same incorrect first half of the BC7 frame: - Opening the alternate file changes the Windows file-object identity. Its directory entries and request ranges match the original file. - Selecting the equal-length decoy in the original file reports directory entry 3585. - Shifting the correct entry's offset by 896 KiB reports entry 1 but reads the same bytes as entry 3585. The ordinary two-page batch also selects entry 2 then jumps to entry 3585. Two ETPF metadata sizes change the absolute start of the compressed data. An oversized count, an out-of-file terminal boundary, and an unavailable second page each return 3 before the provider creates the queue. Moving only the first physical offset to EOF returns 6, leaves that page untouched and completes the second request. Windows 11 build 26200.9974 x64, Release 4f3f79a2, RTX 4060 Laptop GPU 32.0.16.1656 and WARP 10.0.26100.9818. Native PE, mapped PE and AOT: 108 runs, 60 complete RGBA frames, 12 queue EOF controls, 36 pre-enqueue rejections and no capability skips. Existing reader, texture publication and directory queue regressions passed. Documentation checker verified 299 links. ```powershell cmake --build --preset release --target archive_directory_lifted pe_map archive_reader_lifted archive_texture_lifted startup_stub_consumer startup_stub_xcrdapi ctest --preset release --no-tests=error --output-on-failure -R '^(cpu_archive_directory_gpu_(warp|hardware)|cpu_native_archive_reader|cpu_archive_texture_publication|startup_storage_directory_batch)$' ``` The fixture accepts a whole single-page zlib interval for each requested logical page. Its failure controls leave the separate production offset-source question in #1198 open.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:59:51 +00:00
github manually merged commit 4f3f79a231 into gh-pr/1345/base 2026-11-26 22:59:52 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 08:52 UTC · original · reviewed

Technical peer review at commit 4f3f79a23178922dc4b9b1538123ee2cada3f6c2 (LGTM, no blocking findings):

Code audit:

  • tests/cpu/archive/directory_reader.zig: validate checks the 16-byte header, RDS5 magic, entry count bounds against both input.bytes and the entry-0 metadata boundary, strictly increasing logical/physical offsets, and terminal physical/logical bounds against file_size and words[1]. locate binary-searches safely within [0, count - 1], rejects non-zlib/multi-page/zero-or-overflowing spans, and uses entry 0 as a safe sentinel (validated as compression type 0). queueRecord checks @addWithOverflow(start, bias) before calling enqueue_page.
  • tests/cpu/archive/directory_gpu.cpp & tests/cpu/archive_directory_gpu_check.py: _setmode(_fileno(stdin), _O_BINARY) avoids text-mode translation on binary stdin; begin_batch logs the file-object ID (nFileIndexHigh/Low) and defers queue creation until enqueue_page, so validation failures exit 3 before any queue/trace/pixel artifacts are created. Negative controls cover invalid count, terminal beyond EOF, missing second, EOF, wrong file, wrong record, and wrong offset.
  • CMakeLists.txt & docs/experiments.md: EXPORT_SYMBOLS (-rdynamic) is cleanly parsed via cmake_parse_arguments; wording is title-neutral.

Checks:

  • Linux: tests/docs_links_check.py (16 Markdown files, 299 links) passed; tests/bidi_controls_check.py (1113 files) passed; git diff --check clean.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev, archive_directory_lifted pe_map): cpu_archive_directory_gpu_warp 1/1 passed (10.34s).
    • Release /O2 (--preset release, archive_directory_lifted pe_map): cpu_archive_directory_gpu_warp 1/1 passed (9.82s).
**@⁠tedin7** on GitHub · 2026-11-24 08:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1345#pullrequestreview-6036211801) · **reviewed** Technical peer review at commit `4f3f79a23178922dc4b9b1538123ee2cada3f6c2` (LGTM, no blocking findings): **Code audit:** - `tests/cpu/archive/directory_reader.zig`: `validate` checks the 16-byte header, `RDS5` magic, entry count bounds against both `input.bytes` and the entry-0 metadata boundary, strictly increasing logical/physical offsets, and terminal physical/logical bounds against `file_size` and `words[1]`. `locate` binary-searches safely within `[0, count - 1]`, rejects non-zlib/multi-page/zero-or-overflowing spans, and uses entry `0` as a safe sentinel (validated as compression type `0`). `queueRecord` checks `@addWithOverflow(start, bias)` before calling `enqueue_page`. - `tests/cpu/archive/directory_gpu.cpp` & `tests/cpu/archive_directory_gpu_check.py`: `_setmode(_fileno(stdin), _O_BINARY)` avoids text-mode translation on binary stdin; `begin_batch` logs the file-object ID (`nFileIndexHigh`/`Low`) and defers queue creation until `enqueue_page`, so validation failures exit `3` before any queue/trace/pixel artifacts are created. Negative controls cover `invalid count`, `terminal beyond EOF`, `missing second`, `EOF`, `wrong file`, `wrong record`, and `wrong offset`. - `CMakeLists.txt` & `docs/experiments.md`: `EXPORT_SYMBOLS` (`-rdynamic`) is cleanly parsed via `cmake_parse_arguments`; wording is title-neutral. **Checks:** - **Linux**: `tests/docs_links_check.py` (16 Markdown files, 299 links) passed; `tests/bidi_controls_check.py` (1113 files) passed; `git diff --check` clean. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`, `archive_directory_lifted pe_map`): `cpu_archive_directory_gpu_warp` **1/1 passed** (`10.34s`). - Release `/O2` (`--preset release`, `archive_directory_lifted pe_map`): `cpu_archive_directory_gpu_warp` **1/1 passed** (`9.82s`).
This discussion has been locked. Commenting is limited to contributors.
No description provided.