From 5d33e0c74aa260da2f2256a30dad3bbfd30b1646 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sat, 14 Nov 2026 08:18:18 -0800 Subject: [PATCH] Device replay tests write the header's binding counts, as the runtime does SEMANTICS 2111 (eed5f3d84b) made the compute replay read a record's kernel bindings only below the header's packed count (layout::COUNTS, byte 0). The runtime's header always carries it: CommandDescriptor::encode_header writes the descriptor's max_buffer_bind_count there, at the indirect command buffer's making (indirect_command_buffer/home.rs, indirect_commands/host.rs), and Metal's setters cannot set a kernel buffer at or past that count, so a real record never holds a binding the count leaves out. tests::engine_device_replay built its records' header by hand with the capacity alone, a count of 0, so after 2111 its replays read no binding and six tests computed zeros (pin 90b's CORE suite, m3-max-29378, profile amd-780m-hawkpoint-radv). bind::replay's tests had been given the count in 2111; this file was missed. Its header now carries every kernel binding's count, as bind::replay::tests' run_preprocess writes it. A test-only change. Verified next on msi: tests::engine_device_replay, the 72 interpreter tests of 2111 (engine_indirect_commands, bind::replay), clippy. Verified: msi m3-max-29430: nextest -p metal2vulkan (engine_device_replay, engine_indirect_commands, bind::replay) 87/87 incl. pin 90b's six; clippy -p metal2vulkan -D warnings (all targets and features) 0. --- crates/metal2vulkan/src/tests/engine_device_replay.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/metal2vulkan/src/tests/engine_device_replay.rs b/crates/metal2vulkan/src/tests/engine_device_replay.rs index 4b9fc4f12..c9fc2c8b7 100644 --- a/crates/metal2vulkan/src/tests/engine_device_replay.rs +++ b/crates/metal2vulkan/src/tests/engine_device_replay.rs @@ -61,7 +61,8 @@ use crate::device::profile::BufferAccess; use crate::device::{Device, DeviceDescription, DevicePolicy, GeneratedCommandsProperties}; use crate::error::{BindError, Error, Feature, Needs}; use crate::indirect_commands::{ - Action, BufferBinding, BufferStage, CommandRecord, COMMAND_BUFFER_HEADER_BYTES, COMMAND_BYTES, + layout, Action, BufferBinding, BufferStage, CommandRecord, BINDING_COUNT, + COMMAND_BUFFER_HEADER_BYTES, COMMAND_BYTES, }; use crate::library::Library; use crate::pipeline::facts::RuntimeFact; @@ -398,8 +399,13 @@ fn replay_variants_run( instantiated.push(cmds); } + // The header as the runtime writes it (`CommandDescriptor::encode_header`): the capacity, and + // the packed binding counts, which the replay reads the kernel bindings below + // (`layout::COUNTS`), here every kernel binding. let mut records = vec![0u8; COMMAND_BUFFER_HEADER_BYTES]; records[..4].copy_from_slice(&execution.capacity.to_le_bytes()); + let counts = layout::COUNTS as usize; + records[counts..counts + 4].copy_from_slice(&(BINDING_COUNT as u32).to_le_bytes()); for c in commands { let mut bytes = vec![0u8; COMMAND_BYTES]; c.encode_into(&mut bytes).expect("record");