D3D12.X: fix XG optimal_mode overflow, BCn UAV bits_per_pixel, and get_texel_offset bounds #1480
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1480
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1480"
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?
@b3IKK on GitHub · 2026-11-24 16:46 UTC · original
b3IKK:xg/swizzle-and-texel-offset-bounds→main· +41 −5 · 1 files · 1 commits · openFixes three bugs in
crates/xcl/src/hle/xg.rs:optimal_mode()multipliedbits_per_pixel * width * height as u64without saturating, overflowingu64on large widths (aborting acrossextern "system" fn XGSuggestSwizzleModein debug or wrapping into the<= 0x8_00004KB_S_Xthreshold in release).XGSuggestSwizzleMode's fallback path computed8u64 << einstead of dividing byside * sidefor block-compressed formats (16× too large for BCn, selecting64KB_R_Xinstead of4KB_S_Xfor a 128×128 BC7 UAV), and checked onlyd[0] == 2instead of the fullu32Dimensionfield.get_texel_offset()checkedmipandslicebut notx/yagainst the mip's element dimensions, causing out-of-boundsx(such asu64::MAXon a tail mip with non-zero origin) to overflow and abort (STATUS_STACK_BUFFER_OVERRUN) acrossextern "system" fn.This uses
saturating_mulinoptimal_mode(), divides byside * sideand reads the fullu32DimensioninXGSuggestSwizzleMode(), and bounds-checksx < m.width && y < m.heightinget_texel_offset().What is in it
crates/xcl/src/hle/xg.rs: fixoptimal_mode,XGSuggestSwizzleMode, andget_texel_offset; add unit testsoptimal_mode_and_suggest_swizzle_handle_overflow_and_bcn_uavandget_texel_offset_rejects_out_of_bounds_xy(both verified failing/aborting before the fix).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): 772 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib hle::xg::tests: 5 passed, 0 failed (both new tests failed/aborted before the fix)Regression run
main:
PR:
Not tested
AI use
hle/xg.rs, wrote the fixes and unit tests, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@futurepro62 on GitHub · 2026-11-24 16:59 UTC · original · edited 2026-11-24 17:07 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
47e5ef0(on its baseb7aa9f3).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 772 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.optimal_mode_and_suggest_swizzle_handle_overflow_and_bcn_uav,get_texel_offset_rejects_out_of_bounds_xy.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 772 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-24 18:53 UTC · original
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!
@JJAutoCompare on GitHub · 2026-11-25 05:26 UTC · original
Empirical test report (
47e5ef07)Hardware / environment
rustc 1.100.0 (0ef1bc386 2026-11-09), hostx86_64-pc-windows-msvc. DXC reporteddxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47).47e5ef07a33420099a17ff4bec0c240228ac2412. The unoptimized Cargo test profile ran with incremental compilation and debug symbols disabled. Both commands ran outsideInvoke-ArcTest.ps1and did not acquire the Arc GPU mutex.Commands and results
cargo test --workspace --no-runexited 0. Cargo compiled the workspace test executables.With
XCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1, ran:Exit 0. 2 passed, 0 failed, 0 ignored, 0 skipped, 743 filtered out. Counts came from the focused log's case-sensitive test result and
SKIPPEDlines.Observed behavior
optimal_modereturned mode 27 for a UAV whose nominal bit count exceedsu64::MAX. The two-sample 128 × 128 BC7 UAV descriptor took theXGSuggestSwizzleModefallback and returnedS_OKwith4KB_S_X(0x115).get_texel_offsetreturned zero forx = u64::MAXon mip 5 and for each coordinate at the mip-0 extent of 64. The test also confirmed that the bit offset was cleared for the mip-5 call.Not tested
The full GPU workspace suite and game smoke runs were omitted. The changed 32-bit Dimension check has no dedicated assertion in the two focused tests.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1480-focused.logand published.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.