Validation: requirement rows for indirect command buffers and pipeline states
What: five new ToolingRequirement variants for what the runtime does not build of an indirect command buffer, and for a pipeline state an argument buffer holds. Each one stops only the engine candidate (Limit::Runtime), so the Metal oracle still runs and qualifies these cases. executor_contract::case_requirements raises them from the case literals: - indirect_compute_commands: a command buffer of compute commands. - indirect_draw_types: a render command buffer whose descriptor allows draws other than indexed ones alone (non-indexed, patch, indexed patch or mesh draws). - indirect_command_inheritance: a render command buffer that does not inherit the pipeline state, or that inherits buffers. - host_encoded_indirect_commands: commands the host encodes into a command buffer. - argument_buffer_pipeline_state: a pipeline state in an argument buffer (the runtime's pipeline states have no gpuResourceID). The runtime builds kernel-encoded indexed draws that inherit the pipeline state and bind their own buffers (Device::new_indirect_command_buffer). A case in exactly that form raises none of these. Object and mesh cases already stop the candidate by mesh_render_pipeline (executor_contract::mesh), so no new row is needed for them. IndirectCommandBuffer (an authoring requirement about unobserved contents) means something else and is not reused. ENGINE_EXECUTOR_ABI goes to vulkan-engine-v207, because these cases' recorded rows came from the executor's own context. executor_contract is a classifier input, so triage recomputes the census. In the authored compile census, these cases' cells become their requirement refusals; the census is re-blessed on development. Routed: none. No committed case is in the runtime's form: - indexed-draws-a-kernel-and-the-host-encode has host-encoded commands (and point draws, which the translator refuses to encode). - a-vertex-function-whose-only-effect-is-an-indexed-draw-runs-it inherits buffers. The 27 committed cases with a command buffer or a pipeline state, by requirement (a case can raise several): - indirect_compute_commands: 12 - indirect_draw_types: 12 - host_encoded_indirect_commands: 10 - indirect_command_inheritance: 7 - argument_buffer_pipeline_state: 4 Tests: - requirement.rs: the new variants are in ALL, stop only the candidate, and are the runtime's limit. - engine_case_families_follow_the_case_literals: the runtime's form raises nothing, and each other form raises exactly its own requirement. - committed_command_buffer_and_pipeline_state_cases_refuse_by_their_requirements (new): eight committed cases refuse at preparation, with no device, by exactly their requirements. It replaces five tests of the own context's replay and pipeline-state mapping, which these cases no longer reach. - the_census_refuses_command_buffer_cases_by_their_requirements (new integration test): it replaces the census test of replay variants. - The case-literal tests and the argument-buffer-member tests now assert the refusal, or drop the command buffer and pipeline state they used to map. docs/VALIDATION.md names the five requirements. Verified: gate m3-max-63557 (homelab-um870-1) at c38044230b, the tree of this commit: fmt, clippy (all features, --cfg m2v_gpu, --cfg m2v_cpu_icd), Rustdoc and doctests of metal2vulkan-validation passed, and its nextest suite passed (1337 tests). Earlier runs on the same branch (m3-max-63495, m3-max-63532) found the tests fixed above.
This commit is contained in:
1 parent
03d898aac0
commit
01ed696846
9 files changed
+372
-828
No files matched your search
@@ -111,7 +111,7 @@ pub mod variants;
|
||||
/// 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-v205";
|
||||
pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v207";
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -988,6 +988,7 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() {
|
||||
.filter(|case| {
|
||||
matches!(case.stage, Stage::Vertex | Stage::Fragment)
|
||||
&& !case.argument_buffer_buffers.is_empty()
|
||||
&& crate::executor_contract::case_requirements(case).is_empty()
|
||||
})
|
||||
.find_map(|case| {
|
||||
let row = sources
|
||||
@@ -1180,16 +1181,12 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() {
|
||||
);
|
||||
|
||||
// An argument-buffer texture of the fragment stage is a used texture of both stages whose token
|
||||
// follows the buffers' and whose resource id its owner holds at its field; a command buffer is
|
||||
// its record storage, an argument-buffer buffer (initialized under its descriptor) whose guest
|
||||
// address its owner holds, and a pipeline state is its token there; the texture's region is an
|
||||
// output. An argument-buffer sampler is an argument sampler of the bind state whose id its
|
||||
// owner holds at its field.
|
||||
use crate::candidate::engine::argument_buffers::{
|
||||
field_words, records_storage, resource_id, sampler_id,
|
||||
};
|
||||
// follows the buffers' and whose resource id its owner holds at its field; the texture's region
|
||||
// is an output. An argument-buffer sampler is an argument sampler of the bind state whose id
|
||||
// its owner holds at its field.
|
||||
use crate::candidate::engine::argument_buffers::{field_words, resource_id, sampler_id};
|
||||
let mut members = case.clone();
|
||||
let (texture_field, command_field, pipeline_field) = (key.1 + 64, key.1 + 72, key.1 + 80);
|
||||
let texture_field = key.1 + 64;
|
||||
let sampler_field = key.1 + 88;
|
||||
members
|
||||
.argument_buffer_samplers
|
||||
@@ -1216,29 +1213,6 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() {
|
||||
bytes_b64: None,
|
||||
initial_bytes_b64: Some(b64(&[7, 8])),
|
||||
});
|
||||
members.command_buffers.push(
|
||||
serde_json::from_value(serde_json::json!({
|
||||
"buffer_binding": key.0,
|
||||
"field_offset": command_field,
|
||||
"capacity": 1,
|
||||
"descriptor": {"kind": "render", "max_fragment_buffer_bind_count": 0,
|
||||
"max_vertex_buffer_bind_count": 0,
|
||||
"support_dynamic_attribute_stride": false},
|
||||
"execution_range": [0, 1],
|
||||
"inherit_buffers": true,
|
||||
"inherit_pipeline_state": true
|
||||
}))
|
||||
.unwrap(),
|
||||
);
|
||||
members
|
||||
.pipeline_states
|
||||
.push(crate::case::indirect_commands::PipelineResource {
|
||||
buffer_binding: key.0,
|
||||
field_offset: pipeline_field,
|
||||
token: 3,
|
||||
air_sha256: "22".repeat(32),
|
||||
case_id: "33".repeat(32),
|
||||
});
|
||||
members.output = OutputSelection::ArgumentBufferTexture {
|
||||
buffer_binding: key.0,
|
||||
field_offset: texture_field,
|
||||
@@ -1264,56 +1238,14 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() {
|
||||
.collect::<Vec<_>>(),
|
||||
[(key.0, texture_field)]
|
||||
);
|
||||
let records = &fragment.argument_buffer_buffers[&(key.0, command_field)];
|
||||
let command = &members.command_buffers[0];
|
||||
let mut initialized = vec![0; command.record_storage_bytes().unwrap()];
|
||||
command.initialize_records(&mut initialized).unwrap();
|
||||
assert_eq!(records, &initialized);
|
||||
assert_eq!(
|
||||
fragment.command_buffers,
|
||||
BTreeMap::from([((key.0, command_field), command.clone())])
|
||||
);
|
||||
assert_eq!(
|
||||
fragment.objects,
|
||||
BTreeMap::from([((key.0, pipeline_field), 3)])
|
||||
);
|
||||
let member = (ShaderStage::Fragment, key.0, texture_field);
|
||||
let tokens = texture_tokens(&render).unwrap();
|
||||
assert_eq!(tokens, BTreeMap::from([(member, 2)]));
|
||||
// The command buffer's ID is 1, its record storage at that ID's records address with a
|
||||
// device address of its own.
|
||||
let command_key = (ShaderStage::Fragment, key.0, command_field);
|
||||
let ids = records_ids(&render).unwrap();
|
||||
assert_eq!(ids, BTreeMap::from([(command_key, 1)]));
|
||||
assert_eq!(
|
||||
synthetic_used_addresses(&render).unwrap()[&command_key],
|
||||
records_storage(1, None)
|
||||
);
|
||||
let storage = records_storage(1, Some(0x7100_0000));
|
||||
let embedded = BTreeMap::from([
|
||||
((ShaderStage::Fragment, key.0, key.1), pointee),
|
||||
(command_key, storage),
|
||||
]);
|
||||
assert_eq!(tokens, BTreeMap::from([(member, 1)]));
|
||||
let embedded = BTreeMap::from([((ShaderStage::Fragment, key.0, key.1), pointee)]);
|
||||
let state = bind_state(&render, &addresses, &embedded, BufferRanges::default()).unwrap();
|
||||
let [_, stored, used] = state.used_resources.as_slice() else {
|
||||
let [_, used] = state.used_resources.as_slice() else {
|
||||
panic!("{:?}", state.used_resources);
|
||||
};
|
||||
assert_eq!(
|
||||
(
|
||||
stored.class,
|
||||
stored.token,
|
||||
stored.gpu_address,
|
||||
stored.device_address,
|
||||
stored.length
|
||||
),
|
||||
(
|
||||
metal2vulkan::bind::ResourceClass::Buffer,
|
||||
1,
|
||||
Some(storage.guest),
|
||||
storage.host,
|
||||
records.len() as u64
|
||||
)
|
||||
);
|
||||
assert!(
|
||||
matches!(used.class, metal2vulkan::bind::ResourceClass::Texture(_)),
|
||||
"{used:?}"
|
||||
@@ -1321,8 +1253,8 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() {
|
||||
assert_eq!(
|
||||
(used.token, used.resource_id, used.stages),
|
||||
(
|
||||
2,
|
||||
Some(resource_id(2)),
|
||||
1,
|
||||
Some(resource_id(1)),
|
||||
RenderStages::VERTEX | RenderStages::FRAGMENT
|
||||
)
|
||||
);
|
||||
@@ -1344,30 +1276,22 @@ fn render_cases_bind_argument_buffer_buffers_and_texture_arrays() {
|
||||
listed.desc,
|
||||
resources::argument_sampler_descriptor(&members.argument_buffer_samplers[0])
|
||||
);
|
||||
let words = field_words(&embedded, &ids, &tokens, &samplers, render.objects()).unwrap();
|
||||
let words = field_words(
|
||||
&embedded,
|
||||
&BTreeMap::new(),
|
||||
&tokens,
|
||||
&samplers,
|
||||
std::iter::empty(),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
words,
|
||||
BTreeMap::from([
|
||||
((ShaderStage::Fragment, key.0, key.1), pointee.guest),
|
||||
(member, resource_id(2)),
|
||||
(command_key, 1),
|
||||
((ShaderStage::Fragment, key.0, pipeline_field), 3),
|
||||
(member, resource_id(1)),
|
||||
(sampler, sampler_id(0).unwrap()),
|
||||
])
|
||||
);
|
||||
// The run checks each command buffer's final records: as initialized they decode, and a set
|
||||
// fault flag (an encoding the descriptor's policy refused) fails the run.
|
||||
let mut finals = BTreeMap::from([(command_key, records.clone())]);
|
||||
assert_eq!(
|
||||
argument_buffers::validate_records(render.command_buffers(), &finals),
|
||||
Ok(())
|
||||
);
|
||||
finals.get_mut(&command_key).unwrap()[4] = 1;
|
||||
assert!(
|
||||
argument_buffers::validate_records(render.command_buffers(), &finals)
|
||||
.unwrap_err()
|
||||
.contains("encoding failed"),
|
||||
);
|
||||
let finals = RenderFinals {
|
||||
argument_buffer_textures: BTreeMap::from([(
|
||||
member,
|
||||
|
||||
@@ -1138,103 +1138,55 @@ fn a_restricted_row_has_its_own_engine_slot() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The checker accepts the committed public cases over pipeline-state members (a kernel's and a
|
||||
/// rasterization-disabled vertex function's), resolving their two templates, with no requirement
|
||||
/// that stops this executor, which prepares each device-free: every authored pipeline state is its
|
||||
/// authored token in its owner at its field, the word a command's pipeline field records, and the
|
||||
/// owner is created holding it there beside the authored data the function reads.
|
||||
/// The committed public cases over an indirect command buffer or a pipeline state an argument
|
||||
/// buffer holds stop this executor as they are prepared, device-free, by the runtime's limits the
|
||||
/// vocabulary names: compute commands, draws other than indexed ones, inheritance other than the
|
||||
/// pipeline state's alone, commands the host encodes, and pipeline states in an argument buffer.
|
||||
#[test]
|
||||
fn checked_pipeline_state_cases_prepare_with_their_tokens_in_their_owners() {
|
||||
fn committed_command_buffer_and_pipeline_state_cases_refuse_by_their_requirements() {
|
||||
use ToolingRequirement::{
|
||||
ArgumentBufferPipelineState, HostEncodedIndirectCommands, IndirectCommandInheritance,
|
||||
IndirectComputeCommands, IndirectDrawTypes,
|
||||
};
|
||||
let root = metal2vulkan_devtools::validation_dir().join("corpus");
|
||||
let cases = CorpusStore::new(&root).read_all_cases().unwrap();
|
||||
for name in [
|
||||
"pipeline-states-beside-the-data-of-two-stages",
|
||||
"pipeline-states-beside-the-data-a-vertex-reads",
|
||||
] {
|
||||
let case = cases
|
||||
.iter()
|
||||
.find(|case| case.name == name)
|
||||
.unwrap_or_else(|| panic!("the committed public case {name}"))
|
||||
.clone();
|
||||
let expected = case
|
||||
.pipeline_states
|
||||
.iter()
|
||||
.map(|pipeline| {
|
||||
(
|
||||
(pipeline.buffer_binding, pipeline.field_offset),
|
||||
pipeline.token,
|
||||
)
|
||||
})
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
assert_eq!(
|
||||
expected.keys().copied().collect::<Vec<_>>(),
|
||||
[(0, 0), (0, 8)],
|
||||
"{name}"
|
||||
);
|
||||
let device = DeviceType::Cpu;
|
||||
let admitted = admit(&root, case, ExecutionRequest::EngineCandidate { device })
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
assert_eq!(admitted.checked().pipeline_templates.len(), 2, "{name}");
|
||||
assert_eq!(
|
||||
crate::executor_contract::require_executor(
|
||||
&admitted.checked().requirements(),
|
||||
Executor::EngineCandidate
|
||||
),
|
||||
Ok(()),
|
||||
"{name}"
|
||||
);
|
||||
let prepared = prepare_case(device, admitted).unwrap_or_else(|error| panic!("{error}"));
|
||||
let (objects, buffers) = match &prepared.mapped {
|
||||
Mapped::Compute(compute) => (&compute.objects, &compute.buffers),
|
||||
Mapped::Render(render) => (
|
||||
&render.vertex.resources.objects,
|
||||
&render.vertex.resources.buffers,
|
||||
),
|
||||
Mapped::Mesh(_) => panic!("{name}: a kernel or vertex case maps onto no mesh draw"),
|
||||
};
|
||||
assert_eq!(objects, &expected, "{name}");
|
||||
let fields = argument_buffers::field_words(
|
||||
&BTreeMap::new(),
|
||||
&BTreeMap::new(),
|
||||
&BTreeMap::new(),
|
||||
&BTreeMap::new(),
|
||||
objects.iter().map(|(&key, &word)| (key, word)),
|
||||
)
|
||||
.unwrap();
|
||||
let owner = argument_buffers::owner_bytes(buffers, 0, &fields).unwrap();
|
||||
let word = |at: usize| u64::from_le_bytes(owner[at..at + 8].try_into().unwrap());
|
||||
assert_eq!(
|
||||
[word(0), word(8)],
|
||||
[expected[&(0, 0)], expected[&(0, 8)]],
|
||||
"{name}"
|
||||
);
|
||||
assert_eq!(
|
||||
owner[16..20],
|
||||
buffers[&0][16..20],
|
||||
"{name}: the first scale"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The committed render replay cases (a rasterization-disabled vertex producer, the row's shape,
|
||||
/// and a kernel whose draws run on host-encoded or inherited vertex buffers) carry no requirement,
|
||||
/// and prepare device-free: the parent pipeline's token maps to the render template, a
|
||||
/// rasterization-disabled vertex function bound by its buffers alone, beside the producer's own
|
||||
/// executor case.
|
||||
#[test]
|
||||
fn checked_render_replay_cases_prepare_their_render_template() {
|
||||
let root = metal2vulkan_devtools::validation_dir().join("corpus");
|
||||
let cases = CorpusStore::new(&root).read_all_cases().unwrap();
|
||||
for (name, render) in [
|
||||
for (name, expected) in [
|
||||
(
|
||||
"pipeline-states-beside-the-data-of-two-stages",
|
||||
vec![ArgumentBufferPipelineState],
|
||||
),
|
||||
(
|
||||
"pipeline-states-beside-the-data-a-vertex-reads",
|
||||
vec![ArgumentBufferPipelineState],
|
||||
),
|
||||
(
|
||||
"execute-two-gpu-encoded-template-dispatches",
|
||||
vec![IndirectComputeCommands, ArgumentBufferPipelineState],
|
||||
),
|
||||
(
|
||||
"gpu-encoded-buffers-keep-the-host-encoded-dispatches",
|
||||
vec![IndirectComputeCommands, HostEncodedIndirectCommands],
|
||||
),
|
||||
(
|
||||
"gpu-encoded-vertex-buffers-run-the-host-encoded-draws",
|
||||
true,
|
||||
vec![IndirectDrawTypes, HostEncodedIndirectCommands],
|
||||
),
|
||||
(
|
||||
"gpu-encoded-draws-run-the-host-encoded-vertex-buffers",
|
||||
false,
|
||||
vec![IndirectDrawTypes, HostEncodedIndirectCommands],
|
||||
),
|
||||
(
|
||||
"gpu-encoded-draws-run-the-inherited-vertex-buffers",
|
||||
vec![IndirectDrawTypes, IndirectCommandInheritance],
|
||||
),
|
||||
(
|
||||
"patch-draws-a-kernel-encodes-at-factor-scales-and-the-host-encodes",
|
||||
vec![
|
||||
IndirectDrawTypes,
|
||||
IndirectCommandInheritance,
|
||||
HostEncodedIndirectCommands,
|
||||
],
|
||||
),
|
||||
("gpu-encoded-draws-run-the-inherited-vertex-buffers", false),
|
||||
] {
|
||||
let case = cases
|
||||
.iter()
|
||||
@@ -1244,32 +1196,11 @@ fn checked_render_replay_cases_prepare_their_render_template() {
|
||||
let device = DeviceType::Cpu;
|
||||
let admitted = admit(&root, case, ExecutionRequest::EngineCandidate { device })
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
assert!(admitted.checked().requirements().is_empty(), "{name}");
|
||||
let prepared = prepare_case(device, admitted).unwrap_or_else(|error| panic!("{error}"));
|
||||
assert_eq!(
|
||||
matches!(prepared.mapped, Mapped::Render(_)),
|
||||
render,
|
||||
"{name}"
|
||||
);
|
||||
assert_eq!(
|
||||
prepared.templates.keys().copied().collect::<Vec<_>>(),
|
||||
[1],
|
||||
"{name}"
|
||||
);
|
||||
let TemplateCase::Render(template) = &prepared.templates[&1].mapped else {
|
||||
panic!("{name}: the parent pipeline is a render template");
|
||||
};
|
||||
assert!(template.fragment.is_none(), "{name}");
|
||||
assert_eq!(
|
||||
template
|
||||
.vertex
|
||||
.resources
|
||||
.buffers
|
||||
.keys()
|
||||
.copied()
|
||||
.collect::<Vec<_>>(),
|
||||
[0, 1],
|
||||
"{name}"
|
||||
let refused = prepare_case(device, admitted).err();
|
||||
assert!(
|
||||
matches!(&refused, Some(ExecutorError::NotSupported(NotSupported::Requirements(stops)))
|
||||
if stops.iter().eq(&expected)),
|
||||
"{name}: {refused:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1292,146 +1223,6 @@ fn a_replayed_draw_stays_in_its_templates_topology_class() {
|
||||
assert_eq!(replayed_draw_in_class(&lines, Primitive::LineStrip), Ok(()));
|
||||
}
|
||||
|
||||
/// The device replay registers each compute template with its own threadgroup size and lengths, and
|
||||
/// each dispatch the host encodes into an executed compute command buffer with its pipeline (the
|
||||
/// parent's where the commands inherit it) and its regions' sizes, deduplicated in order; where the
|
||||
/// producer encodes an action, each template also registers every edge size of its own. K14b's
|
||||
/// committed case whose producer encodes the dispatches registers `icb_replay_template`'s eight
|
||||
/// sizes of 1 to 8 threads (threadgroup length 32), the one whose host encodes them only its own
|
||||
/// (groups of 8). A host command of another threadgroup size registers a second variant; one with
|
||||
/// no dispatch makes the producer's, and the template's edges, registered; a ragged host-encoded
|
||||
/// thread grid registers its edges.
|
||||
#[test]
|
||||
fn committed_compute_replay_cases_register_their_templates_variant() {
|
||||
use crate::case::indirect_commands::HostAction;
|
||||
use std::num::NonZeroU64;
|
||||
let root = metal2vulkan_devtools::validation_dir().join("corpus");
|
||||
let cases = CorpusStore::new(&root).read_all_cases().unwrap();
|
||||
let mut lengths = [0u32; 31];
|
||||
lengths[0] = 32;
|
||||
let variant = |token: u64, threads: [u32; 3]| {
|
||||
ReplayVariant::new(NonZeroU64::new(token).unwrap(), threads, lengths)
|
||||
};
|
||||
let prepared = |name: &str| {
|
||||
let case = cases
|
||||
.iter()
|
||||
.find(|case| case.name == name)
|
||||
.unwrap_or_else(|| panic!("the committed public case {name}"))
|
||||
.clone();
|
||||
let device = DeviceType::Cpu;
|
||||
let admitted = admit(&root, case, ExecutionRequest::EngineCandidate { device })
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
prepare_case(device, admitted).unwrap_or_else(|error| panic!("{name}: {error}"))
|
||||
};
|
||||
// The producer encodes the first case's actions, so its template registers every edge size
|
||||
// of its own; the host encodes the second's.
|
||||
let edges =
|
||||
|token: u64| -> Vec<ReplayVariant> { (1..=8).map(|x| variant(token, [x, 1, 1])).collect() };
|
||||
let prepared_gpu = prepared("execute-two-gpu-encoded-template-dispatches");
|
||||
let Mapped::Compute(compute) = &prepared_gpu.mapped else {
|
||||
panic!("a kernel case");
|
||||
};
|
||||
assert_eq!(
|
||||
replay_variants(compute, &prepared_gpu.templates).unwrap(),
|
||||
edges(1)
|
||||
);
|
||||
let name = "gpu-encoded-buffers-keep-the-host-encoded-dispatches";
|
||||
let host = prepared(name);
|
||||
let Mapped::Compute(compute) = &host.mapped else {
|
||||
panic!("{name}: a kernel case");
|
||||
};
|
||||
assert_eq!(
|
||||
replay_variants(compute, &host.templates).unwrap(),
|
||||
[variant(2, [8, 1, 1])],
|
||||
"{name}"
|
||||
);
|
||||
let prepared = prepared("gpu-encoded-buffers-keep-the-host-encoded-dispatches");
|
||||
let Mapped::Compute(mut compute) = prepared.mapped else {
|
||||
panic!("a kernel case");
|
||||
};
|
||||
let commands = &mut compute
|
||||
.command_buffers
|
||||
.values_mut()
|
||||
.next()
|
||||
.unwrap()
|
||||
.commands;
|
||||
let Some(HostAction::DispatchThreadgroups {
|
||||
threads_per_threadgroup,
|
||||
..
|
||||
}) = &mut commands[1].action
|
||||
else {
|
||||
panic!("command 1 dispatches threadgroups");
|
||||
};
|
||||
*threads_per_threadgroup = [4, 2, 1];
|
||||
let first = commands[0].action.take();
|
||||
let mut expected = vec![variant(2, [4, 2, 1])];
|
||||
expected.extend(edges(2));
|
||||
expected.sort_by_key(|v| v.threads_per_threadgroup);
|
||||
assert_eq!(
|
||||
replay_variants(&compute, &prepared.templates).unwrap(),
|
||||
expected,
|
||||
"a command whose action the producer encodes registers the template's edges"
|
||||
);
|
||||
// A host-encoded thread grid registers its regions' sizes: 10 x 3 threads in groups of 4 x 2
|
||||
// run groups of 4 x 2, 2 x 2, 4 x 1, and 2 x 1.
|
||||
let commands = &mut compute
|
||||
.command_buffers
|
||||
.values_mut()
|
||||
.next()
|
||||
.unwrap()
|
||||
.commands;
|
||||
commands[0].action = first;
|
||||
commands[1].action = Some(HostAction::DispatchThreads {
|
||||
grid: [10, 3, 1],
|
||||
threads_per_threadgroup: [4, 2, 1],
|
||||
});
|
||||
let mut expected = vec![
|
||||
variant(2, [2, 1, 1]),
|
||||
variant(2, [2, 2, 1]),
|
||||
variant(2, [4, 1, 1]),
|
||||
variant(2, [4, 2, 1]),
|
||||
variant(2, [8, 1, 1]),
|
||||
];
|
||||
expected.sort_by_key(|v| v.threads_per_threadgroup);
|
||||
assert_eq!(
|
||||
replay_variants(&compute, &prepared.templates).unwrap(),
|
||||
expected
|
||||
);
|
||||
}
|
||||
|
||||
/// A template the executor's context cannot replay refuses its case as it is prepared, by the
|
||||
/// requirement the vocabulary names: the committed kernel case whose patch draws run a
|
||||
/// post-tessellation template.
|
||||
#[test]
|
||||
fn a_template_the_context_cannot_replay_refuses_its_case_by_its_requirement() {
|
||||
let root = metal2vulkan_devtools::validation_dir().join("corpus");
|
||||
let name = "patch-draws-a-kernel-encodes-at-factor-scales-and-the-host-encodes";
|
||||
let case = CorpusStore::new(&root)
|
||||
.read_all_cases()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.find(|case| case.name == name)
|
||||
.unwrap_or_else(|| panic!("the committed public case {name}"));
|
||||
let device = DeviceType::Cpu;
|
||||
let admitted = admit(&root, case, ExecutionRequest::EngineCandidate { device })
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let refused = prepare_case(device, admitted)
|
||||
.err()
|
||||
.expect("the context's refusal");
|
||||
assert!(
|
||||
matches!(&refused, ExecutorError::NotSupported(NotSupported::Requirements(requirements))
|
||||
if requirements.contains(&ToolingRequirement::ReplayedTemplateResources)),
|
||||
"{refused}"
|
||||
);
|
||||
}
|
||||
|
||||
/// K14d's committed replay cases register the variants their regions select. The producer of
|
||||
/// `gpu-encoded-ragged-grids-...` encodes every action, so its template (groups of 8 x 4, a
|
||||
/// 128-byte length) registers all 32 sizes no larger; the host of `host-encoded-over-limit-...`
|
||||
/// encodes every action, so it registers the template's own size and each of its dispatches'
|
||||
/// regions (one-thread groups, groups of 2 and their one-thread edge, and groups of 4 x 2 with
|
||||
/// their 1 x 2, 4 x 1, and 1 x 1 edges); and the replay-fault case's template (groups of 4 x 4, 64
|
||||
/// bytes) registers its 16 sizes, none with the commands' 128-byte length.
|
||||
/// A device replay records as many regions per command as keep its dispatches within the
|
||||
/// product's bound, so a range executor v92 ran is never refused for its length: 3,971 commands of
|
||||
/// 33 variants take all eight regions, 3,972 take seven (eight would be `TooManyDispatches`), and
|
||||
@@ -1483,72 +1274,6 @@ fn a_long_replay_records_the_regions_its_dispatch_bound_holds() {
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k14d_replay_cases_register_their_regions_variants() {
|
||||
use std::num::NonZeroU64;
|
||||
let root = metal2vulkan_devtools::validation_dir().join("corpus");
|
||||
let cases = CorpusStore::new(&root).read_all_cases().unwrap();
|
||||
let registered = |name: &str| {
|
||||
let case = cases
|
||||
.iter()
|
||||
.find(|case| case.name == name)
|
||||
.unwrap_or_else(|| panic!("the committed public case {name}"))
|
||||
.clone();
|
||||
let device = DeviceType::Cpu;
|
||||
let admitted = admit(&root, case, ExecutionRequest::EngineCandidate { device })
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let prepared =
|
||||
prepare_case(device, admitted).unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let Mapped::Compute(compute) = &prepared.mapped else {
|
||||
panic!("{name}: a kernel case");
|
||||
};
|
||||
replay_variants(compute, &prepared.templates).unwrap()
|
||||
};
|
||||
let variants = |length: u32, sizes: &[[u32; 3]]| -> Vec<ReplayVariant> {
|
||||
let mut lengths = [0u32; 31];
|
||||
lengths[0] = length;
|
||||
let mut out: Vec<ReplayVariant> = sizes
|
||||
.iter()
|
||||
.map(|&size| ReplayVariant::new(NonZeroU64::new(1).unwrap(), size, lengths))
|
||||
.collect();
|
||||
out.sort_by_key(|v| v.threads_per_threadgroup);
|
||||
out
|
||||
};
|
||||
let edges = |local: [u32; 3]| -> Vec<[u32; 3]> {
|
||||
let mut out = Vec::new();
|
||||
for z in 1..=local[2] {
|
||||
for y in 1..=local[1] {
|
||||
for x in 1..=local[0] {
|
||||
out.push([x, y, z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
};
|
||||
assert_eq!(
|
||||
registered("gpu-encoded-ragged-grids-replay-with-the-inherited-pipeline-and-buffers"),
|
||||
variants(128, &edges([8, 4, 1]))
|
||||
);
|
||||
assert_eq!(
|
||||
registered("host-encoded-over-limit-and-ragged-dispatches-in-two-command-buffers"),
|
||||
variants(
|
||||
128,
|
||||
&[
|
||||
[1, 1, 1],
|
||||
[1, 2, 1],
|
||||
[2, 1, 1],
|
||||
[4, 1, 1],
|
||||
[4, 2, 1],
|
||||
[8, 4, 1]
|
||||
]
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
registered("gpu-encoded-commands-of-a-length-no-variant-registers"),
|
||||
variants(64, &edges([4, 4, 1]))
|
||||
);
|
||||
}
|
||||
|
||||
/// A device replay's fault refuses the row (`not_supported{bind}`) only when every reason is one of
|
||||
/// the product's typed limits (no registered variant, a grid past `2^32 - 1` threads, more regions
|
||||
/// than the execution records); any other reason, alone or beside them, fails the row, as the host
|
||||
|
||||
+27
-263
@@ -1,29 +1,23 @@
|
||||
//! Argument-buffer textures, samplers, command buffers, and pipeline states in the engine
|
||||
//! executor: a texture is a used texture whose resource id its owner holds at its field, a member
|
||||
//! of the plan's heap that the kernel's handle table finds; a sampler is an argument sampler whose
|
||||
//! id its owner holds, an element of the plan's sampler arrays that the kernel's sampler table
|
||||
//! finds; a command buffer is its ID in its owner, and its record storage an argument-buffer buffer
|
||||
//! at the address the product resolves that ID at; a pipeline state is its token in its owner,
|
||||
//! which a translated pipeline reads only as an encoder's operand. No device is opened.
|
||||
//! Argument-buffer textures and samplers in the engine executor: a texture is a used texture whose
|
||||
//! resource id its owner holds at its field, a member of the plan's heap that the kernel's handle
|
||||
//! table finds; a sampler is an argument sampler whose id its owner holds, an element of the plan's
|
||||
//! sampler arrays that the kernel's sampler table finds. No device is opened.
|
||||
|
||||
use super::{b64, device, kernel_case, map_kernel};
|
||||
use crate::candidate::engine::argument_buffers::{
|
||||
field_words, owner_bytes, records_storage, resource_id, sampler_id,
|
||||
field_words, owner_bytes, resource_id, sampler_id,
|
||||
};
|
||||
use crate::candidate::engine::resources::argument_sampler_descriptor;
|
||||
use crate::candidate::engine::{
|
||||
bind_state, compute_shape, product_refusal, records_ids, require_case_families, sampler_ids,
|
||||
synthetic_used_addresses, texture_tokens, variants, BufferAddress, ComputeOutput,
|
||||
bind_state, compute_shape, require_case_families, sampler_ids, texture_tokens, variants,
|
||||
BufferAddress, ComputeOutput,
|
||||
};
|
||||
use crate::case::indirect_commands::{CommandBufferResource, PipelineResource};
|
||||
use crate::case::{
|
||||
ArgumentBufferBufferResource, ArgumentBufferSamplerResource, ArgumentBufferTextureResource,
|
||||
AuthoredCase, BufferResource, OutputSelection, ResourceRole, SamplerAddressMode, SamplerFilter,
|
||||
SamplerMipFilter, TextureFormat, TextureType,
|
||||
};
|
||||
use crate::check::admission::{ExecutorError, NotSupported};
|
||||
use crate::engine::{Outcome, UnsupportedReason};
|
||||
use metal2vulkan::bind::indirect_commands::records_address;
|
||||
use crate::check::admission::NotSupported;
|
||||
use metal2vulkan::bind::{BufferRanges, HeapSource, NeutralResource, ResourceClass, WriteSource};
|
||||
use metal2vulkan::device::DevicePolicy;
|
||||
use metal2vulkan::library::Library;
|
||||
@@ -61,26 +55,6 @@ fn member(
|
||||
}
|
||||
}
|
||||
|
||||
/// A compute-dispatch command buffer at `field_offset` of buffer 0.
|
||||
fn command_buffer(field_offset: u32) -> CommandBufferResource {
|
||||
serde_json::from_value(serde_json::json!({
|
||||
"buffer_binding": 0,
|
||||
"field_offset": field_offset,
|
||||
"capacity": 1,
|
||||
"descriptor": {
|
||||
"dispatch": "threadgroups",
|
||||
"kind": "compute",
|
||||
"max_buffer_bind_count": 0,
|
||||
"max_threadgroup_memory_bind_count": 0,
|
||||
"support_dynamic_attribute_stride": false
|
||||
},
|
||||
"execution_range": [0, 1],
|
||||
"inherit_buffers": true,
|
||||
"inherit_pipeline_state": true
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn gap(case: &AuthoredCase, expected: &str) {
|
||||
match map_kernel(case) {
|
||||
Err(NotSupported::NotImplemented(what)) => assert!(what.contains(expected), "{what}"),
|
||||
@@ -91,11 +65,10 @@ fn gap(case: &AuthoredCase, expected: &str) {
|
||||
/// Every member of buffer 0's argument buffer maps into its owner: the owner (4 authored bytes)
|
||||
/// grows to cover each 8-byte field; each texture is a used texture (its token after the
|
||||
/// argument-buffer buffers', its resource id nonzero and its own), resident for reading and
|
||||
/// writing like the oracle's `useResource`; the command buffer is its initialized record storage,
|
||||
/// an argument-buffer buffer after the authored one; the owner is created holding the buffers'
|
||||
/// addresses, each texture's resource id, and the pipeline state's authored token at their fields;
|
||||
/// a texture's region is an output; and an owner that is not bound, a key authored twice, a texture
|
||||
/// buffer, a field named twice, and overlapping fields are refused.
|
||||
/// writing like the oracle's `useResource`; the owner is created holding the buffer's address and
|
||||
/// each texture's resource id at their fields; a texture's region is an output; and an owner that
|
||||
/// is not bound, a key authored twice, a texture buffer, a field named twice, and overlapping
|
||||
/// fields are refused.
|
||||
#[test]
|
||||
fn argument_buffer_members_are_written_into_their_owner() {
|
||||
let mut case = kernel_case();
|
||||
@@ -124,14 +97,6 @@ fn argument_buffer_members_are_written_into_their_owner() {
|
||||
&[0xab; 4],
|
||||
),
|
||||
]);
|
||||
case.command_buffers.push(command_buffer(32));
|
||||
case.pipeline_states.push(PipelineResource {
|
||||
buffer_binding: 0,
|
||||
field_offset: 40,
|
||||
token: 7,
|
||||
air_sha256: "22".repeat(32),
|
||||
case_id: "33".repeat(32),
|
||||
});
|
||||
case.output = OutputSelection::ArgumentBufferTexture {
|
||||
buffer_binding: 0,
|
||||
field_offset: 24,
|
||||
@@ -140,7 +105,7 @@ fn argument_buffer_members_are_written_into_their_owner() {
|
||||
};
|
||||
assert_eq!(require_case_families(&case), Ok(()));
|
||||
let mapped = map_kernel(&case).unwrap();
|
||||
assert_eq!(mapped.buffers[&0].len(), 48);
|
||||
assert_eq!(mapped.buffers[&0].len(), 32);
|
||||
assert_eq!(&mapped.buffers[&0][..4], &[0xab; 4]);
|
||||
assert_eq!(
|
||||
mapped
|
||||
@@ -165,17 +130,9 @@ fn argument_buffer_members_are_written_into_their_owner() {
|
||||
&[1, 2, 3, 4, 5, 6, 7, 8][..]
|
||||
)
|
||||
);
|
||||
assert_eq!(mapped.objects, BTreeMap::from([((0, 40), 7)]));
|
||||
let command = command_buffer(32);
|
||||
assert_eq!(
|
||||
mapped.command_buffers,
|
||||
BTreeMap::from([((0, 32), command.clone())])
|
||||
);
|
||||
let mut storage_bytes = vec![0; command.record_storage_bytes().unwrap()];
|
||||
command.initialize_records(&mut storage_bytes).unwrap();
|
||||
assert_eq!(
|
||||
mapped.argument_buffer_buffers,
|
||||
BTreeMap::from([((0, 8), vec![5; 12]), ((0, 32), storage_bytes.clone())])
|
||||
BTreeMap::from([((0, 8), vec![5; 12])])
|
||||
);
|
||||
assert_eq!(
|
||||
mapped.output,
|
||||
@@ -187,52 +144,23 @@ fn argument_buffer_members_are_written_into_their_owner() {
|
||||
}
|
||||
);
|
||||
|
||||
// The bind state: the buffer is token 0, the record storage 1, the textures follow them
|
||||
// with their resource ids. The command buffer's ID is 1, its record storage at that ID's
|
||||
// records address with a device address of its own.
|
||||
// The bind state: the buffer is token 0, the textures follow it with their resource ids.
|
||||
let tokens = texture_tokens(&mapped).unwrap();
|
||||
assert_eq!(tokens, BTreeMap::from([((0, 16), 2), ((0, 24), 3)]));
|
||||
let records = records_ids(&mapped).unwrap();
|
||||
assert_eq!(records, BTreeMap::from([((0, 32), 1)]));
|
||||
assert_eq!(
|
||||
synthetic_used_addresses(&mapped).unwrap()[&(0, 32)],
|
||||
records_storage(1, None)
|
||||
);
|
||||
assert_eq!(tokens, BTreeMap::from([((0, 16), 1), ((0, 24), 2)]));
|
||||
let host = |guest| BufferAddress {
|
||||
guest,
|
||||
host: Some(guest),
|
||||
};
|
||||
let addresses = BTreeMap::from([(0, host(0x1000))]);
|
||||
let embedded = BTreeMap::from([
|
||||
((0, 8), host(0xdead_0000)),
|
||||
((0, 32), records_storage(1, Some(0xbeef_0000))),
|
||||
]);
|
||||
let embedded = BTreeMap::from([((0, 8), host(0xdead_0000))]);
|
||||
let state = bind_state(&mapped, &addresses, &embedded, BufferRanges::default()).unwrap();
|
||||
let [buffer, storage, first, second] = state.used_resources.as_slice() else {
|
||||
let [buffer, first, second] = state.used_resources.as_slice() else {
|
||||
panic!("{:?}", state.used_resources);
|
||||
};
|
||||
assert_eq!((buffer.class, buffer.token), (ResourceClass::Buffer, 0));
|
||||
assert_eq!(
|
||||
(
|
||||
storage.class,
|
||||
storage.token,
|
||||
storage.gpu_address,
|
||||
storage.device_address,
|
||||
storage.length,
|
||||
storage.usage
|
||||
),
|
||||
(
|
||||
ResourceClass::Buffer,
|
||||
1,
|
||||
Some(records_address(1)),
|
||||
Some(0xbeef_0000),
|
||||
storage_bytes.len() as u64,
|
||||
ResourceUsage::READ | ResourceUsage::WRITE
|
||||
)
|
||||
);
|
||||
for (used, token, format) in [
|
||||
(first, 2, PixelFormat::RGBA8Unorm),
|
||||
(second, 3, PixelFormat::R32Uint),
|
||||
(first, 1, PixelFormat::RGBA8Unorm),
|
||||
(second, 2, PixelFormat::R32Uint),
|
||||
] {
|
||||
let ResourceClass::Texture(facts) = used.class else {
|
||||
panic!("{used:?}");
|
||||
@@ -249,46 +177,28 @@ fn argument_buffer_members_are_written_into_their_owner() {
|
||||
}
|
||||
for addressed in [false, true] {
|
||||
let shape = compute_shape(&mapped, addressed, BufferRanges::default()).unwrap();
|
||||
assert_eq!(shape.used.len(), 4);
|
||||
assert_eq!(shape.used.len(), 3);
|
||||
if addressed {
|
||||
assert_eq!(state.shape(), shape);
|
||||
}
|
||||
}
|
||||
|
||||
// The owner holds, at each field, the word Metal's argument encoder writes there: the
|
||||
// command buffer's ID, not its record storage's address.
|
||||
// The owner holds, at each field, the word Metal's argument encoder writes there.
|
||||
let fields = field_words(
|
||||
&embedded,
|
||||
&records,
|
||||
&BTreeMap::new(),
|
||||
&tokens,
|
||||
&BTreeMap::new(),
|
||||
mapped.objects.iter().map(|(&key, &word)| (key, word)),
|
||||
std::iter::empty(),
|
||||
)
|
||||
.unwrap();
|
||||
let owner = owner_bytes(&mapped.buffers, 0, &fields).unwrap();
|
||||
let word = |at: usize| u64::from_le_bytes(owner[at..at + 8].try_into().unwrap());
|
||||
assert_eq!(&owner[..8], &[0xab, 0xab, 0xab, 0xab, 0, 0, 0, 0]);
|
||||
assert_eq!(
|
||||
[word(8), word(16), word(24), word(32), word(40)],
|
||||
[0xdead_0000, resource_id(2), resource_id(3), 1, 7]
|
||||
[word(8), word(16), word(24)],
|
||||
[0xdead_0000, resource_id(1), resource_id(2)]
|
||||
);
|
||||
// A command buffer without its record storage, and record storage away from its ID's
|
||||
// address, are refused.
|
||||
let words = |embedded: &BTreeMap<(u32, u32), BufferAddress>| {
|
||||
field_words(
|
||||
embedded,
|
||||
&records,
|
||||
&tokens,
|
||||
&BTreeMap::new(),
|
||||
std::iter::empty(),
|
||||
)
|
||||
};
|
||||
let mut without = embedded.clone();
|
||||
without.remove(&(0, 32));
|
||||
assert!(words(&without).is_err());
|
||||
let mut away = embedded.clone();
|
||||
away.insert((0, 32), host(0xbeef_0000));
|
||||
assert!(words(&away).is_err());
|
||||
// Ids are nonzero (a handle table never enters id 0) and distinct.
|
||||
let ids = (0..64)
|
||||
.map(resource_id)
|
||||
@@ -306,7 +216,7 @@ fn argument_buffer_members_are_written_into_their_owner() {
|
||||
.is_err());
|
||||
let overlapping = BTreeMap::from([((0, 8), 1), ((0, 12), 2)]);
|
||||
assert!(owner_bytes(&mapped.buffers, 0, &overlapping).is_err());
|
||||
assert!(owner_bytes(&mapped.buffers, 0, &BTreeMap::from([((0, 44), 1)])).is_err());
|
||||
assert!(owner_bytes(&mapped.buffers, 0, &BTreeMap::from([((0, 32), 1)])).is_err());
|
||||
|
||||
let mut orphan = case.clone();
|
||||
orphan.argument_buffer_textures[0].buffer_binding = 3;
|
||||
@@ -317,18 +227,6 @@ fn argument_buffer_members_are_written_into_their_owner() {
|
||||
let mut texel = case.clone();
|
||||
texel.argument_buffer_textures[0].texture_type = TextureType::Buffer;
|
||||
gap(&texel, "texture buffer");
|
||||
let mut command_orphan = case.clone();
|
||||
command_orphan.command_buffers[0].buffer_binding = 7;
|
||||
gap(&command_orphan, "without its owner buffer");
|
||||
let mut pipeline_orphan = case.clone();
|
||||
pipeline_orphan.pipeline_states[0].buffer_binding = 7;
|
||||
gap(&pipeline_orphan, "without its owner buffer");
|
||||
let mut shared = case.clone();
|
||||
shared.pipeline_states[0].field_offset = 32;
|
||||
gap(&shared, "pipeline state 0+32 bound twice");
|
||||
let mut over_buffer = case.clone();
|
||||
over_buffer.command_buffers[0].field_offset = 8;
|
||||
gap(&over_buffer, "command buffer 0+8 bound twice");
|
||||
}
|
||||
|
||||
/// End to end without a device: `argument_buffer_read` of the owned `handles` fixture on
|
||||
@@ -455,140 +353,6 @@ fn an_argument_buffer_texture_is_the_heap_member_its_owner_names() {
|
||||
.any(|used| used.token == token && used.resource_id == Some(id)));
|
||||
}
|
||||
|
||||
/// A kernel `name` whose argument buffer `%ab` (Metal buffer 0, constant space) is
|
||||
/// `{compute_pipeline_state compute; uint scale; uint bias;}`, with a `ulong` output buffer `%out`
|
||||
/// (Metal buffer 1); `body` precedes its `ret`.
|
||||
fn pipeline_state_kernel(name: &str, body: &str) -> String {
|
||||
format!(
|
||||
r#"%ab = type {{ ptr addrspace(1), i32, i32 }}
|
||||
|
||||
define void @{name}(ptr addrspace(2) %ab, ptr addrspace(1) %out) {{
|
||||
{body}
|
||||
ret void
|
||||
}}
|
||||
|
||||
!air.kernel = !{{!0}}
|
||||
!air.version = !{{!9}}
|
||||
!air.language_version = !{{!10}}
|
||||
!0 = !{{ptr @{name}, !1, !2}}
|
||||
!1 = !{{}}
|
||||
!2 = !{{!3, !8}}
|
||||
!3 = !{{i32 0, !"air.indirect_buffer", !"air.buffer_size", i32 16, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !4, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"Pipelines", !"air.arg_name", !"ab"}}
|
||||
!4 = !{{i32 0, i32 8, i32 0, !"compute_pipeline_state", !"compute", !"air.indirect_argument", !5, i32 8, i32 4, i32 0, !"uint", !"scale", !"air.indirect_argument", !6, i32 12, i32 4, i32 0, !"uint", !"bias", !"air.indirect_argument", !7}}
|
||||
!5 = !{{i32 0, !"air.compute_pipeline_state", !"air.location_index", i32 0, i32 1, !"air.arg_type_name", !"compute_pipeline_state", !"air.arg_name", !"compute"}}
|
||||
!6 = !{{i32 1, !"air.indirect_constant", !"air.location_index", i32 1, i32 1, !"air.arg_type_name", !"uint", !"air.arg_name", !"scale"}}
|
||||
!7 = !{{i32 2, !"air.indirect_constant", !"air.location_index", i32 2, i32 1, !"air.arg_type_name", !"uint", !"air.arg_name", !"bias"}}
|
||||
!8 = !{{i32 1, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"ulong", !"air.arg_name", !"out"}}
|
||||
!9 = !{{i32 2, i32 8, i32 0}}
|
||||
!10 = !{{!"Metal", i32 4, i32 0, i32 0}}
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
||||
/// The executor's word for a pipeline state (the case's token) is never the id Metal's encoder
|
||||
/// writes, so no case whose output depends on a pipeline-state member's bytes may be compared.
|
||||
/// Through the executor's own mapping and compile, on each Vulkan profile the candidate runs: a
|
||||
/// kernel that reads only the argument buffer's data members compiles, and its owner holds the
|
||||
/// token at the pipeline-state field; a kernel whose output depends on the field is the product's
|
||||
/// typed `ArgumentBufferObjects` refusal, which the executor reports as not supported, never as an
|
||||
/// observation. That covers the field's word, and a null test of the pipeline state, loaded as the
|
||||
/// handle or at an offset not known at translation time: Metal's resource id and the token are both
|
||||
/// nonzero once set, so a null test would otherwise agree.
|
||||
#[test]
|
||||
fn a_pipeline_state_whose_bytes_a_kernel_reads_never_reaches_a_comparison() {
|
||||
let data = " %ps = getelementptr inbounds %ab, ptr addrspace(2) %ab, i64 0, i32 1\n %s = load i32, ptr addrspace(2) %ps, align 4\n %pb = getelementptr inbounds %ab, ptr addrspace(2) %ab, i64 0, i32 2\n %b = load i32, ptr addrspace(2) %pb, align 4\n %v = add i32 %s, %b\n %z = zext i32 %v to i64\n store i64 %z, ptr addrspace(1) %out, align 8";
|
||||
let word = " %w = load i64, ptr addrspace(2) %ab, align 8\n store i64 %w, ptr addrspace(1) %out, align 8";
|
||||
let null = " %c = icmp eq ptr addrspace(1) %h, null\n %w = zext i1 %c to i64\n store i64 %w, ptr addrspace(1) %out, align 8";
|
||||
let handle_null =
|
||||
format!(" %h = load ptr addrspace(1), ptr addrspace(2) %ab, align 8\n{null}");
|
||||
// `scale & 1` selects the field (0) or the data that follows it (8).
|
||||
let dynamic_null = format!(" %ps = getelementptr inbounds %ab, ptr addrspace(2) %ab, i64 0, i32 1\n %s = load i32, ptr addrspace(2) %ps, align 4\n %a = and i32 %s, 1\n %i = zext i32 %a to i64\n %pp = getelementptr inbounds ptr addrspace(1), ptr addrspace(2) %ab, i64 %i\n %h = load ptr addrspace(1), ptr addrspace(2) %pp, align 8\n{null}");
|
||||
for (entry, body, compiles) in [
|
||||
("pipeline_data", data, true),
|
||||
("pipeline_word", word, false),
|
||||
("pipeline_null", handle_null.as_str(), false),
|
||||
("pipeline_dynamic_null", dynamic_null.as_str(), false),
|
||||
] {
|
||||
let Some(bitcode) = super::assemble(&pipeline_state_kernel(entry, body)) else {
|
||||
return;
|
||||
};
|
||||
let mut case = kernel_case();
|
||||
case.entry = entry.into();
|
||||
case.buffers = vec![
|
||||
BufferResource {
|
||||
binding: 0,
|
||||
role: ResourceRole::Input,
|
||||
bytes_b64: Some(b64(&[0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0])),
|
||||
initial_bytes_b64: None,
|
||||
rasterization_rate_map: None,
|
||||
},
|
||||
BufferResource {
|
||||
binding: 1,
|
||||
role: ResourceRole::Output,
|
||||
bytes_b64: None,
|
||||
initial_bytes_b64: Some(b64(&[0xab; 8])),
|
||||
rasterization_rate_map: None,
|
||||
},
|
||||
];
|
||||
case.pipeline_states.push(PipelineResource {
|
||||
buffer_binding: 0,
|
||||
field_offset: 0,
|
||||
token: 5,
|
||||
air_sha256: "22".repeat(32),
|
||||
case_id: "33".repeat(32),
|
||||
});
|
||||
case.output = OutputSelection::Buffer {
|
||||
binding: 1,
|
||||
offset: 0,
|
||||
length: 8,
|
||||
};
|
||||
assert_eq!(require_case_families(&case), Ok(()));
|
||||
let mapped = map_kernel(&case).unwrap();
|
||||
let fields = field_words(
|
||||
&BTreeMap::new(),
|
||||
&BTreeMap::new(),
|
||||
&BTreeMap::new(),
|
||||
&BTreeMap::new(),
|
||||
mapped.objects.iter().map(|(&key, &word)| (key, word)),
|
||||
)
|
||||
.unwrap();
|
||||
let owner = owner_bytes(&mapped.buffers, 0, &fields).unwrap();
|
||||
assert_eq!(u64::from_le_bytes(owner[..8].try_into().unwrap()), 5);
|
||||
assert_eq!(&owner[8..], &[3, 0, 0, 0, 4, 0, 0, 0]);
|
||||
let library = Library::from_air(&bitcode).unwrap();
|
||||
let function = FunctionDescriptor::new(library.function(entry).unwrap());
|
||||
for stem in ["moltenvk-m3", "lavapipe", "runtime-floor"] {
|
||||
let device = device(stem, DevicePolicy::RESIDENT_TABLES);
|
||||
for addressed in [false, true] {
|
||||
let shape = compute_shape(&mapped, addressed, BufferRanges::default()).unwrap();
|
||||
let compiled = variants::compile_compute_for_shape(
|
||||
&device,
|
||||
&function,
|
||||
&shape,
|
||||
Some(&mapped.dispatch),
|
||||
&Budget::standard(),
|
||||
);
|
||||
match (compiled, compiles) {
|
||||
(Ok(_), true) => {}
|
||||
(Err(error), false) => match product_refusal(&error) {
|
||||
ExecutorError::NotSupported(NotSupported::Product {
|
||||
outcome:
|
||||
Outcome::Unsupported {
|
||||
reason: UnsupportedReason::NotImplemented,
|
||||
feature,
|
||||
},
|
||||
..
|
||||
}) => assert_eq!(feature, "ArgumentBufferObjects", "{stem} {entry}"),
|
||||
other => panic!("{stem} {entry}: {other:?}"),
|
||||
},
|
||||
(Ok(_), false) => panic!("{stem} {entry} compiled"),
|
||||
(Err(error), true) => panic!("{stem} {entry}: {error}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The material `{ texture2d<float> t; sampler s; }` of `argument_sampler_sample` (the owned
|
||||
/// `tail_argument_samplers` fixture): buffer 0 holds it, buffer 1 the four `float4` outputs.
|
||||
fn sampler_case() -> AuthoredCase {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use crate::requirement::ToolingRequirement;
|
||||
|
||||
#[test]
|
||||
fn command_buffer_literals_participate_in_identity_and_validate_resources() {
|
||||
@@ -93,37 +94,21 @@ fn command_buffer_literals_participate_in_identity_and_validate_resources() {
|
||||
.unwrap_err()
|
||||
.iter()
|
||||
.any(|error| error.contains("owns an undeclared buffer")));
|
||||
// The Metal oracle and the old-engine candidate supply command-buffer handles, so the shared
|
||||
// gate admits the literal. The engine candidate maps a command buffer as its record
|
||||
// storage, an argument-buffer buffer whose address its owner holds, and refuses one whose owner
|
||||
// is not bound with a typed executor reason.
|
||||
// The Metal oracle supplies command-buffer handles, so the shared gate admits the literal; the
|
||||
// engine candidate refuses a buffer of compute commands, the runtime's limit, before it maps
|
||||
// the case.
|
||||
assert!(crate::executor_contract::require_case(&case, "test").is_ok());
|
||||
assert_engine_refuses(&case, "without its owner buffer");
|
||||
case.command_buffers[0].buffer_binding = case.buffers[0].binding;
|
||||
let mapped = crate::candidate::engine::compute_case(&case).unwrap();
|
||||
let key = (case.buffers[0].binding, 0);
|
||||
assert!(mapped.objects.is_empty());
|
||||
assert_eq!(
|
||||
mapped.command_buffers,
|
||||
std::collections::BTreeMap::from([(key, case.command_buffers[0].clone())])
|
||||
);
|
||||
let mut records = vec![0; case.command_buffers[0].record_storage_bytes().unwrap()];
|
||||
case.command_buffers[0]
|
||||
.initialize_records(&mut records)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
mapped.argument_buffer_buffers,
|
||||
std::collections::BTreeMap::from([(key, records)])
|
||||
);
|
||||
assert_engine_refuses(&case, ToolingRequirement::IndirectComputeCommands);
|
||||
}
|
||||
|
||||
fn assert_engine_refuses(case: &AuthoredCase, what: &str) {
|
||||
match crate::candidate::engine::compute_case(case) {
|
||||
Err(crate::check::admission::NotSupported::NotImplemented(detail)) => {
|
||||
assert!(detail.contains(what), "{detail}")
|
||||
}
|
||||
other => panic!("expected a typed not-implemented refusal, got {other:?}"),
|
||||
}
|
||||
/// The engine candidate refuses `case` by `requirement` alone, before it maps the case.
|
||||
fn assert_engine_refuses(case: &AuthoredCase, requirement: ToolingRequirement) {
|
||||
assert_eq!(
|
||||
crate::candidate::engine::compute_case(case).err(),
|
||||
Some(crate::check::admission::NotSupported::Requirements(
|
||||
[requirement].into()
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -164,15 +149,9 @@ fn pipeline_handles_require_unique_tokens_and_hash_the_template() {
|
||||
.any(|error| error.contains("tokens must be nonzero and unique")));
|
||||
case.pipeline_states[0].token = 1;
|
||||
assert!(crate::executor_contract::require_case(&case, "test").is_ok());
|
||||
// The engine candidate maps a pipeline state as its authored token in its owner, the
|
||||
// word a command's pipeline field records, and refuses one whose owner is not bound.
|
||||
let mapped = crate::candidate::engine::compute_case(&case).unwrap();
|
||||
assert_eq!(
|
||||
mapped.objects.into_iter().collect::<Vec<_>>(),
|
||||
[((case.buffers[0].binding, 0), 1)]
|
||||
);
|
||||
case.pipeline_states[0].buffer_binding = u32::MAX;
|
||||
assert_engine_refuses(&case, "without its owner buffer");
|
||||
// The engine candidate refuses a pipeline state an argument buffer holds, the runtime's
|
||||
// limit, before it maps the case.
|
||||
assert_engine_refuses(&case, ToolingRequirement::ArgumentBufferPipelineState);
|
||||
}
|
||||
|
||||
/// What the host encodes and executes: a case without it keeps its identity, one with it changes
|
||||
@@ -1474,19 +1453,6 @@ fn executed_command_buffers_run_in_identity_order() {
|
||||
case.computed_case_id().unwrap()
|
||||
);
|
||||
assert_eq!(keys(&reversed), keys(&case));
|
||||
// The candidate's map iterates the same keys in the same order.
|
||||
for listing in [&case, &reversed] {
|
||||
let mapped = crate::candidate::engine::compute_case(listing).unwrap();
|
||||
assert_eq!(
|
||||
mapped
|
||||
.command_buffers
|
||||
.iter()
|
||||
.filter(|(_, resource)| resource.execute.is_some())
|
||||
.map(|(&key, _)| key)
|
||||
.collect::<Vec<_>>(),
|
||||
keys(&case)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A render descriptor of mesh draws: its draw kinds and object and mesh counts serialize only
|
||||
|
||||
@@ -19,6 +19,7 @@ use crate::air::reflect::{
|
||||
ResourceKind, ShaderInterface, ShaderStage, TextureDimension,
|
||||
TextureFormat as ReflectedTextureFormat,
|
||||
};
|
||||
use crate::case::indirect_commands::{CommandDescriptor, RenderDraws};
|
||||
use crate::case::out_of_bounds::OutOfBoundsResource;
|
||||
use crate::case::{
|
||||
AuthoredCase, DeviceBufferArrayResource, OutputSelection, Primitive, Stage, TextureFormat,
|
||||
@@ -810,8 +811,11 @@ pub fn engine_source_requirements(reflection: &ShaderInterface) -> BTreeSet<Tool
|
||||
/// attachment of both aspects ([`ToolingRequirement::SeparateDepthStencil`]). So are the families
|
||||
/// the runtime builds no call for, or refuses at creation on every device: a kernel's function
|
||||
/// table, explicit imageblock, acceleration structure or stage inputs, a bound texture buffer or
|
||||
/// sparse texture, a fragment function's imageblock, a rasterization-rate map, and a vertex
|
||||
/// buffer's dynamic stride.
|
||||
/// sparse texture, a fragment function's imageblock, a rasterization-rate map, a vertex
|
||||
/// buffer's dynamic stride, an indirect command buffer of any form but kernel-encoded indexed
|
||||
/// draws that inherit the pipeline state and bind their own buffers (its compute commands, its
|
||||
/// other draw types, its other inheritance, or a command the host encodes), and a pipeline state
|
||||
/// an argument buffer holds.
|
||||
pub fn case_requirements(case: &AuthoredCase) -> BTreeSet<ToolingRequirement> {
|
||||
let render = matches!(case.stage, Stage::Vertex | Stage::Fragment);
|
||||
let kernel = case.stage == Stage::Kernel;
|
||||
@@ -931,6 +935,36 @@ pub fn case_requirements(case: &AuthoredCase) -> BTreeSet<ToolingRequirement> {
|
||||
case.vertex_inputs.iter().any(|input| input.dynamic_stride),
|
||||
ToolingRequirement::DynamicVertexStride,
|
||||
),
|
||||
(
|
||||
case.command_buffers
|
||||
.iter()
|
||||
.any(|buffer| matches!(buffer.descriptor, CommandDescriptor::Compute { .. })),
|
||||
ToolingRequirement::IndirectComputeCommands,
|
||||
),
|
||||
(
|
||||
case.command_buffers.iter().any(|buffer| {
|
||||
matches!(&buffer.descriptor, CommandDescriptor::Render { draws, .. }
|
||||
if *draws != INDEXED_DRAWS_ALONE)
|
||||
}),
|
||||
ToolingRequirement::IndirectDrawTypes,
|
||||
),
|
||||
(
|
||||
case.command_buffers.iter().any(|buffer| {
|
||||
matches!(buffer.descriptor, CommandDescriptor::Render { .. })
|
||||
&& (!buffer.inherit_pipeline_state || buffer.inherit_buffers)
|
||||
}),
|
||||
ToolingRequirement::IndirectCommandInheritance,
|
||||
),
|
||||
(
|
||||
case.command_buffers
|
||||
.iter()
|
||||
.any(|buffer| !buffer.commands.is_empty()),
|
||||
ToolingRequirement::HostEncodedIndirectCommands,
|
||||
),
|
||||
(
|
||||
!case.pipeline_states.is_empty(),
|
||||
ToolingRequirement::ArgumentBufferPipelineState,
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.filter_map(|(present, requirement)| present.then_some(requirement))
|
||||
@@ -938,6 +972,17 @@ pub fn case_requirements(case: &AuthoredCase) -> BTreeSet<ToolingRequirement> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The one draw type the runtime's indirect command buffer holds: indexed draws alone
|
||||
/// ([`ToolingRequirement::IndirectDrawTypes`] for any other).
|
||||
const INDEXED_DRAWS_ALONE: RenderDraws = RenderDraws {
|
||||
primitives: false,
|
||||
indexed: true,
|
||||
patches: false,
|
||||
indexed_patches: false,
|
||||
mesh_threadgroups: false,
|
||||
mesh_threads: false,
|
||||
};
|
||||
|
||||
/// Every requirement of `case` against its source: what the source's structure raises
|
||||
/// ([`unsupported_source_requirements`]), what its mesh draw needs ([`mesh::mesh_requirements`]),
|
||||
/// what its stage's observation needs ([`unsupported_observation_requirements`]), and the families
|
||||
@@ -1777,9 +1822,12 @@ mod tests {
|
||||
mesh_buffers: vec![],
|
||||
},
|
||||
)));
|
||||
// The executed compute commands are the runtime's limit alone, no reflection gap.
|
||||
assert_eq!(
|
||||
require_reflection(&executing, encoding_only, &reflection, "test executor"),
|
||||
Ok(BTreeSet::new())
|
||||
Ok(BTreeSet::from([
|
||||
ToolingRequirement::IndirectComputeCommands
|
||||
]))
|
||||
);
|
||||
|
||||
let vertex = crate::air::reflect::interface_from_vertex(
|
||||
@@ -1816,7 +1864,9 @@ mod tests {
|
||||
executing_vertex.command_buffers = executing.command_buffers.clone();
|
||||
assert_eq!(
|
||||
require_reflection(&executing_vertex, indexed, &vertex, "test executor"),
|
||||
Ok(BTreeSet::new())
|
||||
Ok(BTreeSet::from([
|
||||
ToolingRequirement::IndirectComputeCommands
|
||||
]))
|
||||
);
|
||||
// Commands no replay observes leave the vertex function without an observed effect: a
|
||||
// fragment buffer alone, which no replayed command reads.
|
||||
@@ -2024,12 +2074,20 @@ mod tests {
|
||||
assert!(!requirement(&ll), "{modeled}");
|
||||
}
|
||||
|
||||
// The executors' shared gate supplies authored command-buffer and pipeline handles.
|
||||
// The executors' shared gate supplies authored command-buffer and pipeline handles; a
|
||||
// buffer of compute commands is the runtime's limit alone, so the Metal oracle runs it.
|
||||
let engine_only = |case: &AuthoredCase| {
|
||||
let requirements = case_requirements(case);
|
||||
assert!(requirements.contains(&ToolingRequirement::IndirectComputeCommands));
|
||||
for requirement in requirements {
|
||||
assert_eq!(requirement.stops(), [Executor::EngineCandidate]);
|
||||
}
|
||||
};
|
||||
let mut authored = case();
|
||||
authored.command_buffers.push(command_buffer(None));
|
||||
assert!(require_case(&authored, "test executor").is_ok());
|
||||
assert!(case_requirements(&authored).is_empty());
|
||||
// Host-encoded or executed commands are no executor's gap.
|
||||
engine_only(&authored);
|
||||
// Host-encoded or executed commands are no authoring gap.
|
||||
let mut host = command_buffer(None);
|
||||
host.commands
|
||||
.push(crate::case::indirect_commands::HostCommand {
|
||||
@@ -2056,7 +2114,7 @@ mod tests {
|
||||
] {
|
||||
let mut authored = case();
|
||||
authored.command_buffers.push(resource);
|
||||
assert!(case_requirements(&authored).is_empty());
|
||||
engine_only(&authored);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2890,19 +2948,6 @@ entry:
|
||||
assert_eq!(requirement.stops(), [Executor::EngineCandidate]);
|
||||
};
|
||||
|
||||
let mut pipelines = kernel.clone();
|
||||
pipelines
|
||||
.pipeline_states
|
||||
.push(crate::case::indirect_commands::PipelineResource {
|
||||
buffer_binding: 0,
|
||||
field_offset: 8,
|
||||
token: 1,
|
||||
air_sha256: "33".repeat(32),
|
||||
case_id: "44".repeat(32),
|
||||
});
|
||||
// A pipeline-state literal is an opaque id in its owner.
|
||||
assert!(case_requirements(&pipelines).is_empty());
|
||||
|
||||
// A kernel's imageblock, a tile function's implicit one or an explicit one, is the
|
||||
// runtime's limit.
|
||||
let mut tile = kernel.clone();
|
||||
@@ -3136,6 +3181,83 @@ entry:
|
||||
&disabled,
|
||||
ToolingRequirement::RasterizationDisabledRenderTarget,
|
||||
);
|
||||
// What the runtime builds of an indirect command buffer: kernel-encoded indexed draws that
|
||||
// inherit the pipeline state and bind their own buffers, which raise nothing here. Its
|
||||
// compute commands, its other draw types, its other inheritance and a command the host
|
||||
// encodes are each the runtime's limit, and so is a pipeline state an argument buffer
|
||||
// holds.
|
||||
use crate::case::indirect_commands::{CommandDescriptor, HostCommand, RenderDraws};
|
||||
let indexed = crate::case::indirect_commands::CommandBufferResource {
|
||||
inherit_pipeline_state: true,
|
||||
descriptor: CommandDescriptor::Render {
|
||||
draws: INDEXED_DRAWS_ALONE,
|
||||
max_vertex_buffer_bind_count: 1,
|
||||
max_fragment_buffer_bind_count: 0,
|
||||
max_object_buffer_bind_count: 0,
|
||||
max_mesh_buffer_bind_count: 0,
|
||||
support_dynamic_attribute_stride: false,
|
||||
},
|
||||
..command_buffer(None)
|
||||
};
|
||||
let mut encoding = kernel.clone();
|
||||
encoding.command_buffers = vec![indexed.clone()];
|
||||
assert!(case_requirements(&encoding).is_empty());
|
||||
encoding.command_buffers = vec![command_buffer(None)];
|
||||
only(&encoding, ToolingRequirement::IndirectComputeCommands);
|
||||
for draws in [
|
||||
RenderDraws::default(),
|
||||
RenderDraws {
|
||||
patches: true,
|
||||
..INDEXED_DRAWS_ALONE
|
||||
},
|
||||
RenderDraws {
|
||||
indexed: false,
|
||||
mesh_threads: true,
|
||||
..INDEXED_DRAWS_ALONE
|
||||
},
|
||||
] {
|
||||
let mut drawn = indexed.clone();
|
||||
if let CommandDescriptor::Render { draws: allowed, .. } = &mut drawn.descriptor {
|
||||
*allowed = draws;
|
||||
}
|
||||
encoding.command_buffers = vec![drawn];
|
||||
only(&encoding, ToolingRequirement::IndirectDrawTypes);
|
||||
}
|
||||
for (inherit_pipeline_state, inherit_buffers) in [(false, false), (true, true)] {
|
||||
encoding.command_buffers =
|
||||
vec![crate::case::indirect_commands::CommandBufferResource {
|
||||
inherit_pipeline_state,
|
||||
inherit_buffers,
|
||||
..indexed.clone()
|
||||
}];
|
||||
only(&encoding, ToolingRequirement::IndirectCommandInheritance);
|
||||
}
|
||||
encoding.command_buffers = vec![crate::case::indirect_commands::CommandBufferResource {
|
||||
commands: vec![HostCommand {
|
||||
index: 0,
|
||||
action: None,
|
||||
barrier: false,
|
||||
pipeline: None,
|
||||
buffers: Vec::new(),
|
||||
threadgroup_memory_lengths: Vec::new(),
|
||||
stage_in_region: None,
|
||||
vertex_buffers: Vec::new(),
|
||||
fragment_buffers: Vec::new(),
|
||||
}],
|
||||
..indexed
|
||||
}];
|
||||
only(&encoding, ToolingRequirement::HostEncodedIndirectCommands);
|
||||
let mut holding = kernel.clone();
|
||||
holding
|
||||
.pipeline_states
|
||||
.push(crate::case::indirect_commands::PipelineResource {
|
||||
buffer_binding: 0,
|
||||
field_offset: 0,
|
||||
token: 1,
|
||||
air_sha256: "33".repeat(32),
|
||||
case_id: "44".repeat(32),
|
||||
});
|
||||
only(&holding, ToolingRequirement::ArgumentBufferPipelineState);
|
||||
|
||||
// The engine's candidate draws a tessellation in any authored state.
|
||||
let mut patches = vertex.clone();
|
||||
|
||||
@@ -271,6 +271,41 @@ pub enum ToolingRequirement {
|
||||
/// `setVertexBuffer:offset:attributeStride:atIndex:`, a known gap its README states, which is
|
||||
/// its guard.
|
||||
DynamicVertexStride,
|
||||
/// An indirect command buffer of compute commands a case holds
|
||||
/// (`executor_contract::case_requirements`). The runtime builds no compute command:
|
||||
/// `Device::new_indirect_command_buffer` makes indexed draw commands alone
|
||||
/// (`metal2vulkan_runtime::Gap::IndirectCommandBuffers` of `IndirectCommandsKind::CommandTypes`
|
||||
/// for any other type), and a compute pipeline state made for indirect command buffers is
|
||||
/// `IndirectCommandsKind::ComputeCommands`, known gaps its README states, which are its guard.
|
||||
IndirectComputeCommands,
|
||||
/// An indirect command buffer of render commands whose descriptor allows draws other than
|
||||
/// indexed draws alone (`executor_contract::case_requirements`): draws of primitives, patch or
|
||||
/// indexed patch draws, or mesh draws of threadgroups or threads. The runtime's indirect
|
||||
/// command buffer holds indexed draws alone
|
||||
/// (`metal2vulkan_runtime::Gap::IndirectCommandBuffers` of `IndirectCommandsKind::CommandTypes`
|
||||
/// for any other type), and the translator refuses a kernel's encoding of any draw but an
|
||||
/// indexed triangle draw (`Unsupported{GpuEncodedIndirectCommands, NotImplemented}`), known
|
||||
/// gaps its README states, which are its guard.
|
||||
IndirectDrawTypes,
|
||||
/// An indirect command buffer of render commands that set their own pipeline state
|
||||
/// (`inheritPipelineState` false) or draw with the executing encoder's buffers
|
||||
/// (`inheritBuffers` true) (`executor_contract::case_requirements`). The runtime builds commands
|
||||
/// that inherit the pipeline state and bind their own buffers alone
|
||||
/// (`metal2vulkan_runtime::Gap::IndirectCommandBuffers` of
|
||||
/// `IndirectCommandsKind::CommandPipelines` or `IndirectCommandsKind::InheritedBuffers`),
|
||||
/// known gaps its README states, which are its guard.
|
||||
IndirectCommandInheritance,
|
||||
/// A command the host encodes into an indirect command buffer before its producer runs
|
||||
/// (`executor_contract::case_requirements`, the command buffer's `commands`). The runtime has
|
||||
/// no `indirectRenderCommandAtIndex:` or `indirectComputeCommandAtIndex:`: the CPU encodes no
|
||||
/// command into its Private records, a known gap its README states, which is its guard.
|
||||
HostEncodedIndirectCommands,
|
||||
/// A render or compute pipeline state an argument buffer holds
|
||||
/// (`executor_contract::case_requirements`, the case's `pipeline_states`). The runtime's
|
||||
/// pipeline states answer no `gpuResourceID`, so no call of it gives the word a program writes
|
||||
/// into an argument buffer's pipeline-state field, and its indirect commands set no pipeline
|
||||
/// state of their own (`IndirectCommandsKind::CommandPipelines`).
|
||||
ArgumentBufferPipelineState,
|
||||
}
|
||||
|
||||
/// Every executor (the requirement leaves no case to author, or none to observe).
|
||||
@@ -278,7 +313,7 @@ const AUTHORING: &[Executor] = &Executor::ALL;
|
||||
const ENGINE: &[Executor] = &[Executor::EngineCandidate];
|
||||
|
||||
impl ToolingRequirement {
|
||||
pub const ALL: [Self; 39] = [
|
||||
pub const ALL: [Self; 44] = [
|
||||
Self::FunctionConstantLiteral,
|
||||
Self::VertexAttributeLiteral,
|
||||
Self::TessellationAttributeLiteral,
|
||||
@@ -318,6 +353,11 @@ impl ToolingRequirement {
|
||||
Self::KernelStageInput,
|
||||
Self::RasterizationRateMap,
|
||||
Self::DynamicVertexStride,
|
||||
Self::IndirectComputeCommands,
|
||||
Self::IndirectDrawTypes,
|
||||
Self::IndirectCommandInheritance,
|
||||
Self::HostEncodedIndirectCommands,
|
||||
Self::ArgumentBufferPipelineState,
|
||||
];
|
||||
|
||||
pub const fn as_str(self) -> &'static str {
|
||||
@@ -363,6 +403,11 @@ impl ToolingRequirement {
|
||||
Self::KernelStageInput => "kernel_stage_input",
|
||||
Self::RasterizationRateMap => "rasterization_rate_map",
|
||||
Self::DynamicVertexStride => "dynamic_vertex_stride",
|
||||
Self::IndirectComputeCommands => "indirect_compute_commands",
|
||||
Self::IndirectDrawTypes => "indirect_draw_types",
|
||||
Self::IndirectCommandInheritance => "indirect_command_inheritance",
|
||||
Self::HostEncodedIndirectCommands => "host_encoded_indirect_commands",
|
||||
Self::ArgumentBufferPipelineState => "argument_buffer_pipeline_state",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +476,12 @@ impl ToolingRequirement {
|
||||
| Self::KernelAccelerationStructure
|
||||
| Self::KernelStageInput
|
||||
| Self::RasterizationRateMap
|
||||
| Self::DynamicVertexStride => ENGINE,
|
||||
| Self::DynamicVertexStride
|
||||
| Self::IndirectComputeCommands
|
||||
| Self::IndirectDrawTypes
|
||||
| Self::IndirectCommandInheritance
|
||||
| Self::HostEncodedIndirectCommands
|
||||
| Self::ArgumentBufferPipelineState => ENGINE,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,8 +503,12 @@ impl ToolingRequirement {
|
||||
/// [`ToolingRequirement::KernelFunctionTable`], [`ToolingRequirement::KernelImageblock`],
|
||||
/// [`ToolingRequirement::TextureBuffer`], [`ToolingRequirement::FragmentImageblock`],
|
||||
/// [`ToolingRequirement::SparseTexture`], [`ToolingRequirement::KernelAccelerationStructure`],
|
||||
/// [`ToolingRequirement::KernelStageInput`], [`ToolingRequirement::RasterizationRateMap`] and
|
||||
/// [`ToolingRequirement::DynamicVertexStride`], which the runtime refuses or does not build.
|
||||
/// [`ToolingRequirement::KernelStageInput`], [`ToolingRequirement::RasterizationRateMap`],
|
||||
/// [`ToolingRequirement::DynamicVertexStride`], [`ToolingRequirement::IndirectComputeCommands`],
|
||||
/// [`ToolingRequirement::IndirectDrawTypes`], [`ToolingRequirement::IndirectCommandInheritance`],
|
||||
/// [`ToolingRequirement::HostEncodedIndirectCommands`] and
|
||||
/// [`ToolingRequirement::ArgumentBufferPipelineState`], which the runtime refuses or does not
|
||||
/// build.
|
||||
pub const fn limit(self) -> Limit {
|
||||
match self {
|
||||
Self::KernelMinLodClamp => Limit::Metal,
|
||||
@@ -474,7 +528,12 @@ impl ToolingRequirement {
|
||||
| Self::KernelAccelerationStructure
|
||||
| Self::KernelStageInput
|
||||
| Self::RasterizationRateMap
|
||||
| Self::DynamicVertexStride => Limit::Runtime,
|
||||
| Self::DynamicVertexStride
|
||||
| Self::IndirectComputeCommands
|
||||
| Self::IndirectDrawTypes
|
||||
| Self::IndirectCommandInheritance
|
||||
| Self::HostEncodedIndirectCommands
|
||||
| Self::ArgumentBufferPipelineState => Limit::Runtime,
|
||||
_ => Limit::Tooling,
|
||||
}
|
||||
}
|
||||
@@ -729,6 +788,23 @@ mod tests {
|
||||
ToolingRequirement::DynamicVertexStride,
|
||||
"dynamic_vertex_stride",
|
||||
),
|
||||
(
|
||||
ToolingRequirement::IndirectComputeCommands,
|
||||
"indirect_compute_commands",
|
||||
),
|
||||
(ToolingRequirement::IndirectDrawTypes, "indirect_draw_types"),
|
||||
(
|
||||
ToolingRequirement::IndirectCommandInheritance,
|
||||
"indirect_command_inheritance",
|
||||
),
|
||||
(
|
||||
ToolingRequirement::HostEncodedIndirectCommands,
|
||||
"host_encoded_indirect_commands",
|
||||
),
|
||||
(
|
||||
ToolingRequirement::ArgumentBufferPipelineState,
|
||||
"argument_buffer_pipeline_state",
|
||||
),
|
||||
] {
|
||||
assert_eq!(requirement.stops(), [Executor::EngineCandidate]);
|
||||
assert_eq!(requirement.limit(), Limit::Runtime, "{requirement}");
|
||||
@@ -799,6 +875,11 @@ mod tests {
|
||||
ToolingRequirement::KernelStageInput,
|
||||
ToolingRequirement::RasterizationRateMap,
|
||||
ToolingRequirement::DynamicVertexStride,
|
||||
ToolingRequirement::IndirectComputeCommands,
|
||||
ToolingRequirement::IndirectDrawTypes,
|
||||
ToolingRequirement::IndirectCommandInheritance,
|
||||
ToolingRequirement::HostEncodedIndirectCommands,
|
||||
ToolingRequirement::ArgumentBufferPipelineState,
|
||||
]
|
||||
);
|
||||
for executor in Executor::ALL {
|
||||
|
||||
@@ -261,19 +261,12 @@ fn corpus_with_templates(name: &str) -> (ScratchDir, metal2vulkan_validation::ca
|
||||
(scratch, case)
|
||||
}
|
||||
|
||||
/// The executor's requests for a case whose executed compute command buffer the device replay
|
||||
/// runs: on a profile with device addresses, the case's pipeline and each registered variant; on
|
||||
/// one without, the command buffer is host-replayed and only the case's own pipeline. A render
|
||||
/// command buffer is always host-replayed. Both devices take the resident-table domains, the
|
||||
/// executor's own context's, which runs the command buffers. The case's kernel encodes commands,
|
||||
/// which no device lowers (`GpuEncodedIndirectCommands`), so its cell is that refusal on both, with
|
||||
/// no digest.
|
||||
/// A case over an indirect command buffer, which no candidate runs (here the runtime's limits on
|
||||
/// compute commands and on commands the host encodes), is refused in the census by those
|
||||
/// requirements, as a run's preparation refuses it: one cell per device, no compile, no digest.
|
||||
#[test]
|
||||
fn case_compiles_lists_the_replay_variants_where_the_device_replay_runs() {
|
||||
use metal2vulkan_validation::authored_compile::compile_prepared;
|
||||
use metal2vulkan_validation::candidate::engine::{case_compiles, prepare_case, CompileSubject};
|
||||
use metal2vulkan_validation::check::admission::{admit, ExecutionRequest};
|
||||
use metal2vulkan_validation::gpu::DeviceType;
|
||||
fn the_census_refuses_command_buffer_cases_by_their_requirements() {
|
||||
use metal2vulkan_validation::authored_compile::compile_case;
|
||||
if !llvm_as_available() {
|
||||
return;
|
||||
}
|
||||
@@ -282,64 +275,26 @@ fn case_compiles_lists_the_replay_variants_where_the_device_replay_runs() {
|
||||
let _ = Command::new(&program).arg("--help").output();
|
||||
CompileWorker::program(program)
|
||||
};
|
||||
let prepared = |root: &Path, case: &metal2vulkan_validation::case::AuthoredCase| {
|
||||
let device = DeviceType::Cpu;
|
||||
let admitted = admit(
|
||||
root,
|
||||
case.clone(),
|
||||
ExecutionRequest::EngineCandidate { device },
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("admission: {error}"));
|
||||
prepare_case(device, admitted).unwrap_or_else(|error| panic!("preparation: {error}"))
|
||||
};
|
||||
let resident = |description| {
|
||||
metal2vulkan_validation::worker::compile::WorkerDevice::new(
|
||||
description,
|
||||
metal2vulkan::device::DevicePolicy::RESIDENT_TABLES,
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
let lavapipe = resident(metal2vulkan_validation::engine::load_description("lavapipe").unwrap());
|
||||
// A device without device addresses (`runtime-floor` without `bufferDeviceAddress`, below the
|
||||
// runtime's floor): the GPU-encoded command buffers replay on the host there.
|
||||
let floor = {
|
||||
let mut description =
|
||||
metal2vulkan_validation::engine::load_description("runtime-floor").unwrap();
|
||||
assert!(description
|
||||
.features
|
||||
.remove(&metal2vulkan::device::VkFeature::BufferDeviceAddress));
|
||||
resident(description)
|
||||
};
|
||||
|
||||
let lavapipe = metal2vulkan_validation::worker::compile::WorkerDevice::new(
|
||||
metal2vulkan_validation::engine::load_description("lavapipe").unwrap(),
|
||||
metal2vulkan::device::DevicePolicy::RESIDENT_TABLES,
|
||||
)
|
||||
.unwrap();
|
||||
let (scratch, case) =
|
||||
corpus_with_templates("gpu-encoded-buffers-keep-the-host-encoded-dispatches");
|
||||
let compute = prepared(scratch.path(), &case);
|
||||
let on_device = case_compiles(&compute, &lavapipe).unwrap();
|
||||
assert_eq!(on_device.host_replayed, 0);
|
||||
assert_eq!(on_device.compiles[0].subject, CompileSubject::Case);
|
||||
assert!(on_device.compiles.len() > 1);
|
||||
assert!(on_device.compiles[1..]
|
||||
.iter()
|
||||
.all(|compile| matches!(compile.subject, CompileSubject::ReplayVariant { .. })));
|
||||
let refused = Ok(CellOutcome::Refused(
|
||||
"not_supported{unsupported:not_implemented GpuEncodedIndirectCommands}".into(),
|
||||
));
|
||||
let cell = compile_prepared(&compute, &worker, &lavapipe);
|
||||
assert_eq!(cell.outcome, refused, "{cell:?}");
|
||||
assert_eq!(cell.artifact, None, "{cell:?}");
|
||||
let on_host = case_compiles(&compute, &floor).unwrap();
|
||||
assert_eq!(on_host.host_replayed, 1);
|
||||
assert_eq!(on_host.compiles.len(), 1);
|
||||
let host = compile_prepared(&compute, &worker, &floor);
|
||||
assert_eq!(host.outcome, refused, "{host:?}");
|
||||
assert_eq!(host.artifact, None, "{host:?}");
|
||||
|
||||
let (scratch, case) =
|
||||
corpus_with_templates("gpu-encoded-vertex-buffers-run-the-host-encoded-draws");
|
||||
let render = prepared(scratch.path(), &case);
|
||||
let drawn = case_compiles(&render, &lavapipe).unwrap();
|
||||
assert_eq!(drawn.host_replayed, 1);
|
||||
assert_eq!(drawn.compiles.len(), 1);
|
||||
let cells = compile_case(scratch.path(), &worker, &case, &[&lavapipe]);
|
||||
assert_eq!(cells.len(), 1, "{cells:?}");
|
||||
assert_eq!(
|
||||
cells[0].outcome,
|
||||
Ok(CellOutcome::Refused(
|
||||
"not_supported{tooling_requirement:indirect_compute_commands,\
|
||||
host_encoded_indirect_commands}"
|
||||
.into()
|
||||
)),
|
||||
"{cells:?}"
|
||||
);
|
||||
assert_eq!(cells[0].compiles, 0, "{cells:?}");
|
||||
assert_eq!(cells[0].artifact, None, "{cells:?}");
|
||||
}
|
||||
|
||||
/// An object or mesh case, which no candidate draws (`mesh_render_pipeline`), still compiles its
|
||||
|
||||
+11
-4
@@ -484,7 +484,14 @@ cargo run -p metal2vulkan-validation --release --bin corpus-vulkan -- \
|
||||
tile function's included) `kernel_imageblock`, its acceleration structure or
|
||||
intersection-function table `kernel_acceleration_structure`, its stage inputs or stage-in region
|
||||
`kernel_stage_input`, and a rasterization-rate map, a render pass's or one whose data a buffer
|
||||
holds, `rasterization_rate_map`: each the runtime's limit, run on Metal alone. A pixel format the runtime makes no image of on the device records `not_enabled`, as
|
||||
holds, `rasterization_rate_map`: each the runtime's limit, run on Metal alone. The runtime's
|
||||
indirect command buffer holds kernel-encoded indexed draws that inherit the pipeline state and
|
||||
bind their own buffers; one of compute commands carries `indirect_compute_commands`, one that
|
||||
allows other draws `indirect_draw_types`, one whose commands set their own pipeline state or
|
||||
inherit the encoder's buffers `indirect_command_inheritance`, a command the host encodes
|
||||
`host_encoded_indirect_commands`, and a pipeline state an argument buffer holds, which the
|
||||
runtime gives no `gpuResourceID`, `argument_buffer_pipeline_state`: each the runtime's limit,
|
||||
run on Metal alone. A pixel format the runtime makes no image of on the device records `not_enabled`, as
|
||||
the executor's own context records a format its query lacks. A vertex or fragment case of any
|
||||
sample count draws through the runtime the same way (`engine::runs_render_through_runtime`): its own
|
||||
stage's buffers, bound textures and samplers, argument buffers of buffers, textures and samplers
|
||||
@@ -508,9 +515,9 @@ cargo run -p metal2vulkan-validation --release --bin corpus-vulkan -- \
|
||||
`not_supported{uncontained:unchecked vertex_input}`. A rasterization-disabled vertex case renders
|
||||
into the oracle's 1x1 `R8Unorm` attachment, and a fragment case of no attachment into the
|
||||
oracle's pass of none: `renderTargetWidth` and `renderTargetHeight` 1, `defaultRasterSampleCount`
|
||||
the case's samples. Layered rendering, an argument buffer's pipeline state or indirect command
|
||||
buffer, a patch index buffer or an out-of-bounds target other than an attribute buffer keeps the
|
||||
case on the executor's own context. A vertex buffer's dynamic stride carries `dynamic_vertex_stride` and a fragment
|
||||
the case's samples. Layered rendering, an indirect command buffer, a patch index buffer or an
|
||||
out-of-bounds target other than an attribute buffer keeps the case on the executor's own
|
||||
context. A vertex buffer's dynamic stride carries `dynamic_vertex_stride` and a fragment
|
||||
function's imageblock `fragment_imageblock`, each the runtime's limit. An indexed
|
||||
draw past its index buffer, which the runtime refuses as Metal's validation does
|
||||
(`Refusal::IndexBufferOffset`), carries `index_buffer_past_end`, and a depth/stencil attachment
|
||||
|
||||
Reference in new issue
Block a user