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.
This commit is contained in:
Anees Iqbal committed 2026-11-20 00:05:06 -08:00
1 parent 71ef1ba14b
commit b97d37c104
1 file changed
+8 -1
+8 -1
View File
@@ -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),