Skip to content

DirectStorage: count BCPack refusals per mode; opt-in solid fill to test what they cost - #201

Closed
Kalmarv wants to merge 1 commit into
ivall:mainfrom
Kalmarv:fix/dstorage-bcpack-refusals
Closed

Kalmarv wants to merge 1 commit into
ivall:mainfrom
Kalmarv:fix/dstorage-bcpack-refusals

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

#195 reports that the retail menus' body text is missing most of its letters. Its one lead is the log line DirectStorage: BCPack mode 7 unsupported, read as refusing one 64 KiB chunk. On main, that line can't say how many chunks were refused. Every BCPack refusal shares one warn_once("BCPack", …) key, so the log shows the first refused request of any mode, and every later one fails silently with E_DECOMPRESSION. This PR makes the refusals visible and adds an opt-in experiment to test the lead. It doesn't decode BCPack, and without the switch every request behaves as on main.

Only crates/xcl/src/hle/dstorage.rs and crates/xcl/src/report.rs change (+387/−14). The tests are about 185 of those lines.

Counts

  • One warning per mode and zlib stage, for example BCPack BC7 and BCPack BC7 after zlib. It gives the sizes and swizzle mode of the first such request, and says the request fails with E_DECOMPRESSION.
  • A running count line on the first 16 refusals and every power of two, in the style of the existing request #k lines: BCPack refusals so far: N requests: BC1 … (… bytes), BC7 … (… bytes).
  • report.json gets dstorage.bcpack_refused, keyed by DSTORAGE_BCPACK_MODE name (BC1 … BC7, or mode N for values outside the GDK enum). It holds requests, with_zlib, destination_bytes and filled_bytes. The field is #[serde(default)], like the other subsystem sections.
  • Counting happens where a title's request is refused at enqueue, so the direct Request::check calls in tests aren't counted.

XCL_DSTORAGE_BCPACK_FILL=1 (off by default; unset, empty or 0 means off)

  • Each refused BCPack destination gets solid blocks of the requested BCn format instead of staying as it was:

    • BC1/BC2/BC3: magenta, alpha 255;
    • BC4: 255;
    • BC5: (255, 0);
    • BC6H: mode 11, (1.0, 0, 1.0);
    • BC7: mode 6, (255, 1, 255, 255).

    A solid fill looks the same under any tiling or swizzle, so the layout doesn't matter.

  • It writes exactly destination_size bytes. The fill runs on the queue's worker, in queue order, where the request would have run. The destination is checked the same way as for a request that runs: committed, writable memory (writable), or the physical page array snapshotted at enqueue and written through write_physical_pages. If the snapshot fails, nothing is written.

  • The request still fails with E_DECOMPRESSION, as before.

How to use it with #195: run the menus with XCL_DSTORAGE_BCPACK_FILL=1. If the body text turns into magenta boxes, the missing letters come from BCPack. If it doesn't change, the cause is elsewhere, for example indexed or shader-made rect lists, or XGTextureAddressComputer #10. bcpack_refused in report.json shows how many chunks and bytes are involved either way.

Tests (cargo test -p xcl --lib dstorage, MSVC debug, Windows 11; synthetic only)

base 956a476 this branch (bb66204)
hle::dstorage tests 8 11 / 11 pass

The new tests:

  • bcpack_fill_blocks_are_solid_in_their_bcn_format decodes every fill block with small decoders in the test module (BC1, BC4/BC3 alpha, BC6H mode 11 UF16, BC7 mode 6). It checks all 16 texels of each block.
  • bcpack_refusals_are_counted_per_mode_and_still_fail checks counts per mode, the zlib-combined count, destination bytes and the summary line. It also checks that check() still returns E_DECOMPRESSION for modes 1–7.
  • a_refused_bcpack_request_is_filled_only_under_the_switch uses a memory queue and a BC7 destination of 0x1008 bytes (a partial block at the end) followed by guard bytes:
    • with the switch off, the destination is untouched and the status is E_DECOMPRESSION;
    • with it on, the destination holds solid blocks up to exactly its size, the guard bytes are untouched and the status is unchanged.

Five mutations each fail one of the new tests: BC7 p-bits cleared, the fill ignoring the switch, a fill 16 bytes past the size, no zlib count, and the fill clearing the status. cargo check -p xcl is clean.

Not covered:

  • The physical-page fill path isn't exercised by a test. It reuses the snapshot and write_physical_pages code that physical_page_destinations_and_sources covers.
  • The test decoders cover only the block modes the fills use; they are not full BCn decoders.
  • No GPU or retail run. Whether the missing text is BCPack is for the experiment above to show.

AI-assisted (Claude Code). No game data.

🤖 Generated with Claude Code

…heir destinations

A BCPack refusal was logged once per run (warn_once "BCPack"), so a log
showed the first refused request and nothing about the rest. Now:

- one warning per mode and zlib stage, and a running count line on the
  first 16 refusals and every power of two;
- report.json gets dstorage.bcpack_refused: requests, zlib-combined
  requests, destination bytes and filled bytes per DSTORAGE_BCPACK_MODE;
- XCL_DSTORAGE_BCPACK_FILL=1 fills each refused BCPack destination with
  solid blocks of its BCn format (magenta, red for BC4/BC5), exactly
  destination_size bytes, into committed writable memory or the
  physical pages snapshot at enqueue. The request still fails with
  E_DECOMPRESSION; nothing changes without the switch.

Tests: per-mode counts, the fill blocks decoded by small BC1/BC4/BC6H
mode 11/BC7 mode 6 decoders in the test module, and a memory queue run
with and without the switch (status unchanged, no byte past the size).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Kalmarv
Kalmarv force-pushed the fix/dstorage-bcpack-refusals branch from bb66204 to a486652 Compare November 23, 2026 21:03
@Kalmarv

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main eaa36b6 (a486652, no conflicts). cargo test --release -p xcl --lib dstorage: 12 passed. Main's writable() now accepts the UMA committed window as well, which the fill path uses.

Overlaps: #208 is stacked on this commit (the BCPack decoder; its refusal counts are this PR's). #167 also edits hle/dstorage.rs (the refused factory IID in the log); the two merge without conflicts.

@Kalmarv

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Correction to this PR's motivation: #211 found the cause of the missing menu letters, and it isn't BCPack. The glyph caches are small render targets the title fills from the CPU, which title_textures::register never uploaded; with #211 the body text is complete.

What still stands: main refuses every DirectStorage request with a BCPack stage, and nothing shows how many. Whether a refused request loses anything visible in this title isn't known. The per-mode counts in report.json would show how much is refused in a run.

AI-assisted (Claude Code).

ivall added a commit that referenced this pull request Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Merged into main (6da33fa) as bb66204, the head before your last rebase - the same patch (identical patch-id), so GitHub does not show it as merged; closing it by hand. Checked on an RX 9070 (RDNA4) with the 22 PRs merged together: 582 unit tests passed, 0 failed, the integration and e2e tests passed, and the retail game still reaches its first menu (646 frames in 30 s, no device removal). Thanks!

@ivall ivall closed this Nov 23, 2026
josilo added a commit to josilo/xcl that referenced this pull request Nov 23, 2026
Apply XCL ivall#204, ivall#205, ivall#147, ivall#167, ivall#191, ivall#201 and ivall#210: sparse range tracking, frame-origin ordering, crash reporting, refused interface and BCPack diagnostics, shader fixes, and console format queries. Keep menu glyph syncing and slot-57 tracking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants