diff --git a/crates/metal2vulkan-validation/src/candidate/engine.rs b/crates/metal2vulkan-validation/src/candidate/engine.rs index 35ddf8e4c..b061d3daf 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine.rs @@ -82,8 +82,9 @@ use crate::worker::device::{DeviceInput, DeviceOutcome, DeviceRun, OpenedDevice, use crate::worker::WorkerFailure; use base64::Engine as _; use metal2vulkan::bind::{ - BindShape, BindState, BoundAccelerationStructure, BoundBuffer, Dispatch, ExecutionStatus, - FunctionTableWords, ImageblockSize, MetalInstance, ReplayVariant, StageTable, StatusReport, + BindShape, BindState, BoundAccelerationStructure, BoundBuffer, BufferRanges, Dispatch, + ExecutionStatus, FunctionTableWords, ImageblockSize, MetalInstance, ReplayVariant, StageTable, + StatusReport, }; use metal2vulkan::cache::Hash256; use metal2vulkan::device::DeviceProfile; @@ -123,7 +124,7 @@ use tables::{function_tables, table_buffers, FunctionTable, TableBuffers}; /// how it decides a match. A change no recorded row can observe (a case kind no earlier executor /// ran, or one it refused) needs no bump; its commit says why. The commit that bumps it says what /// changed; this comment keeps no history. -pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v182"; +pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v183"; /// One kernel case in the terms the binder takes: what this executor supports of an /// [`AuthoredCase`] (buffers, device buffer arrays, argument-buffer buffers and textures, command @@ -888,12 +889,16 @@ pub const VIEW_BASE_ALIGNMENT: u32 = 256; /// buffer the executor binds is, then reads at its bind offset alone in its plan, as in the /// runtime's plan of the same binds, which tells offset 0 apart at the slots its pipeline reads /// through a storage view there. Elsewhere no storage view declares the key, and a uniform view's -/// range starts at its bind offset at offset 0 under either class, so the plan is the same. -pub fn views_told_apart(mut state: BindState) -> BindState { +/// range starts at its bind offset at offset 0 under either class, so the plan is the same. Each +/// stage table classes its buffers' lengths under `ranges` (`StageTable::buffer_ranges`), the +/// device's range limits (`BufferRanges::of`), as the runtime's tables class them, so a buffer's +/// shape states the length class the runtime's shape of the same bind states. +pub fn views_told_apart(mut state: BindState, ranges: BufferRanges) -> BindState { state.view_base_alignment = VIEW_BASE_ALIGNMENT; for table in state.stages.values_mut() { table.at_bind_views = u64::MAX; table.zero_offset_views = u64::MAX; + table.buffer_ranges = ranges; } state } @@ -909,12 +914,13 @@ pub fn views_told_apart(mut state: BindState) -> BindState { /// with its resource id (its token follows the buffers', [`argument_buffers::texture_tokens`]), /// each made resident for reading and writing, as the Metal oracle's `useResource` does, and each /// argument-buffer sampler as an argument sampler with its id -/// ([`argument_buffers::argument_samplers`]); telling the executor's view base alignment apart -/// ([`views_told_apart`]). +/// ([`argument_buffers::argument_samplers`]); telling the executor's view base alignment apart and +/// classing lengths under the device's range limits `ranges` ([`views_told_apart`]). pub fn bind_state( case: &ComputeCase, addresses: &BTreeMap, embedded: &BTreeMap<(u32, u32), BufferAddress>, + ranges: BufferRanges, ) -> Result { let mut table = StageTable::default(); let lengths = case @@ -993,7 +999,7 @@ pub fn bind_state( } state.argument_samplers = argument_buffers::argument_samplers(case.argument_buffer_samplers.iter())?; - Ok(views_told_apart(state)) + Ok(views_told_apart(state, ranges)) } /// The consumer token of each argument-buffer texture of `case`, by its key @@ -1888,16 +1894,14 @@ pub fn compile_render( } /// The `BindShape` the executor binds `case` with on a device that has device addresses exactly -/// when `addressed`: [`compute_state`]'s. -pub fn compute_shape(case: &ComputeCase, addressed: bool) -> Result { - Ok(compute_state(case, addressed)?.shape()) -} - -/// The `BindState` whose shape the executor binds `case` with on a device that has device -/// addresses exactly when `addressed`: [`bind_state`] with every buffer's guest address and, when -/// `addressed`, a host address (only whether a buffer has one is part of the shape, not its -/// value). -pub fn compute_state(case: &ComputeCase, addressed: bool) -> Result { +/// when `addressed` and the range limits `ranges` (`BufferRanges::of`): [`bind_state`] with every +/// buffer's guest address and, when `addressed`, a host address (only whether a buffer has one is +/// part of the shape, not its value). +pub fn compute_shape( + case: &ComputeCase, + addressed: bool, + ranges: BufferRanges, +) -> Result { let with_host = |mut address: BufferAddress| { address.host = addressed.then_some(address.guest); address @@ -1912,7 +1916,7 @@ pub fn compute_state(case: &ComputeCase, addressed: bool) -> Result { /// resident allocations, [`run_allocations`]). The bind shapes depend on the device only through /// whether it has device addresses, which the executor reads from what its context enabled and this /// from `device`'s description: the same fact for an opened device, whose description is restricted -/// to what was enabled. The authored compile census compiles these on each committed profile; the +/// to what was enabled; and through its profile's range limits (`BufferRanges::of`), which both +/// read from the device's profile. The authored compile census compiles these on each committed profile; the /// executor builds the same requests through [`compile_case`], [`compile_render_case`], and /// `compile_child`. pub fn case_compiles<'a>( @@ -2577,6 +2582,7 @@ pub fn case_compiles<'a>( ) -> Result, ExecutorError> { use metal2vulkan::device::VkFeature; let addressed = device.description().has(VkFeature::BufferDeviceAddress); + let ranges = BufferRanges::of(device.device().profile().limits()); let executed = |command: &CommandBufferResource| { command.execute.is_some() && command.execution_range[0] != command.execution_range[1] }; @@ -2594,7 +2600,7 @@ pub fn case_compiles<'a>( Err(_) if runtime_run::route(prepared) == runtime_run::Route::Runtime => Vec::new(), Err(refused) => return Err(refused), }; - let shape = compute_shape(compute, addressed).map_err(ExecutorError::Failed)?; + let shape = compute_shape(compute, addressed, ranges).map_err(ExecutorError::Failed)?; let (request, libraries) = compute_request(&library, linked, compute, &shape); compiles.push(CaseCompile { subject: CompileSubject::Case, @@ -2672,7 +2678,8 @@ pub fn case_compiles<'a>( } } Mapped::Render(render) => { - let shape = graphics::render_shape(render, addressed).map_err(ExecutorError::Failed)?; + let shape = + graphics::render_shape(render, addressed, ranges).map_err(ExecutorError::Failed)?; let companion = companion_source(render); let (request, libraries) = render_request(&library, companion.as_ref(), linked, render, &shape)?; @@ -2694,7 +2701,7 @@ pub fn case_compiles<'a>( // The pipeline the runtime compiles in the run itself (`runtime_run`), for its own // stage's resources. Mapped::Mesh(mesh) => { - let shape = mesh::mesh_shape(mesh, addressed)?; + let shape = mesh::mesh_shape(mesh, addressed, ranges)?; let companion = mesh .companion .as_ref() diff --git a/crates/metal2vulkan-validation/src/candidate/engine/graphics.rs b/crates/metal2vulkan-validation/src/candidate/engine/graphics.rs index 6767b8de6..24bf68a47 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine/graphics.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine/graphics.rs @@ -62,8 +62,9 @@ use crate::executor_contract::tessellation as patches; use crate::executor_contract::DrawDepthStencil; use crate::literal::{LiteralDepthStencil, LiteralResources, LiteralStageInput, LiteralTexture}; use metal2vulkan::bind::{ - BindShape, BindState, BoundBuffer, DrawCall, IndexBufferRef, RasterizationRateMap, - RateMapRegions, RegionLimits, StageTable, TessellationFactorBuffer, TessellationFactors, + BindShape, BindState, BoundBuffer, BufferRanges, DrawCall, IndexBufferRef, + RasterizationRateMap, RateMapRegions, RegionLimits, StageTable, TessellationFactorBuffer, + TessellationFactors, }; use metal2vulkan::error::{DescriptorError, Error, MetalAnswer}; use metal2vulkan::library::FunctionConstantValues; @@ -1220,11 +1221,12 @@ pub fn synthetic_address(stage: ShaderStage, index: u32) -> BufferAddress { /// with Metal's default scale (`executor_contract::tessellation`); and the draw's depth/stencil /// descriptor, the one the Metal oracle sets (`RenderCase::depth_stencil_state`), which a /// pipeline's shader-side stencil reads as push data; telling the executor's view base alignment -/// apart ([`views_told_apart`]). +/// apart and classing lengths under the device's range limits `ranges` ([`views_told_apart`]). pub fn bind_state( case: &RenderCase, addresses: &BTreeMap<(ShaderStage, u32), BufferAddress>, embedded: &BTreeMap<(ShaderStage, u32, u32), BufferAddress>, + ranges: BufferRanges, ) -> Result { let bound = |stage: ShaderStage, index: u32, length: u64, attribute_stride: Option| { let address = addresses.get(&(stage, index)).copied().unwrap_or_default(); @@ -1289,7 +1291,7 @@ pub fn bind_state( } state.argument_samplers = argument_buffers::argument_samplers(case.argument_buffer_samplers())?; state.depth_stencil = case.depth_stencil_state.descriptor; - Ok(views_told_apart(state)) + Ok(views_told_apart(state, ranges)) } /// The bind table of `function`'s own resources at `stage`: its buffers and visible function @@ -1369,11 +1371,15 @@ pub fn records_ids(case: &RenderCase) -> Result Result { +pub fn render_shape( + case: &RenderCase, + addressed: bool, + ranges: BufferRanges, +) -> Result { let with_host = |mut address: BufferAddress| { address.host = addressed.then_some(address.guest); address @@ -1398,7 +1404,7 @@ pub fn render_shape(case: &RenderCase, addressed: bool) -> Result assert_eq!( (u.feature, u.needs), @@ -653,7 +665,13 @@ fn a_rasterization_disabled_vertex_case_maps_onto_the_oracles_draw() { (ShaderStage::Vertex, 0), synthetic_address(ShaderStage::Vertex, 0), )]); - let state = bind_state(&render, &addresses, &BTreeMap::new()).unwrap(); + let state = bind_state( + &render, + &addresses, + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); let vertex = &state.stages[&ShaderStage::Vertex]; assert_eq!( vertex.buffers.keys().copied().collect::>(), @@ -846,7 +864,7 @@ fn planned_draw( // device address equal to its guest base, as the render executor binds them on a device with // buffer device addresses: a slot the pipeline reaches through a physical pointer needs one // to plan. - let shape = render_shape(case, true).unwrap(); + let shape = render_shape(case, true, BufferRanges::default()).unwrap(); let pipeline = compile_in_process(device, case, libraries, &shape)?; assert_eq!( pipeline.graphics.rasterizer_discard, @@ -877,7 +895,7 @@ fn planned_draw( .into_iter() .map(|(key, address)| (key, own(address.guest))) .collect(); - let state = bind_state(case, &addresses, &embedded).unwrap(); + let state = bind_state(case, &addresses, &embedded, BufferRanges::default()).unwrap(); assert_eq!(state.shape(), shape); let plan = pipeline.plan(device, &shape).unwrap(); let chooses_slice = pipeline.dependencies.iter().any(|dependency| { @@ -1044,7 +1062,7 @@ fn a_tessellation_case_maps_onto_the_oracles_patch_draw() { assembly_input(&render.assembly), (vk::PrimitiveTopology::PATCH_LIST, false) ); - let shape = render_shape(&render, true).unwrap(); + let shape = render_shape(&render, true, BufferRanges::default()).unwrap(); assert!(shape.tessellation_factor_buffer); let companion = observer.as_ref().unwrap().opaque_bitcode().unwrap(); @@ -1262,7 +1280,7 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() { .collect(); let pointee = address(0x7000_0000); let embedded = BTreeMap::from([((ShaderStage::Fragment, key.0, key.1), pointee)]); - let state = bind_state(&render, &addresses, &embedded).unwrap(); + let state = bind_state(&render, &addresses, &embedded, BufferRanges::default()).unwrap(); let [used] = state.used_resources.as_slice() else { panic!("{:?}", state.used_resources); }; @@ -1296,7 +1314,7 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() { }; for stem in ["lavapipe", "moltenvk-m3"] { let device = device(stem); - let shape = render_shape(&render, true).unwrap(); + let shape = render_shape(&render, true, BufferRanges::default()).unwrap(); assert_eq!(state.shape(), shape, "{stem}"); let pipeline = compile_in_process(&device, &render, libraries, &shape) .unwrap_or_else(|error| panic!("{stem}: compile: {error}")); @@ -1483,7 +1501,7 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() { ((ShaderStage::Fragment, key.0, key.1), pointee), (command_key, storage), ]); - let state = bind_state(&render, &addresses, &embedded).unwrap(); + let state = bind_state(&render, &addresses, &embedded, BufferRanges::default()).unwrap(); let [_, stored, used] = state.used_resources.as_slice() else { panic!("{:?}", state.used_resources); }; @@ -1515,7 +1533,10 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() { RenderStages::VERTEX | RenderStages::FRAGMENT ) ); - assert_eq!(render_shape(&render, true).unwrap(), state.shape()); + assert_eq!( + render_shape(&render, true, BufferRanges::default()).unwrap(), + state.shape() + ); let sampler = (ShaderStage::Fragment, key.0, sampler_field); let samplers = sampler_ids(&render).unwrap(); assert_eq!( @@ -1602,7 +1623,7 @@ fn a_slice_choosing_case_binds_the_oracles_one_layer_pass() { ) ); assert_eq!(render.render_target_array_length, 1); - let shape = render_shape(&render, true).unwrap(); + let shape = render_shape(&render, true, BufferRanges::default()).unwrap(); assert_eq!(shape.render_target_array_length, 1); let scratch = crate::ScratchDir::new("slice-choosing-case").unwrap(); @@ -2536,7 +2557,7 @@ fn imageblock_draws_the_product_does_not_model_are_refused_typed() { render_target_array_length: 2, ..render.clone() }; - let shape = render_shape(&layered, true).unwrap(); + let shape = render_shape(&layered, true, BufferRanges::default()).unwrap(); let pipeline = compile_in_process(&lavapipe, &layered, libraries, &shape) .unwrap_or_else(|error| panic!("a layered pass links: {error}")); let refused = pipeline.plan(&lavapipe, &shape).err(); @@ -2557,7 +2578,7 @@ fn imageblock_draws_the_product_does_not_model_are_refused_typed() { }), ..render.clone() }; - let shape = render_shape(&late_depth, true).unwrap(); + let shape = render_shape(&late_depth, true, BufferRanges::default()).unwrap(); let pipeline = compile_in_process(&lavapipe, &late_depth, libraries, &shape) .unwrap_or_else(|error| panic!("a late depth test links: {error}")); pipeline @@ -2597,7 +2618,7 @@ fn rate_map_position_graphics() -> Option .expect("a fragment case's generated vertex function") .opaque_bitcode() .unwrap(); - let shape = render_shape(&render, true).unwrap(); + let shape = render_shape(&render, true, BufferRanges::default()).unwrap(); let pipeline = compile_in_process( &device("lavapipe"), &render, @@ -2793,7 +2814,7 @@ fn the_imageblock_helpers_view_each_public_cases_master() { vertex: &companion, fragment: Some(&bitcode), }; - let shape = render_shape(&render, true).unwrap(); + let shape = render_shape(&render, true, BufferRanges::default()).unwrap(); let own = compile_in_process(&device, &render, libraries, &shape) .unwrap_or_else(|error| panic!("{name} on {stem}: {error}")); let expected = imageblock(&own); @@ -2811,7 +2832,7 @@ fn the_imageblock_helpers_view_each_public_cases_master() { vertex: &companion, fragment: Some(&helpers), }; - let shape = render_shape(&helper, true).unwrap(); + let shape = render_shape(&helper, true, BufferRanges::default()).unwrap(); let pipeline = compile_in_process(&device, &helper, libraries, &shape) .unwrap_or_else(|error| panic!("{name} {entry} on {stem}: {error}")); assert_eq!(imageblock(&pipeline), expected, "{name} {entry} on {stem}"); diff --git a/crates/metal2vulkan-validation/src/candidate/engine/mesh.rs b/crates/metal2vulkan-validation/src/candidate/engine/mesh.rs index a29ed20b7..4b7ba3faa 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine/mesh.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine/mesh.rs @@ -27,7 +27,7 @@ use crate::check::admission::{ExecutorError, NotSupported}; use crate::companion::Companion; use crate::engine::RowSource; use crate::literal::LiteralResources; -use metal2vulkan::bind::{BindShape, BindState, BoundBuffer}; +use metal2vulkan::bind::{BindShape, BindState, BoundBuffer, BufferRanges}; use metal2vulkan::error::{DescriptorError, Error, MetalAnswer}; use metal2vulkan::library::FunctionConstantValues; use metal2vulkan::pipeline::Stage as ShaderStage; @@ -242,14 +242,19 @@ impl MeshTemplate { } /// The `BindShape` the runtime binds `mesh`'s draw with on a device that has device addresses -/// exactly when `addressed`: its own stage's buffers at their synthetic guest addresses (and, when -/// `addressed`, a host address), textures and samplers ([`graphics::stage_table`]); a partner -/// binds none; telling the executor's view base alignment apart ([`views_told_apart`]), so its -/// plan is the runtime's of the same binds. What the compile worker compiles the draw for +/// exactly when `addressed` and the range limits `ranges`: its own stage's buffers at their +/// synthetic guest addresses (and, when `addressed`, a host address), textures and samplers +/// ([`graphics::stage_table`]); a partner binds none; telling the executor's view base alignment +/// apart and classing lengths under `ranges` ([`views_told_apart`]), so its plan is the runtime's +/// of the same binds. What the compile worker compiles the draw for /// (`variants::compile_mesh_for_shape`). /// A case whose own function takes an argument buffer, a command buffer or a pipeline state is not /// built here (`NotImplemented`). -pub fn mesh_shape(mesh: &MeshCase, addressed: bool) -> Result { +pub fn mesh_shape( + mesh: &MeshCase, + addressed: bool, + ranges: BufferRanges, +) -> Result { let mut state = BindState::default(); for (stage, function) in mesh.stages() { let resources = &function.resources; @@ -279,7 +284,7 @@ pub fn mesh_shape(mesh: &MeshCase, addressed: bool) -> Result>(); - let state = bind_state(&compute, &addresses, &embedded).unwrap(); + let state = bind_state(&compute, &addresses, &embedded, BufferRanges::default()).unwrap(); for stem in ["lavapipe", "moltenvk-m3"] { let device = device(stem); - let shape = compute_shape(&compute, true).unwrap(); + let shape = compute_shape(&compute, true, BufferRanges::default()).unwrap(); assert_eq!(state.shape(), shape); let (pipeline, inputs) = variants::compile_compute_for_shape( &device, @@ -560,7 +560,7 @@ fn the_public_stage_input_case_compiles_under_the_oracles_descriptor() { function.constants = compute.constants.clone(); for stem in ["lavapipe", "moltenvk-m3", "swiftshader"] { let device = device(stem); - let shape = compute_shape(&compute, true).unwrap(); + let shape = compute_shape(&compute, true, BufferRanges::default()).unwrap(); // Without the descriptor, the kernel asks for it. assert!(matches!( variants::compile_compute_for_shape( @@ -600,7 +600,13 @@ fn the_public_stage_input_case_compiles_under_the_oracles_descriptor() { (index, address) }) .collect(); - let state = bind_state(&compute, &addresses, &BTreeMap::new()).unwrap(); + let state = bind_state( + &compute, + &addresses, + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); assert_eq!(state.shape(), shape, "{stem}"); assert_eq!( state.stage_in_region.map(|r| r.size), @@ -714,7 +720,7 @@ fn public_tile_cases_plan_their_attachments() { let library = Library::from_air(&bitcode).unwrap(); let mut function = FunctionDescriptor::new(library.function(&compute.entry).unwrap()); function.constants = compute.constants.clone(); - let shape = compute_shape(&compute, true).unwrap(); + let shape = compute_shape(&compute, true, BufferRanges::default()).unwrap(); let (pipeline, inputs) = match variants::compile_tile_for_shape( &device, &function, diff --git a/crates/metal2vulkan-validation/src/candidate/engine/tests.rs b/crates/metal2vulkan-validation/src/candidate/engine/tests.rs index fd6a1429f..be07ad45f 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine/tests.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine/tests.rs @@ -178,6 +178,7 @@ fn the_case_maps_onto_the_binder_or_names_the_gap() { }, )]), &BTreeMap::new(), + BufferRanges::default(), ) .unwrap(); assert!(state.used_resources.is_empty()); @@ -211,7 +212,13 @@ fn the_case_maps_onto_the_binder_or_names_the_gap() { let explicit = map_kernel(&imageblock).unwrap(); assert_eq!(explicit.imageblock, Some([16, 8])); assert_eq!(explicit.tile, None); - let state = bind_state(&explicit, &BTreeMap::new(), &BTreeMap::new()).unwrap(); + let state = bind_state( + &explicit, + &BTreeMap::new(), + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); assert_eq!( state.imageblock_size, metal2vulkan::bind::ImageblockSize::new(16, 8) @@ -281,7 +288,13 @@ fn stage_inputs_are_bound_where_the_oracle_binds_them() { d.layouts[&1].step_function, metal2vulkan::metal::StepFunction::ThreadPositionInGridX ); - let state = bind_state(&mapped, &BTreeMap::new(), &BTreeMap::new()).unwrap(); + let state = bind_state( + &mapped, + &BTreeMap::new(), + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); let grid = case.dispatch.as_ref().unwrap().grid; assert_eq!( state.stage_in_region, @@ -306,7 +319,13 @@ fn stage_inputs_are_bound_where_the_oracle_binds_them() { None ); assert_eq!(mapped.attribute_strides, BTreeMap::from([(1, 16)])); - let state = bind_state(&mapped, &BTreeMap::new(), &BTreeMap::new()).unwrap(); + let state = bind_state( + &mapped, + &BTreeMap::new(), + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); assert!(matches!( state.stages[&ShaderStage::Kernel].buffers[&1], BoundBuffer::Buffer { @@ -317,7 +336,13 @@ fn stage_inputs_are_bound_where_the_oracle_binds_them() { // Without stage inputs: no descriptor, and no region, as the oracle sets none. let plain = map_kernel(&kernel_case()).unwrap(); assert_eq!(plain.stage_input, None); - let state = bind_state(&plain, &BTreeMap::new(), &BTreeMap::new()).unwrap(); + let state = bind_state( + &plain, + &BTreeMap::new(), + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); assert_eq!(state.stage_in_region, None); let gap = |case: &AuthoredCase, interface: &AirInterface, what: &str| match compute_case( @@ -565,6 +590,7 @@ fn acceleration_structures_map_to_what_the_oracle_builds() { &map_kernel(&case).unwrap(), &BTreeMap::new(), &BTreeMap::new(), + BufferRanges::default(), ) .unwrap(); assert_eq!( @@ -643,13 +669,14 @@ fn a_tables_words_are_its_size_and_the_handles_of_its_functions() { &case, &BTreeMap::from([(7, BufferAddress::synthetic(7))]), &BTreeMap::new(), + BufferRanges::default(), ) .unwrap(); match state.stages[&ShaderStage::Kernel].buffers.get(&7) { Some(BoundBuffer::Buffer { length, .. }) => assert_eq!(*length, table.byte_len()), other => panic!("{other:?}"), } - let shape = compute_shape(&case, false).unwrap(); + let shape = compute_shape(&case, false, BufferRanges::default()).unwrap(); assert_eq!(state.shape(), shape); assert_eq!( compute_tables(&case, &linked, std::slice::from_ref(&handles)).unwrap(), @@ -1136,7 +1163,13 @@ fn a_tile_kernel_runs_in_its_tile_pass() { dimensions: [4, 3], } ); - let state = bind_state(&mapped, &BTreeMap::new(), &BTreeMap::new()).unwrap(); + let state = bind_state( + &mapped, + &BTreeMap::new(), + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); assert_eq!(state.render_area, [48, 32]); assert_eq!( state.imageblock_size, @@ -1276,7 +1309,7 @@ fn arrays_and_argument_buffers_map_onto_the_binder() { .map(|&index| (index, host(0x1000 * u64::from(index + 1)))) .collect(); let embedded = BTreeMap::from([((0, 8), host(0xdead_0000))]); - let state = bind_state(&mapped, &addresses, &embedded).unwrap(); + let state = bind_state(&mapped, &addresses, &embedded, BufferRanges::default()).unwrap(); assert_eq!( state.stages[&ShaderStage::Kernel] .buffers @@ -1297,7 +1330,7 @@ fn arrays_and_argument_buffers_map_onto_the_binder() { assert_eq!(used.usage, ResourceUsage::READ | ResourceUsage::WRITE); // The executor's shape is the one it compiles for, with and without device addresses. for addressed in [false, true] { - let shape = compute_shape(&mapped, addressed).unwrap(); + let shape = compute_shape(&mapped, addressed, BufferRanges::default()).unwrap(); assert_eq!(shape.used.len(), 1); let addresses = mapped .buffers @@ -1312,7 +1345,9 @@ fn arrays_and_argument_buffers_map_onto_the_binder() { used.host = addressed.then_some(0xa000); let embedded = BTreeMap::from([((0, 8), used)]); assert_eq!( - bind_state(&mapped, &addresses, &embedded).unwrap().shape(), + bind_state(&mapped, &addresses, &embedded, BufferRanges::default()) + .unwrap() + .shape(), shape ); } @@ -1448,7 +1483,13 @@ fn texture_arrays_bind_each_element_at_its_slot() { dimensions: [1, 1, 1], } ); - let state = bind_state(&mapped, &BTreeMap::new(), &BTreeMap::new()).unwrap(); + let state = bind_state( + &mapped, + &BTreeMap::new(), + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); let table = &state.stages[&ShaderStage::Kernel]; assert_eq!( table.textures.keys().copied().collect::>(), @@ -1577,7 +1618,7 @@ fn a_device_buffer_array_plans_as_the_functions_buffer_table() { ("vk12-floor", false), ] { let device = device(stem, DevicePolicy::default()); - let shape = compute_shape(&compute, addressed).unwrap(); + let shape = compute_shape(&compute, addressed, BufferRanges::default()).unwrap(); let (pipeline, inputs) = variants::compile_compute_for_shape( &device, &function, @@ -1603,7 +1644,13 @@ fn a_device_buffer_array_plans_as_the_functions_buffer_table() { (index, address) }) .collect(); - let state = bind_state(&compute, &addresses, &BTreeMap::new()).unwrap(); + let state = bind_state( + &compute, + &addresses, + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); assert_eq!(state.shape(), shape, "{stem}"); let commands = plan .instantiate_dispatch(&state, &compute.dispatch) @@ -1663,8 +1710,13 @@ fn the_binder_plans_the_executors_state() { host: Some(0x10_0000), }, ] { - let state = - bind_state(&case, &BTreeMap::from([(0, address)]), &BTreeMap::new()).unwrap(); + let state = bind_state( + &case, + &BTreeMap::from([(0, address)]), + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); let plan = pipeline.plan(&device, &state.shape()).unwrap(); let commands = plan.instantiate_dispatch(&state, &case.dispatch).unwrap(); assert!(!commands.regions.is_empty(), "{stem}"); diff --git a/crates/metal2vulkan-validation/src/candidate/engine/tests/argument_buffer_members.rs b/crates/metal2vulkan-validation/src/candidate/engine/tests/argument_buffer_members.rs index 7f79eaadb..542f306e8 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine/tests/argument_buffer_members.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine/tests/argument_buffer_members.rs @@ -24,7 +24,7 @@ use crate::case::{ use crate::check::admission::{ExecutorError, NotSupported}; use crate::engine::{Outcome, UnsupportedReason}; use metal2vulkan::bind::indirect_commands::records_address; -use metal2vulkan::bind::{HeapSource, NeutralResource, ResourceClass, WriteSource}; +use metal2vulkan::bind::{BufferRanges, HeapSource, NeutralResource, ResourceClass, WriteSource}; use metal2vulkan::device::DevicePolicy; use metal2vulkan::library::Library; use metal2vulkan::metal::{ @@ -207,7 +207,7 @@ fn argument_buffer_members_are_written_into_their_owner() { ((0, 8), host(0xdead_0000)), ((0, 32), records_storage(1, Some(0xbeef_0000))), ]); - let state = bind_state(&mapped, &addresses, &embedded).unwrap(); + let state = bind_state(&mapped, &addresses, &embedded, BufferRanges::default()).unwrap(); let [buffer, storage, first, second] = state.used_resources.as_slice() else { panic!("{:?}", state.used_resources); }; @@ -248,7 +248,7 @@ fn argument_buffer_members_are_written_into_their_owner() { assert_eq!((used.gpu_address, used.device_address), (None, None)); } for addressed in [false, true] { - let shape = compute_shape(&mapped, addressed).unwrap(); + let shape = compute_shape(&mapped, addressed, BufferRanges::default()).unwrap(); assert_eq!(shape.used.len(), 4); if addressed { assert_eq!(state.shape(), shape); @@ -382,7 +382,7 @@ fn an_argument_buffer_texture_is_the_heap_member_its_owner_names() { let device = device("moltenvk-m3", DevicePolicy::default()); let library = Library::from_air(&bitcode).unwrap(); let function = FunctionDescriptor::new(library.function(&mapped.entry).unwrap()); - let shape = compute_shape(&mapped, true).unwrap(); + let shape = compute_shape(&mapped, true, BufferRanges::default()).unwrap(); let (pipeline, _) = variants::compile_compute_for_shape( &device, &function, @@ -401,7 +401,13 @@ fn an_argument_buffer_texture_is_the_heap_member_its_owner_names() { (index, address) }) .collect(); - let state = bind_state(&mapped, &addresses, &BTreeMap::new()).unwrap(); + let state = bind_state( + &mapped, + &addresses, + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); assert_eq!(state.shape(), shape); let plan = pipeline.plan(&device, &shape).unwrap(); assert!(plan.diagnostics.is_empty(), "{:?}", plan.diagnostics); @@ -555,7 +561,7 @@ fn a_pipeline_state_whose_bytes_a_kernel_reads_never_reaches_a_comparison() { for stem in ["moltenvk-m3", "lavapipe", "vk12-floor"] { let device = device(stem, DevicePolicy::default()); for addressed in [false, true] { - let shape = compute_shape(&mapped, addressed).unwrap(); + let shape = compute_shape(&mapped, addressed, BufferRanges::default()).unwrap(); let compiled = variants::compile_compute_for_shape( &device, &function, @@ -691,7 +697,7 @@ fn an_argument_buffer_sampler_is_the_sampler_table_entry_its_owner_names() { let device = device("moltenvk-m3", DevicePolicy::default()); let library = Library::from_air(&bitcode).unwrap(); let function = FunctionDescriptor::new(library.function(&mapped.entry).unwrap()); - let shape = compute_shape(&mapped, true).unwrap(); + let shape = compute_shape(&mapped, true, BufferRanges::default()).unwrap(); let (pipeline, _) = variants::compile_compute_for_shape( &device, &function, @@ -710,7 +716,13 @@ fn an_argument_buffer_sampler_is_the_sampler_table_entry_its_owner_names() { (index, address) }) .collect(); - let state = bind_state(&mapped, &addresses, &BTreeMap::new()).unwrap(); + let state = bind_state( + &mapped, + &addresses, + &BTreeMap::new(), + BufferRanges::default(), + ) + .unwrap(); assert_eq!(state.shape(), shape); let id = sampler_ids(&mapped).unwrap()[&(0, 8)]; assert_eq!(id, sampler_id(0).unwrap()); diff --git a/crates/metal2vulkan-validation/src/candidate/platform/compute.rs b/crates/metal2vulkan-validation/src/candidate/platform/compute.rs index 4890dc9cc..be3db2b35 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/compute.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/compute.rs @@ -39,8 +39,8 @@ use crate::literal::LiteralTexture; use crate::observation::{Backend, TRANSLATOR_FINGERPRINT}; use crate::worker::compile::WorkerDevice; use ash::vk; -use metal2vulkan::bind::BindShape; use metal2vulkan::bind::BindingPlan; +use metal2vulkan::bind::{BindShape, BufferRanges}; use metal2vulkan::bind::{ DispatchCommands, DispatchRegion, ExecutionStatus, NeutralResource, PushHole, ReplayVariant, RootTable, SamplerDescriptor, @@ -275,7 +275,8 @@ fn run( .enabled .features .contains(&VkFeature::BufferDeviceAddress); - let shape = compute_shape(case, addressed).map_err(ExecutorError::Failed)?; + let ranges = BufferRanges::of(target.device().profile().limits()); + let shape = compute_shape(case, addressed, ranges).map_err(ExecutorError::Failed)?; // The census and the precision notes come from the artifact the compile worker returned and // this process decoded (`pipeline.stage`), never from a compile of its own. let CompiledCase { pipeline, tables } = compile(&target, &shape)?; @@ -645,7 +646,9 @@ fn execute( }) .map_err(ExecutorError::Failed)?; } - let state = bind_state(case, &addresses, &embedded_addresses).map_err(ExecutorError::Failed)?; + let ranges = BufferRanges::of(device.profile().limits()); + let state = + bind_state(case, &addresses, &embedded_addresses, ranges).map_err(ExecutorError::Failed)?; // The compile settled the plan's variant for this shape (`variants`): planning is a function // of the pipeline, the device's profile, and the shape, so the same shape plans the variant // the pipeline was compiled with. diff --git a/crates/metal2vulkan-validation/src/candidate/platform/render.rs b/crates/metal2vulkan-validation/src/candidate/platform/render.rs index 47b1f70d0..de3a558e9 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/render.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/render.rs @@ -103,8 +103,8 @@ use crate::observation::Backend; use crate::worker::compile::WorkerDevice; use ash::vk; use metal2vulkan::bind::{ - BindShape, BindState, BindingPlan, DrawCommands, ExecutionStatus, PushHole, RateMapRegions, - SamplerDescriptor, StatusReport, DRAW_ARGUMENT_BYTES, + BindShape, BindState, BindingPlan, BufferRanges, DrawCommands, ExecutionStatus, PushHole, + RateMapRegions, SamplerDescriptor, StatusReport, DRAW_ARGUMENT_BYTES, }; use metal2vulkan::device::Device; use metal2vulkan::device::VkFeature; @@ -170,7 +170,8 @@ fn run( .enabled .features .contains(&VkFeature::BufferDeviceAddress); - let shape = graphics::render_shape(case, addressed).map_err(ExecutorError::Failed)?; + let ranges = BufferRanges::of(target.device().profile().limits()); + let shape = graphics::render_shape(case, addressed, ranges).map_err(ExecutorError::Failed)?; let compiled = compile(&target, &shape)?; let pipeline = &compiled.pipeline; let device = target.device(); @@ -427,7 +428,8 @@ fn execute( .encode_host_records(mapped.bytes, |buffer| case_address(key, buffer)) .map_err(ExecutorError::Failed)?; } - let state = graphics::bind_state(case, &addresses, &embedded_addresses) + let ranges = BufferRanges::of(device.profile().limits()); + let state = graphics::bind_state(case, &addresses, &embedded_addresses, ranges) .map_err(ExecutorError::Failed)?; // The compile settled the plan's variant for this shape (`variants::compile_render_for_shape`): // planning is a function of the pipeline, the device's profile, and the shape, so the same diff --git a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs index 96973fb43..4209f4d86 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs @@ -257,7 +257,7 @@ use crate::candidate::engine::compute_shape; use crate::candidate::engine::resources::pixel_format; use crate::candidate::engine::variants::compile_compute_for_shape; use crate::gpu::TEST_DEVICE; -use metal2vulkan::bind::{AstcDecode, Dispatch, SamplerDescriptor}; +use metal2vulkan::bind::{AstcDecode, BufferRanges, Dispatch, SamplerDescriptor}; use metal2vulkan::cache::VariantKey; use metal2vulkan::device::VkExtension; use metal2vulkan::device::{DriverFact, DriverWorkaround, OpBits, VkFeature, VkProperty}; @@ -1399,7 +1399,12 @@ fn blits_degrade_once_per_kind() { fn emulates_simdgroups(device: &Device, case: &PublicCase) -> bool { let compile = device.compile_device(); let addressed = compile.profile().descriptors().buffer_device_address; - let shape = compute_shape(&case.compute, addressed).unwrap(); + let shape = compute_shape( + &case.compute, + addressed, + BufferRanges::of(compile.profile().limits()), + ) + .unwrap(); let library = Library::from_air(&case.bitcode).unwrap(); let function = FunctionDescriptor::new(library.function(&case.compute.entry).unwrap()); let dispatch = Some(&case.compute.dispatch); @@ -1421,7 +1426,12 @@ fn emulates_simdgroups(device: &Device, case: &PublicCase) -> bool { fn splits_ragged(device: &Device, case: &PublicCase) -> bool { let compile = device.compile_device(); let addressed = compile.profile().descriptors().buffer_device_address; - let shape = compute_shape(&case.compute, addressed).unwrap(); + let shape = compute_shape( + &case.compute, + addressed, + BufferRanges::of(compile.profile().limits()), + ) + .unwrap(); let library = Library::from_air(&case.bitcode).unwrap(); let function = FunctionDescriptor::new(library.function(&case.compute.entry).unwrap()); let Dispatch::Threads { @@ -1581,7 +1591,12 @@ const SPECIALIZED: [&str; 2] = [ fn run_kinds(device: &Device, case: &PublicCase) -> (BTreeSet, BTreeSet) { let compile = device.compile_device(); let addressed = compile.profile().descriptors().buffer_device_address; - let shape = compute_shape(&case.compute, addressed).unwrap(); + let shape = compute_shape( + &case.compute, + addressed, + BufferRanges::of(compile.profile().limits()), + ) + .unwrap(); let library = Library::from_air(&case.bitcode).unwrap(); let function = FunctionDescriptor::new(library.function(&case.compute.entry).unwrap()); let dispatch = Some(&case.compute.dispatch); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/executions.rs b/crates/metal2vulkan-validation/src/runtime_lane/executions.rs index f02c4a1cf..4aa8f946d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/executions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/executions.rs @@ -8,7 +8,7 @@ use super::{ public_case, run_case, validated_device_with, CaseResources, Messages, ScratchCache, WAIT, }; use crate::budgets::creation_within_ceiling; -use crate::candidate::engine::compute_state; +use crate::candidate::engine::compute_shape; use crate::candidate::engine::variants::compile_compute_for_shape; use crate::candidate::runtime_case::executor_layer_settings; use crate::coverage::ROBUSTNESS_FEATURES; @@ -37,15 +37,9 @@ pub(super) fn on_device_with(adjust: impl FnOnce(&mut DeviceOptions), test: impl /// which is the case's compile for the recorded bind shape and dispatch (the compile the /// executor's artifact digest covers), planned for the recorded bind shape as for the one the /// executor computes for the case (the two tell different view base alignments apart: -/// `engine::VIEW_BASE_ALIGNMENT`), and each `VkPipeline` the dispatch records, created within the -/// ceiling. A dispatch of no threads records an execution with no `VkPipeline`. -/// -/// The runtime classes a buffer's length under the device's range limits -/// (`StageTable::buffer_ranges`, `BufferRanges::of`) and the executor's state tells every class -/// apart (the default ranges), and a plan states the class it bound (for its instantiation's kind -/// check): the runtime's plan is the executor's state's under the device's ranges, digest for -/// digest, and the executor's own plan makes the runtime plan's every decision, its variant, -/// specialization and descriptor writes. +/// `engine::VIEW_BASE_ALIGNMENT`; both class a buffer's length under the device's range limits, +/// `BufferRanges::of`), and each `VkPipeline` the dispatch records, created within the ceiling. A +/// dispatch of no threads records an execution with no `VkPipeline`. #[test] fn the_execution_record_names_each_dispatchs_compiled_pipeline() { on_device_with(at_plan, |device| { @@ -64,29 +58,15 @@ fn the_execution_record_names_each_dispatchs_compiled_pipeline() { } let compile = device.compile_device(); let addressed = compile.profile().descriptors().buffer_device_address; - let planned = |shape| pipeline.plan(compile, shape).unwrap(); - let executor = compute_state(&case.compute, addressed).unwrap(); - let mut ranged = executor.clone(); let ranges = BufferRanges::of(compile.profile().limits()); - for table in ranged.stages.values_mut() { - table.buffer_ranges = ranges; - } - let (ranged, executor) = (ranged.shape(), executor.shape()); - let runtime = planned(execution.shape()); + let planned = |shape| { + let plan = pipeline.plan(compile, shape).unwrap(); + plan.content_digest().unwrap() + }; assert_eq!( - runtime.content_digest().unwrap(), - planned(&ranged).content_digest().unwrap(), - "the runtime planned other than the executor plans under the device's ranges" - ); - let own = planned(&executor); - assert_eq!( - (&own.variant, &own.specialization, &own.descriptors), - ( - &runtime.variant, - &runtime.specialization, - &runtime.descriptors - ), - "the executor's own plan decides other than the runtime's" + planned(execution.shape()), + planned(&compute_shape(&case.compute, addressed, ranges).unwrap()), + "the runtime planned other than the executor plans" ); let library = Library::from_air(&case.bitcode).unwrap(); let function = FunctionDescriptor::new(library.function(&case.compute.entry).unwrap()); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/kernel_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/kernel_textures.rs index 9217d8cf7..9f9d7c9de 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/kernel_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/kernel_textures.rs @@ -43,7 +43,7 @@ use crate::candidate::tests::engine_compute; use crate::case::{AuthoredCase, Stage}; use crate::gpu::TEST_DEVICE; use crate::requirement::ToolingRequirement; -use metal2vulkan::bind::{SamplerDescriptor, StatusReport}; +use metal2vulkan::bind::{BufferRanges, SamplerDescriptor, StatusReport}; use metal2vulkan::cache::VariantKey; use metal2vulkan::error::Feature; use metal2vulkan::library::Library; @@ -426,7 +426,12 @@ fn stand_in_states_answer_queries_as_their_formats_compile(shard: usize) { if !needs { continue; } - let shape = compute_shape(&case.compute, addressed).unwrap(); + let shape = compute_shape( + &case.compute, + addressed, + BufferRanges::of(compile.profile().limits()), + ) + .unwrap(); let own = compile_compute_for_shape(compile, &function, &shape, None, None, &budget); let state = pipeline_state(device, case); match (own, state) { diff --git a/crates/metal2vulkan-validation/src/worker/compile.rs b/crates/metal2vulkan-validation/src/worker/compile.rs index c7eb2f14d..1f31bd767 100644 --- a/crates/metal2vulkan-validation/src/worker/compile.rs +++ b/crates/metal2vulkan-validation/src/worker/compile.rs @@ -641,7 +641,7 @@ mod tests { use super::*; use crate::acceptance::RequestFunction; use crate::worker::MEMORY_LIMIT_BYTES; - use metal2vulkan::bind::BindShape; + use metal2vulkan::bind::{BindShape, BufferRanges}; use metal2vulkan_devtools::{engine_dir, llvm_assemble, AssembleError}; fn fixture(name: &str) -> Option> { @@ -820,7 +820,7 @@ mod tests { }, output: ComputeOutput::None, }; - let shape = compute_shape(&case, false).unwrap(); + let shape = compute_shape(&case, false, BufferRanges::default()).unwrap(); let request = PipelineRequest::BoundCompute { function: RequestFunction::new(case.entry.as_str(), case.constants.clone()), shape: shape.clone(), @@ -896,7 +896,14 @@ mod tests { case.vertex.constants.clone(), ), template, - shape: Some(crate::candidate::engine::graphics::render_shape(&case, false).unwrap()), + shape: Some( + crate::candidate::engine::graphics::render_shape( + &case, + false, + BufferRanges::default(), + ) + .unwrap(), + ), form: crate::candidate::engine::variants::DrawForm::Bound, }; let (bytes, digest) = input(&device, &bitcode, request.clone()); diff --git a/crates/metal2vulkan-validation/tests/integration/engine_linked_cases.rs b/crates/metal2vulkan-validation/tests/integration/engine_linked_cases.rs index e0b880f6c..0d40dfd2f 100644 --- a/crates/metal2vulkan-validation/tests/integration/engine_linked_cases.rs +++ b/crates/metal2vulkan-validation/tests/integration/engine_linked_cases.rs @@ -6,6 +6,7 @@ //! it compiles for. No device is opened: the GPU run (Metal and the candidate) is the operator's. use base64::Engine as _; +use metal2vulkan::bind::BufferRanges; use metal2vulkan::device::DevicePolicy; use metal2vulkan_devtools::{engine_dir, llvm_assemble, AssembleError}; use metal2vulkan_validation::acceptance::{retained, LinkedLibrary}; @@ -149,7 +150,8 @@ fn a_case_with_visible_function_references_compiles_linked_through_the_worker() let device = WorkerDevice::new(load_description(stem).unwrap(), DevicePolicy::default()).unwrap(); let profile = device.device().profile(); - let shape = compute_shape(&compute, profile.descriptors().buffer_device_address).unwrap(); + let addressed = profile.descriptors().buffer_device_address; + let shape = compute_shape(&compute, addressed, BufferRanges::of(profile.limits())).unwrap(); let pipeline = compile_case( &worker, &device, @@ -281,7 +283,7 @@ fn a_case_with_a_visible_function_table_binds_the_products_table_words() { WorkerDevice::new(load_description(stem).unwrap(), DevicePolicy::default()).unwrap(); let profile = device.device().profile(); let addressed = profile.descriptors().buffer_device_address; - let shape = compute_shape(&compute, addressed).unwrap(); + let shape = compute_shape(&compute, addressed, BufferRanges::of(profile.limits())).unwrap(); let compiled = compile_case( &worker, &device, @@ -301,7 +303,13 @@ fn a_case_with_a_visible_function_table_binds_the_products_table_words() { assert_eq!(words, [1, 5, 2, 3, 0, 4, 5], "{stem}"); assert_eq!(compiled.tables.len(), 1, "{stem}"); // The table is a buffer of its words' length at its index, in the compiled-for shape. - let state = bind_state(&compute, &Default::default(), &Default::default()).unwrap(); + let state = bind_state( + &compute, + &Default::default(), + &Default::default(), + BufferRanges::default(), + ) + .unwrap(); match state.stages[&Stage::Kernel].buffers.get(&1) { Some(BoundBuffer::Buffer { length, .. }) => assert_eq!(*length, 28, "{stem}"), other => panic!("{stem}: {other:?}"),