From b97d37c1046900ff5954dc2ca9a5a4d7d65da6f9 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 19 Nov 2026 23:44:55 -0800 Subject: [PATCH] rt test: the refill test binds vertex buffers at offsets Metal takes The random test bound the vertex function's buffers at the offset one off every alignment (2), which the vertex descriptor's fetch read at an attribute address the format's alignment does not divide (VUID-vkCmdDraw-None-02721 on lavapipe, job m3-max-57025). Metal takes a vertex buffer's offset at a multiple of 4: the vertex function's binds take 4 there; the fragment function's keep 2, which the alignment check refuses. --- crates/metal2vulkan-rt/src/tests/refill.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/metal2vulkan-rt/src/tests/refill.rs b/crates/metal2vulkan-rt/src/tests/refill.rs index 3d3b39215..84f562250 100644 --- a/crates/metal2vulkan-rt/src/tests/refill.rs +++ b/crates/metal2vulkan-rt/src/tests/refill.rs @@ -287,6 +287,12 @@ mod on_device { .unwrap_or_else(|error| panic!("{name}: {error}")); // Offsets inside the buffers, one off every argument's alignment, one past their end. const OFFSETS: [u64; 5] = [0, 16, 48, 2, 4096]; + // A vertex buffer's offset is a multiple of 4, as Metal takes it for the vertex + // descriptor's fetch: the one off every alignment moves to 4 there. + let vertex_aligned = |table: usize, offset: u64| match (table, offset) { + (0, 2) => 4, + _ => offset, + }; let mut sequence = Sequence(0x9e37_79b9_7f4a_7c15); let (mut drawn, mut refused) = (0, 0); let call = |result: Result<(), Error>| result.unwrap_or_else(|e| panic!("{name}: {e}")); @@ -298,7 +304,7 @@ mod on_device { 1..=3 => { let slot = sequence.below(31) as u32; let buffer = (sequence.below(8) != 0).then(|| &bound[sequence.below(4)]); - let offset = OFFSETS[sequence.below(5)]; + let offset = vertex_aligned(table, OFFSETS[sequence.below(5)]); call(match table { 0 => encoder.set_vertex_buffer(buffer, offset, slot % 3), _ => encoder.set_fragment_buffer(buffer, offset, slot), @@ -308,6 +314,7 @@ mod on_device { // Refused where the slot holds no buffer, as Metal's. let (slot, offset) = (sequence.below(31) as u32, OFFSETS[sequence.below(5)]); + let offset = vertex_aligned(table, offset); let _ = match table { 0 => encoder.set_vertex_buffer_offset(offset, slot % 3), _ => encoder.set_fragment_buffer_offset(offset, slot),