The executor classes buffer lengths under the device's range limits, as the runtime does

What: views_told_apart takes the device's BufferRanges and sets every stage table's
buffer_ranges to them, so the executor's bind states state the length class the runtime's
states of the same binds state (RUNTIME 2412 rounds a buffer's class under
BufferRanges::of(limits); the executor kept the defaults, which tell every class apart). The
compute, render and mesh builders (bind_state, compute_shape, graphics::bind_state,
render_shape, mesh_shape) take the ranges; the executor passes its device profile's limits
(case_compiles from the worker device, platform run/execute from the opened device), the
runtime-lane tests their compile device's, and the unit tests the defaults. ENGINE_EXECUTOR_ABI
goes to vulkan-engine-v183: every executed artifact whose plan binds a buffer changes digest.

Why: a BindingPlan states its bound length class (BoundKind::Buffer), so the runtime path's plan
digest differed from the executor's and from the authored compile census's on every device:
candidate::engine::runtime_run's parity (run.census.artifact == on_context.census.artifact)
and runtime_lane::executions' plan digest check failed on lavapipe and the Iris. With both on
the device's ranges the executions test is back to its single digest equality, and the earlier
split of compute_state for its decision-only comparison is folded back.

The authored compile census owes a re-bless after this landing (executor ABI and digests
change); it is re-blessed once, at the next pin sha.

Verification: a lavapipe (cpuicd) job runs the three runtime_run tests, executions, and the
touched engine, graphics, public_cases, argument_buffer_members, worker::compile and
runtime_lane suites, plus a negative control (views_told_apart on default ranges) that must
fail the runtime_run parity; results go to main with the job id.
This commit is contained in:
Anees Iqbal committed 2026-11-15 21:43:46 -08:00
1 parent 5328cb1149
commit 175706d3f2
14 files changed
+264 -135

No files matched your search

@@ -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<u32, BufferAddress>,
embedded: &BTreeMap<(u32, u32), BufferAddress>,
ranges: BufferRanges,
) -> Result<BindState, String> {
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<BindShape, String> {
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<BindState, String> {
/// 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<BindShape, String> {
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<BindState, S
.into_iter()
.map(|(key, address)| (key, with_host(address)))
.collect();
bind_state(case, &addresses, &embedded)
Ok(bind_state(case, &addresses, &embedded, ranges)?.shape())
}
/// The synthetic guest address of each argument-buffer buffer of `case`, by its key
@@ -2568,7 +2572,8 @@ pub struct CaseCompiles<'a> {
/// 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<CaseCompiles<'a>, 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()
@@ -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<BindState, String> {
let bound = |stage: ShaderStage, index: u32, length: u64, attribute_stride: Option<u32>| {
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<BTreeMap<(ShaderStage, u32, u32)
}
/// The `BindShape` the render executor binds `case` with on a device that has device addresses
/// exactly when `addressed` ([`bind_state`] with every buffer's and argument-buffer buffer's
/// synthetic guest address and, when `addressed`, a host address; only whether a buffer has one
/// is part of the shape): what the compile worker compiles the draw for
/// exactly when `addressed` and the range limits `ranges` ([`bind_state`] with every buffer's and
/// argument-buffer buffer's synthetic guest address and, when `addressed`, a host address; only
/// whether a buffer has one is part of the shape): what the compile worker compiles the draw for
/// (`variants::compile_render_for_shape`).
pub fn render_shape(case: &RenderCase, addressed: bool) -> Result<BindShape, String> {
pub fn render_shape(
case: &RenderCase,
addressed: bool,
ranges: BufferRanges,
) -> Result<BindShape, String> {
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<BindShape, Str
.into_iter()
.map(|(key, address)| (key, with_host(address)))
.collect();
Ok(bind_state(case, &addresses, &embedded)?.shape())
Ok(bind_state(case, &addresses, &embedded, ranges)?.shape())
}
/// The final contents of a render run, by stage and Metal index (color targets by index).
@@ -249,7 +249,13 @@ fn a_stencil_output_case_plans_its_shadow_where_the_device_lacks_export() {
.count(),
1
);
let state = bind_state(&render, &BTreeMap::new(), &BTreeMap::new()).unwrap();
let state = bind_state(
&render,
&BTreeMap::new(),
&BTreeMap::new(),
BufferRanges::default(),
)
.unwrap();
assert_eq!(state.depth_stencil, render.depth_stencil_state.descriptor);
// A depth test that can fail, under a face whose depth-failure operation (`Keep`) is not its
@@ -259,7 +265,13 @@ fn a_stencil_output_case_plans_its_shadow_where_the_device_lacks_export() {
.depth_stencil_state
.descriptor
.depth_compare_function = metal2vulkan::metal::CompareFunction::Less;
let state = bind_state(&dependent, &BTreeMap::new(), &BTreeMap::new()).unwrap();
let state = bind_state(
&dependent,
&BTreeMap::new(),
&BTreeMap::new(),
BufferRanges::default(),
)
.unwrap();
match plan.instantiate_draw(&state, &dependent.draw) {
Err(BindError::Unsupported(u)) => 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::<Vec<_>>(),
@@ -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<metal2vulkan::pipeline::GraphicsState>
.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}");
@@ -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<BindShape, ExecutorError> {
pub fn mesh_shape(
mesh: &MeshCase,
addressed: bool,
ranges: BufferRanges,
) -> Result<BindShape, ExecutorError> {
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<BindShape, Executo
let table = graphics::stage_table(stage, function, bound).map_err(ExecutorError::Failed)?;
state.stages.insert(stage, table);
}
Ok(views_told_apart(state).shape())
Ok(views_told_apart(state, ranges).shape())
}
/// The compile request for `mesh`'s pipeline for the bind shape `shape`, and its libraries in
@@ -103,7 +103,7 @@ fn plan_case(device: &Device, case: &AuthoredCase, row: &crate::source::SourceRo
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_compute_for_shape(
device,
&function,
@@ -145,7 +145,7 @@ fn plan_case(device: &Device, case: &AuthoredCase, row: &crate::source::SourceRo
)
})
.collect();
let state = bind_state(&compute, &addresses, &embedded).unwrap();
let state = bind_state(&compute, &addresses, &embedded, BufferRanges::default()).unwrap();
// The executor's shape is the one it compiles for.
assert_eq!(state.shape(), shape, "{}", case.name);
let plan = match pipeline.plan(device, &state.shape()) {
@@ -363,7 +363,7 @@ fn public_texture_array_cases_plan_their_elements_at_their_slots() {
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();
let (pipeline, inputs) = variants::compile_compute_for_shape(
&device,
&function,
@@ -469,10 +469,10 @@ fn the_public_argument_buffer_cases_plan_their_pointees_resident() {
.zip(0u64..)
.map(|(&key, ordinal)| (key, address(0x7000_0000 + 0x100_0000 * ordinal)))
.collect::<BTreeMap<_, _>>();
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,
@@ -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::<Vec<_>>(),
@@ -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}");
@@ -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());
@@ -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.
@@ -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
@@ -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<Degradation>, BTreeSet<Degradation>) {
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);
@@ -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());
@@ -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) {
@@ -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<Vec<u8>> {
@@ -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());
@@ -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:?}"),