D3D12.X: guard mip shift overflow and zero dimensions in tiling::Chain and image_chain #1499
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1509"
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 b3IKK on 2026-11-24T17:09:15Z.
tiling::Chainshifted the mip dimensions and the depth by the level index unconditionally: a chain with more than 32 levels (mips > 32) hit a shift overflow (a panic in debug, a wrong value in release), andChain::new_3dwith a zero width or height producedlevels[0]of 0, soslice_bytesno longer matched the level it describes.image_chaindid not reject a zero width/height or amax_mipof 32 or more at all; it computed a chain for them.This clamps every dimension to at least 1, uses checked shifts (a shift past 32 gives 1), and makes
image_chainreturnNonefor a zero dimension ormax_mip >= 32.What is in it
crates/xcl/src/gpu/tiling.rs: themax(1)clamps andchecked_shrinChain::new/new_3d; theimage_chainguard; testchain_and_image_chain_handle_large_mips_and_zero_dimensions(33 levels of a 16×16 image, a zero-size 3D chain, andimage_chainwithmax_mip = u32::MAX,32, a zero width and a zero height).Since the last push: rebased onto
main06c9f55(the commit was then re-created with the same tree so GitHub refreshed the PR's head); the only conflict was a test module wheremainhad addedlayout_cache_shares_tables_and_isolates_base_xorat the same place, and both are kept.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 1266 passed, 0 failed, 46 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses,no heap windows, andcannot disable the driver cache (Windows Developer Mode is required))cargo test -p xcl --lib -- gpu::tiling: all pass, including the new testimage_chainguard removed: 0 passed, 1 failed — a shift-overflow panic attiling.rs:497Regression run
main (
426a5a7, clean tree, no local changes):PR (
a0178fc, clean tree, no local changes):(The main block is
426a5a7, an ancestor of the currentmain06c9f55, from the same machine and data folder.)Not tested
AI use
06c9f55, kept both tests at the conflict, re-verified that the new test fails without the guard, ran the suite and thescripts/smoke.ps1pair.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:53:46Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by Belox17 on 2026-11-24T20:02:58Z.
Test report for
175ed9c6on NVIDIA (RTX 3060 Ti): passes, and the test fails without the fixTested
175ed9c6as is (baseb7aa9f3), clean tree.chain_and_image_chain_handle_large_mips_and_zero_dimensions) withcargo test -p xcl --lib <name>: 1 passed.cargo test --workspace -- --test-threads=4on the head: 771 passed, 0 failed, 41 ignored; its baseb7aa9f3on the same machine: 770 passed, 0 failed, 41 ignored. SKIPPED on both:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).mainc160d86e(clean merge): 859 passed, 0 failed, 42 ignored;mainalone: 858 passed, 0 failed, 42 ignored, the same three SKIPPED as above.gpu/tiling.rsreverted (test kept), the test panics withattempt to shift right with overflowattiling.rs:282.Not tested
AI use: Claude Code (Claude Opus 5.5) ran the commands on this machine and wrote this report from those runs.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:20:25Z.
Empirical test report (
175ed9c6)PR #1509 was tested at commit
175ed9c6060b4424a25f856a423808844ee030cdfrom a clean checkout.Hardware / environment
rustc 1.100.0 (0ef1bc386 2026-11-09), hostx86_64-pc-windows-msvc.dxc.exe --versionreporteddxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47).XCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1. Both commands ran outsideInvoke-ArcTest.ps1without acquiring the Arc GPU mutex.Commands and results
cargo test --workspace --no-runexited 0 and built the workspace test binaries. The build emitted a Rust deprecation warning forAtomicU32::fetch_updatein XGameRuntime.cargo test -p xcl --lib gpu::tiling::tests::chain_and_image_chain_handle_large_mips_and_zero_dimensions -- --exact --nocaptureexited 0. The log recorded 1 passed, 0 failed, 0 ignored, 0 skipped, and 743 filtered out.Observed behavior
image_chainreturnedNoneformax_mipvalues of 32 andu32::MAX, and for descriptors with zero width or zero height.Not tested
The full GPU workspace suite and game smoke runs were omitted.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1509-focused.logand published.Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-25T16:04:12Z.
Rebased onto
main06c9f55; the only conflict waslayout_cache_shares_tables_and_isolates_base_xor, whichmainhad added at the same place, and both tests are kept. The commit was then re-created with the same tree to refresh the PR head (GitHub kept the previous head after the first force-push). Current heada0178fc: suite 1266 passed, 0 failed, 46 ignored; the new test fails with theimage_chainguard removed (shift-overflow panic attiling.rs:497); smoke 1641 frames, 0 crashes, 0 removals. The JJAutoCompare report above is for the old175ed9c; the smoke pair in the description now names this head.AI use: OpenCode, Claude Fable 5.2 rebased it, re-created the commit, ran the suite and the smoke run and wrote this.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:40:27Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T15:37:30Z.
Independent desktop NVIDIA verification of PR #1509 at head
a0178fce33f76bb767a461a04f12867e4c4f1f05(1commit; exact parent & merge-base:06c9f5505f63f10c5ec49ef932d75b2c28177324, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted tests & build (
a0178fce)cargo test --release -p xcl --lib -- --nocapture chain_and_image_chain_handle_large_mips_and_zero_dimensions(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1222 filtered out× 3 (0.00s,0.00s,0.00s,0skipped)cargo test --release -p xcl --lib -- --nocapture gpu::tiling::(3 consecutive runs)16 passed; 0 failed; 0 ignored; 1207 filtered out× 3 (1.04s,1.05s,1.10s,0skipped)cargo build --release -p xcl1m 30s, exit0,0new warnings ingpu/tiling.rs)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
06c9f5505f63f10c5ec49ef932d75b2c28177324, cached baseline on the same machine):PR #1509 (
a0178fce33f76bb767a461a04f12867e4c4f1f05):Limits of coverage
chain_and_image_chain_handle_large_mips_and_zero_dimensionsand the fullgpu::tiling::suite (16/16,0skipped) passed3/3, directly verifyingchecked_shr/checked_shlformips > 32,.max(1)clamping for zero dimensions inChain::new_3d, and early rejection of zero dimensions ormax_mip >= 32inimage_chain.0device removals,0crashes, steady 60 Hz) rather than malformed T# descriptors withmax_mip >= 32or zero dimensions; single-run frame/commit delta vs. the cached parent reflects normal startup variance.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-27T16:12:35Z.
Tested on AMD / Linux:
a0178fce(RX 9070 16 GB, RDNA4, Mesa 26.3.1 RADV; Ryzen 5 9600X, 32 GB; CachyOS; Proton Experimentalexperimental-11.0-20261112with vkd3d-proton masterec207194plus a local patch dropping thelpVtblchecks of command allocators and lists; DXC 1.9.2609.5; Rust 1.96.0,x86_64-pc-windows-gnudebug build, tests run under Wine)The head as it is (not merged onto current
main), with its base06c9f550as the baseline.Tests (
XCL_REQUIRE_GPU=wave64)cargo test -p xcl --lib -- gpu::tiling:: --test-threads=1: 16 passed, 0 failed, 0 ignored (includeschain_and_image_chain_handle_large_mips_and_zero_dimensions).cargo test --workspace --no-fail-fast -- --test-threads=4with--skip compositor_blends_ui_plane_over_scene_plane --skip failed_restore_stops_before_importing_an_unbacked_window --skip grooming_leaves_a_window_under_1_gib_only_its_hole(here the first loses the RADV device, the other two run out of memory under Wine): lib 1181 passed, 16 failed, 26 ignored; base06c9f550(this PR's base) the same session: lib 1180 passed, 16 failed, 26 ignored. The failures are the same set as on the base. The other binaries fail the same 3 tests as on the base (e2e,pls_quota,predication_e2e).d3d12_resource_and_sync: its fence and queue test ended the process here, as it does on the base and most other trees in this setup.Not tested
AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:57:34Z.
Triage (#1607) – head
a0178fcNo open or merged PR makes the same change. #1624 also clamps side/depth to 1 in Chain::new_3d, but its subject is mip-tail depth and base_xor masking, not the shift overflow.
The image_chain guards (width == 0, max_mip >= 32) cannot trigger for a decoded T# (desc.rs: width is a field + 1, max_mip is 4 bits); the Chain::new_3d clamps matter for the XG callers (hle/xg.rs), which pass title-supplied sizes and mip counts.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.