From b22e57cceafdeb46f01deab6f633d491e35a6488 Mon Sep 17 00:00:00 2001 From: vakaobr <15154330+vakaobr@users.noreply.github.com> Date: Tue, 24 Nov 2026 08:04:01 -0300 Subject: [PATCH] Tests: GPU UMA tests skip where D3D12 has no heaps over process memory On Apple's D3DMetal (macOS, CrossOver) OpenExistingHeapFromAddress answers E_NOTIMPL (0x80004001). Five GPU tests unwrapped runner::run_in_arena and panicked on it (gpu_unified_memory_arena, gpu_mesh_mode_reads_memory_windows, gpu_memory_windows_above_4_gib, gpu_memory_windows_reject_out_of_uma_aliasing, gpu_bvh64_intersect_ray_across_memory_windows_and_grazing), and gpu_sparse_vram_descriptors_buffers_and_xmem found no window VAs. no_host_heaps() skips with "no GPU UMA" only for that error (the runner's error, or the runtime's uma_error after init); run_in_arena_or_skip() wraps run_in_arena with it. Any other error still fails the tests: with the check looking for another code, all six fail again on this host. (#258) Assisted-by: Claude Code (Claude Opus 5.5) --- crates/xcl/src/gpu/recomp/tests.rs | 43 +++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 4e032b68d1..d0c6307dc2 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -48,6 +48,26 @@ fn mesh_ready() -> bool { } } +/// A D3D12 that cannot place a heap over process memory: D3DMetal answers E_NOTIMPL +/// (0x80004001) to `OpenExistingHeapFromAddress`. Such a host has no GPU UMA, so a test that +/// needs it skips; any other error still fails the test. +fn no_host_heaps(err: &str) -> bool { + if err.starts_with("OpenExistingHeapFromAddress") && err.contains("0x80004001") { + println!("no heaps over process memory on this D3D12 – skipping ({err})"); + runner::skip_test("no GPU UMA"); + return true; + } + false +} + +/// `runner::run_in_arena`, or `None` after a `no_host_heaps` skip. +fn run_in_arena_or_skip(dxil: &[u8], st: &KernelState, arena: &crate::gpu::uma::Uma) -> Option { + match runner::run_in_arena(dxil, st, arena) { + Err(e) if no_host_heaps(&e) => None, + r => Some(r.unwrap()), + } +} + /// The wave sizes a per-lane test runs in, as the `wave64` option: true where the GPU has /// wave64, and false on every GPU, so the test also runs on NVIDIA. Empty without a GPU or DXC. fn gpu_waves() -> Vec { @@ -3112,7 +3132,7 @@ fn gpu_unified_memory_arena() { r[0] = l as u32; r[2] = 7 * l as u32; } - let r = runner::run_in_arena(&dxil, &st, &arena).unwrap(); + let Some(r) = run_in_arena_or_skip(&dxil, &st, &arena) else { return }; assert_eq!((r.sgpr[20], r.sgpr[21]), (0xC0FFEE, 0x1234), "s_load from process memory"); for l in 0..64 { assert_eq!(r.vgpr[l][1], 1000 + l as u32, "lane {l} buffer_load from process memory"); @@ -3165,16 +3185,18 @@ fn gpu_mesh_mode_reads_memory_windows() { // V#: the vertex table in window 1, stride 16, 3 records st.sgpr[16..20].copy_from_slice(&[(w1 + 0x100) as u32, ((w1 >> 32) as u32) & 0xFFFF | 16 << 16, 3, 0]); let vd = ms.vert_dwords(); - let positions = |windows: u32| -> Vec<[f32; 4]> { + let positions = |windows: u32| -> Option> { let t = super::translate_mesh(&code, ms.clone(), true, runner::split_wave64(), windows).unwrap(); assert!(t.complete(), "{:?}", t.unsupported_why); let cs = dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("{e}")); - let r = runner::run_in_arena(&cs, &st, &arena).unwrap(); + let r = run_in_arena_or_skip(&cs, &st, &arena)?; assert_eq!((r.raw[0], r.raw[1]), (3, 1), "GS_ALLOC_REQ counts ({windows} windows)"); - (0..3).map(|v| std::array::from_fn(|c| f32::from_bits(r.raw[MESH_HEADER + v * vd + c]))).collect() + Some((0..3).map(|v| std::array::from_fn(|c| f32::from_bits(r.raw[MESH_HEADER + v * vd + c]))).collect()) }; - assert_eq!(positions(2), vec![[-1.0, -1.0, 0.0, 1.0], [-1.0, 1.0, 0.0, 1.0], [0.0, -1.0, 0.0, 1.0]], "the vertex table from window 1"); - assert_eq!(positions(1)[0], [9.0; 4], "one window: window 0 at the same offset (the old MS / GS translation)"); + let Some(two) = positions(2) else { return }; + assert_eq!(two, vec![[-1.0, -1.0, 0.0, 1.0], [-1.0, 1.0, 0.0, 1.0], [0.0, -1.0, 0.0, 1.0]], "the vertex table from window 1"); + let Some(one) = positions(1) else { return }; + assert_eq!(one[0], [9.0; 4], "one window: window 0 at the same offset (the old MS / GS translation)"); } /// Memory above 4 GiB: two UMA windows 4 GiB apart; every access kind picks its window from @@ -3233,7 +3255,7 @@ fn gpu_memory_windows_above_4_gib() { r[9] = hi(w1); r[11] = 1; } - let r = runner::run_in_arena(&dxil, &st, &arena).unwrap(); + let Some(r) = run_in_arena_or_skip(&dxil, &st, &arena) else { return }; assert_eq!((r.sgpr[20], r.sgpr[21]), (0xC0FFEE, 0x1234), "s_load from window 1"); assert_eq!(r.sgpr[24..28], [1001, 1002, 1003, 1004], "s_buffer_load_dwordx4 from window 1"); for l in 0..64u64 { @@ -3339,7 +3361,7 @@ fn gpu_memory_windows_reject_out_of_uma_aliasing() { r[18] = 0x7777_7777; } - let r = runner::run_in_arena(&dxil, &st, &arena).unwrap(); + let Some(r) = run_in_arena_or_skip(&dxil, &st, &arena) else { return }; assert_eq!(r.sgpr[30], 0, "out-of-UMA s_load must return 0"); assert_eq!(r.sgpr[31], 0xABCD_0123, "hi == 0 s_load must still read window 0 (32-bit descriptor tables)"); assert_eq!(r.vgpr[0][2], 0, "out-of-UMA buffer_load must return 0"); @@ -3393,6 +3415,9 @@ fn gpu_sparse_vram_descriptors_buffers_and_xmem() { assert_eq!(u.shader_windows(), 4, "runtime layout has 4 shader windows"); assert!(u.is_sparse_window(0) && u.is_sparse_window(1) && u.is_sparse_window(2), "windows 0..2 sparse VRAM"); assert!(u.is_committed_window(3), "window 3 coherent committed RAM"); + if no_host_heaps(&crate::hle::d3d12x::real::stats().uma_error) { + return; + } let windows = crate::hle::d3d12x::real::uma_window_vas(); assert_eq!(windows.len(), 4); assert!(windows.iter().all(|&va| va != 0), "all 4 window GPU VAs must be valid: {windows:x?}"); @@ -4417,7 +4442,7 @@ fn gpu_bvh64_intersect_ray_across_memory_windows_and_grazing() { r[40] = 5; // relative root box32 at bvh_addr put_ray(r, 41); } - let res = runner::run_in_arena(&dxil, &st, &arena).unwrap(); + let Some(res) = run_in_arena_or_skip(&dxil, &st, &arena) else { return }; const F: u32 = u32::MAX; for l in 0..64usize { let v = &res.vgpr[l];