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<f32> 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.
This commit is contained in:
Anees Iqbal committed 2026-12-02 22:11:25 -08:00
1 parent b8b43ccbaf
commit 674b837fa7
2 files changed
+13 -4

No files matched your search

@@ -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;
@@ -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)