Files
metal2vulkan/crates/metal2vulkan-validation/Cargo.toml
T
Anees Iqbal cc4c44bd7e Make the GPU hazard tests opt-in under --cfg m2v_gpu_hazards
Owner's rule (11-05): tests that fault a real GPU, hold one for long, or
allocate toward its limits never run in sweeps, lanes, stress loops or
gates; they run only when that feature is tested, on request. On the M3
Max a GPU fault's recovery fails other processes' command buffers in
flight (.config/nextest.toml has the measurement). #[ignore] is not
enough, since lanes run --run-ignored all, so the gate is a cfg: on a
real GPU a hazard compiles only under --cfg m2v_gpu --cfg
m2v_gpu_hazards. Under --cfg m2v_cpu_icd it compiles and runs as
before, so lavapipe CI keeps them.

Gated (each doc comment now says which hazard it is):
- runtime_lane::host_memory::a_gpu_fault_fails_its_command_buffer_and_the_queue_runs_on
  and ::a_lost_device_s_command_buffers_let_go_of_their_pools_after_the_driver_s_completion:
  GPU writes into read-only host pages, real page faults (2 and 3).
- host_memory::a_no_copy_buffer_s_pages_are_imported_when_it_is_made:
  no-copy buffers of 1 to 16 GiB.
- vertex_strides::vertex_fetches_past_4_gib_of_a_buffer_are_refused and
  stage_in_strides::stage_in_fetches_past_4_gib_of_a_buffer_are_refused
  (and their `Large` helper): 4 GiB + 4 KiB buffers.
- heaps::the_largest_heap_lies_in_one_allocation: a heap of the device's
  largest allocation, up to 4 GiB.
- cross_queue_shadows: the three tests whose spin holds one command
  buffer for 1.5 s.
- framebuffer_fetch::storage_forms::a_steady_stream_takes_the_storage_form_at_its_first_lone_commit:
  a single-dispatch spin of up to 1 s that only its cap ends on Apple GPUs.
- detach::table_3_a_detach_waits_for_running_work_then_refuses: single
  dispatches calibrated to 500 ms (up to 2 s loaded), the cap alone ending
  them on the M3 Max, where Metal ended some 0.5 s dispatches as hung.
- runtime tests::detach_lost: one dispatch of 2^25 loads (about 4.5 s on
  the M3 Max) whose word the GPU does not see raised.

Made safe instead of gated:
- mesh_draws::object_grids_run_as_metal_runs_them: on a GPU without the
  hazards cfg, grids past 2^20 object threadgroups are skipped (printed),
  as a CPU ICD already skips them; the 70k to 262k grids and the
  past-the-watchdog discards still run. The 4.6M grid took 12 s in one
  command buffer on the RTX 5080 Laptop GPU.
- detach::a_resident_buffer_no_command_reaches_fails_its_submission_once_detached
  takes the spin kernel without calibrating a cap (`spin_kernel`): its
  word is raised, so the cap never mattered, and the calibration's
  unraised runs are bounded only at 16 x 50 ms.
- cross_queue_shadows::an_encoder_after_a_signal_reads_what_another_queue_wrote_after_it
  no longer calibrates a spin it never ran.

The cfg is declared for unexpected_cfgs in the runtime, validation and
conformance manifests. docs/VALIDATION.md says what a hazard is and how
to run one; CONTRIBUTING.md and .config/nextest.toml mention the cfg.
The device lane is unaffected: its builds set RUSTFLAGS to --cfg
m2v_gpu alone. No product code changed (no RUNTIME_VERSION bump; the
runtime-sources pin skips test modules).

Verified on this Mac (no test run on any GPU): cargo fmt --all; cargo
clippy --workspace --all-targets --all-features -D warnings clean plain,
under --cfg m2v_gpu, --cfg m2v_gpu --cfg m2v_gpu_hazards and --cfg
m2v_cpu_icd. cargo nextest list -p metal2vulkan-runtime -p
metal2vulkan-validation --all-features --run-ignored all: under --cfg
m2v_gpu 5022 tests, under --cfg m2v_gpu --cfg m2v_gpu_hazards 5034, and
the difference is exactly the 12 gated tests; all 12 are listed under
--cfg m2v_cpu_icd (5000 tests).

(cherry picked from commit 7b57d9a87a3dd8275a2ece547fc0bd9b9cb6808c)
2026-11-05 00:43:51 -08:00

129 lines
3.8 KiB
TOML

[package]
name = "metal2vulkan-validation"
version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
authors.workspace = true
description = "Authored-case validation tools for metal2vulkan"
# Never publish this workspace member to crates.io (oracle/executor + private corpus).
publish = false
autobins = false
readme = "README.md"
# Belt-and-suspenders if someone packages this crate locally: keep private harvest out.
exclude = [
"corpus/local/",
"corpus/local/**",
"target/",
"**/*.air",
"**/*.metallib",
"**/*.mtlb",
"**/*.spv",
"**/*.spvasm",
]
[dependencies]
# `cli` adds nothing validation uses (it builds the product's binary and enables `serde`), but with
# it the product's library here has the feature set of `cargo test -p metal2vulkan --all-features`,
# so one target dir builds the product (and the runtime on it) once for both suites, not twice.
metal2vulkan = { path = "../metal2vulkan", features = ["serde", "ash", "cli"] }
# The AIR front end the product pins exactly: the same crate the product
# builds, which validation decodes, canonicalizes, and audits AIR through.
metal2vulkan-air = { path = "../metal2vulkan-air" }
metal2vulkan-runtime = { path = "../metal2vulkan-runtime" }
metal2vulkan-devtools = { path = "../metal2vulkan-devtools" }
base64 = "0.22"
libc.workspace = true
memchr = "2"
rusqlite = { version = "0.32", features = ["bundled"] }
serde.workspace = true
serde_json.workspace = true
sha2.workspace = true
wait-timeout = "0.2"
[target.'cfg(target_os = "macos")'.dependencies]
block2 = "0.6"
objc2 = "0.6"
objc2-foundation = "0.3"
objc2-metal = "0.3"
ash = { workspace = true, features = ["loaded"] }
[target.'cfg(target_os = "linux")'.dependencies]
ash = { workspace = true, features = ["loaded"] }
# Device-executing tests are gated on non-default cfgs rather than features, because the ordinary
# gate builds with `--all-features`: `--cfg m2v_gpu` (a real GPU) and `--cfg m2v_cpu_icd` (a CPU
# Vulkan ICD such as lavapipe). See docs/VALIDATION.md. `--cfg m2v_system_alloc` keeps the system
# allocator in the lib test binary for the runtime lanes' cost measurements (worker/alloc.rs).
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(m2v_gpu)", "cfg(m2v_cpu_icd)", "cfg(m2v_gpu_hazards)", "cfg(m2v_system_alloc)"] }
[build-dependencies]
sha2.workspace = true
[dev-dependencies]
# Resolves the modules the classifier's sources reach (triage's analyzer-key test).
syn = { version = "2", features = ["full", "visit"] }
proc-macro2 = "1"
# A binary without unit tests sets `test = false`: `cargo test`, nextest and `clippy --all-targets`
# then build no test harness of it (one compile and one link of the whole translator, runtime and
# validation saved per binary on every test build). The integration test `bins.rs` fails when such a
# binary's sources hold a `#[test]`; a binary that gains unit tests drops the line.
[[bin]]
name = "corpus-draw-ab"
path = "src/bin/corpus-draw-ab.rs"
[[bin]]
name = "command-replay"
path = "src/bin/command-replay.rs"
test = false
[[bin]]
name = "corpus-harvest"
path = "src/bin/corpus-harvest.rs"
[[bin]]
name = "corpus-index"
path = "src/bin/corpus-index.rs"
test = false
[[bin]]
name = "corpus-case-check"
path = "src/bin/corpus-case-check.rs"
test = false
[[bin]]
name = "corpus-status"
path = "src/bin/corpus-status.rs"
test = false
[[bin]]
name = "corpus-metal"
path = "src/bin/corpus-metal.rs"
test = false
[[bin]]
name = "corpus-moltenvk"
path = "src/bin/corpus-moltenvk.rs"
test = false
[[bin]]
name = "corpus-vulkan"
path = "src/bin/corpus-vulkan.rs"
test = false
[[bin]]
name = "corpus-pipeline"
path = "src/bin/corpus-pipeline.rs"
[[bin]]
name = "corpus-triage"
path = "src/bin/corpus-triage.rs"
[[bin]]
name = "format-scout"
path = "src/bin/format-scout.rs"
test = false