Repository navigation
dxil: support 64-bit typed image_atomic_* via SM 6.6 heap atomics - #1948
raylitebull wants to merge 1 commit into
Conversation
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Regression run for this PR: head main this PR: No device removals or crashes; 99 % of main's frames, 99 % of its peak commit. Not tested: the whole suite; the direct DXIL path this PR changes (these runs use the default HLSL path, Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
|
@Anon64 Thank you for the RTX 3060 60 s regression pair on 1e4f2bd (1622/1629 frames, 0 removals/crashes) — absorbed into the PR description! Also thanks @futurepro62 for the RTX 5070 Ti full-suite pass (977/0/43). Independent AMD verification is still invited before merging. |
|
Ran the 64-bit typed image atomics on a GPU, which the description lists as untested: RTX 3070 (Ampere, driver 616.56, 32-lane waves), Windows 11, debug, at The local test is a wave64 compute program through
So the heap The same program on the HLSL path ( AI-assisted (Claude Code). Synthetic tests only. |
1e4f2bd to
5dc9a0f
Compare
|
Rebased
|
5dc9a0f to
d88bf95
Compare
|
Rebased Pushed |
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
PR #1948 CPU validation of typed image atomicsTested At
Commands $env:Path = "C:/Users/ljensen/.cargo/bin;$env:Path"
$env:RUSTUP_TOOLCHAIN = 'stable-x86_64-pc-windows-msvc'
$env:TEMP = 'L:/XclTooling/pr1948/d88bf95-20261125T031309552Z/temp'
$env:TMP = $env:TEMP
$env:CARGO_TARGET_DIR = 'L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target'
$env:CARGO_BUILD_JOBS = '2'
$env:CARGO_INCREMENTAL = '0'
$env:CARGO_PROFILE_DEV_DEBUG = '0'
$env:CARGO_PROFILE_TEST_DEBUG = '0'
$env:XCL_DXC_DIR = 'C:/Users/ljensen/AppData/Local/XclTooling/dxc-1.9.2609/bin/x64'
cargo test -p xcl --lib --jobs 2 gpu::dxil::ops_tests::direct_image_atomic_64bit_validates -- --exact --nocaptureThe test command ran via Live PR and deduplication At the final check around Not tested GPU dispatch and readback, device support for 64-bit typed atomics, runtime arithmetic results, compatibility on specific GPU drivers, extra input variations, other Cargo tests, and retail-title smoke runs were outside this CPU-only run. AI use T3 Code / Codex ( |
|
Verified the rebased 64-bit image floating compare-exchange path on Tested
Not tested: contention/retry-loop bounds, coordinate-out-of-range accesses, AMD/native wave64/Intel, full workspace, newer-main integration, other wide atomics, performance/peak memory, retail shaders or title smoke. No merge-readiness claim. AI use: Codex (GPT-6), source investigation, regression-test preparation, native Windows verification and this report. Test-only patch; no competing implementation. Portable test-only patch on d88bf95 (also applies to its parent)diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 527dc4e..914f47e 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -9027,3 +9027,75 @@ fn gpu_scalar_sext_mulhi_and_vector_i24_sub_co_ci_u64_shifts() {
assert_eq!(v[22], subrev, "lane {l} v_subrev_co_ci_u32");
}
}
+
+
+/// The wide image float CAS added by #1948 uses ordered f64 equality, including
+/// signed zero and NaN, while integer CAS remains bitwise. GLC returns both words.
+#[test]
+fn gpu_image_fcas64_preserves_ieee_and_guards() {
+ if !gpu_ready() { return; }
+ use runner::{TestTexture, TexDim};
+ use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32_UINT;
+ const CASES: [(u64, u64); 8] = [
+ (0x8000_0000_0000_0000, 0),
+ (0, 0x8000_0000_0000_0000),
+ (0x7FF8_0000_0000_1234, 0x7FF8_0000_0000_1234),
+ (0x7FF0_0000_0000_1234, 0x7FF0_0000_0000_1234),
+ (1, 0),
+ (0x3FF8_0000_0000_0000, 0x3FF8_0000_0000_0000),
+ (0x3FF8_0000_0000_0000, 0x4004_0000_0000_0000),
+ (0xFFF0_0000_0000_0000, 0xFFF0_0000_0000_0000),
+ ];
+ const GUARD: u64 = 0xdead_beef_1234_abcd;
+ let mut code = Vec::new();
+ for (name, dst, srsrc) in [("IMAGE_ATOMIC_FCMPSWAP", 10, 4), ("IMAGE_ATOMIC_CMPSWAP", 20, 6)] {
+ code.extend(encode(name, "ENC_MIMG", &[("VDATA", dst), ("VADDR", 0), ("SRSRC", srsrc), ("DMASK", 15), ("DIM", 1), ("UNORM", 1), ("GLC", 1)], None).unwrap());
+ }
+ code.extend(encode("S_ENDPGM", "ENC_SOPP", &[], None).unwrap());
+ let split = !runner::wave64_supported().unwrap();
+ let dxil = crate::gpu::dxil::kernel::translate(&code, crate::gpu::dxil::kernel::KernelOptions { wave64: true, split, mem_windows: 1, sampler_base: 0 }).unwrap();
+ crate::gpu::dxil::validate::validate(&dxil).unwrap();
+ println!("IMAGE_FCAS64 adapter={} split={split} dxil_bytes={}", runner::adapter().unwrap(), dxil.len());
+ for (mask, valid) in [(u64::MAX, true), (0xF0F0_F0F0_0F0F_0F0Fu64, true), (u64::MAX, false)] {
+ let mut st = KernelState::default();
+ st.sgpr[126] = mask as u32;
+ st.sgpr[127] = (mask >> 32) as u32;
+ if valid {
+ st.sgpr[16..24].copy_from_slice(&tsharp(0, 62, 9));
+ st.sgpr[24..32].copy_from_slice(&tsharp(2, 62, 9));
+ }
+ for (lane, v) in st.vgpr.iter_mut().enumerate() {
+ v[0] = lane as u32;
+ let new = (1000.0 + lane as f64).to_bits();
+ let cmp = CASES[lane % 8].1;
+ for base in [10, 20] {
+ v[base] = new as u32; v[base + 1] = (new >> 32) as u32;
+ v[base + 2] = cmp as u32; v[base + 3] = (cmp >> 32) as u32;
+ }
+ }
+ let initial: Vec<u64> = (0..80).map(|lane| if lane < 64 { CASES[lane % 8].0 } else { GUARD }).collect();
+ let tex = || TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32_UINT, width: 80, height: 1, depth: 1, texel_bytes: 8, data: initial.iter().flat_map(|v| v.to_le_bytes()).collect(), uav: true };
+ let r = runner::run_with(&dxil, &st, &[0; 64], &[tex(), tex()], &[]).unwrap();
+ let word = |v: &[u32], k: usize| v[k] as u64 | (v[k + 1] as u64) << 32;
+ let mut failures = Vec::new();
+ for (ti, base) in [(0, 10), (1, 20)] {
+ let got: Vec<u64> = r.textures[ti].chunks_exact(8).map(|b| u64::from_le_bytes(b.try_into().unwrap())).collect();
+ assert_eq!(got.len(), 80);
+ for lane in 0..80 {
+ let (old, cmp) = CASES[lane % 8];
+ let active = lane < 64 && mask & (1u64 << (lane % 64)) != 0;
+ let new = (1000.0 + lane as f64).to_bits();
+ let equal = if ti == 0 { f64::from_bits(old) == f64::from_bits(cmp) } else { old == cmp };
+ let want = if lane >= 64 { GUARD } else if active && valid && equal { new } else { old };
+ if got[lane] != want { failures.push(format!("tex{ti} lane{lane}: {:016x} != {want:016x}", got[lane])); }
+ if lane < 64 {
+ let returned = if !active { new } else if valid { old } else { 0 };
+ if word(&r.vgpr[lane], base) != returned { failures.push(format!("return{ti} lane{lane}: {:016x} != {returned:016x}", word(&r.vgpr[lane], base))); }
+ assert_eq!(word(&r.vgpr[lane], base + 2), cmp, "compare operands are unchanged");
+ }
+ }
+ }
+ println!("IMAGE_FCAS64 mask={mask:016x} valid={valid} mismatches={} textures=160 returns=128 compare_pairs=128", failures.len());
+ assert!(failures.is_empty(), "{}", failures.join("\n"));
+ }
+} |
|
Regression run of Against the limits in CONTRIBUTING.md: 100 % of AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, AI use: Claude Code (Claude Opus 5.5) built both trees and ran |
Supports 64-bit typed
image_atomic_*instructions in the direct RDNA2 -> DXIL translator using SM 6.6Int64Ops+AtomicInt64Typed+AtomicInt64Heapdescriptor-heap atomics (RWTexture*<U64|I64>), instead of silently loweringDMASK=0x3(or0xFforcmpswap/fcmpswap) 64-bit typed image atomics as 32-bitRWTexture*<uint>atomics.Part of #1269 and #1833.
What is in it
crates/xcl/src/gpu/dxil/lower_image.rs&lower_mem.rs: detect 64-bit typed image atomics viaDMASK(comps.len() == 4forcmpswap/fcmpswap,comps.len() == 2for all otheratomic_*variants) while keeping 32-bitcmpswap(DMASK=0x3) untouched; addmimg_atomic64,texel_cas64, and IEEE-754f64texel_fcas64(viapub(super) fn feq_bits64inlower_mem.rs, matching#2011), passing#1969's OOB-guardedrunpredicate intomimg_atomic64(self.guarded(run, ...)) and supporting all 16 ops (add,sub,smin,umin,smax,umax,and,or,xor,swap,cmpswap,fcmpswap,inc,dec,fmin,fmax) withCompType::I64/CompType::U64resources,heap_typed_atomic64(), andGLC2-VGPR writeback.crates/xcl/src/gpu/dxil/ops_tests.rs: adddirect_image_atomic_64bit_validatescompiling and validating all 16 64-bit variants withdxil.dll 1.8and verifying 32-bitIMAGE_ATOMIC_CMPSWAP(DMASK=0x3) remainsatomicCompareExchange.i32.Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly ontoaaa0936(d88bf95).d88bf95was rebased cleanly ontoaaa0936(resolving theops_tests.rsEOF append conflict via pure git during a local test hold) and is queued for GitHub ActionsBuild and test+ fresh AMD / NVIDIA verification (gpu::dxil::ops_tests::direct_image_atomic_64bit_validates).1e4f2bd(onto62265d3) passedcargo check --workspace --tests,gpu::dxil::ops_tests(21/21on AMD RX 9070 XT),XCL_REQUIRE_GPU=mesh cargo test --workspace(977/0/43on NVIDIA RTX 5070 Ti,@futurepro62), and 60 sscripts/smoke.ps1(1622/1629frames on RTX 3060,@Anon64).Regression run
scripts/smoke.ps1pair and tests on rebasedd88bf95vsaaa0936have not been run yet. AMD and NVIDIA reviewers are invited to testd88bf95vsaaa0936and post results in the comments.Not tested
cargo check/gpu::dxil::ops_testsandscripts/smoke.ps1on rebased headd88bf95, independent AMD GPU runtime verification of 64-bit typed image atomics (XCL_DIRECT_DXIL=1), wave32-only AMD adapters, and Linux/Wine/vkd3d-proton.AI use