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)