Files
metal2vulkan/crates/metal2vulkan-conformance/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

73 lines
3.2 KiB
TOML

[package]
name = "metal2vulkan-conformance"
version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
authors.workspace = true
description = "The Metal conformance suite: one case run on Metal and on metal2vulkan-runtime, recorded and compared"
# Never publish this workspace member to crates.io.
publish = false
readme = "README.md"
[dependencies]
# The translator's public API, with the feature set `cargo test -p metal2vulkan --all-features`
# builds, so one target directory builds the product (and the runtime on it) once for every suite
# rather than once per feature set.
metal2vulkan = { path = "../metal2vulkan", features = ["serde", "ash", "cli"] }
metal2vulkan-runtime = { path = "../metal2vulkan-runtime" }
# Fixture paths, `llvm_assemble` and the scratch root: the suite's shaders are the owned public
# fixtures.
metal2vulkan-devtools = { path = "../metal2vulkan-devtools" }
ash = { workspace = true, features = ["loaded"] }
base64 = "0.22"
# The two CPU clocks the cost table reads: the calling thread's and the whole process's
# (`src/clocks.rs`). `std` exposes neither.
libc.workspace = true
serde.workspace = true
serde_json.workspace = true
sha2.workspace = true
[target.'cfg(target_os = "macos")'.dependencies]
# The command-buffer handler blocks the event cases add: `addScheduledHandler:` and
# `addCompletedHandler:` take Objective-C blocks, which is how a probe bounds a wait Metal has no
# bounded form of. Already objc2-metal's own dependency; named here so the suite can build one.
block2 = "0.6"
# `newLibraryWithData:error:` takes a `dispatch_data_t`, which `objc2-metal` binds as
# `dispatch2::DispatchData`. Already that crate's own dependency; named here so the suite can
# build one ([`metal2vulkan_conformance::archives`]).
dispatch2 = "0.3"
objc2 = "0.6"
objc2-foundation = "0.3"
objc2-metal = "0.3"
# The suite's command. It has no unit tests, so `test = false` keeps `cargo test`, nextest and
# `clippy --all-targets` from building and linking a test harness of it.
[[bin]]
name = "conformance"
path = "src/bin/conformance.rs"
test = false
# The run `tests/killed_scratch.rs` kills, to prove that a killed run's scratch directory is swept
# and a live run's is not. A binary rather than a test so the test can find it by path
# (`CARGO_BIN_EXE_scratch-holder`); `test = false` keeps any runner from executing it directly,
# since it waits to be killed.
[[bin]]
name = "scratch-holder"
path = "src/bin/scratch-holder.rs"
test = false
# A reading of which side holds a `compute_pipeline_with_stage_input` call's cost: our translation,
# the driver's compile, or the rest of the call. A probe rather than a test -- it wants one process
# per cache arrangement and prints a table -- so `test = false`.
[[bin]]
name = "stage-input-split"
path = "src/bin/stage-input-split.rs"
test = false
# 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.
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(m2v_gpu)", "cfg(m2v_cpu_icd)", "cfg(m2v_gpu_hazards)"] }