From cd8d288a55c01cca8764df099fe31c9e970e4c3a Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 5 Nov 2026 02:05:36 -0800 Subject: [PATCH] Read tile_edges' cell codes within an f32 epsilon of c / 255, as the device converts them tile_edges' cfb_tn_read4 reads each cell's code as c / 255; the RTX 5080 Laptop GPU reads 200's as 0.7843138, the quotient's next f32 up, as a product by 1 / 255 gives it, and the lane compared the quotient exactly. Vulkan states the conversion, not its precision. A test bug. What: each read value is held within f32::EPSILON (relative) of c / 255. Verified: in the lane proof runs on the 5080 and the M3 (counts in the series' last commit). (cherry picked from commit d55055f2e5e4b9b719bba34e2ee93667059fbda2) --- .../src/runtime_lane/tile_edges.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/tile_edges.rs b/crates/metal2vulkan-validation/src/runtime_lane/tile_edges.rs index b87515a4d..08a347454 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/tile_edges.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/tile_edges.rs @@ -93,7 +93,10 @@ fn texels(target: &Texture) -> Vec<[u8; 4]> { .collect() } -/// Each cell's codes in a buffer `cfb_tn_read4` filled: each value is a code's, `c / 255`. +/// Each cell's codes in a buffer `cfb_tn_read4` filled: each value is a code's, `c / 255`, as the +/// device converts it to `float`, within `f32::EPSILON` of the quotient, relative (the RTX 5080 Laptop GPU +/// reads 200's as 0.7843138, the quotient's next `f32` up, as a product by `1 / 255` gives it; +/// Vulkan states the conversion, not its precision). fn codes(buffer: &Buffer) -> Vec<[u8; 4]> { let bytes = read_buffer(buffer, 0, CELLS * 16).unwrap(); bytes @@ -106,8 +109,10 @@ fn codes(buffer: &Buffer) -> Vec<[u8; 4]> { for (k, lane) in cell.as_chunks::<4>().0.iter().enumerate() { let value = f32::from_le_bytes([lane[0], lane[1], lane[2], lane[3]]); let code = (value * 255.0).round(); + let quotient = code / 255.0; assert!( - (0.0..=255.0).contains(&code) && value == code / 255.0, + (0.0..=255.0).contains(&code) + && (value - quotient).abs() <= f32::EPSILON * quotient, "cell {i} channel {k}: {value} is no code's" ); codes[k] = code as u8;