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)
This commit is contained in:
Anees Iqbal committed 2026-11-05 05:10:39 -08:00
1 parent 341737e2e9
commit cd8d288a55
1 file changed
+7 -2
@@ -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;