From 8816cb11b2025b7bfba7ea9c087eded3ce73edff Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Mon, 23 Nov 2026 00:30:49 -0800 Subject: [PATCH] Validation test: program-scope bindings are required buffers at their slots, after the entry's parameters Over the owned fixture kernel_program_scope_buffers: the case checker's interface lists the three bound globals as required buffers at slots 1, 2 and 0, numbered after the entry's two parameters, beside the kernel's own buffer(0). Run in the lane's check job. --- .../src/check/interface/tests.rs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/crates/metal2vulkan-validation/src/check/interface/tests.rs b/crates/metal2vulkan-validation/src/check/interface/tests.rs index de3fba9d5..5a92b8880 100644 --- a/crates/metal2vulkan-validation/src/check/interface/tests.rs +++ b/crates/metal2vulkan-validation/src/check/interface/tests.rs @@ -158,6 +158,42 @@ fn slots_and_declared_access_come_from_the_metadata_and_writes_from_the_ir() { assert!(interface.writes_through(1)); } +#[test] +fn program_scope_bindings_are_required_buffers_at_their_slots() { + // `psb_scale` and `psb_words` are bound at program scope at buffer(1) and buffer(2), and + // `psb_out` at buffer(0), the slot of the kernel's own `out`: each is a required buffer + // after the entry's parameters. + let interface = of_text( + &fixture("engine/kernel_program_scope_buffers.ll"), + "program_scope_buffers", + &BTreeMap::new(), + ) + .unwrap(); + let buffers = interface + .params_of(|role| match role { + ParamRole::Buffer(buffer) => Some(buffer.access), + _ => None, + }) + .map(|(param, access)| { + ( + param.binding.param, + param.slots().unwrap(), + access, + param.required(), + ) + }) + .collect::>(); + assert_eq!( + buffers, + [ + (0, (0, 1), Access::ReadWrite, true), + (2, (1, 1), Access::Read, true), + (3, (2, 1), Access::Read, true), + (4, (0, 1), Access::ReadWrite, true), + ] + ); +} + #[test] fn predicates_and_computed_slots_resolve_for_the_case_constants() { // Textures 0 and 1 are gated by `provide_absent` and bound at slots the static initializer