rt: a refused pipeline state's Error::Translation names its functions

What: Error::Translation is now Error::Translation { error, functions }. new_compute_pipeline_state
and new_render_pipeline_state fill `functions` at their public entry with each Function stage's own
name in its library (FunctionInfo::name), in stage order (the vertex function before the fragment
function), and the Display prints them: "the translator made no pipeline of a, b: ...". A compiled
stage has no name; a sampler state, a device and a dispatch's late kernel variant name none, and
then the text is as before. It is a diagnostic for the program's log, documented as the text of
the NSError Metal's failed creation gives; no lowering or decision reads it.

Why: the consumer logged only the first refusal of each kind, which hid 6 of one 3D modelling
app's 8 refused kernels; with the names it logs every refused create.

How: the existing creation bodies moved to private compute_pipeline_state and
render_pipeline_state, whose translator errors name no function (Error::translation, for map_err),
and the public entries map them through Error::of_stages. The one-token map_err edits are in
pipeline.rs, render.rs, sampler.rs:371 and device.rs:1290 and 1294.

Same commit: 10 rt test patterns; validation's candidate/platform/runtime.rs (2),
candidate/tests/engine_compute.rs, replay/new_runtime/mod.rs and replay/new_runtime/tests.rs (3);
conformance's rt_side.rs, rt_side/states.rs and case.rs. Conformance's Failure::of_rt records the
error's text without the names (they are the case's own functions), so the 484 answers in
known-gaps-rt.tsv stay as they are. The rt README's compute and render state entries say what
`functions` holds; REFUSALS.md and api_signatures.tsv are regenerated (one changed signature).

Consumer break to follow: reims-vgpu builds or matches rt::Error::Translation(..) at 17 sites,
all in crates/reims-vgpu-vulkan/src/rt_platform/: unbuilt.rs (7), diag.rs (5), library.rs (3),
pipeline.rs (1), argument.rs (1). Each becomes Translation { error, .. } in a match, or
Translation { error, functions: Vec::new() } where it builds one.

Tests (device cfgs): every_device_names_the_function_of_a_refused_compute_state (translate.rs):
a compute state of the vertex function colored_vertex is Error::Translation with functions
["colored_vertex"], and its text starts "the translator made no pipeline of colored_vertex: ".
every_device_refuses_the_patch_draws_it_does_not_build (patch.rs) now also holds the
control-point index type's Tessellation refusal to functions ["tess_triangle_points",
"tess_fragment"] and to the text that names them in that order. Without the entry mapping both
fail on an empty `functions`.
This commit is contained in:
Anees Iqbal committed 2026-11-20 22:25:11 -08:00
1 parent 627379eb19
commit 2c5573d598
26 files changed
+247 -81

No files matched your search

+18 -5
View File
@@ -490,11 +490,24 @@ pub struct Failure {
impl Failure {
/// The failure a typed error of the runtime (`metal2vulkan-runtime`) is. A translator refusal
/// that names a capability the device could enable is the venue's gap ([`device_gap_of`]).
/// The functions a refused pipeline state names are the case's own, a diagnostic: the failure
/// holds the error's text without them.
pub fn of_rt(error: &metal2vulkan_runtime::Error) -> Self {
let text = match error {
metal2vulkan_runtime::Error::Translation { error, .. } => {
let unnamed = metal2vulkan_runtime::Error::Translation {
error: error.clone(),
functions: Vec::new(),
};
unnamed.to_string()
}
other => other.to_string(),
};
let lacks = match error {
metal2vulkan_runtime::Error::Translation(metal2vulkan::error::Error::Unsupported(
unsupported,
)) => device_gap_of(unsupported),
metal2vulkan_runtime::Error::Translation {
error: metal2vulkan::error::Error::Unsupported(unsupported),
..
} => device_gap_of(unsupported),
// A threadgroup Metal runs and this device's limits for the kernel do not.
metal2vulkan_runtime::Error::Limit(
metal2vulkan_runtime::Limit::ThreadgroupThreads { .. },
@@ -504,10 +517,10 @@ impl Failure {
Self {
error: Value::Variant {
name: error_variant(error),
payload: Box::new(Value::Lines(vec![error.to_string()])),
payload: Box::new(Value::Lines(vec![text.clone()])),
},
lacks,
refusal: Some(error.to_string()),
refusal: Some(text),
}
}
@@ -160,7 +160,10 @@ impl RtDevice {
/// refusal of the runtime's until a stream uses it, and the failure is the runtime's refusal.
pub(crate) fn failure(&self, error: &rt::Error) -> Failure {
let mut failure = Failure::of_rt(error);
if let rt::Error::Translation(metal2vulkan::error::Error::Unsupported(unsupported)) = error
if let rt::Error::Translation {
error: metal2vulkan::error::Error::Unsupported(unsupported),
..
} = error
{
if offers_one(&self.offered, unsupported) {
failure.lacks = None;
@@ -21,7 +21,10 @@ fn refuses_as_metal(error: &rt::Error) -> bool {
matches!(
error,
rt::Error::Refused(_)
| rt::Error::Translation(metal2vulkan::error::Error::InvalidDescriptor(_))
| rt::Error::Translation {
error: metal2vulkan::error::Error::InvalidDescriptor(_),
..
}
)
}
+6 -2
View File
@@ -2183,7 +2183,10 @@ while the driver's exit handler waited on a lock, with every runtime thread alre
budget per lowering, for what device creation enabled and under its identity domains: each
buffer argument is the guest address of the bound buffer plus its offset, and each texture and
sampler argument the bound object's resource ID, pushed; set 1 is the only descriptor set a
kernel reads. A refusal of the translator is `Error::Translation`.
kernel reads. A refusal of the translator is `Error::Translation`, whose `functions` names the
kernel by its own name in its library and whose text prints it, for the program's log as the
text of Metal's `NSError` is; nothing decides by it. A kernel the consumer compiled has no name
there.
- rt builds no pipeline reflection and acts on no `MTLPipelineOption`; its consumer builds
reflection from the library's AIR. The options it leaves to the consumer are
`MTLPipelineOptionFailOnBinaryArchiveMiss`, `MTLPipelineOptionArgumentInfo`,
@@ -2693,7 +2696,8 @@ or does not check is rebuilt from the generations' names, with young counted ful
`newRenderPipelineStateWithDescriptor:error:` without reflection. The translator lowers the
vertex and fragment functions on the calling thread, which waits for them, within its 20-second
budget per lowering, for what device creation enabled and under its identity domains, as for a
compute state. A refusal of the translator is `Error::Translation`.
compute state. A refusal of the translator is `Error::Translation`, whose `functions` names the
vertex function and then the fragment function, as for a compute state.
- rt builds no pipeline reflection and acts on no `MTLPipelineOption`; its consumer builds
reflection from the library's AIR, as for a compute state.
- `RenderPipelineState::texture_accesses(stage)` answers each texture slot the vertex
+2 -2
View File
@@ -1287,11 +1287,11 @@ unsafe fn translator(
unsafe { DeviceDescription::query(instance, raw, ApiVersion::from_packed(floor::VERSION)) };
let description = described
.and_then(|description| description.with_enabled(&floor::shader_enables(capabilities)))
.map_err(Error::Translation)?;
.map_err(Error::translation)?;
let mut policy = DevicePolicy::default();
policy.pointer_domain = PointerDomain::Identity;
policy.handle_domain = HandleDomain::Identity;
metal2vulkan::device::Device::from_queries(description, policy).map_err(Error::Translation)
metal2vulkan::device::Device::from_queries(description, policy).map_err(Error::translation)
}
/// The features device creation enables: the floor's of `capabilities`, and each of `asked` the
+55 -9
View File
@@ -7,6 +7,7 @@ use crate::import::ImportHandle;
use crate::memory::{BlockId, MemoryClass};
use ash::vk;
use metal2vulkan::metal::{PixelFormat, PrimitiveTopologyClass, TextureType};
use metal2vulkan::pipeline::StageSource;
use std::{fmt, io};
/// What a failing call returns.
@@ -49,15 +50,27 @@ pub enum Error {
/// duplicate of the runtime's own fd of the surface's dma-buf, which the buffer's import
/// takes, as where the process holds as many open fds as it may. Metal has no counterpart.
Fd(io::Error),
/// [`Device::new_compute_pipeline_state`](crate::Device::new_compute_pipeline_state): the
/// translator made no pipeline of the kernel: a typed refusal of what it does not translate,
/// a descriptor Metal refuses, or a translation past its 20-second budget.
/// [`Device::new_compute_pipeline_state`](crate::Device::new_compute_pipeline_state) and
/// [`Device::new_render_pipeline_state`](crate::Device::new_render_pipeline_state): the
/// translator made no pipeline of the descriptor's functions: a typed refusal of what it does
/// not translate, a descriptor Metal refuses, or a translation past its 20-second budget.
/// Metal's counterpart is `newComputePipelineStateWithFunction:error:` or
/// `newRenderPipelineStateWithDescriptor:error:` failing, which Metal does only for a
/// descriptor it refuses, with an `NSError` whose text says why.
/// [`Device::new_sampler_state`](crate::Device::new_sampler_state): the translator made no
/// device sampler of the descriptor. Metal's
/// counterpart is `newComputePipelineStateWithFunction:error:` failing, which Metal does only
/// for a descriptor it refuses. [`Device::new`](crate::Device::new) gives it too where the
/// device sampler of the descriptor. [`Device::new`](crate::Device::new) gives it too where the
/// translator takes no description of the device, which the floor leaves no device to do.
Translation(metal2vulkan::error::Error),
Translation {
/// The translator's error.
error: metal2vulkan::error::Error,
/// The functions of the pipeline state made, each by its own name in its library
/// (`MTLFunction`'s `name`), in stage order (the vertex function before the fragment
/// function), which the error's text prints: a diagnostic for the program's log, as the
/// `NSError`'s text of Metal's failed creation is, that nothing decides by. A stage the
/// consumer compiled (`StageSource::Compiled`) has no name here; a sampler state, a
/// device and a dispatch's variant of a kernel name none.
functions: Vec<String>,
},
/// A Metal feature the runtime does not build yet: a typed known gap.
Unsupported(Gap),
/// A call that needs one of the runtime's threads, after
@@ -1825,6 +1838,32 @@ pub enum Limit {
}
impl Error {
/// The translator's `error` ([`Error::Translation`]), naming no function, for `map_err`.
pub(crate) fn translation(error: metal2vulkan::error::Error) -> Error {
Error::Translation {
error,
functions: Vec::new(),
}
}
/// This error, where it is the translator's ([`Error::Translation`]), naming each function of
/// `stages` by its own name in its library; any other error as it is.
pub(crate) fn of_stages<'a>(self, stages: impl IntoIterator<Item = &'a StageSource>) -> Error {
match self {
Error::Translation { error, .. } => Error::Translation {
error,
functions: (stages.into_iter())
.filter_map(|stage| match stage {
StageSource::Function(function) => Some(function.function.info().name),
StageSource::Compiled(_) => None,
})
.map(str::to_owned)
.collect(),
},
other => other,
}
}
/// The error of a failed Vulkan `call`, for `map_err`.
pub(crate) fn vulkan(call: &'static str) -> impl FnOnce(vk::Result) -> Error {
move |result| Error::Vulkan { call, result }
@@ -1867,7 +1906,14 @@ impl fmt::Display for Error {
Error::Thread(error) => write!(f, "a runtime thread did not start: {error}"),
Error::Fd(error) => write!(f, "no duplicate of a dma-buf's fd: {error}"),
Error::Quiesced => f.write_str("the device is quiesced"),
Error::Translation(error) => write!(f, "the translator made no pipeline: {error}"),
Error::Translation { error, functions } if functions.is_empty() => {
write!(f, "the translator made no pipeline: {error}")
}
Error::Translation { error, functions } => write!(
f,
"the translator made no pipeline of {}: {error}",
functions.join(", ")
),
Error::Unsupported(gap) => write!(f, "{gap}"),
}
}
@@ -2474,7 +2520,7 @@ impl std::error::Error for Error {
Error::BelowFloor(below) => Some(below),
Error::Vulkan { result, .. } => Some(result),
Error::Thread(error) | Error::Fd(error) => Some(error),
Error::Translation(error) => Some(error),
Error::Translation { error, .. } => Some(error),
Error::NoDirectDriverLoading
| Error::Refused(_)
| Error::Limit(_)
+25 -14
View File
@@ -321,7 +321,7 @@ fn constexpr_uses(
for (_, sampler) in uses.iter().filter(|(place, _)| *place == at) {
let desc = sampler
.constexpr_sampler(profile)
.map_err(Error::Translation)?
.map_err(Error::translation)?
.ok_or_else(gap)?;
held[sampler_array(sampler)] = Some(canonical(desc));
}
@@ -809,15 +809,26 @@ impl crate::Device {
/// their indices. What `sampler_ids` answers as an error, the call answers; once it has
/// answered, a failing call holds none of the indices.
///
/// Err: [`Error::Translation`], the translator's typed refusal or a descriptor Metal refuses;
/// [`Gap::IndirectCommandBuffers`]; [`Gap::KernelInput`] for a kernel that reads what the
/// compute encoder does not supply yet; [`Refusal::SamplerIds`] where `sampler_ids` answers
/// another count; [`Refusal::IndicesNotGranted`] for a constexpr sampler's index;
/// [`Limit::DeviceSamplers`](crate::Limit::DeviceSamplers); [`Error::Vulkan`].
/// Err: [`Error::Translation`], the translator's typed refusal or a descriptor Metal refuses,
/// naming the kernel; [`Gap::IndirectCommandBuffers`]; [`Gap::KernelInput`] for a kernel that
/// reads what the compute encoder does not supply yet; [`Refusal::SamplerIds`] where
/// `sampler_ids` answers another count; [`Refusal::IndicesNotGranted`] for a constexpr
/// sampler's index; [`Limit::DeviceSamplers`](crate::Limit::DeviceSamplers); [`Error::Vulkan`].
pub fn new_compute_pipeline_state(
&self,
descriptor: &ComputePipelineDescriptor,
sampler_ids: impl FnOnce(&[NumberedSampler]) -> Result<Vec<u32>, Error>,
) -> Result<ComputePipelineState, Error> {
(self.compute_pipeline_state(descriptor, sampler_ids))
.map_err(|error| error.of_stages([&descriptor.kernel]))
}
/// [`new_compute_pipeline_state`](Self::new_compute_pipeline_state), its translator's error
/// naming no function.
fn compute_pipeline_state(
&self,
descriptor: &ComputePipelineDescriptor,
sampler_ids: impl FnOnce(&[NumberedSampler]) -> Result<Vec<u32>, Error>,
) -> Result<ComputePipelineState, Error> {
if descriptor.support_indirect_command_buffers {
return Err(Error::Unsupported(Gap::IndirectCommandBuffers));
@@ -866,7 +877,7 @@ impl Compiled {
entries,
)
})
.map_err(Error::Translation)?;
.map_err(Error::translation)?;
let source = (
function,
plain.kernel_variant(KernelVariant::EmulatedSimdgroups),
@@ -893,7 +904,7 @@ impl Compiled {
let observes = translating(&core, || {
translator.kernel_observes_partition(function, &inputs, &budget, entries)
})
.map_err(Error::Translation);
.map_err(Error::translation);
core.note_entries();
if observes? {
cache::keep_observer(&core, &variant_key);
@@ -907,7 +918,7 @@ impl Compiled {
cache::keep_refusal(&core, &variant_key);
Found::Refused
}
Err(error) => return Err(Error::Translation(error)),
Err(error) => return Err(Error::translation(error)),
}
}
};
@@ -917,7 +928,7 @@ impl Compiled {
Found::Lowered(variant) if !variant.observes_threadgroup_partition() => {
let image_only = variant.is_image_only();
let imageblock = declares_imageblock(descriptor, &variant, &budget);
let pipeline = compiled(variant).map_err(Error::Translation)?;
let pipeline = compiled(variant).map_err(Error::translation)?;
let partial = (!grid_tiles(&pipeline)).then_some(None);
let answers = Answers::of(&pipeline, imageblock);
(pipeline, partial, image_only, Some(source), answers)
@@ -925,9 +936,9 @@ impl Compiled {
// The kernel observes its partition, or its variant is refused: its plain
// module, and the variant for the grids that need it.
variant => {
let plain = lower(&plain).map_err(Error::Translation)?;
let plain = lower(&plain).map_err(Error::translation)?;
let imageblock = declares_imageblock(descriptor, &plain, &budget);
let plain = compiled(plain).map_err(Error::Translation)?;
let plain = compiled(plain).map_err(Error::translation)?;
let answers = Answers::of(&plain, imageblock);
let partial = Some((function, inputs, variant));
(plain, Some(partial), false, Some(source), answers)
@@ -939,7 +950,7 @@ impl Compiled {
let pipeline = translating(&core, || {
translator.compile_compute_pipeline(descriptor, &budget)
})
.map_err(Error::Translation)?;
.map_err(Error::translation)?;
// Only a non-observer's partial variant runs its grid in tiles. It has no
// emulated variant: the kernel keeps the variant it was compiled under. The
// translator links a compiled kernel only for its own profile
@@ -1859,7 +1870,7 @@ impl Lowered {
match self {
Lowered::Made(kernel, _) => Ok(&**kernel),
Lowered::Refused => Err(refused()),
Lowered::Translation(error) => Err(Error::Translation(error.clone())),
Lowered::Translation(error) => Err(Error::translation(error.clone())),
&Lowered::Unsupplied(kind) => Err(gap(kind)),
&Lowered::Failed(result) => Err(Error::Vulkan {
call: "vkCreateShaderModule",
+23 -10
View File
@@ -362,16 +362,29 @@ impl crate::Device {
/// Each constexpr sampler a function samples through takes the device sampler of each use it
/// has at its index before the call returns, and every draw pushes the index.
///
/// Err: [`Error::Translation`], the translator's typed refusal or a descriptor Metal refuses;
/// [`Gap::IndirectCommandBuffers`]; [`Gap::RenderPipeline`] for what the runtime does not
/// build, naming it; [`Refusal::PointSizeTopology`] for a vertex function that writes
/// `[[point_size]]` under the line or the triangle class; [`Refusal::SamplerIds`] where
/// `sampler_ids` answers another count; [`Refusal::IndicesNotGranted`] for a constexpr
/// sampler's index; [`Limit::DeviceSamplers`](crate::Limit::DeviceSamplers); [`Error::Vulkan`].
/// Err: [`Error::Translation`], the translator's typed refusal or a descriptor Metal refuses,
/// naming the vertex and the fragment function; [`Gap::IndirectCommandBuffers`];
/// [`Gap::RenderPipeline`] for what the runtime does not build, naming it;
/// [`Refusal::PointSizeTopology`] for a vertex function that writes `[[point_size]]` under
/// the line or the triangle class; [`Refusal::SamplerIds`] where `sampler_ids` answers another
/// count; [`Refusal::IndicesNotGranted`] for a constexpr sampler's index;
/// [`Limit::DeviceSamplers`](crate::Limit::DeviceSamplers); [`Error::Vulkan`].
pub fn new_render_pipeline_state(
&self,
descriptor: &RenderPipelineDescriptor,
sampler_ids: impl FnOnce(&[NumberedSampler]) -> Result<Vec<u32>, Error>,
) -> Result<RenderPipelineState, Error> {
let stages = std::iter::once(&descriptor.vertex).chain(&descriptor.fragment);
(self.render_pipeline_state(descriptor, sampler_ids))
.map_err(|error| error.of_stages(stages))
}
/// [`new_render_pipeline_state`](Self::new_render_pipeline_state), its translator's error
/// naming no function.
fn render_pipeline_state(
&self,
descriptor: &RenderPipelineDescriptor,
sampler_ids: impl FnOnce(&[NumberedSampler]) -> Result<Vec<u32>, Error>,
) -> Result<RenderPipelineState, Error> {
refuse(descriptor)?;
let core = self.core();
@@ -396,7 +409,7 @@ impl crate::Device {
entries,
)
})
.map_err(Error::Translation)?;
.map_err(Error::translation)?;
let lowered = lower_stages(core, descriptor, &keys, &budget, entries);
core.note_entries();
let (lowered, lowerings) = lowered?;
@@ -881,7 +894,7 @@ fn lower_stages(
(&descriptor.vertex, &keys.vertex_inputs)
{
let function = lower(core, function, inputs, budget, entries);
let function = function.map_err(Error::Translation)?;
let function = function.map_err(Error::translation)?;
lowerings.vertex = Some(*function.key().digest());
lowered.vertex = StageSource::Compiled(function);
}
@@ -891,7 +904,7 @@ fn lower_stages(
(&descriptor.fragment, &keys.fragment_inputs)
{
let function = lower(core, function, inputs, budget, entries);
let function = function.map_err(Error::Translation)?;
let function = function.map_err(Error::translation)?;
lowerings.fragment = Some(*function.key().digest());
lowered.fragment = Some(StageSource::Compiled(function));
}
@@ -942,7 +955,7 @@ impl RenderCompiled {
) -> Result<RenderCompiled, Error> {
let translator = &core.translator;
let pipeline = translating(core, || translator.compile_render_pipeline(lowered, budget))
.map_err(Error::Translation)?;
.map_err(Error::translation)?;
// Metal makes no pipeline of a vertex function that writes `[[point_size]]` under the line
// or the triangle class.
let class = lowered.input_primitive_topology;
+1 -1
View File
@@ -368,7 +368,7 @@ impl Device {
let desc = |compare, integer| {
vk_sampler(descriptor, SamplerUse::new(compare, integer), profile)
.map(canonical)
.map_err(Error::Translation)
.map_err(Error::translation)
};
let compare = descriptor.compare_function != CompareFunction::Never;
let uses = [
@@ -90,7 +90,10 @@ mod on_device {
crate::tests::no_constexpr_samplers,
) {
Ok(state) => state,
Err(Error::Translation(metal2vulkan::error::Error::Unsupported(u))) if !on => {
Err(Error::Translation {
error: metal2vulkan::error::Error::Unsupported(u),
..
}) if !on => {
assert_eq!(u.feature, Feature::Barycentrics, "{name}: {u:?}");
println!(
"barycentrics: {name}: no fragmentShaderBarycentric; {fragment}'s \
+13 -11
View File
@@ -2292,17 +2292,19 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" {
let divides = profile.fragment().vertex_attribute_divisor
&& profile.limits().max_vertex_attrib_divisor >= 2;
let nonzero = profile.limits().supports_non_zero_first_instance;
let state = match device
.new_render_pipeline_state(&d, crate::tests::no_constexpr_samplers)
{
Ok(state) => state,
Err(Error::Translation(metal2vulkan::error::Error::Unsupported(u))) if !divides => {
assert_eq!(u.feature, Feature::VertexStepRate, "{name}: {u:?}");
println!("{name}: no step rates; a step rate of 2 refused");
return;
}
Err(other) => panic!("{name}: {other}"),
};
let state =
match device.new_render_pipeline_state(&d, crate::tests::no_constexpr_samplers) {
Ok(state) => state,
Err(Error::Translation {
error: metal2vulkan::error::Error::Unsupported(u),
..
}) if !divides => {
assert_eq!(u.feature, Feature::VertexStepRate, "{name}: {u:?}");
println!("{name}: no step rates; a step rate of 2 refused");
return;
}
Err(other) => panic!("{name}: {other}"),
};
assert!(divides, "{name}: a step rate of 2 made a state");
let from_zero = two_instances(name, &device, &state, 0)
.unwrap_or_else(|error| panic!("{name}: from base instance 0: {error}"));
@@ -168,9 +168,11 @@ keep:
match device
.new_render_pipeline_state(&with(function), crate::tests::no_constexpr_samplers)
{
Err(Error::Translation(metal2vulkan::error::Error::Unsupported(u)))
if u.feature == Feature::DivergentInterpolation
&& u.needs == Needs::NotImplemented => {}
Err(Error::Translation {
error: metal2vulkan::error::Error::Unsupported(u),
..
}) if u.feature == Feature::DivergentInterpolation
&& u.needs == Needs::NotImplemented => {}
Err(error) => panic!("{name}: {function}: {error}"),
Ok(_) => panic!("{name}: {function} was made"),
}
@@ -215,7 +215,10 @@ mod on_device {
crate::tests::no_constexpr_samplers,
);
let refused = match differing {
Err(Error::Translation(metal2vulkan::error::Error::Unsupported(u))) => {
Err(Error::Translation {
error: metal2vulkan::error::Error::Unsupported(u),
..
}) => {
assert_eq!(u.feature, Feature::LayeredRendering, "{name}: {u:?}");
u
}
@@ -36,7 +36,7 @@ fn a_lowering_error_is_not_reported_as_the_variant_s_gap() {
assert!(
matches!(
Lowered::Translation(internal.clone()).kernel(partial_simdgroups),
Err(Error::Translation(ref error)) if *error == internal
Err(Error::Translation { ref error, .. }) if *error == internal
),
"a builder error: {}",
reported(&Lowered::Translation(internal))
@@ -58,7 +58,10 @@ mod on_device {
let state =
match device.new_render_pipeline_state(&d, crate::tests::no_constexpr_samplers) {
Ok(state) => state,
Err(Error::Translation(metal2vulkan::error::Error::Unsupported(u))) if !on => {
Err(Error::Translation {
error: metal2vulkan::error::Error::Unsupported(u),
..
}) if !on => {
assert_eq!(u.feature, Feature::MinLodClamp, "{name}: {u:?}");
println!("min_lod: {name}: no shaderResourceMinLod; the state is refused");
return;
+14 -3
View File
@@ -690,11 +690,22 @@ BUFFER_META"#;
assert!(
matches!(
&got,
Err(Error::Translation(metal2vulkan::error::Error::Unsupported(u)))
if u.feature == Feature::Tessellation
Err(Error::Translation {
error: metal2vulkan::error::Error::Unsupported(u),
functions,
}) if u.feature == Feature::Tessellation
&& *functions == ["tess_triangle_points", "tess_fragment"]
),
"{name}: a control-point index type: {:?}",
got.err()
got.as_ref().err()
);
// The error's text names the vertex and the fragment function, in that order.
let text = got.err().map(|error| error.to_string()).unwrap_or_default();
assert!(
text.starts_with(
"the translator made no pipeline of tess_triangle_points, tess_fragment: "
),
"{name}: {text}"
);
let patch_state = state(name, &device, &d);
let plain_state = state(name, &device, &plain);
@@ -51,7 +51,10 @@ mod on_device {
.new_render_pipeline_state(&d, crate::tests::no_constexpr_samplers)
{
Ok(state) => state,
Err(Error::Translation(metal2vulkan::error::Error::Unsupported(u))) if !on => {
Err(Error::Translation {
error: metal2vulkan::error::Error::Unsupported(u),
..
}) if !on => {
assert_eq!(u.feature, Feature::RasterOrderGroups, "{name}: {u:?}");
println!("pixel_interlock: {name}: no pixel interlock; the state is refused");
return;
@@ -57,7 +57,10 @@ mod on_device {
let state =
match device.new_render_pipeline_state(&d, crate::tests::no_constexpr_samplers) {
Ok(state) => state,
Err(Error::Translation(metal2vulkan::error::Error::Unsupported(u))) if !on => {
Err(Error::Translation {
error: metal2vulkan::error::Error::Unsupported(u),
..
}) if !on => {
assert_eq!(u.feature, Feature::SubgroupOperations, "{name}: {u:?}");
println!("quad_control: {name}: no quad control; the state is refused");
return;
@@ -262,7 +262,7 @@ mod on_device {
},
);
assert!(
matches!(numbered, Err(Error::Translation(_))),
matches!(numbered, Err(Error::Translation { .. })),
"{name}: the NaN bias is the translator's refusal"
);
assert_eq!(
@@ -3650,4 +3650,34 @@ declare i32 @air.get_height_texture_2d(ptr addrspace(1), i32)
);
});
}
/// A refused state's error names its function by its own name in its library: a compute
/// state of the examples' vertex function `colored_vertex`, which Metal makes no compute state
/// of, is `Error::Translation` naming it, and its text prints the name.
#[test]
fn every_device_names_the_function_of_a_refused_compute_state() {
let Some(examples) = crate::tests::draw::on_device::examples() else {
return;
};
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(
FunctionDescriptor::new(examples.function("colored_vertex").expect("the function")),
));
each_device("refused compute names", |name, _, device| {
let got = device
.new_compute_pipeline_state(&descriptor, |samplers| Ok(vec![0; samplers.len()]));
match got {
Err(Error::Translation { error, functions }) => {
assert_eq!(functions, ["colored_vertex"], "{name}: {error}");
let text = Error::Translation { error, functions }.to_string();
assert!(
text.starts_with("the translator made no pipeline of colored_vertex: "),
"{name}: {text}"
);
println!("{name}: {text}");
}
Err(other) => panic!("{name}: {other}"),
Ok(_) => panic!("{name}: a compute state of a vertex function was made"),
}
});
}
}
@@ -251,7 +251,10 @@ pub fn make_kernel(
) -> Result<rt::ComputePipelineState, rt::Error> {
let function = Library::from_air(bitcode)
.and_then(|library| library.function(entry))
.map_err(rt::Error::Translation)?;
.map_err(|error| rt::Error::Translation {
error,
functions: Vec::new(),
})?;
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(
FunctionDescriptor::new(function).with_specialized(true),
));
@@ -358,7 +361,7 @@ fn environment(identity: &Identity, tools: &[ActiveTool], executor: &str) -> ser
/// ([`execute_runtime`]).
pub(super) fn runtime_error(what: &str, error: rt::Error) -> ExecutorError {
match error {
rt::Error::Translation(error) => product_refusal(&error),
rt::Error::Translation { error, .. } => product_refusal(&error),
rt::Error::Unsupported(gap @ rt::Gap::TextureFormat { .. }) => {
ExecutorError::NotSupported(NotSupported::NotEnabled(vec![format!("{what}: {gap}")]))
}
@@ -797,9 +797,10 @@ fn a_texture_buffer_member_is_refused_at_the_make_where_a_2d_member_is_made() {
let bitcode = llvm_assemble(&engine_dir().join("rlm_runtime_limits.ll")).unwrap();
platform::on_runtime_device(crate::gpu::TEST_DEVICE, |device| {
match platform::make_kernel(device, &bitcode, "rlm_member_texture_buffer") {
Err(metal2vulkan_runtime::Error::Translation(
metal2vulkan::error::Error::Unsupported(refused),
)) => assert!(
Err(metal2vulkan_runtime::Error::Translation {
error: metal2vulkan::error::Error::Unsupported(refused),
..
}) => assert!(
matches!(
refused.feature,
Feature::IdentityDomains | Feature::ArgumentBufferTextures
@@ -141,7 +141,7 @@ impl Skips {
) -> bool {
let gap = match error {
rt::Error::Unsupported(gap) => format!("{gap:?}"),
rt::Error::Translation(refused) => translation_kind(refused),
rt::Error::Translation { error: refused, .. } => translation_kind(refused),
_ => return false,
};
let kind = states.entry(gap);
@@ -24,14 +24,20 @@ fn made(result: u64) -> Call {
fn translator_refusals_are_counted_by_kind() {
let tessellation = || {
let feature = Feature::Lowering(LowerFamily::Tessellation);
rt::Error::Translation(Unsupported::not_implemented(feature).into())
rt::Error::Translation {
error: Unsupported::not_implemented(feature).into(),
functions: Vec::new(),
}
};
let answers = [
(7, tessellation()),
(8, tessellation()),
(
9,
rt::Error::Translation(Error::LimitExceeded(Limit::SpirvWords)),
rt::Error::Translation {
error: Error::LimitExceeded(Limit::SpirvWords),
functions: Vec::new(),
},
),
(
10,
@@ -75,7 +81,10 @@ fn creations_not_attempted_are_counted_by_kind_and_root() {
skips.not_attempted(&function, Via::Receiver, 2);
skips.not_attempted(&made(4), Via::Argument, 3);
skips.not_attempted(&made(5), Via::Argument, 3);
let refused = rt::Error::Translation(Error::LimitExceeded(Limit::SpirvWords));
let refused = rt::Error::Translation {
error: Error::LimitExceeded(Limit::SpirvWords),
functions: Vec::new(),
};
assert!(Skips::skipped_state(
&mut skips.render_states,
&made(6),
+1 -1
View File
@@ -9200,7 +9200,7 @@ variant metal2vulkan-runtime::Error::NoSuchBlock NoSuchBlock(BlockId)
variant metal2vulkan-runtime::Error::Quiesced Quiesced
variant metal2vulkan-runtime::Error::Refused Refused(Refusal)
variant metal2vulkan-runtime::Error::Thread Thread(io::Error)
variant metal2vulkan-runtime::Error::Translation Translation(metal2vulkan::error::Error)
variant metal2vulkan-runtime::Error::Translation Translation { error: metal2vulkan::error::Error, functions: Vec<String> }
variant metal2vulkan-runtime::Error::Unsupported Unsupported(Gap)
variant metal2vulkan-runtime::Error::Vulkan Vulkan { call: &'static str, result: vk::Result }
variant metal2vulkan-runtime::ExportHandle::DmaBuf DmaBuf
Can't render this file because it is too large.
+2 -2
View File
@@ -359,7 +359,7 @@ Columns:
| Variant | What it blocks | Where | Basis | Sites | Reach |
|---|---|---|---|---|---|
| `IndirectCommandBuffers` | A compute pipeline state for indirect command buffers (`supportIndirectCommandBuffers`) | every device (a public call's own check of its arguments) | `ours`: indirect command buffers are not built | 2: `crates/metal2vulkan-runtime/src/pipeline.rs (new_compute_pipeline_state)`, `crates/metal2vulkan-runtime/src/render.rs (refuse)` | `-` |
| `IndirectCommandBuffers` | A compute pipeline state for indirect command buffers (`supportIndirectCommandBuffers`) | every device (a public call's own check of its arguments) | `ours`: indirect command buffers are not built | 2: `crates/metal2vulkan-runtime/src/pipeline.rs (compute_pipeline_state)`, `crates/metal2vulkan-runtime/src/render.rs (refuse)` | `-` |
| `KernelInput` | A kernel that reads something the compute encoder does not supply yet, `kind` naming what | every device (a public call's own check of its arguments) | `ours`: the encoder supplies only those | 1: `crates/metal2vulkan-runtime/src/pipeline.rs (gap)` | `-` |
| `ImageblockLength` | An imageblock length Metal answers that no case measures | every device (a public call's own check of its arguments) | `ours`: the length is not measured against Metal's | 2: `crates/metal2vulkan-runtime/src/pipeline.rs (imageblock_memory_length_for_dimensions)`, `crates/metal2vulkan-runtime/src/render.rs (imageblock_sample_length)` | `-` |
| `PartialSimdgroups` | A dispatch whose threadgroup is not whole SIMD groups of a kernel whose tier runs each SIMD group as one subgroup of `width` threads (a pinned... | every device (a public call's own check of its arguments) | `ours`: no emulated-SIMD-group module | 1: `crates/metal2vulkan-runtime/src/encoder.rs (decide)` | `-` |
@@ -644,7 +644,7 @@ Each refusal's sites, with the function that builds it.
- `rt:Limit::NoExport`: `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)`; `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
- `rt:Limit::ExportType`: `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`; `crates/metal2vulkan-runtime/src/import.rs (surface_import)`; `crates/metal2vulkan-runtime/src/memory.rs (export)`; `crates/metal2vulkan-runtime/src/memory.rs (surface_view)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
- `rt:Limit::TextureSamples`: `crates/metal2vulkan-runtime/src/texture.rs (plan)`
- `rt:Gap::IndirectCommandBuffers`: `crates/metal2vulkan-runtime/src/pipeline.rs (new_compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/render.rs (refuse)`
- `rt:Gap::IndirectCommandBuffers`: `crates/metal2vulkan-runtime/src/pipeline.rs (compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/render.rs (refuse)`
- `rt:Gap::KernelInput`: `crates/metal2vulkan-runtime/src/pipeline.rs (gap)`
- `rt:Gap::ImageblockLength`: `crates/metal2vulkan-runtime/src/pipeline.rs (imageblock_memory_length_for_dimensions)`; `crates/metal2vulkan-runtime/src/render.rs (imageblock_sample_length)`
- `rt:Gap::PartialSimdgroups`: `crates/metal2vulkan-runtime/src/encoder.rs (decide)`