Skip to content

Shaders: scan short archive records at the end of the input - #1107

Open
anakatt wants to merge 1 commit into
xcl-dev:mainfrom
anakatt:shaders/scan-short-final-records
Open

anakatt wants to merge 1 commit into
xcl-dev:mainfrom
anakatt:shaders/scan-short-final-records

Conversation

@anakatt

@anakatt anakatt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

I fixed pack::scan dropping valid short records at the end of its input. The loop required more than 32 bytes remaining, but the accepted record format needs only 23 bytes at minimum. A synthetic 28-byte record was ignored without trailing padding.

What is in it

  • Use the actual minimum candidate size; keep the existing name, header, payload and overflow checks.
  • Add a regression for 28- and 32-byte final records, both at offset zero and after a prefix, including inflation of their payloads.
  • Document unpadded final-record support in the RPF tool guidance.

Tested

  • macOS Darwin 24.6.0, arm64; rustc 1.99.1, miniz_oxide 0.9.1; debug. No GPU used.

  • A temporary Cargo harness linked the actual repository crates/xcl/src/gpu/pack.rs as its library, without compiling the Windows runtime or mocking the scanner.

  • Before the fix, cargo test --offline --manifest-path /tmp/xcl-pack-probe.ANtIu4/Cargo.toml --test short_records failed: the 28-byte record returned no records.

  • After the fix, cargo test --offline --manifest-path /tmp/xcl-pack-probe.ANtIu4/Cargo.toml --test short_records --test bounds: 2 passed, 0 failed, 0 ignored, 0 skipped. The harness checked four short-record/prefix combinations plus short buffers and out-of-range offsets, and was removed afterward.

  • Windows 11 Pro ARM64 10.0.26100.1742 in UTM (4 GiB VM RAM, Red Hat VirtIO GPU DOD), running x64 binaries through Windows emulation; rustc 1.100.0 x86_64-pc-windows-msvc, Windows SDK 26100. Debug build with CARGO_PROFILE_DEV_DEBUG=0, CARGO_PROFILE_TEST_DEBUG=0, CARGO_BUILD_JOBS=1; no GPU tests selected.

  • Exact source archive 5ab17d4fc701aecb1b3b017229b08a908114a5ee, after cargo clean -p xcl: cargo test --locked -p xcl --lib gpu::pack -- --test-threads=4: 5 passed, 0 failed, 0 ignored, 715 filtered out; no SKIPPED lines. The new short_records_do_not_need_trailing_padding test ran and passed. An earlier shared-cache run reused the prior test executable and is not counted as verification of this revision.

Regression run

  • Not run. Required main/head Windows title smoke blocks remain outstanding; this PR is a draft.

Not tested

  • Full Windows/GPU suite, native x64 hardware, CLI extraction path and real game archives. The focused Windows run is not a full workspace or title run.

AI use

  • I used omp (openai-codex/gpt-6-astra) to find and reproduce the boundary bug, write the fix and regression, run the isolated native harness and focused Windows tests, and prepare this description.

The scanner stopped with 32 bytes remaining even though its format permits
a 23-byte candidate. Valid short records were found with padding but lost
when they were the archive's final record.

Use the actual minimum candidate size. Cover 28- and 32-byte records at
the start and after a prefix, and document unpadded final-record support.

A temporary native harness linked the real pack.rs with miniz_oxide 0.9.1:
the short-record test failed before the change; afterward 2 tests passed
(short records and bounds). This is not a Windows workspace test run.
Windows/GPU tests and main/head title smoke runs remain outstanding.

Assisted-by: omp (openai-codex/gpt-6-astra)
@futurepro62

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 5ab17d4 (on its base 47efa2e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: short_records_do_not_need_trailing_padding.

Not tested

  • AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 5ab17d4f on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 5ab17d4fc701aecb1b3b017229b08a908114a5ee
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14817 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

@github-actions

Copy link
Copy Markdown

Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 29, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 5ab17d4

No open or merged PR changes pack::scan's loop bound. The other PRs that touched pack.rs (#4, #8, #2906) are closed and kept the - 32 bound. The new bound is right: a candidate needs at least 1 + 3 + 18 + 1 = 23 bytes. Every read in the loop body is still guarded by header_end <= d.len() before d[p] and rd32(.., p + 14), so no index can go out of range. No problems found in the diff.
Minor: the README line sits between the command block and the launcher-menu bullet, and it would read better in the xcl rpf description.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants