validation: delete runs_through_runtime, always true for a mapped kernel case

The predicate answered true for a Threads or Threadgroups dispatch. Every kernel case the engine
maps comes from compute_case, which dispatches by threads (a case has no indirect dispatch to map),
so it was true for every case it was asked about. Its one product caller, run_on_context, now
routes every mapped kernel case through the runtime when no profiles-layer restriction is
requested, as before. The runtime run's own match still refuses any dispatch but threads or
threadgroups.

Deleted with it: the predicate's own test (a_plain_kernel_case_and_only_one_runs_through_the_runtime)
and its plain_kernel helper, which nothing else used. The doc references are rewritten
(ComputeRun::spv_sha256, runtime_fingerprint, run_on_runtime, runs_render_through_runtime,
platform::runtime, engine_textures' runs, docs/VALIDATION.md).

Search: `git grep -n runs_through_runtime` at 3d2b846caa gives 19 hits (the definition, 1 caller,
8 doc references, 9 test asserts); after, 0. The crate is unpublished, so no consumer calls it.
No version bump: routing and rows do not change for any case.

Verified: m3-max-65445 (fmt, signatures, clippy plain / --cfg m2v_gpu / --cfg m2v_cpu_icd, workspace
Rustdoc -D warnings, 51 engine tests) and m3-max-65449 (two public kernel cases, gated-bias-on and
one-d-array-reads-and-width-queries-at-32-and-16-bit-coordinates, Match through runtime-compute on
lavapipe).
This commit is contained in:
Anees Iqbal committed 2026-11-21 18:23:39 -08:00
1 parent b4559d038c
commit bebd518dfb
5 files changed
+21 -214

No files matched your search

@@ -205,8 +205,8 @@ pub enum ComputeOutput {
pub struct ComputeRun {
pub output: Vec<u8>,
/// SHA-256 of the pipeline's SPIR-V bytes (before specialization), where the executor
/// compiled it itself; `None` for a run through the runtime ([`runs_through_runtime`]), which
/// keeps its modules to itself.
/// compiled it itself; `None` for a run through the runtime, which keeps its modules to
/// itself.
pub spv_sha256: Option<String>,
/// [`engine_fingerprint`] of the profile the case compiled for, or [`runtime_fingerprint`]
/// for a run through the runtime.
@@ -695,8 +695,8 @@ pub fn engine_fingerprint_of(profile: &Hash256) -> String {
sha256_bytes(&bytes)
}
/// The translator fingerprint of a run through the runtime ([`runs_through_runtime`]): the
/// product, its semantics version and the runtime crate's sources
/// The translator fingerprint of a run through the runtime: the product, its semantics version
/// and the runtime crate's sources
/// ([`RUNTIME_CRATE_FINGERPRINT`]). The runtime derives what it compiles for from the device it
/// opened and answers none of it, so no profile is part of it; the row's slot and its recorded
/// device are.
@@ -710,40 +710,6 @@ pub fn runtime_fingerprint() -> String {
sha256_bytes(&bytes)
}
/// Whether `case` runs through the runtime (`metal2vulkan-runtime`'s public API,
/// `platform::execute_runtime`) in place of the executor's own context: a kernel case of buffers
/// (each device buffer array's elements among them), bound textures and samplers, made as the
/// Metal oracle makes them (`platform::runtime_textures`: a 32-bit float depth, whose bytes the
/// runtime takes no upload of, filled by a draw, `platform::runtime_depth`, and a multisampled
/// texture by a draw per slice, `platform::runtime_multisample`, and a texture buffer over a
/// buffer of its bytes; a sparse texture is the runtime's limit, which stops the candidate
/// first), argument buffers of buffers, textures (texture buffers among them) and samplers,
/// threadgroup memory lengths, function constants and linked functions, dispatched by
/// `dispatchThreads` or `dispatchThreadgroups`, observing any output the mapping makes, its
/// out-of-bounds targets among them (`platform::runtime_bounds`). Decided by the case's structure
/// alone: every field the mapping fills is named here, so a new one is decided when it is added.
pub fn runs_through_runtime(case: &ComputeCase) -> bool {
let ComputeCase {
entry: _,
constants: _,
buffers: _,
argument_buffer_buffers: _,
argument_buffer_textures: _,
argument_buffer_samplers: _,
textures: _,
samplers: _,
threadgroup_lengths: _,
dispatch,
output: _,
out_of_bounds: _,
creation_bound: _,
} = case;
matches!(
dispatch,
Dispatch::Threads { .. } | Dispatch::Threadgroups { .. }
)
}
/// The bytes of each buffer a run through the runtime binds, by Metal index, as the Metal oracle
/// creates them (`metal::platform::buffers`): a bound buffer's authored bytes padded to the size
/// its argument declares ([`buffer_bytes_padded_to_declared_size`]), and a device buffer array's
@@ -799,8 +765,8 @@ fn runtime_reductions(
Ok(reductions)
}
/// A run through the runtime ([`runs_through_runtime`]) of `prepared`'s kernel case `compute`:
/// the row's AIR and each module it links, its buffers as the oracle makes them
/// A run through the runtime of `prepared`'s kernel case `compute`: the row's AIR and each
/// module it links, its buffers as the oracle makes them
/// ([`runtime_buffers`]), and the float reductions it executes ([`runtime_reductions`]), run by
/// `platform::execute_runtime`.
fn run_on_runtime(prepared: &PreparedCase, compute: &ComputeCase) -> RunAttempt {
@@ -914,9 +880,9 @@ pub struct RuntimeKernel<'a> {
/// (`platform::execute_runtime_render`) in place of the executor's own context: a vertex or
/// fragment case of any sample count (`raster_sample_count`; each attachment of more samples
/// filled and read back sample by sample, `platform::runtime_multisample`), its own stage's
/// buffers, bound textures (as [`runs_through_runtime`] makes them) and bound samplers, argument
/// buffers of buffers, textures and samplers (as [`runs_through_runtime`] makes them), function
/// constants and linked functions, its vertex buffers, its color targets and a depth/stencil
/// buffers, bound textures (made as a kernel case's run makes them, `platform::runtime_textures`)
/// and bound samplers, argument buffers of buffers, textures and samplers (their textures made so
/// too), function constants and linked functions, its vertex buffers, its color targets and a depth/stencil
/// attachment of one aspect, or none (a fragment case's pass of no attachment is the oracle's 1x1
/// at its samples), the encoder's depth-stencil state, cull mode and winding, and
/// one direct or indexed draw of primitives or one patch draw with no patch or control-point index
@@ -1943,10 +1909,10 @@ fn run_on_context(prepared: &PreparedCase, worker: &CompileWorker) -> RunAttempt
let library = RowSource::of_row(&prepared.checked.primary.source);
let linked = &prepared.linked;
// A case the runtime runs, run so in this process's default run: no profiles-layer
// restriction. It records no artifact: the runtime keeps what it compiled to
// itself.
// restriction. Every kernel case the engine maps is one (`compute_case` dispatches it by
// threads). It records no artifact: the runtime keeps what it compiled to itself.
if let Mapped::Compute(compute) = &prepared.mapped {
if runs_through_runtime(compute) && super::requested_restriction().is_none() {
if super::requested_restriction().is_none() {
return run_on_runtime(prepared, compute);
}
}
@@ -1208,164 +1208,6 @@ fn addressed_allocations_take_metal_addresses() {
assert!(BufferAddress::addressed(records_address(1)).is_err());
}
/// A kernel case of buffers and threadgroup memory, dispatched by threads and observing a buffer.
fn plain_kernel() -> ComputeCase {
ComputeCase {
out_of_bounds: Vec::new(),
creation_bound: crate::budgets::PIPELINE_CREATION_CEILING,
entry: "main".into(),
constants: FunctionConstantValues::defaults(),
buffers: BTreeMap::from([(0, vec![0; 4]), (1, vec![0; 16])]),
argument_buffer_buffers: BTreeMap::new(),
argument_buffer_textures: BTreeMap::new(),
argument_buffer_samplers: BTreeMap::new(),
textures: BTreeMap::new(),
samplers: BTreeMap::new(),
threadgroup_lengths: BTreeMap::from([(0, 64)]),
dispatch: Dispatch::Threads {
threads: [5, 1, 1],
threads_per_group: [2, 1, 1],
},
output: ComputeOutput::Buffer {
binding: 0,
offset: 0,
length: 4,
},
}
}
/// The runtime runs a kernel case of buffers, threadgroup memory and constants, bound textures it
/// makes and bound samplers, argument buffers of buffers, such textures and samplers, dispatched
/// by threads or threadgroups and observing a buffer, a texture, an argument-buffer member or
/// nothing, a 32-bit float depth or a multisampled texture among its textures (which the run
/// fills by a draw), a cube array among them, and its out-of-bounds targets among them
/// (`platform::runtime_bounds`); a case with an indirect dispatch stays on the executor's own
/// context.
#[test]
fn a_plain_kernel_case_and_only_one_runs_through_the_runtime() {
use crate::case::{
ArgumentBufferSamplerResource, ResourceRole, SamplerAddressMode, SamplerFilter,
SamplerMipFilter, SamplerResource, TextureFormat, TextureType,
};
let plain = plain_kernel();
assert!(runs_through_runtime(&plain));
let groups = ComputeCase {
dispatch: Dispatch::Threadgroups {
groups: [2, 1, 1],
threads_per_group: [2, 1, 1],
},
output: ComputeOutput::None,
..plain.clone()
};
assert!(runs_through_runtime(&groups));
let texture = |texture_type, sample_count| LiteralTexture {
binding: 0,
role: ResourceRole::InOut,
texture_type,
format: TextureFormat::Rgba8Unorm,
dimensions: [4, 4, 1],
sample_count,
bytes: vec![0; 64 * sample_count as usize],
sparse: None,
mip_levels: 1,
};
let textured = |texture: LiteralTexture| {
let mut case = plain.clone();
case.textures.insert(0, texture);
case.output = ComputeOutput::Texture {
binding: 0,
origin: [0; 3],
dimensions: [1; 3],
};
case
};
let mut sampled = textured(texture(TextureType::D2, 1));
sampled.samplers.insert(
0,
SamplerResource {
binding: 0,
address_mode: SamplerAddressMode::ClampToEdge,
min_filter: SamplerFilter::Linear,
mag_filter: SamplerFilter::Linear,
mip_filter: SamplerMipFilter::NotMipmapped,
normalized_coordinates: true,
},
);
assert!(runs_through_runtime(&sampled));
let mut members = plain.clone();
members.argument_buffer_buffers.insert((0, 0), vec![0; 16]);
members
.argument_buffer_textures
.insert((0, 8), texture(TextureType::D2, 1));
members.argument_buffer_samplers.insert(
(0, 16),
ArgumentBufferSamplerResource {
buffer_binding: 0,
field_offset: 16,
address_mode: SamplerAddressMode::ClampToEdge,
min_filter: SamplerFilter::Nearest,
mag_filter: SamplerFilter::Nearest,
mip_filter: SamplerMipFilter::NotMipmapped,
normalized_coordinates: true,
compare_function: None,
},
);
for output in [
ComputeOutput::ArgumentBufferBuffer {
owner: 0,
field_offset: 0,
offset: 0,
length: 4,
},
ComputeOutput::ArgumentBufferTexture {
owner: 0,
field_offset: 8,
origin: [0; 3],
dimensions: [1; 3],
},
] {
let case = ComputeCase {
output,
..members.clone()
};
assert!(runs_through_runtime(&case));
}
let depth = LiteralTexture {
format: TextureFormat::Depth32Float,
bytes: vec![0; 64],
..texture(TextureType::D2, 1)
};
assert!(runs_through_runtime(&textured(depth)));
assert!(runs_through_runtime(&textured(texture(
TextureType::D2Multisample,
4
))));
let cube_array = LiteralTexture {
dimensions: [4, 4, 12],
bytes: vec![0; 768],
..texture(TextureType::CubeArray, 1)
};
assert!(runs_through_runtime(&textured(cube_array)));
let bounded = ComputeCase {
out_of_bounds: vec![OutOfBoundsTarget {
resource: OutOfBoundsResource::Buffer { binding: 0 },
form: crate::case::out_of_bounds::ContainmentForm::StorageBuffer,
reach_before: 0,
reach_after: 256,
}],
..plain.clone()
};
assert!(runs_through_runtime(&bounded));
let indirect = ComputeCase {
dispatch: Dispatch::ThreadgroupsIndirect {
indirect: metal2vulkan::bind::IndirectRef::new(0, 0),
threads_per_group: [2, 1, 1],
},
..plain.clone()
};
assert!(!runs_through_runtime(&indirect), "{indirect:?}");
}
/// The runtime draws a vertex or fragment case of any sample count, its own stage's buffers,
/// textures and samplers, argument-buffer members, vertex buffers, color targets, and one direct
/// or indexed draw of primitives or one patch draw with no index buffer, observing a buffer, a
@@ -1,7 +1,7 @@
//! The engine compute executor through the runtime (`metal2vulkan-runtime`).
//!
//! A kernel case the engine routes here (`engine::runs_through_runtime`) runs as a consumer runs
//! it, on the runtime's public API alone: its instance, the loader's first physical device of the
//! Every kernel case the engine maps runs here outside a profiles-layer restriction
//! (`engine::run_on_context`), as a consumer runs it, on the runtime's public API alone: its instance, the loader's first physical device of the
//! requested kind (as the executor's own context selects one), a device with the default
//! options, a library and a function from the row's AIR with the case's constants and linked
//! functions, one compute pipeline state, one Shared buffer per bound buffer and per
@@ -101,7 +101,7 @@ fn fixture(name: &str) -> Vec<u8> {
type Run = fn(&ComputeCase, &[u8]) -> Result<ComputeRun, ExecutorError>;
/// The runs a case the runtime makes takes: on the executor's own context, and on Linux through
/// the runtime (`engine::runs_through_runtime`), each named.
/// the runtime (`engine_compute::run_through_runtime`), each named.
#[cfg(target_os = "linux")]
fn runs() -> [(&'static str, Run); 2] {
[
+6 -7
View File
@@ -451,13 +451,12 @@ cargo run -p metal2vulkan-validation --release --bin corpus-vulkan -- \
case through the public API in a killable compile worker, executes exactly what the binder plans,
and compares the observations with Metal's. Every context runs under the validation layer and
enables every robustness feature the device states.
- **Through the runtime.** On Linux, without a profile restriction, a kernel
case of buffers (device buffer arrays included), bound textures and samplers, argument buffers
of buffers, textures and samplers, threadgroup memory, function constants and linked functions,
dispatched by threads or threadgroups and observing a buffer, a texture, an argument-buffer
member or nothing, runs through `metal2vulkan-runtime`'s public API instead, as a consumer runs
it (`engine::runs_through_runtime` decides it from the case's structure). Each texture is made
as the Metal oracle makes it, Shared and written with `replace_region`, at an index the run
- **Through the runtime.** On Linux, without a profile restriction, every kernel case the engine
maps (buffers, device buffer arrays included, bound textures and samplers, argument buffers of
buffers, textures and samplers, threadgroup memory, function constants and linked functions,
dispatched by threads and observing a buffer, a texture, an argument-buffer member or nothing)
runs through `metal2vulkan-runtime`'s public API instead, as a consumer runs it. Each texture is
made as the Metal oracle makes it, Shared and written with `replace_region`, at an index the run
grants. An argument buffer holds each member's `gpuAddress` or `gpuResourceID` at its field, as
a program writes them, and each member buffer and texture is used for reading and writing
(`use_resource`). A 32-bit float depth texture, which the runtime takes no upload of, is filled