From 674b837fa7a5af39a98c8ff38d32c8fa33680a50 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 17:10:19 -0800 Subject: [PATCH] Texture buffer tests: the handles dispatch binds a buffer at slot 2; an own view's values within one ulp The handles dispatch passed the read-written values (a Vec by then) at slot 2, which the kernel does not use, so the runtime's device tests did not build (job m3-max-80971 on lavapipe, E0308); it binds the values buffer there. The texture buffer stream compared an own view's values bit for bit with the CPU's c / (2^n - 1); lavapipe's conversion multiplies by the reciprocal and lands one f32 ulp off for RGBA8Unorm, R8Unorm and BGRA8Unorm (80971). The device's own conversion is the answer (the owner's rule 1), so an own view's values are taken within one ulp; words, our own decode, stay bit for bit (B5G6R5Unorm matched exactly). Not yet rerun. --- .../src/tests/texture_buffer_words.rs | 3 ++- .../src/replay/rt_replay.rs | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/texture_buffer_words.rs b/crates/metal2vulkan-runtime/src/tests/texture_buffer_words.rs index 076ebc675..0c7b3f4fa 100644 --- a/crates/metal2vulkan-runtime/src/tests/texture_buffer_words.rs +++ b/crates/metal2vulkan-runtime/src/tests/texture_buffer_words.rs @@ -637,7 +637,8 @@ mod on_device { device, &state, &[], - &[&values, &args_reads, &rw_reads, &args_widths, &args], + // Slot 2 is unused by the kernel. + &[&values, &args_reads, &values, &args_widths, &args], ) { wrong.push(format!("not dispatched through handles: {error}")); return wrong; diff --git a/crates/metal2vulkan-validation/src/replay/rt_replay.rs b/crates/metal2vulkan-validation/src/replay/rt_replay.rs index ea7e8afab..a58ce4030 100644 --- a/crates/metal2vulkan-validation/src/replay/rt_replay.rs +++ b/crates/metal2vulkan-validation/src/replay/rt_replay.rs @@ -149,7 +149,9 @@ //! owned fixture `tb_word_formats`, play with the IDs the stream recorded (each its index and //! `TextureWord::of_texture_buffer`, which is the same on every device), no `id` line, and the //! texels and values the CPU decodes, whichever form the device holds each format in -//! (`metal::format::texel_buffer_form`: its own view or words), which the test prints. +//! (`metal::format::texel_buffer_form`: its own view or words), which the test prints. Words +//! decode to the CPU's values bit for bit; an own view's values are the device's own conversion +//! of each code (lavapipe multiplies by the reciprocal), within one `f32` ulp of the CPU's. //! //! The runtime's device is opened behind the hang tripwire, as every device open in this crate //! is (`gpu.rs`), its kernels kept in a cache the test owns ([`ScratchCache`]). Every device a test @@ -2518,6 +2520,12 @@ fn texture_buffers_play_with_their_recorded_ids_and_the_cpu_s_texels() { if report.first_skip.is_some() { wrong.push(format!("skipped: {lines:?}")); } + // Words decode bit for bit; an own view is the device's conversion, within one ulp. + let ulps = if form == "words" { 0 } else { 1 }; + let agree = |got: [f32; 4], want: [f32; 4]| { + (got.iter().zip(want)) + .all(|(g, w)| (i64::from(g.to_bits()) - i64::from(w.to_bits())).abs() <= ulps) + }; let floats = |b: &[u8], t: usize| -> [f32; 4] { [0, 1, 2, 3].map(|c| { let at = 16 * t + 4 * c; @@ -2526,14 +2534,14 @@ fn texture_buffers_play_with_their_recorded_ids_and_the_cpu_s_texels() { }; for t in 0..TB_WIDTH { let read = (case.value)(tb_texel(&case, &texels, t)); - if floats(&reads, t) != read { + if !agree(floats(&reads, t), read) { wrong.push(format!( "read {t}: {:?}, the CPU's {read:?}", floats(&reads, t) )); } let first = (case.value)(tb_texel(&case, &texels, TB_WIDTH - 1 - t)); - if floats(&rw_reads, t) != first { + if !agree(floats(&rw_reads, t), first) { wrong.push(format!( "read_write {t}: {:?}, the CPU's {first:?}", floats(&rw_reads, t)