Three changes to framebuffer fetch and the pixel interlock.
1. An unordered framebuffer fetch is refused; FramebufferFetchPolicy is deleted. Metal orders a
fragment function's read of its color attachment after every earlier fragment of the pixel,
within a draw and across draws. Where a device offers neither ordered form
(rasterization-order attachment access, or the pixel interlock's storage form where the
pipeline's state lets it be exact), the opt-in FramebufferFetchPolicy::AcceptUnordered
compiled the read as an unordered input attachment with a precision note. An unordered read
can return the attachment before an earlier overlapping fragment's write: a different value
in memory, not a rounding, which the owner's rule allows neither as a default nor as a
switch. No exact form exists on such a device, so the fetch is refused there, as the default
already did. The runtime never ran the unordered form, so no runtime behaviour changes.
- Removed: DevicePolicy::framebuffer_fetch, the enum FramebufferFetchPolicy and its
re-export (and its api_surface row), ProfileFields::framebuffer_fetch,
PrecisionNote::UnorderedFramebufferFetch, and the runtime's note kind of that name, whose
code metal2vulkan-degrade-unordered-framebuffer-fetch is retired; the runtime's
framebuffer_fetch::ordered check; validation's --accept-unordered-fetch on corpus-vulkan,
corpus-moltenvk and corpus-pipeline, and the device worker's framebuffer_fetch field.
- lower::fragment::color refuses a read no ordered form serves (Unsupported{FramebufferFetch},
naming both forms); lower::fragment::fetch refuses a blocked storage form with its blocker.
- The profile's fields change, so every profile fingerprint does.
2. No barrier between interlocked draws' colors on a driver measured to order them. Between two
draws of a render pass instance where the later one reaches a color in the fetch's
interlocked storage form (or an extended-range color's half shadow) that the earlier one
wrote, the runtime recorded a fragment-to-fragment storage barrier on every device. Vulkan
orders such draws by the interlock alone (ordered interlock modes follow rasterization
order, which follows primitive order through a subpass, and the interlocked storage image is
decorated Coherent). A new answer fact, DriverFact::InterlockOrdersDraws, measured on ANV on
the Iris Xe of Raptor Lake-P, drops that barrier there for these colors alone. The fragment
imageblock's storage and the depth stand-in keep their barrier everywhere, as does every
unmeasured driver. RADV on the Radeon 780M still needs the barrier: without it one blend
table case leaves 19 of 495 band results wrong over 5 runs. New lanes:
runtime_lane::interlocked_draw_order (every device, with its owned fixture ido_draw_order) and
the ignored release bench runtime_lane::tile_path_costs (a window server's composite on
Metal's tile path, fixture tgp_composite), with their engine inventory rows. A FAST-PATHS
bullet records the barrier and the fact.
3. A left-out interlock color's framebuffer slot holds a placeholder image. A color attachment
the draws read and write as a storage image in the interlock is left out of their subpass,
but its framebuffer slot held a view of the very image the draws write, which the validation
layer reads as VUID-vkCmdDraw-None-06537 for a draw recorded inline. The slot now holds a view
of a placeholder that nothing reads or writes (DONT_CARE load and store, GENERAL layouts): the
device keeps one for each format and sample count, plus one for each further color of that
shape in the same framebuffer, grown to cover a larger framebuffer and freed once no
framebuffer holds it; none is made per frame. A color whose draws use sample planes, and the
planes' anchor, keep their own image's view. New WorkCounts fields
storage_placeholders_made and storage_placeholder_attachments.
Verified, as the commits state:
- The translator's fetch tests (pipeline::compile ordering, engine_fragment, engine_moved_writers,
device profile fingerprints and serde, fast_paths) keep the refusals; the raster-order-group
read on a device with neither ordered form expects the fetch's own refusal naming both forms.
Validation checks every public fetch case is refused on lunarg-desktop-baseline-2023 and
vk12-floor, and that the command-line flag is gone.
- Iris Xe (ANV) with the fact in place: interlocked_draw_order 3 runs with every texel right,
extended_range_blend_table 17 passed (0 of 495 bands wrong), framebuffer_fetch 49 passed. A
1080p pass of 27 interlocked draws took about 1.08 million GPU cycles with the fact against
1.46 million with the barrier forced (about 9 to 20 us a draw).
- The placeholder lane test (two RGBA32Uint colors over four passes and sizes): placeholders and
slots (2, 2), (2, 4), (4, 6), (4, 8) through the interlock on the RX 7900 XTX (RADV) and the
UHD 770 (ANV), none through input attachments, no validation message. On lavapipe 122 lane
tests and 47 runtime render unit tests passed; on the RX 7900 XTX 94 lane tests passed.
- The engine inventory and llvm_as parts pass for the new fixtures; clippy in every
configuration and Rustdoc -D warnings.
120 lines
6.2 KiB
Rust
120 lines
6.2 KiB
Rust
//! Every tool that runs engine cases serves the device worker: started with
|
|
//! `--engine-device-worker`, it reads the parent's input from stdin, applies the parent's
|
|
//! profiles-layer restriction, and reports a typed result with its build identity and
|
|
//! framebuffer-fetch policy on stdout, so the parent's device half never runs in the parent.
|
|
|
|
use metal2vulkan_validation::observation::TRANSLATOR_FINGERPRINT;
|
|
use metal2vulkan_validation::worker::device::{VALIDATION_FINGERPRINT, WORKER_ARG};
|
|
use std::io::Write as _;
|
|
use std::process::{Command, Output, Stdio};
|
|
|
|
/// Every binary that executes engine cases (`candidate::engine::execute_prepared`).
|
|
const SERVING: [&str; 2] = [
|
|
env!("CARGO_BIN_EXE_corpus-vulkan"),
|
|
env!("CARGO_BIN_EXE_corpus-moltenvk"),
|
|
];
|
|
|
|
/// A public authored case (`primitive-acceleration-structure-intersection`), whose AIR the
|
|
/// public fixtures give.
|
|
const CASE: &str = r#"{"acceleration_structures":[{"binding":5,"kind":"primitive","primitive_triangles_b64":"AACAvwAAgL8AAAAAAACAPwAAgL8AAAAAAAAAAAAAgD8AAAAA"}],"air_sha256":"3dec51430c72d7901180dcdc22624a135640bf74af06c3a59b100b048a4107c6","argument_buffer_buffers":[],"argument_buffer_intersection_function_tables":[],"argument_buffer_textures":[],"authored_by":"codex:gpt-5.6-sol","buffers":[{"binding":0,"initial_bytes_b64":"q6urq6urq6urq6urq6urq6urq6urq6ur","role":"output"}],"case_id":"21de8b823123dfcac765adf9786fbb1f0741b4543d307064df6832313eb6b575","compare":{"kind":"exact"},"device_buffer_arrays":[],"dispatch":{"grid":[1,1,1],"threads_per_threadgroup":[1,1,1]},"entry":"primitive_as_intersect","execution_safety":"loop_free","function_constants":[],"intersection_function_tables":[],"kernel_stage_inputs":[],"name":"primitive-acceleration-structure-intersection","output":{"binding":0,"kind":"buffer","length":24,"offset":0},"rationale":"A downward ray hits one authored counter-clockwise triangle at unit distance; all observable triangle-intersection result fields are compared exactly.","render_targets":[],"samplers":[],"stage":"kernel","texture_arrays":[],"textures":[],"threadgroup_memory":[],"vertex_inputs":[],"visible_function_references":[],"visible_function_tables":[]}"#;
|
|
|
|
/// The worker input for [`CASE`] restricted to `restricted_to`, in the stated robustness leg,
|
|
/// with `VK_EXT_device_generated_commands` enabled where supported or not (`generated_commands`),
|
|
/// claiming a checked-input digest the case does not have.
|
|
fn input(restricted_to: Option<&str>, generated_commands: bool) -> String {
|
|
format!(
|
|
r#"{{"root":"/nonexistent/device-worker-corpus","case":{CASE},"device":"Cpu","backend":"vulkan","input_sha256":"{}","wait_timeout_ms":10000,"restricted_to":{},"leg":"stated","generated_commands":{generated_commands}}}"#,
|
|
"0".repeat(64),
|
|
serde_json::to_string(&restricted_to).unwrap()
|
|
)
|
|
}
|
|
|
|
/// `program` started as a device worker on `input`.
|
|
fn serve(program: &str, input: &str) -> Output {
|
|
let mut child = Command::new(program)
|
|
.arg(WORKER_ARG)
|
|
.stdin(Stdio::piped())
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped())
|
|
.spawn()
|
|
.unwrap();
|
|
child
|
|
.stdin
|
|
.take()
|
|
.unwrap()
|
|
.write_all(input.as_bytes())
|
|
.unwrap();
|
|
child.wait_with_output().unwrap()
|
|
}
|
|
|
|
/// The worker's own check disagrees with its parent's input digest, and it reports that as the
|
|
/// run's typed failure, with its build identity and the generated-commands path its parent asked
|
|
/// for, before it opens a device: unrestricted, and restricted to a committed profile.
|
|
#[test]
|
|
fn every_case_running_tool_serves_the_device_worker() {
|
|
for program in SERVING {
|
|
for (restricted_to, generated_commands) in
|
|
[(None, true), (Some("gate-lavapipe"), true), (None, false)]
|
|
{
|
|
let output = serve(program, &input(restricted_to, generated_commands));
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
assert!(output.status.success(), "{program}: {stderr}");
|
|
let report: serde_json::Value = serde_json::from_slice(&output.stdout)
|
|
.unwrap_or_else(|error| panic!("{program}: {error}: {stderr}"));
|
|
let result = &report["result"];
|
|
assert_eq!(
|
|
result["product_fingerprint"], TRANSLATOR_FINGERPRINT,
|
|
"{program}"
|
|
);
|
|
assert_eq!(
|
|
result["validation_fingerprint"], VALIDATION_FINGERPRINT,
|
|
"{program}"
|
|
);
|
|
assert_eq!(
|
|
result["generated_commands"], generated_commands,
|
|
"{program}"
|
|
);
|
|
let failed = result["result"]["Err"]["Failed"]
|
|
.as_str()
|
|
.unwrap_or_else(|| panic!("{program}: {report}"));
|
|
assert!(
|
|
failed.contains(&format!("its parent as {}", "0".repeat(64))),
|
|
"{program}: {failed}"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// The worker restricts its contexts to the profile its parent's are restricted to before it
|
|
/// checks the case or opens a device: a profile it cannot apply stops it there (exit 1, named on
|
|
/// stderr), with no report.
|
|
#[test]
|
|
fn a_worker_applies_the_parents_restriction_first() {
|
|
for program in SERVING {
|
|
let output = serve(program, &input(Some("no-such-profile"), true));
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
assert_eq!(output.status.code(), Some(1), "{program}: {stderr}");
|
|
assert!(
|
|
stderr.starts_with("engine device worker: unknown profile \"no-such-profile\""),
|
|
"{program}: {stderr}"
|
|
);
|
|
assert!(output.stdout.is_empty(), "{program}");
|
|
}
|
|
}
|
|
|
|
/// An input the worker cannot decode is the worker's own failure (exit 1, named on stderr), not a
|
|
/// tool's usage error.
|
|
#[test]
|
|
fn a_worker_refuses_an_input_it_cannot_decode() {
|
|
for program in SERVING {
|
|
let output = serve(program, "{}");
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
assert_eq!(output.status.code(), Some(1), "{program}: {stderr}");
|
|
assert!(
|
|
stderr.starts_with("engine device worker: decode the device worker's input"),
|
|
"{program}: {stderr}"
|
|
);
|
|
assert!(output.stdout.is_empty(), "{program}");
|
|
}
|
|
}
|