Validation: a render function's visible function table is the runtime's limit

The runtime's render pipeline state reads no function table: its make refuses a vertex or
fragment function that calls through one as Gap::RenderPipeline{DrawInput}, a known gap its
README states. Function pointers from a render pipeline are an Apple6-family feature, which Metal
lets a program ask for through supportsFunctionPointersFromRender; the planner's ruling is that
the consumer's device answers no to it and to supportsFunctionPointers, so the refusal is Metal's
own and the rows close as the runtime's limit with their typed refusal, by the mechanism of the
fence and mesh rows.

ToolingRequirement::RenderFunctionTable ("render_function_table"): Limit::Runtime, it stops the
engine's candidate and keeps its cases Metal-qualified (qualifies_on_metal). It is raised from the
source's structure, a vertex, post-tessellation vertex or fragment function's
visible-function-table argument (executor_contract::engine_source_requirements), and from a
vertex or fragment case's bound function table (case_requirements). executor_contract.rs is a
classifier input, so every cached triage recomputes.

What lost execution: of the committed cases, 22 vertex cases bind a function table, all with
private sources and none public: the 2 of family E/F's private selection that failed through
the runtime (vertex.function_tables, DrawInput), and 20 that ran on the old executor. No
fragment case binds one; a kernel's still runs.

Tests: requirement.rs's a_render_function_table_stops_only_the_candidate and both requirement
lists; executor_contract's source test (a vertex function's visible_function_table argument
raises it, a kernel's or a mesh function's does not) and case test (a vertex or fragment case's
table raises it, a kernel case's does not).

Verified: cargo fmt; the compile gate follows as a potluck job.
This commit is contained in:
Anees Iqbal committed 2026-11-20 21:27:19 -08:00
1 parent 34c8f0e67c
commit fc168d0173
2 files changed
+75 -12

No files matched your search

@@ -720,7 +720,9 @@ pub fn unsupported_source_requirements(
/// checker requires authored as a device-buffer array);
/// - [`ToolingRequirement::RenderAccelerationStructure`]: a vertex or fragment function's
/// acceleration-structure or intersection-function-table argument (the checker requires every
/// bound one).
/// bound one);
/// - [`ToolingRequirement::RenderFunctionTable`]: a vertex or fragment function's
/// visible-function-table argument, which the runtime's render pipeline state does not read.
///
/// A post-tessellation vertex function is none of them: the candidate draws its patches as the
/// oracle does (`tessellation`); nor is a fragment function's color input, whose render target the
@@ -750,6 +752,8 @@ pub fn engine_source_requirements(reflection: &ShaderInterface) -> BTreeSet<Tool
.as_deref()
.is_some_and(crate::air::meta::is_device_buffer_array_type_name)
});
let function_table = (reflection.bindings.iter())
.any(|binding| binding.kind == ResourceKind::VisibleFunctionTable);
let acceleration_structure = reflection.bindings.iter().any(|binding| {
matches!(
binding.kind,
@@ -767,6 +771,10 @@ pub fn engine_source_requirements(reflection: &ShaderInterface) -> BTreeSet<Tool
render && acceleration_structure,
ToolingRequirement::RenderAccelerationStructure,
),
(
render && function_table,
ToolingRequirement::RenderFunctionTable,
),
]
.into_iter()
.filter_map(|(present, requirement)| present.then_some(requirement))
@@ -816,6 +824,10 @@ pub fn case_requirements(case: &AuthoredCase) -> BTreeSet<ToolingRequirement> {
|| !case.intersection_function_tables.is_empty()),
ToolingRequirement::RenderAccelerationStructure,
),
(
render && !case.visible_function_tables.is_empty(),
ToolingRequirement::RenderFunctionTable,
),
(
case.stage == Stage::Vertex && case.depth_stencil.is_some(),
ToolingRequirement::VertexDepthStencilAttachment,
@@ -2698,6 +2710,11 @@ entry:
"intersection_function_table<triangle_data>",
ToolingRequirement::RenderAccelerationStructure,
),
(
ResourceKind::VisibleFunctionTable,
"visible_function_table<WordOp>",
ToolingRequirement::RenderFunctionTable,
),
] {
let mut binding = buffer.clone();
binding.kind = kind;
@@ -2865,6 +2882,20 @@ entry:
let mut fragment = traced.clone();
fragment.stage = Stage::Fragment;
only(&fragment, ToolingRequirement::RenderAccelerationStructure);
// A function table: a kernel's runs; a vertex or fragment function's is the runtime's
// limit.
let mut tabled = kernel.clone();
tabled.visible_function_tables = vec![crate::case::FunctionTableResource {
binding: 1,
size: 1,
entries: Vec::new(),
}];
assert!(case_requirements(&tabled).is_empty());
for stage in [Stage::Vertex, Stage::Fragment] {
let mut drawn = tabled.clone();
drawn.stage = stage;
only(&drawn, ToolingRequirement::RenderFunctionTable);
}
let mut arrays = kernel.clone();
arrays.device_buffer_arrays = vec![device_buffer_array(0, 1, &[0])];
assert!(case_requirements(&arrays).is_empty());
@@ -180,6 +180,16 @@ pub enum ToolingRequirement {
/// and `..::a_fence_of_another_order_is_made_through_the_runtime` hold it both ways. The Metal
/// oracle runs it, so a case of it stays Metal-qualified ([`Self::qualifies_on_metal`]).
SeqCstFence,
/// A visible function table bound to a vertex or fragment function (`executor_contract`'s
/// `engine_source_requirements` and `case_requirements`): function pointers called from a
/// render pipeline, which Metal lets a program ask for through
/// `supportsFunctionPointersFromRender`, an Apple6-family feature. The runtime's render
/// pipeline state reads no function table (its make is
/// `metal2vulkan_runtime::Gap::RenderPipeline` of `DrawInput`, a known gap its README states,
/// which is its guard), so the limit is the runtime's ([`Limit::Runtime`]) and the engine's
/// candidate does not run the case. The Metal oracle draws it, so a case of it stays
/// Metal-qualified ([`Self::qualifies_on_metal`]).
RenderFunctionTable,
}
/// Every executor (the requirement leaves no case to author, or none to observe).
@@ -187,7 +197,7 @@ const AUTHORING: &[Executor] = &Executor::ALL;
const ENGINE: &[Executor] = &[Executor::EngineCandidate];
impl ToolingRequirement {
pub const ALL: [Self; 26] = [
pub const ALL: [Self; 27] = [
Self::FunctionConstantLiteral,
Self::VertexAttributeLiteral,
Self::TessellationAttributeLiteral,
@@ -214,6 +224,7 @@ impl ToolingRequirement {
Self::MeshRenderPipeline,
Self::ReplayedTemplateResources,
Self::SeqCstFence,
Self::RenderFunctionTable,
];
pub const fn as_str(self) -> &'static str {
@@ -246,6 +257,7 @@ impl ToolingRequirement {
Self::MeshRenderPipeline => "mesh_render_pipeline",
Self::ReplayedTemplateResources => "replayed_template_resources",
Self::SeqCstFence => "seq_cst_fence",
Self::RenderFunctionTable => "render_function_table",
}
}
@@ -267,8 +279,9 @@ impl ToolingRequirement {
/// template it does not draw or replay ([`ToolingRequirement::MeshRenderPipeline`],
/// [`ToolingRequirement::ReplayedTemplateResources`]), and a texture buffer an argument
/// buffer or a texture-handle array holds ([`ToolingRequirement::TextureBufferMember`]),
/// and a sequentially consistent fence, which the runtime refuses
/// ([`ToolingRequirement::SeqCstFence`]).
/// and a sequentially consistent fence and a render function's function table, which the
/// runtime refuses ([`ToolingRequirement::SeqCstFence`],
/// [`ToolingRequirement::RenderFunctionTable`]).
///
/// The requirements that stopped only the old engine's candidate were retired with it.
pub const fn stops(self) -> &'static [Executor] {
@@ -298,7 +311,8 @@ impl ToolingRequirement {
| Self::MeshRenderPipeline
| Self::TextureBufferMember
| Self::ReplayedTemplateResources
| Self::SeqCstFence => ENGINE,
| Self::SeqCstFence
| Self::RenderFunctionTable => ENGINE,
}
}
@@ -306,8 +320,9 @@ impl ToolingRequirement {
/// and its observation is evidence for a candidate that runs the family again, so the checker
/// accepts it with no candidate (`executor_contract::evidence_gap`), and the engine's candidate
/// refuses it, typed. Only [`ToolingRequirement::MeshRenderPipeline`],
/// [`ToolingRequirement::TextureBufferMember`], [`ToolingRequirement::DepthOutsideUnitRange`]
/// and [`ToolingRequirement::SeqCstFence`]: their cases are qualified on Metal.
/// [`ToolingRequirement::TextureBufferMember`], [`ToolingRequirement::DepthOutsideUnitRange`],
/// [`ToolingRequirement::SeqCstFence`] and [`ToolingRequirement::RenderFunctionTable`]: their
/// cases are qualified on Metal.
pub const fn qualifies_on_metal(self) -> bool {
matches!(
self,
@@ -315,21 +330,23 @@ impl ToolingRequirement {
| Self::TextureBufferMember
| Self::DepthOutsideUnitRange
| Self::SeqCstFence
| Self::RenderFunctionTable
)
}
/// Whose limit this requirement records. Every requirement is this crate's tooling's except
/// [`ToolingRequirement::KernelMinLodClamp`], which Apple's compiler cannot build a pipeline
/// for, and [`ToolingRequirement::SeqCstFence`], [`ToolingRequirement::TextureBufferMember`],
/// [`ToolingRequirement::DepthOutsideUnitRange`] and
/// [`ToolingRequirement::MeshRenderPipeline`], which the runtime refuses.
/// [`ToolingRequirement::DepthOutsideUnitRange`], [`ToolingRequirement::MeshRenderPipeline`]
/// and [`ToolingRequirement::RenderFunctionTable`], which the runtime refuses.
pub const fn limit(self) -> Limit {
match self {
Self::KernelMinLodClamp => Limit::Metal,
Self::SeqCstFence
| Self::TextureBufferMember
| Self::DepthOutsideUnitRange
| Self::MeshRenderPipeline => Limit::Runtime,
| Self::MeshRenderPipeline
| Self::RenderFunctionTable => Limit::Runtime,
_ => Limit::Tooling,
}
}
@@ -481,7 +498,8 @@ mod tests {
ToolingRequirement::TextureBufferMember,
ToolingRequirement::DepthOutsideUnitRange,
ToolingRequirement::MeshRenderPipeline,
ToolingRequirement::SeqCstFence
ToolingRequirement::SeqCstFence,
ToolingRequirement::RenderFunctionTable
]
);
}
@@ -514,6 +532,19 @@ mod tests {
assert_eq!("seq_cst_fence".parse(), Ok(requirement));
}
/// A render function's function table: the Metal oracle draws it, so its cases stay
/// Metal-qualified; the runtime's render pipeline state reads none, so the engine's candidate
/// runs none, the runtime's limit, which closes its rows.
#[test]
fn a_render_function_table_stops_only_the_candidate() {
let requirement = ToolingRequirement::RenderFunctionTable;
assert_eq!(requirement.stops(), [Executor::EngineCandidate]);
assert_eq!(requirement.limit(), Limit::Runtime, "{requirement}");
assert!(!requirement.blocks_closure(), "{requirement}");
assert!(requirement.qualifies_on_metal(), "{requirement}");
assert_eq!("render_function_table".parse(), Ok(requirement));
}
/// Every requirement stops some executor, and an executor's name is as stable as a
/// requirement's. A requirement that stops the Metal oracle stops every executor: when Metal
/// cannot run a case, no candidate has an observation to be compared with. Only a tooling gap
@@ -561,7 +592,8 @@ mod tests {
ToolingRequirement::TextureBufferMember,
ToolingRequirement::DepthOutsideUnitRange,
ToolingRequirement::MeshRenderPipeline,
ToolingRequirement::SeqCstFence
ToolingRequirement::SeqCstFence,
ToolingRequirement::RenderFunctionTable
]
);
for executor in Executor::ALL {