What: metal2vulkan-runtime writes the FALLBACK repro bundle the command line writes for its own failures when it refuses a library or pipeline creation, where METAL2VULKAN_REPRO_DIR names a directory (unset, nothing is written). - The CLI's bundle writer moves into the library as the hidden crate-root module metal2vulkan::repro (feature serde), shared by the binary and the runtime. A bundle's directory is named by its content (metal2vulkan-repro-<16 hex>), written under a temporary name and renamed, so an identical failure is written once, across threads, processes and runs. The CLI's own bundles keep their files (input, profile.json, the descriptor files, repro.sh, repro-command.txt, failure.txt); only the directory's name changed, so a bundle written before still replays. - The CLI takes --device FILE in place of --profile: the JSON of a DeviceDescription and DevicePolicy (ReproDevice), which builds the runtime's own compile device. - The runtime hooks each creation where its refusal returns: a library of a metallib, a function's lookup, every compute and tile state (ComputePipelineState/TileState::create_adding: creations, added binary functions, archive adds) and every render state (GraphicsState::create_reflecting). It bundles Unsupported, NotImplemented and Compile refusals but a cancelled compile and a name the library lacks (Metal's own nil); never Invalid/Nil/MetalError. The bundle holds the library's bytes, device.json, the request as the CLI's options and descriptor files, and failure.txt with the call, the refusal and what the command does not replay. That list comes from a full destructuring of the compute, tile and render descriptors (and the stage functions): a new descriptor field fails to compile in repro.rs until it is replayed or listed. - Bounded: at most 32 bundles and 256 MiB per process; past either nothing more is written and one line says so. Written on the refusing thread; the call returns the same refusal; a write failure is said once. Each bundle is named in one line through the device's message sink (id name metal2vulkan-repro). The runtime's metal2vulkan dependency gains serde. - Not bundled: mesh states (no CLI mesh path), a dispatch's or draw's later variant, driver VkPipeline makings, Metal-source libraries. Docs: env_vars registry, README CLI, docs/HOWTO.md section 4, the runtime README's Errors section, the CLI help. Tests: runtime CPU tests of the bounds (a tally with the seam's limits); a lavapipe/GPU device test (ob3_stage_input with no stage-input descriptor: one bundle with the expected parts and command, device.json rebuilding the runtime's compile device by profile fingerprint and answering the same refusal, none for a second identical refusal or a missing name, none without a directory); CLI tests replaying library-written runtime bundles (compute, and render with a vertex descriptor) through repro.sh to the same FALLBACK, and --device compiling what --profile does. Verified at ae56b195e9 (msi, m3-max-32986): metal2vulkan cli, api_surface and api_signatures 25 passed; runtime repro tests 9 passed; clippy -p metal2vulkan -p metal2vulkan-runtime all targets, all features 0. Lavapipe (m3-max-32978): repro_device writes one bundle that the CLI replays to the same refusal; a second identical refusal writes nothing.
54 lines
2.1 KiB
Bash
Executable File
54 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Renders the consumer reference of the new API's frozen surface, warnings
|
|
# denied. CI runs it after the ordinary documentation build; so does the gate in CONTRIBUTING.md.
|
|
#
|
|
# scripts/api-docs # render into <target>/doc/metal2vulkan
|
|
# scripts/api-docs --open # and open it in a browser
|
|
#
|
|
# It is the ordinary rustdoc build of the library with every feature: the crate root shows the new
|
|
# API's public module roots, `Budget`, and `CancelToken`, and hides the hidden crate-root
|
|
# modules (`env_vars` and `repro`, which the binary and the runtime use). Hidden items and
|
|
# submodules inside the roots stay hidden.
|
|
# `crates/metal2vulkan/tests/api_surface.rs` keeps that set equal to the pinned surface table.
|
|
#
|
|
# The previous output is removed first, so no page of another build survives in the reference.
|
|
# Rustdoc renders a link to an item it does not document (a hidden or internal one) as its
|
|
# bracketed text, without a warning; the script fails when a page shows one, so the reference
|
|
# never points at internals.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
case "${1-}" in
|
|
"" | --open) ;;
|
|
*)
|
|
echo "usage: scripts/api-docs [--open]" >&2
|
|
exit 64
|
|
;;
|
|
esac
|
|
|
|
target_dir=$(cargo metadata --format-version 1 --no-deps |
|
|
sed -n 's/.*"target_directory":"\([^"]*\)".*/\1/p')
|
|
doc="$target_dir/doc/metal2vulkan"
|
|
rm -rf "$doc"
|
|
export RUSTDOCFLAGS="${RUSTDOCFLAGS-} -D warnings"
|
|
cargo doc -p metal2vulkan --lib --no-deps --all-features
|
|
|
|
if [ ! -f "$doc/pipeline/index.html" ]; then
|
|
echo "scripts/api-docs: $doc has no pipeline module page" >&2
|
|
exit 1
|
|
fi
|
|
unresolved=$(find "$doc" -name '*.html' -print0 |
|
|
xargs -0 grep -L 'http-equiv="refresh"' |
|
|
tr '\n' '\0' |
|
|
xargs -0 grep -Ho '\[<code>[^<]*</code>\]' || true)
|
|
if [ -n "$unresolved" ]; then
|
|
echo "scripts/api-docs: links that did not resolve (to hidden or internal items):" >&2
|
|
printf '%s\n' "$unresolved" | sed "s#^$doc/##" >&2
|
|
exit 1
|
|
fi
|
|
echo "scripts/api-docs: rendered $doc/index.html"
|
|
|
|
if [ "${1-}" = --open ]; then
|
|
cargo doc -p metal2vulkan --lib --no-deps --all-features --open
|
|
fi
|