The runtime never made a plan (it binds each draw and dispatch by the pipeline's interface), and since the census digests each pipeline's content alone (two commits back) nothing in the tree calls one. What only the plan reached goes with it: - bind: BindState, BindShape and their shapes, BindingPlan and its instantiation (DispatchCommands, DrawCommands, push, descriptor and root-table templates and writes), plan.rs and plan/ (compute, resources, slots), instantiate.rs, resident.rs, the neutral resources' plan side, the heap's member planning and table bytes, the mesh arguments pass (MeshArguments, MeshArgumentsForm, fold_object_grid, metal_object_grid), ExecutionStatus and StatusBits as public items, TextureShape::Buffer, IndirectRef with the four indirect call variants (Dispatch::ThreadgroupsIndirect, DrawCall::Indirect, PatchesIndirect, MeshThreadgroupsIndirect) and IndexBufferRef::fetch_end. Dispatch, DrawCall and IndexBufferRef stay: validation states its cases' calls with them. - error::BindError leaves the public surface; a crate-private BindError of three variants stays as the error of the heap's view derivation, which lower::texture::slot's storage-read check reads (bind::heap::tier_read_gaps). That check keeps only the storage view's format: the sampled-view branch and ImageViewDesc were reached by the plan alone. - vk::DrawCommand, the plan's draw output. - pipeline: ComputePipeline::plan, RenderPipeline::plan; cache: VariantKey::covers and large_buffer_form. - The TexelRows form (bind::texel_rows, LoweringInputs::texel_rows, RuntimeFact and PushField TexelRows) and the YCbCrInPlace form (bind::ycbcr_in_place, lower/sampler/in_place.rs, LoweringInputs::ycbcr_in_place and ycbcr_planes_sampled, RuntimeFact and PushField YCbCrInPlace, PrecisionNote FloatSampleFilter and HalfSampleFilter, Routine::Quad). Only the binder set those inputs. - The tests of the deleted items, and the plan halves of mixed tests. Of 6810 tests (`#[test]` functions in the workspace) 309 leave and 11 come in their place: the lowering halves of mixed tests, kept without the plan (the heap layout, the stage-in stride and region facts, the emulated-simdgroup and bicubic facts, the iris-xe storage classes), and the kept tests of the two renamed files. 50 others are edited to drop a plan half or a deleted item (the api_surface round trips; the simd_emulated, extended-range, recursion, dynamic-root, handles, heap-storage-read and mesh lowering cases). 6512 remain. engine_graphics_binder.rs and engine_heap_binder.rs keep one and two tests and are renamed engine_unattached_colors.rs and engine_heap_groups.rs. - The runtime guard test's list of files the runtime inputs reach without being inputs drops the seven no input reaches since the cut: cache/digest.rs, lower/simd/divergent.rs, lower/simd/workgroup.rs, pipeline/artifact.rs, pipeline/layout.rs, pipeline/stage_io.rs and pipeline/vertex.rs; three of its reasons that named the plan or the binder say what reaches the file now. 559 public items leave (api_signatures.tsv: 55 structs, 26 enums, 140 variants, 245 fields, 52 methods, 24 associated constants, 7 constants, 5 functions, 5 impls). Consumer search, the consumer's development at 92ffbed817, `git grep -w NAME` of each of the 112 removed names: 0 hits for 105; the others are the consumer's own items: TessellationFactors 4 (its Bound::TessellationFactors), YCbCrMatrix 3 (its own string and doc), texel_rows 2 (its own fn), ThreadgroupsIndirect 6 (its own Dispatch enums and rt::Dispatch::Indirect), DrawIndexed 1 (a doc naming MTLIndirectCommandType values), covers 109 and plan 105 (generic words; the `.covers(` calls are its Extent's, the `.plan(` calls its video encoder's rate.plan). Its one import of metal2vulkan::bind is the argument-buffer layout types, which stay. The forms' audit. A texture over a buffer: the runtime's tests::over::every_device_holds_a_texture_over_a_buffer_in_place. A two-plane YCbCr sample: no runtime test; the runtime makes no texture of a two-plane YCbCr format (Gap::TextureFormat, the runtime README's "A format is made where the translator's format table maps it" row), the conformance cases ycbcr_gathers and ycbcr_textures record Metal's answers, and known-gaps-rt.tsv lists the runtime's refusals (ycbcr-gathers-*, ycbcr-texel-reads-420v). Versions: - RUNTIME_VERSION 2550: it covers plan instantiation and the binder's run-time data. Nothing calls those since step 2: the runtime never used the binder, and the own-context executor is gone. A run of an unchanged artifact does nothing different, so the guard hash (runtime-sources.sha256) moves alone, and the RUNTIME_VERSION doc is rewritten to name what it still covers. - SEMANTICS_VERSION 2273: no output changes for any input that still exists. The TexelRows and YCbCrInPlace forms, their facts, push fields and the two notes were reachable only through LoweringInputs::ycbcr_in_place, ycbcr_planes_sampled and texel_rows. Only the binder set those; the runtime sets none. The function key appended each of them only when set, so every surviving key hashes the same bytes. Two type declarations stay where they were, so module words do not move: bool in the bicubic types, uvec4 in the bicubic routines. Byte-identical modules are expected, not verified here; the 252-row hash probe is the check. - ARTIFACT_FORMAT_VERSION 591: the codec tags enum variants by name. The removed RuntimeFact, PushField and PrecisionNote variants leave their tags unused, which cache/mod.rs's rule says needs no bump: an old entry holding one fails to decode, which is a miss. No codec_struct field is removed. That is why SamplerDesc.ycbcr stays. The guard hash (crates/metal2vulkan-validation/runtime-sources.sha256) moves for the bind/ sources this deletes and edits and for vk/draw.rs, which leaves its list. No run of an unchanged artifact changes: what stays in bind/ computes what it did (the heap's tier check takes the same storage format; its removed sampled branch had no caller). Docs: docs/API.md (section 5 is the interface; the binding and plan sections go), README.md, docs/ARCHITECTURE.md, docs/HOWTO.md, docs/VALIDATION.md, the runtime README's DrawInput and identity-domain rows, docs/REFUSALS.md (regenerated; the binder's section goes), api_reference.md, api_signatures.tsv (blessed: removals only), tests/api_surface.rs, the signatures floor (5000), the bind modules' own docs, and the public field docs of PushField, RuntimeFact and SpecKey that named BindState, BindShape or BindingPlan. AGENTS.md: the project table names pipelines and their interfaces, not binding plans; its "core lives in" line stays true (bind/ still holds what the lowering reads). Verified on 31692939d4, this commit's tree (steelbrain/cutbinder-probe-6): job m3-max-68107, fmt, signatures, refusal surface, clippy -D warnings (workspace plain, --cfg m2v_gpu, --cfg m2v_cpu_icd; the translator with no feature and with each alone; the AIR crate alone), workspace Rustdoc -D warnings, each crate's private intra-doc links at 0, api-docs; job m3-max-68109, the product, validation and conformance suites, doctests, and on lavapipe the validation and runtime suites under --cfg m2v_cpu_icd, the conformance replay and the public cases' qualification.
259 lines
12 KiB
Rust
259 lines
12 KiB
Rust
use sha2::{Digest, Sha256};
|
|
use std::fs;
|
|
use std::path::{Path, PathBuf};
|
|
mod build_support;
|
|
mod product_fingerprint;
|
|
use build_support::hash_files;
|
|
use product_fingerprint::{collect_files, product_fingerprint};
|
|
|
|
fn main() {
|
|
// The product fingerprint (`product_fingerprint.rs`): the translator's and the dev-tools
|
|
// crate's sources beside this crate in the workspace's crates/, and nothing of this crate.
|
|
println!(
|
|
"cargo:rustc-env=METAL2VULKAN_PRODUCT_FINGERPRINT={}",
|
|
product_fingerprint(Path::new(".."))
|
|
);
|
|
|
|
// This crate's own sources (its manifest, this script and its fingerprint modules, and every
|
|
// file under src/): the build
|
|
// identity a device worker reports, so a parent refuses a worker rebuilt since it started. It
|
|
// keys one cached fact: a case's reference facts (`c3::reference::CASE_FACTS_ABI`), which a
|
|
// case's check derives through most of this crate.
|
|
let validation = PathBuf::from(".");
|
|
let mut validation_hash = Sha256::new();
|
|
hash_files(&mut validation_hash, &validation, &crate_files(&validation));
|
|
println!(
|
|
"cargo:rustc-env=METAL2VULKAN_VALIDATION_FINGERPRINT={}",
|
|
hex(&validation_hash.finalize())
|
|
);
|
|
|
|
// The runtime crate's sources (`metal2vulkan-runtime`: its manifest and the files its module
|
|
// tree compiles, `build_support::product_files`), through which the engine candidate runs a
|
|
// case: a row it ran is current only for this build of them
|
|
// (`candidate::engine::runtime_fingerprint`).
|
|
let runtime_crate = Path::new("../metal2vulkan-runtime");
|
|
println!(
|
|
"cargo:rerun-if-changed={}",
|
|
runtime_crate.join("src").display()
|
|
);
|
|
let mut runtime_crate_files = vec![runtime_crate.join("Cargo.toml")];
|
|
runtime_crate_files.extend(build_support::product_files(runtime_crate));
|
|
runtime_crate_files.sort();
|
|
let mut runtime_crate_hash = Sha256::new();
|
|
hash_files(
|
|
&mut runtime_crate_hash,
|
|
Path::new(".."),
|
|
&runtime_crate_files,
|
|
);
|
|
println!(
|
|
"cargo:rustc-env=METAL2VULKAN_RUNTIME_CRATE_FINGERPRINT={}",
|
|
hex(&runtime_crate_hash.finalize())
|
|
);
|
|
|
|
// Authoring-capability classification (`triage::ANALYZER_ABI`) reads exactly these files of
|
|
// this crate beside the product: its manifest (which selects the product's features) and the
|
|
// modules its non-test code reaches. An edit to one invalidates the cached facts; an edit
|
|
// anywhere else in the crate does not. `triage`'s key test holds the list closed over every
|
|
// module file those sources reach.
|
|
let classifier_inputs = [
|
|
"Cargo.toml",
|
|
"src/triage.rs",
|
|
"src/air.rs",
|
|
"src/air/calls.rs",
|
|
"src/air/fc_specialize.rs",
|
|
"src/air/meta.rs",
|
|
"src/air/meta/embedded.rs",
|
|
"src/air/meta/fragment.rs",
|
|
"src/air/meta/function_constants.rs",
|
|
"src/air/meta/globals.rs",
|
|
"src/air/meta/intersections.rs",
|
|
"src/air/meta/kernel.rs",
|
|
"src/air/meta/mesh.rs",
|
|
"src/air/meta/textures.rs",
|
|
"src/air/meta/types.rs",
|
|
"src/air/meta/vertex.rs",
|
|
"src/air/projection.rs",
|
|
"src/air/reflect.rs",
|
|
"src/air/reflect/access.rs",
|
|
"src/air/reflect/build.rs",
|
|
"src/air/reflect/descriptors.rs",
|
|
"src/air/reflect/samplers.rs",
|
|
"src/air/sanitize.rs",
|
|
"src/air/text.rs",
|
|
"src/air/visible_references.rs",
|
|
"src/executor_contract.rs",
|
|
"src/executor_contract/mesh.rs",
|
|
"src/executor_contract/min_lod_clamp.rs",
|
|
"src/executor_contract/rate_map.rs",
|
|
"src/executor_contract/rate_map/layout.rs",
|
|
"src/executor_contract/rate_map/value.rs",
|
|
"src/executor_contract/sample_rate.rs",
|
|
"src/executor_contract/seq_cst_fence.rs",
|
|
"src/requirement.rs",
|
|
"src/check/cfg_fact.rs",
|
|
"src/observation_contract.rs",
|
|
"src/observation_contract/comparison.rs",
|
|
"src/case.rs",
|
|
"src/hash.rs",
|
|
];
|
|
let classifier_files = classifier_inputs
|
|
.iter()
|
|
.map(|path| validation.join(path))
|
|
.collect::<Vec<_>>();
|
|
let mut classifier_hash = Sha256::new();
|
|
hash_files(&mut classifier_hash, &validation, &classifier_files);
|
|
println!(
|
|
"cargo:rustc-env=METAL2VULKAN_CLASSIFIER_INPUTS={}",
|
|
classifier_inputs.join(":")
|
|
);
|
|
println!(
|
|
"cargo:rustc-env=METAL2VULKAN_CLASSIFIER_FINGERPRINT={}",
|
|
hex(&classifier_hash.finalize())
|
|
);
|
|
|
|
// The product's runtime: the modules that act on a compiled pipeline after the compile, whose
|
|
// behaviour C3's currency holds to `metal2vulkan::cache::RUNTIME_VERSION` beside an artifact's
|
|
// content digest. That is `src/bind` (argument-buffer layouts, the texel decoders, rate maps,
|
|
// indirect-command records, the device replay's helpers, the heap classes and status words),
|
|
// the device a run opens and what it enables (`src/device`,
|
|
// `src/ash_interop`), the Vulkan and Metal vocabularies the runtime maps (`src/vk`,
|
|
// `src/metal`, and the AIR front end's `metal2vulkan-air/src/metal`, whose `MTLDataType`
|
|
// `metal` re-exports), the record and table formats it writes (indirect commands, the rate and
|
|
// tile maps, function tables; the rate map's and function table's words are the AIR front end's
|
|
// `metal2vulkan-air/src/canon` formats), root tables, handles and the threadgroup regions'
|
|
// alignment (`src/memory`), the dispatch-region encoding (`src/lower/dispatch.rs`, and the
|
|
// used-parameter walk it reads, `src/lower/users.rs`), a patch's factor bytes
|
|
// (`src/lower/tessellation/factors.rs`),
|
|
// the sRGB steps the ASTC and PVRTC decoders read (`src/lower/arith/srgb.rs`), the sRGB
|
|
// encode the YCbCr write takes from `air.pack`'s lowering (`src/lower/arith/pack.rs`), and
|
|
// half-float conversion. The translator's paths above are below its crate (`metal2vulkan/src/...`). Each
|
|
// path is a product file below the workspace's crates/ directory, this crate's parent: those
|
|
// listed here and the Rust sources under `metal2vulkan/src/bind/`, test modules aside
|
|
// (`runtime_files`, so a file added there joins), all sorted as strings. The guard test in
|
|
// `candidate::engine::artifact` requires this hash to be the one validation pins
|
|
// (`runtime-sources.sha256`), and the inputs to be closed over the module files their non-test
|
|
// code reaches (each is an input, or listed there with why a run does not depend on it beyond
|
|
// the artifact digest).
|
|
let listed = [
|
|
"metal2vulkan-air/src/canon/function_table.rs",
|
|
"metal2vulkan-air/src/canon/rate_map_data.rs",
|
|
"metal2vulkan-air/src/metal/generated.rs",
|
|
"metal2vulkan-air/src/metal/mod.rs",
|
|
"metal2vulkan/src/ash_interop/convert.rs",
|
|
"metal2vulkan/src/ash_interop/mod.rs",
|
|
"metal2vulkan/src/ash_interop/query.rs",
|
|
"metal2vulkan/src/device/check.rs",
|
|
"metal2vulkan/src/device/derive.rs",
|
|
"metal2vulkan/src/device/description.rs",
|
|
"metal2vulkan/src/device/enables.rs",
|
|
"metal2vulkan/src/device/function_storage.rs",
|
|
"metal2vulkan/src/device/khronos.rs",
|
|
"metal2vulkan/src/device/mechanism.rs",
|
|
"metal2vulkan/src/device/metal.rs",
|
|
"metal2vulkan/src/device/mod.rs",
|
|
"metal2vulkan/src/device/policy.rs",
|
|
"metal2vulkan/src/device/profile.rs",
|
|
"metal2vulkan/src/device/requirements.rs",
|
|
"metal2vulkan/src/device/subgroup.rs",
|
|
"metal2vulkan/src/float16.rs",
|
|
"metal2vulkan/src/indirect_commands.rs",
|
|
"metal2vulkan/src/indirect_commands/descriptor.rs",
|
|
"metal2vulkan/src/indirect_commands/host.rs",
|
|
"metal2vulkan/src/lower/dispatch.rs",
|
|
"metal2vulkan/src/lower/users.rs",
|
|
"metal2vulkan/src/lower/arith/exact_division.rs",
|
|
"metal2vulkan/src/lower/arith/pack.rs",
|
|
"metal2vulkan/src/lower/arith/srgb.rs",
|
|
"metal2vulkan/src/lower/tessellation/factors.rs",
|
|
"metal2vulkan/src/memory/arena.rs",
|
|
"metal2vulkan/src/memory/handles.rs",
|
|
"metal2vulkan/src/memory/roots.rs",
|
|
"metal2vulkan/src/metal/bicubic.rs",
|
|
"metal2vulkan/src/metal/format/extended_srgb.rs",
|
|
"metal2vulkan/src/metal/format/footprint.rs",
|
|
"metal2vulkan/src/metal/format/mod.rs",
|
|
"metal2vulkan/src/metal/format/packed_codes.rs",
|
|
"metal2vulkan/src/metal/format/padded_srgb.rs",
|
|
"metal2vulkan/src/metal/format/word.rs",
|
|
"metal2vulkan/src/metal/generated.rs",
|
|
"metal2vulkan/src/metal/mod.rs",
|
|
"metal2vulkan/src/metal/sampler.rs",
|
|
"metal2vulkan/src/metal/state.rs",
|
|
"metal2vulkan/src/metal/texel_format.rs",
|
|
"metal2vulkan/src/metal/vertex.rs",
|
|
"metal2vulkan/src/pipeline/table.rs",
|
|
"metal2vulkan/src/pipeline/tile_map.rs",
|
|
"metal2vulkan/src/vk/generated.rs",
|
|
"metal2vulkan/src/vk/mod.rs",
|
|
"metal2vulkan/src/vk/structs.rs",
|
|
];
|
|
let product = PathBuf::from("..");
|
|
let mut runtime_inputs = listed.map(String::from).to_vec();
|
|
runtime_files(
|
|
&product,
|
|
Path::new("metal2vulkan/src/bind"),
|
|
&mut runtime_inputs,
|
|
);
|
|
runtime_inputs.sort();
|
|
let runtime_files = runtime_inputs
|
|
.iter()
|
|
.map(|path| product.join(path))
|
|
.collect::<Vec<_>>();
|
|
let mut runtime_hash = Sha256::new();
|
|
hash_files(&mut runtime_hash, &product, &runtime_files);
|
|
println!(
|
|
"cargo:rustc-env=METAL2VULKAN_RUNTIME_INPUTS={}",
|
|
runtime_inputs.join(":")
|
|
);
|
|
println!(
|
|
"cargo:rustc-env=METAL2VULKAN_RUNTIME_FINGERPRINT={}",
|
|
hex(&runtime_hash.finalize())
|
|
);
|
|
}
|
|
|
|
/// This crate's manifest, build script and its fingerprint modules (`product_fingerprint.rs`, its
|
|
/// copy of `build_support.rs`), and every file under its `src/`, sorted.
|
|
fn crate_files(root: &Path) -> Vec<PathBuf> {
|
|
let mut files = vec![
|
|
root.join("Cargo.toml"),
|
|
root.join("build.rs"),
|
|
root.join("product_fingerprint.rs"),
|
|
root.join("build_support.rs"),
|
|
];
|
|
collect_files(&root.join("src"), &mut files);
|
|
files.sort();
|
|
files
|
|
}
|
|
|
|
/// Every Rust source below `relative` under `product` but test modules (a `tests` directory, a
|
|
/// `tests.rs` or `*_tests.rs` file) and hidden files, pushed as paths relative to `product` with
|
|
/// `/` separators: those of `metal2vulkan/src/bind/`, whose non-test code reads no data file
|
|
/// (its `.txt` files are its tests' measured answers). Cargo reruns this script when anything
|
|
/// under the directory changes, so a file added there joins the runtime's inputs.
|
|
fn runtime_files(product: &Path, relative: &Path, output: &mut Vec<String>) {
|
|
let directory = product.join(relative);
|
|
println!("cargo:rerun-if-changed={}", directory.display());
|
|
let entries = fs::read_dir(&directory)
|
|
.unwrap_or_else(|error| panic!("read {}: {error}", directory.display()));
|
|
for entry in entries {
|
|
let entry = entry.expect("directory entry");
|
|
let name = entry.file_name().to_string_lossy().into_owned();
|
|
if name.starts_with('.') {
|
|
continue;
|
|
}
|
|
let path = relative.join(&name);
|
|
if entry.path().is_dir() {
|
|
if name != "tests" {
|
|
runtime_files(product, &path, output);
|
|
}
|
|
} else if name != "tests.rs" && !name.ends_with("_tests.rs") && name.ends_with(".rs") {
|
|
output.push(path.to_string_lossy().replace('\\', "/"));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// `bytes` as lowercase hex, two digits a byte: the form of every digest string here.
|
|
fn hex(bytes: &[u8]) -> String {
|
|
bytes.iter().map(|byte| format!("{byte:02x}")).collect()
|
|
}
|