DirectStorage: gate BC7 rotation by mode #3081
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3081"
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 mokkamokacaffe on 2026-11-27T23:09:39Z.
Part of #3011.
BC7 control bits 3–4 encode channel rotation only in modes 4 and 5. The existing XCL BCPack port reads them as rotation in every mode; in the other modes those bits have different meanings, so this can swap alpha with a colour channel.
This ports the mode gate from ScarlettPort #108, which credits fxceless/victory-fork
06702fevia VIscosityb8e7001d.What is in it
crates/xcl/src/hle/bcpack/victory.rs: read BC7 rotation only for modes 4 and 5 in both precision selection and block packing.crates/xcl/src/hle/bcpack/victory.rs: add a regression covering modes 0–7 and confirm rotation bits do not alter precision in modes 0–3, 6, or 7.THIRD_PARTY.md: record the ScarlettPort provenance and upstream credits.Tested
Foniass’s contributor report reported a successful workspace build and 2,901 passed, 0 failed, 51 ignored, with 28 explicit skips on the integration of
197d9872onto493dbd3d. The table audit found zero out-of-mode rotation bits among 512 CTRL7 entries and 255 BC7 dictionary entries. The synthetic control-word tests leave bc7_pack coverage open.Hardware: NVIDIA GeForce RTX 4080 SUPER, driver 617.14; Intel Core i9-14900KF; 63.7 GiB RAM.
Windows 11 Pro 10.0.26100.
Rust 1.100.0, Cargo 1.100.0, x86_64-pc-windows-msvc.
DXC/DXIL 1.9.2609.5; D3D12 Agility SDK 1.620.2.
Debug and release profiles.
Tested head:
197d9872eb27da31ba7ede7185131624170d2696.Tested main:
2c717a043c8488938179fca81da4bb9e7913a358.cargo build --workspace: passed.cargo test --workspace --no-fail-fast -- --test-threads=4: 1,467 passed, 0 failed, 47 ignored.Focused exact regression: 1 passed, 0 failed.
BCPack tests: 7 passed, 0 failed.
python -B -m unittest discover -s scripts -p "test_*.py" -v: 25 passed, 0 failed.cargo build --release --locked -p xcl: passed separately on main and this head.git diff --check: passed.Explicit GPU
SKIPPEDresults:no wave64.no heap windows.V_MUL_F16,V_PK_MUL_F16VOP3 modifiers, andV_CVT_F16_F32semantics.Paired retail smokes used clean worktrees and separate copies of the same 33,752-file starting shader cache. Both exited normally with no device removal or crash.
Windows/NVIDIA integration check by @Kalmarv for head
197d9872: the merge-check used basefa204595a4, passed cargo build --workspace, and reported 2,600 passed, 0 failed, 49 ignored and 9 filtered, including all nine BCPack tests. Earlier, upipibi independently inspected the shipped tables on2c717a0. Both source audits found zero shipped CTRL7 or BC7-dictionary entries with rotation bits set outside modes 4/5, supporting this as spec/fuzzer hardening rather than an expected title-visible change.Regression run
main:
PR:
Not tested
AI use
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-27T23:15:22Z.
The fix is right for BC7. One thing reviewers may want to know: with the tables xcl ships, it changes no decoded block. I checked by reading the tables, not by running anything.
A BC7 control word comes from
CTRL7(tables.rs:154onmain2c717a0), indexed by stream bits atvictory.rs:617, or from a dictionary entry'sBc7Ep.ctrl(tables.rs:1440). I counted the words with bits 3-4 set outside modes 4 and 5:CTRL7BC7dictionarySo, with the shipped tables, the alpha/colour swap the description mentions doesn't happen. The same holds for the other effect of the old read. In mode 1, a rotation swaps alpha's precision of 0 into red, so
field(row, 0, prec[0])(victory.rs:734) shifts au16right by 16 (:717), which panics in a debug build. On VIctory#3111, which makes the same fix upstream, gabrielvbraga reached that panic with a fuzzer only after overwriting table bytes, and noted that the built-in tables never set these bits (comment).That makes this a low-risk hardening, worth keeping for its test, with no visible change to expect in a title.
AI-assisted (Claude Code, Claude Opus 5.5 read the code and counted the table words).
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T06:05:26Z.
merge-check
base:
fa204595a4head:
197d9872ebmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests:: -> 2600 passed, 0 failed, 49 ignored, 9 filtered (26 SKIPPED: 21 no wave64, 3 wave32 per-lane #1426 semantics, 2 no heap windows); failing: none (all 9 bcpack tests including bc7_rotation_tests::rotation_is_read_only_in_modes_4_and_5 passed)
review: none blocking. Whole diff read (
THIRD_PARTY.mdprovenance note +crates/xcl/src/hle/bcpack/victory.rsbc7_rotation,bc7_precision,bc7_pack, andbc7_rotation_tests). Confirmed by inspectingtables.rsthat shippedCTRL7(512 entries) andBC7dictionary (255 entries) already have 0 entries outside modes 4/5 with rotation bits [4:3] set, so this changes no decoded blocks with shipped tables and acts as clean BC7 spec/fuzzer hardening. Note: GitHubBuild and test (Windows, no GPU)has not yet been approved to run on this head.performance: zero measurable impact by default (reasoned: one branch on
ctrl & 7inbc7_rotationinside BC7 block unpack).verdict: safe to merge
hardware / tool and model: Windows 11 Pro (build 26200), NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074, wave32), AMD Ryzen 9 9950X, rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609; Antigravity (reviewed full diff, audited tables.rs, ran merge/build/workspace suite).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:27:56Z.
Triage (#1607) – head
197d987No open or merged PR changes the BC7 rotation handling in
bcpack/victory.rs; the other PRs on #3011 are unrelated (ray tracing / wave-local work).The gate does not change any decode today: every BC7 control word comes from
tables::CTRL7, and all of its entries for modes 0-3, 6 and 7 have bits 3-4 = 0, so the alpha/colour swap the description mentions cannot happen with XCL's tables. The description should say this is hardening with no behaviour change; the test only uses synthetic control words not in the table.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T11:34:13Z.
merge-check
base:
493dbd3dd0head:
197d9872ebmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2901 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+37/-2). Rotation bits now count only in BC7 modes 4 and 5, which is what the format defines. Findings: (1) No block decodes differently today. The control word always comes from a table, and I counted rotation bits outside modes 4 / 5: 0 of 512 in
CTRL7and 0 of 255 in theBC7dictionary. So the description's "can swap alpha with a colour channel" doesn't happen with these tables; it's hardening, and the description should say so. (2) The test checksbc7_rotation/bc7_precisionon made-up control words, whilebc7_pack(victory.rs~713) isn't covered. (3)Build and test (Windows, no GPU)hasn't run on this head (onlyPR descriptionandtriageare listed); the run below covers that. Fine: the p-bit +1 applies again in modes 0 / 1 / 3 / 6 / 7, the mode-4 index-selection bit is written unchanged, and the 2-bit-then-3-bit index order is right either way. No smoke run: the retail title's runs log no BCPack use, and the output would be identical anyway.performance: no smoke run (the default path doesn't reach this change); not measured. No block from the current tables has rotation bits outside modes 4 / 5, so output is identical.
verdict: safe to merge (hardening: no block from the current tables decodes differently; the description could say so)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.