DirectStorage: requests with swizzle modes 14 are interleaved on the CPU #3310
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3310"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T06:58:49Z.
Draft: rayy (raylitebull, who wrote it), can you confirm the group layouts (or where they were checked)? The code and tests are clean, but nothing here can verify the interleaving against a real title.
A DirectStorage request may ask for one of the BCn swizzle modes, in
which the stream holds each block component as its own array and the
destination wants them interleaved in 16 KiB or 32 KiB groups (mode 1
4K_4K_8K: BC1 endpoints and indices; 2 4K_4K_24K: BC4; 3 4K_12K_4K_4K_8K:
BC3 alpha and colour; 4 4K_12K_4K_12K: BC5). XCL refused every swizzled
request (E_DECOMPRESSION). Modes 1–4 are now interleaved after zlib and
BCPack (swizzle_interleave); a destination that is not a whole number of
groups is E_DESTINATION_SIZE; modes above 4 are still refused.
The group layouts come from the mode names; they were not checked
against a title or the console here (the retail title tested never asks
for a swizzle mode).
Ported from amd-dev
081da4b9(raylitebull).What is in it
crates/xcl/src/hle/dstorage.rs:swizzle_chunks,swizzle_group_size,swizzle_interleave; the request check accepts modes 1–4 with a whole number of groups; the decompress path interleaves after zlib and BCPack; testswizzle_interleave_all_four_modes_and_validationand updated request-check assertsTested
cargo test --workspace --no-fail-fast -- --test-threads=4oncf735734(rebased onto main3b6a91ed): 2722 passed, 4 failed, 49 ignored. The 4 failures aregpu::dxil::geometry_tests::msg_gs_done_emits_in_dxil,gpu::dxil::geometry_tests::gpu_geometry_msg_gs_done_records,gpu::dxil::lower_geom::tests::gpu_epilogue_filters_oob_triangles_and_no_store_emitsandgpu::dxil::lower_mem::stage_guard_tests::geometry_export_rejected; they fail the same way on main3b6a91ed(run here, and main's CI fails the two that need no GPU). SKIPPED GPU tests: 45 notices, almost allno wave64.Regression run
main:
this PR:
Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T22:45:54Z.
Code review location:
crates/xcl/src/hle/dstorage.rs; line 1082The swizzle reshuffle also runs on BCPack output, but
bcpack_unpackreturns ordinary interleaved BCn blocks, not one array per block component, so the same function gets two different input layouts. For BCPack BC1 + swizzle mode 1 with a 32 KiB dest,swizzle_interleavetreats bytes 0..8K of 4096 normal 8-byte blocks as the whole-buffer e0 array, 8K..16K as e1, and so on. Each 16 KiB group gets slices of whole blocks in the wrong places, and the request reports S_OK. Either this path or the raw/zlib path is wrong.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T22:45:54Z.
Code review location:
crates/xcl/src/hle/dstorage.rs; line 791Modes 1-4 used to be refused with a warning. They're now on by default with an unverified layout (the PR says the group layouts come only from the mode names), and with no log line at all, not even a first-use info line like BCPack's. If any layout is wrong, every swizzled request returns S_OK with scrambled textures instead of E_DECOMPRESSION, and nothing in the log points here. The "no log line in any run" evidence also can't tell whether the title uses swizzle at all. An env opt-in like XCL_DSTORAGE_BCPACK_FILL, or a first-use log line, would avoid this.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T22:45:54Z.
Review: COMMENTED
Review of
cf735734: 3 finding(s). 2 are inline. These are on lines outside the diff:crates/xcl/src/hle/dstorage.rs:1075: zlib + swizzle with intermediate_size < destination_size (check() allows this for (true,0)): the inflated data is zero-padded to n before the reshuffle, so the padding is spread across every group. With intermediate=16 KiB, dest=32 KiB and mode 1, bytes 0..8K become e0 for both groups, 8K..16K become e1, and the padding is taken as all the index data. Group 0 gets zero indices and real index bytes are read as endpoints. The padding should come after the reshuffle, or the reshuffle should be limited to the real data.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T08:05:54Z.
Closing: the swizzle group layouts are unverified (they were guessed from the mode names), no title we run asks for swizzle modes 1-4, and BCPack + swizzle would reshuffle already-interleaved blocks (
dstorage.rs~1082), so the request would return S_OK with scrambled data. Reopen, behind an opt-in and with the BCPack case refused, when a title needs these modes.AI-assisted: Claude Code (Claude Opus 5.5), posted by Foniass.
Pull request closed