From 39bff0de2ab055cd0d63368e250708219f87bd9e Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sat, 14 Nov 2026 23:21:25 -0800 Subject: [PATCH] The carried test trees read the checkout where the test runner names it Every env!("CARGO_MANIFEST_DIR") in validation's runtime_lane.rs and runtime_lane/ and in metal2vulkan-runtime/src/tests (135 sites) named the directory the test binary was built in. A nextest archive built on msi and run on another node with --workspace-remap read msi's path there: teardown_threads panicked reading runtime_examples.ll, and public_cases read no case shard. metal2vulkan-devtools gets one resolver, workspace_dir(): two levels above the manifest directory the runner names as the test runs (cargo and nextest name the test's crate; a remapped archive names it in the running machine's checkout), where that root holds the validation fixtures, else above the dev-tools crate as built (the fallback fixtures_dir already had). validation_dir() and fixtures_dir() sit on it; engine_dir() is unchanged. The sites move onto them: - fixture reads (fixtures/public, engine/ and examples/) onto fixtures_dir() and engine_dir(), with the two hand-rolled "runtime variable else built" copies (attachment_reads, encoder_holds); - committed cases and observations (validation_dir()/corpus), and public_cases and public_case_names now read the public source rows through source::public_sources_under on fixtures_dir() instead of source::public_sources(), which bakes the path; - the runtime tests' device profiles (validation_dir()/profiles) and degradation_sites' read of the lane's sources; - the conformance recordings, docs/API.md and the runtime's own src/ through workspace_dir(). The imports of std::path the moves left unused are removed. Test-only. tests::the_carried_tests_read_the_checkout_where_the_runner_names_it (devtools, the previous commit) fails before this commit and passes after. Verification: the msi job that builds both commits, runs the remapped archive at each and lints the tip is reported with this sha. With 4e06c87523 (the scan check), e9a0927685 (render_state.rs and line_width tests; the scan covers all of runtime/src), 74aa3e44cc and 086962f1fa (fixes; source.rs fixture reads through fixtures_dir). Test code only. Compiled in m3-max-31605 (msi: clippy x3; scan passes; lavapipe suites 6235 passed, failures all pre-existing pin-97 items or the runtime-sources pin; remapped run with the build tree hidden 201/202, the last needing an all-targets archive, 31641). Base 4e06c87523 (31508): scan lists 135 sites; remapped run fails 63/202. --- crates/metal2vulkan-devtools/src/lib.rs | 46 +++++++++++---- crates/metal2vulkan-devtools/src/tests.rs | 59 +++++++++++++++++++ .../src/render/line_width/tests.rs | 7 +-- .../metal2vulkan-runtime/src/render_state.rs | 16 ++--- .../src/tests/argument_buffers.rs | 3 +- .../src/tests/argument_sampler_count.rs | 3 +- .../metal2vulkan-runtime/src/tests/batches.rs | 3 +- .../src/tests/binary_archive.rs | 11 +--- .../src/tests/capabilities.rs | 9 ++- .../src/tests/compute_create_bench.rs | 4 +- .../src/tests/core_image_libraries.rs | 4 +- .../src/tests/creation_prediction_kinds.rs | 4 +- .../src/tests/creation_prediction_reach.rs | 4 +- .../src/tests/creation_split.rs | 4 +- .../src/tests/deferred_calls.rs | 3 +- .../src/tests/degradation.rs | 2 +- .../src/tests/degradation_catalogue.rs | 5 +- .../src/tests/degradation_sites.rs | 10 ++-- .../src/tests/derived_once.rs | 5 +- .../src/tests/descriptor_key_once.rs | 4 +- .../src/tests/detach_lost.rs | 4 +- .../metal2vulkan-runtime/src/tests/device.rs | 3 +- .../tests/direct_arguments_from_compiled.rs | 4 +- .../src/tests/dirty_pages_device.rs | 4 +- .../src/tests/driver_defects.rs | 7 +-- .../src/tests/dynamic_multi_variable.rs | 4 +- .../metal2vulkan-runtime/src/tests/enables.rs | 9 +-- .../src/tests/encoder_holds.rs | 12 +--- .../src/tests/error_kinds.rs | 2 +- .../src/tests/exit_guard.rs | 2 +- .../src/tests/functions_translated.rs | 4 +- crates/metal2vulkan-runtime/src/tests/heap.rs | 3 +- .../src/tests/icb_records_home.rs | 4 +- .../src/tests/image_plan.rs | 3 +- .../src/tests/interlocked_writes.rs | 3 +- .../src/tests/kept_heap_uses.rs | 5 +- .../src/tests/kept_variants.rs | 5 +- crates/metal2vulkan-runtime/src/tests/memo.rs | 11 ++-- .../src/tests/mesh_reflection_derived.rs | 3 +- crates/metal2vulkan-runtime/src/tests/mod.rs | 4 +- .../src/tests/neutral_zeros_shared.rs | 6 +- .../src/tests/pipeline.rs | 8 +-- .../src/tests/pipeline_wait_order.rs | 3 +- .../src/tests/pool_room_creations.rs | 4 +- .../src/tests/released_programs.rs | 4 +- .../src/tests/rerun_arenas.rs | 4 +- .../src/tests/shadow_carried_read.rs | 5 +- .../src/tests/shadow_host_writes.rs | 4 +- .../src/tests/shadow_merge_read.rs | 5 +- .../src/tests/stage_entries_shared.rs | 4 +- .../src/tests/teardown_threads.rs | 3 +- .../src/tests/twin_flights.rs | 3 +- .../src/tests/uniform_bind_offsets.rs | 4 +- .../src/tests/upload_chunk_zeros.rs | 3 +- .../src/tests/video_interop.rs | 4 +- crates/metal2vulkan-runtime/src/tests/warm.rs | 3 +- .../src/tests/warm_record.rs | 5 +- .../src/runtime_lane.rs | 4 +- .../src/runtime_lane/amplified_draws.rs | 4 +- .../src/runtime_lane/attachment_reads.rs | 8 +-- .../src/runtime_lane/attachmentless.rs | 4 +- .../runtime_lane/buffer_texture_renders.rs | 7 +-- .../src/runtime_lane/commit_costs.rs | 4 +- .../src/runtime_lane/coverage_loop.rs | 3 +- .../src/runtime_lane/cross_queue_shadows.rs | 5 +- .../src/runtime_lane/cubic_reach_costs.rs | 5 +- .../src/runtime_lane/depth_costs.rs | 4 +- .../src/runtime_lane/discard_counts.rs | 4 +- .../src/runtime_lane/discard_hoist.rs | 4 +- .../src/runtime_lane/draw_bases.rs | 2 +- .../src/runtime_lane/driver_deviations.rs | 10 ++-- .../src/runtime_lane/fence_stages.rs | 4 +- .../src/runtime_lane/fetch_costs.rs | 5 +- .../src/runtime_lane/first_use.rs | 4 +- .../src/runtime_lane/first_vertex.rs | 4 +- .../src/runtime_lane/function_tables.rs | 3 +- .../src/runtime_lane/generic_pointers.rs | 4 +- .../src/runtime_lane/global_builtins.rs | 4 +- .../src/runtime_lane/guarded_effects.rs | 4 +- .../src/runtime_lane/heap_layouts.rs | 7 +-- .../src/runtime_lane/helper_select.rs | 4 +- .../src/runtime_lane/helper_tangle.rs | 4 +- .../runtime_lane/indirect_command_buffers.rs | 15 ++--- .../src/runtime_lane/kept_textured.rs | 4 +- .../src/runtime_lane/kept_variants.rs | 5 +- .../src/runtime_lane/layered_passes.rs | 8 +-- .../src/runtime_lane/made_at_creation.rs | 4 +- .../src/runtime_lane/math_routines.rs | 4 +- .../src/runtime_lane/moved_writers.rs | 3 +- .../src/runtime_lane/msaa_depth_moves.rs | 4 +- .../runtime_lane/normalized_vertex_fetch.rs | 9 ++- .../src/runtime_lane/nullable_private.rs | 4 +- .../src/runtime_lane/pipeline_records.rs | 3 +- .../src/runtime_lane/pooled_cells.rs | 3 +- .../src/runtime_lane/post_depth_coverage.rs | 4 +- .../src/runtime_lane/queue_storms.rs | 6 +- .../src/runtime_lane/raster_orders.rs | 4 +- .../src/runtime_lane/raster_sample_counts.rs | 3 +- .../src/runtime_lane/rate_mapped_passes.rs | 3 +- .../src/runtime_lane/read_through_views.rs | 7 +-- .../src/runtime_lane/render_barriers.rs | 7 +-- .../src/runtime_lane/render_state.rs | 6 +- .../src/runtime_lane/renders.rs | 6 +- .../src/runtime_lane/rotated_textures.rs | 4 +- .../src/runtime_lane/sample_imageblocks.rs | 4 +- .../src/runtime_lane/sampler_tables.rs | 3 +- .../src/runtime_lane/stage_in_regions.rs | 4 +- .../src/runtime_lane/stage_in_strides.rs | 7 +-- .../src/runtime_lane/teardown_holders.rs | 7 +-- .../src/runtime_lane/tensors_air29.rs | 4 +- .../src/runtime_lane/vertex_strides.rs | 4 +- .../src/runtime_lane/view_attachments.rs | 5 +- .../src/runtime_lane/viewport_ranges.rs | 3 +- .../src/runtime_lane/xr_codes.rs | 9 ++- crates/metal2vulkan-validation/src/source.rs | 11 ++-- 115 files changed, 269 insertions(+), 397 deletions(-) create mode 100644 crates/metal2vulkan-devtools/src/tests.rs diff --git a/crates/metal2vulkan-devtools/src/lib.rs b/crates/metal2vulkan-devtools/src/lib.rs index 42f936062..20b105600 100644 --- a/crates/metal2vulkan-devtools/src/lib.rs +++ b/crates/metal2vulkan-devtools/src/lib.rs @@ -35,23 +35,49 @@ pub mod stitched; pub mod tools; pub mod xr_bicubic; -/// The validation crate's `fixtures/public` (`crates/metal2vulkan-validation/fixtures/public`, -/// read-only): beside the manifest directory the test runner names as a test runs (`cargo test` -/// and `cargo nextest` name the test's crate; a run of a nextest archive on another machine names -/// it in that machine's checkout, `--workspace-remap`), else beside this crate as it was built. -pub fn fixtures_dir() -> PathBuf { - let beside = |manifest: &Path| { - (manifest.parent()).map(|crates| crates.join("metal2vulkan-validation/fixtures/public")) +#[cfg(test)] +mod tests; + +/// The workspace's root (read-only), as the test runner names it as a test runs: two levels above +/// the manifest directory it names (`cargo test` and `cargo nextest` name the test's crate, +/// `crates/`; a run of a nextest archive on another machine names it in that machine's +/// checkout, `--workspace-remap`) where that root holds the validation crate's fixtures, else above +/// this crate as it was built. Tests read the checkout through it and the helpers on it +/// ([`validation_dir`], [`fixtures_dir`], [`engine_dir`]), never through a path the build baked in +/// (`env!("CARGO_MANIFEST_DIR")`), which names the build machine's checkout. +pub fn workspace_dir() -> PathBuf { + let root = |manifest: &Path| { + manifest + .parent() + .and_then(Path::parent) + .map(Path::to_path_buf) }; let running = std::env::var_os("CARGO_MANIFEST_DIR") - .and_then(|manifest| beside(Path::new(&manifest))) - .filter(|fixtures| fixtures.is_dir()); + .and_then(|manifest| root(Path::new(&manifest))) + .filter(|root| root.join(VALIDATION).join(FIXTURES).is_dir()); running.unwrap_or_else(|| { - beside(Path::new(env!("CARGO_MANIFEST_DIR"))) + root(Path::new(env!("CARGO_MANIFEST_DIR"))) .expect("the dev-tools crate lies in the workspace's crates/") }) } +/// The validation crate, relative to the workspace. +const VALIDATION: &str = "crates/metal2vulkan-validation"; + +/// The public fixtures, relative to the validation crate. +const FIXTURES: &str = "fixtures/public"; + +/// The validation crate's directory under [`workspace_dir`] (read-only): its committed cases and +/// observations (`corpus/`), device profiles (`profiles/`) and sources. +pub fn validation_dir() -> PathBuf { + workspace_dir().join(VALIDATION) +} + +/// The validation crate's `fixtures/public` under [`validation_dir`] (read-only). +pub fn fixtures_dir() -> PathBuf { + validation_dir().join(FIXTURES) +} + /// [`fixtures_dir`]'s `engine` (read-only; the engine's own fixtures). pub fn engine_dir() -> PathBuf { fixtures_dir().join("engine") diff --git a/crates/metal2vulkan-devtools/src/tests.rs b/crates/metal2vulkan-devtools/src/tests.rs new file mode 100644 index 000000000..ecd70c992 --- /dev/null +++ b/crates/metal2vulkan-devtools/src/tests.rs @@ -0,0 +1,59 @@ +//! Checks of the test trees that read the checkout through this crate's directory helpers. + +use std::path::{Path, PathBuf}; + +/// The test trees, relative to the workspace, that run from nextest archives carried to other +/// machines (`cargo nextest run --archive-file ... --workspace-remap `): the runtime +/// lanes and the runtime's lib tests (`src/tests/` and the test modules beside its sources). +const CARRIED: [&str; 3] = [ + "crates/metal2vulkan-validation/src/runtime_lane", + "crates/metal2vulkan-validation/src/runtime_lane.rs", + "crates/metal2vulkan-runtime/src", +]; + +/// The `.rs` files at or below `path`. +fn sources(path: &Path, out: &mut Vec) { + if path.is_dir() { + for entry in std::fs::read_dir(path).unwrap() { + sources(&entry.unwrap().path(), out); + } + } else if path.extension().is_some_and(|extension| extension == "rs") { + out.push(path.to_path_buf()); + } +} + +/// `env!("CARGO_MANIFEST_DIR")` is the directory the test binary was built in. A carried archive +/// runs where that directory does not exist, so a test that reads a fixture, a committed case, a +/// profile or a source file by it fails there ("No such file or directory"), or finds nothing to +/// read. The carried trees read the checkout through [`crate::workspace_dir`] and the helpers on it, +/// which take the directory the test runner names as the test runs; this lists every baked site +/// left, as `file:line`. +#[test] +fn the_carried_tests_read_the_checkout_where_the_runner_names_it() { + let root = crate::workspace_dir(); + let mut files = Vec::new(); + for tree in CARRIED { + let path = root.join(tree); + assert!(path.exists(), "{} is missing", path.display()); + sources(&path, &mut files); + } + files.sort(); + assert!(files.len() > 500, "{} sources read", files.len()); + let mut baked = Vec::new(); + for file in &files { + let text = std::fs::read_to_string(file).unwrap(); + let relative = file.strip_prefix(&root).unwrap().display().to_string(); + for (at, line) in text.lines().enumerate() { + if line.contains("env!(\"CARGO_MANIFEST_DIR\")") { + baked.push(format!("{relative}:{}", at + 1)); + } + } + } + assert!( + baked.is_empty(), + "{} reads of the build's directory in the carried tests (read through \ + metal2vulkan_devtools::{{workspace_dir, validation_dir, fixtures_dir, engine_dir}}):\n{}", + baked.len(), + baked.join("\n") + ); +} diff --git a/crates/metal2vulkan-runtime/src/render/line_width/tests.rs b/crates/metal2vulkan-runtime/src/render/line_width/tests.rs index 7c6b47419..09f94bec6 100644 --- a/crates/metal2vulkan-runtime/src/render/line_width/tests.rs +++ b/crates/metal2vulkan-runtime/src/render/line_width/tests.rs @@ -46,10 +46,9 @@ impl Cell { /// A profile of the repository's, read as the runtime reads its device /// (`DeviceDescription::from_khronos_json`), so this runs from the workspace checkout. fn device(stem: &str) -> Device { - let path = format!( - "{}/../metal2vulkan-validation/profiles/{stem}.json", - env!("CARGO_MANIFEST_DIR") - ); + let path = metal2vulkan_devtools::validation_dir() + .join("profiles") + .join(format!("{stem}.json")); let text = std::fs::read_to_string(&path).unwrap(); let description = DeviceDescription::from_khronos_json(&text, None).unwrap(); Device::new(description, DevicePolicy::default()).unwrap() diff --git a/crates/metal2vulkan-runtime/src/render_state.rs b/crates/metal2vulkan-runtime/src/render_state.rs index 98f67815d..0ee7c606d 100644 --- a/crates/metal2vulkan-runtime/src/render_state.rs +++ b/crates/metal2vulkan-runtime/src/render_state.rs @@ -2602,10 +2602,7 @@ mod tests { use metal2vulkan::vk::PrimitiveTopology as T; use DepthBiasEffect::{Factors, Offset, Saturated}; // The repository's profile: this test runs only from the workspace checkout. - let path = concat!( - env!("CARGO_MANIFEST_DIR"), - "/../metal2vulkan-validation/profiles/moltenvk-m3.json" - ); + let path = metal2vulkan_devtools::validation_dir().join("profiles/moltenvk-m3.json"); let text = std::fs::read_to_string(path).unwrap(); let description = metal2vulkan::device::DeviceDescription::from_khronos_json(&text, None).unwrap(); @@ -3247,10 +3244,7 @@ mod tests { fn biased_depths_move_the_draw_s_viewports() { use metal2vulkan::vk::PrimitiveTopology as T; // The repository's profile: this test runs only from the workspace checkout. - let path = concat!( - env!("CARGO_MANIFEST_DIR"), - "/../metal2vulkan-validation/profiles/moltenvk-m3.json" - ); + let path = metal2vulkan_devtools::validation_dir().join("profiles/moltenvk-m3.json"); let text = std::fs::read_to_string(path).unwrap(); let description = metal2vulkan::device::DeviceDescription::from_khronos_json(&text, None).unwrap(); @@ -3332,10 +3326,8 @@ mod tests { fn a_returned_depth_keeps_its_range_under_the_written_clamp_s_compensation() { use metal2vulkan::vk::PrimitiveTopology as T; // The repository's profile: this test runs only from the workspace checkout. - let path = concat!( - env!("CARGO_MANIFEST_DIR"), - "/../metal2vulkan-validation/profiles/intel-irisxe-rplp-anv.json" - ); + let path = + metal2vulkan_devtools::validation_dir().join("profiles/intel-irisxe-rplp-anv.json"); let text = std::fs::read_to_string(path).unwrap(); let description = metal2vulkan::device::DeviceDescription::from_khronos_json(&text, None).unwrap(); diff --git a/crates/metal2vulkan-runtime/src/tests/argument_buffers.rs b/crates/metal2vulkan-runtime/src/tests/argument_buffers.rs index f133e2753..237b2856d 100644 --- a/crates/metal2vulkan-runtime/src/tests/argument_buffers.rs +++ b/crates/metal2vulkan-runtime/src/tests/argument_buffers.rs @@ -8,7 +8,6 @@ use crate::device::LayerSettingValue; use crate::error::{DriverSetting, Error}; use metal2vulkan::device::DeviceDescription; use metal2vulkan::vk::DriverId; -use std::path::PathBuf; /// MoltenVK 1.4.1 on an Apple M3 Max, as `vulkaninfo` reported it (2026-10-07) with /// `MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS` on (the default) and off. @@ -115,7 +114,7 @@ fn the_instance_asks_moltenvk_for_argument_buffers() { /// as binding through argument buffers, and every other profile as not MoltenVK. #[test] fn the_committed_profiles_read_as_measured() { - let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut moltenvk = 0; for path in std::fs::read_dir(&dir).expect("validation/profiles is readable") { let path = path.expect("directory entry").path(); diff --git a/crates/metal2vulkan-runtime/src/tests/argument_sampler_count.rs b/crates/metal2vulkan-runtime/src/tests/argument_sampler_count.rs index 88b30041d..6a780e64b 100644 --- a/crates/metal2vulkan-runtime/src/tests/argument_sampler_count.rs +++ b/crates/metal2vulkan-runtime/src/tests/argument_sampler_count.rs @@ -64,8 +64,7 @@ fn device(cache: &Path, heard: &Heard) -> Device { /// The element count of the set-1 sampler array of the kernel's pipeline on `device`'s profile. fn kernel_sampler_array(device: &Device) -> u32 { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/tail_argument_samplers.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("tail_argument_samplers.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let function = metal2vulkan::library::Library::from_air(&bitcode) .unwrap() diff --git a/crates/metal2vulkan-runtime/src/tests/batches.rs b/crates/metal2vulkan-runtime/src/tests/batches.rs index 38e5c5c54..5c2387508 100644 --- a/crates/metal2vulkan-runtime/src/tests/batches.rs +++ b/crates/metal2vulkan-runtime/src/tests/batches.rs @@ -277,8 +277,7 @@ fn signals_after_a_failing_encoder_are_dropped() { /// including at a release and on a GPU no lane measured. #[test] fn only_drivers_that_report_their_failures_by_messenger_relay_them() { - let dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut moltenvk = 0; let mut other = 0; for entry in std::fs::read_dir(&dir).expect("validation/profiles is readable") { diff --git a/crates/metal2vulkan-runtime/src/tests/binary_archive.rs b/crates/metal2vulkan-runtime/src/tests/binary_archive.rs index deec604b0..6495f9196 100644 --- a/crates/metal2vulkan-runtime/src/tests/binary_archive.rs +++ b/crates/metal2vulkan-runtime/src/tests/binary_archive.rs @@ -260,9 +260,7 @@ fn writing_into_a_missing_directory_or_onto_a_directory_fails_as_metal_does() { /// The function `name` of the committed AIR of fixture `stem`, its library made anew. fn function(stem: &str, name: &str) -> Function { - let air = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine") - .join(format!("{stem}.air")); + let air = metal2vulkan_devtools::engine_dir().join(format!("{stem}.air")); Library::from_air(&fs::read(air).expect("the committed AIR")) .expect("library") .function(name) @@ -1073,11 +1071,8 @@ fn a_render_lookup_tells_one_adds_stages_from_two_adds() { fn a_metallib_loads_as_an_archive_holding_nothing() { use metal2vulkan_devtools::metallib::{metallib, wrap, MtlbFunction}; let scratch = Scratch::new(); - let air = fs::read( - Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/ob3_texture_array.air"), - ) - .expect("the committed AIR"); + let air = fs::read(metal2vulkan_devtools::engine_dir().join("ob3_texture_array.air")) + .expect("the committed AIR"); let bytes = metallib(&[MtlbFunction { name: "ob3_texture_array", type_code: 2, diff --git a/crates/metal2vulkan-runtime/src/tests/capabilities.rs b/crates/metal2vulkan-runtime/src/tests/capabilities.rs index d301dc8e0..c36596587 100644 --- a/crates/metal2vulkan-runtime/src/tests/capabilities.rs +++ b/crates/metal2vulkan-runtime/src/tests/capabilities.rs @@ -1,8 +1,6 @@ //! `capabilities`: Metal's device queries over every committed device profile //! (`validation/profiles/`, read-only), each checked against its source. -use std::path::PathBuf; - use crate::capabilities::{ amplification_count_supported, linear_alignment_rule, rate_map_layers_supported, sample_count_supported, working_set_buffer_bound, DeviceIdentity, RATE_MAP_LAYERS, @@ -23,7 +21,7 @@ use std::collections::BTreeMap; /// Every committed profile's description: (file stem, description), sorted by stem. pub(super) fn committed_descriptions() -> Vec<(String, DeviceDescription)> { - let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut out: Vec<(String, DeviceDescription)> = std::fs::read_dir(&dir) .expect("validation/profiles is readable") .map(|e| e.expect("directory entry").path()) @@ -52,8 +50,9 @@ pub(super) fn profile_value(stem: &str, key: &str) -> Option _ => None, } } - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join(format!("../metal2vulkan-validation/profiles/{stem}.json")); + let path = metal2vulkan_devtools::validation_dir() + .join("profiles") + .join(format!("{stem}.json")); let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{stem}: {e}")); let json: serde_json::Value = serde_json::from_str(&text).unwrap_or_else(|e| panic!("{stem}: {e}")); diff --git a/crates/metal2vulkan-runtime/src/tests/compute_create_bench.rs b/crates/metal2vulkan-runtime/src/tests/compute_create_bench.rs index 015358ba5..ca0b53110 100644 --- a/crates/metal2vulkan-runtime/src/tests/compute_create_bench.rs +++ b/crates/metal2vulkan-runtime/src/tests/compute_create_bench.rs @@ -39,7 +39,6 @@ use metal2vulkan::cache::PipelineArtifact; use metal2vulkan::library::{CompiledFunction, FunctionConstantValue, FunctionConstantValues}; use metal2vulkan::metal::DataType; use metal2vulkan::pipeline::{ComputePipeline, ComputePipelineDescriptor, StageSource}; -use std::path::Path; use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; @@ -102,8 +101,7 @@ const PASSES: usize = 4; /// `kernel`'s library on `device`. fn library(device: &Device, kernel: &Kernel) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public") + let ll = metal2vulkan_devtools::fixtures_dir() .join(kernel.directory) .join(format!("{}.ll", kernel.name)); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); diff --git a/crates/metal2vulkan-runtime/src/tests/core_image_libraries.rs b/crates/metal2vulkan-runtime/src/tests/core_image_libraries.rs index 95c52e9bc..7bcdf9198 100644 --- a/crates/metal2vulkan-runtime/src/tests/core_image_libraries.rs +++ b/crates/metal2vulkan-runtime/src/tests/core_image_libraries.rs @@ -14,7 +14,6 @@ use super::blit_holds::{device, Scratch}; use crate::PipelineOptions; use metal2vulkan::metal::FunctionType; use metal2vulkan_devtools::metallib::{core_image_metallib, metallib, wrap, MtlbFunction}; -use std::path::Path; fn function<'a>(name: &'a str, type_code: u8, bitcode: &[u8]) -> MtlbFunction<'a> { MtlbFunction { @@ -61,8 +60,7 @@ fn a_core_image_library_answers_its_extern_functions() { assert!(library.new_extern_function_with_name("nope").is_err()); // An executable library: no extern names, and its kernel made by either call. - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/kernel_stage_in.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("kernel_stage_in.ll"); let kernel = wrap(&metal2vulkan_devtools::llvm_assemble(&ll).unwrap()); let executable = device .new_library_with_data(&metallib(&[function("stage_in_fetch_wide", 2, &kernel)])) diff --git a/crates/metal2vulkan-runtime/src/tests/creation_prediction_kinds.rs b/crates/metal2vulkan-runtime/src/tests/creation_prediction_kinds.rs index dc5bfc072..04fffd943 100644 --- a/crates/metal2vulkan-runtime/src/tests/creation_prediction_kinds.rs +++ b/crates/metal2vulkan-runtime/src/tests/creation_prediction_kinds.rs @@ -44,7 +44,6 @@ use super::blit_holds::{device, Scratch}; use super::descriptor_key_once::descriptor; use crate::{PipelineOptions, WorkCounts}; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; -use std::path::Path; /// The two predictions' makings, and the whole count: render made, dispatch made, all made. fn made(counts: &WorkCounts) -> [u64; 3] { @@ -87,8 +86,7 @@ fn the_render_and_dispatch_predictions_are_counted_apart() { render[2], render[0] ); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let function = device .new_library_with_compile_library( diff --git a/crates/metal2vulkan-runtime/src/tests/creation_prediction_reach.rs b/crates/metal2vulkan-runtime/src/tests/creation_prediction_reach.rs index 57e98da94..fcbdbee3c 100644 --- a/crates/metal2vulkan-runtime/src/tests/creation_prediction_reach.rs +++ b/crates/metal2vulkan-runtime/src/tests/creation_prediction_reach.rs @@ -38,7 +38,6 @@ use metal2vulkan::metal::{ BlendFactor, PixelFormat, PrimitiveTopologyClass, PrimitiveType, TextureType, TextureUsage, }; use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; -use std::path::Path; /// The target's side, in pixels. const SIDE: u64 = 8; @@ -52,8 +51,7 @@ fn state( samples: u32, class: PrimitiveTopologyClass, ) -> Result { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/rt6_render_state.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_render_state.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = device.new_library_with_compile_library( metal2vulkan::library::Library::from_air(&bitcode).unwrap(), diff --git a/crates/metal2vulkan-runtime/src/tests/creation_split.rs b/crates/metal2vulkan-runtime/src/tests/creation_split.rs index 15accdd9a..7fbb980a6 100644 --- a/crates/metal2vulkan-runtime/src/tests/creation_split.rs +++ b/crates/metal2vulkan-runtime/src/tests/creation_split.rs @@ -53,7 +53,6 @@ use metal2vulkan::pipeline::{ ComputePipelineDescriptor, StageInputAttributeDescriptor, StageInputDescriptor, StageInputLayoutDescriptor, StageSource, }; -use std::path::Path; /// The compute states the sweep makes. const SWEEP: u32 = 4; @@ -110,8 +109,7 @@ fn adds_up(made: &ShaderCacheStatistics) { fn a_creation_s_driver_time_and_directory_reads_reach_the_work_counts() { let scratch = Scratch::new("creation-split"); let device = device(&scratch.0); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/kernel_stage_in.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("kernel_stage_in.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = device.new_library_with_compile_library( metal2vulkan::library::Library::from_air(&bitcode).unwrap(), diff --git a/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs b/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs index 00f974aff..28e5fd0c4 100644 --- a/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs +++ b/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs @@ -1697,8 +1697,7 @@ fn a_compute_state_s_creation_waits_its_bound_for_its_predicted_making() { let scratch = Scratch::new("deferred-compute-creation-bound"); let heard = Heard::default(); let device = waiting_device(&scratch.0, waits, &heard); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let function = device .new_library_with_compile_library( diff --git a/crates/metal2vulkan-runtime/src/tests/degradation.rs b/crates/metal2vulkan-runtime/src/tests/degradation.rs index aec23c4c7..3c93f5772 100644 --- a/crates/metal2vulkan-runtime/src/tests/degradation.rs +++ b/crates/metal2vulkan-runtime/src/tests/degradation.rs @@ -147,7 +147,7 @@ fn notices_are_warnings_named_by_code() { /// docs/API.md's catalogue lists every kind's code once, with its category, and no other code. #[test] fn the_catalogue_lists_every_kind_and_only_them() { - let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../../docs/API.md"); + let path = metal2vulkan_devtools::workspace_dir().join("docs/API.md"); let guide = std::fs::read_to_string(path).unwrap(); let mut listed = BTreeMap::new(); for line in guide.lines() { diff --git a/crates/metal2vulkan-runtime/src/tests/degradation_catalogue.rs b/crates/metal2vulkan-runtime/src/tests/degradation_catalogue.rs index eab5d17c0..debdb1c9a 100644 --- a/crates/metal2vulkan-runtime/src/tests/degradation_catalogue.rs +++ b/crates/metal2vulkan-runtime/src/tests/degradation_catalogue.rs @@ -32,7 +32,7 @@ use std::collections::BTreeMap; /// docs/API.md's catalogue, each code's entry as one line of text: the words after the code and /// its category (`- \`\` (). `), with every continuation line. fn catalogue() -> BTreeMap { - let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../../docs/API.md"); + let path = metal2vulkan_devtools::workspace_dir().join("docs/API.md"); let guide = std::fs::read_to_string(path).unwrap(); let mut entries = BTreeMap::new(); let mut open: Option<(String, String)> = None; @@ -210,7 +210,8 @@ fn an_entry_that_only_resembles_the_cost_does_not_state_it() { /// Each kind's declaration in `degradation.rs`, keyed by its code: the rustdoc of its line in /// `degradations!`, every line of it as one line of text. fn declarations() -> BTreeMap { - let path = concat!(env!("CARGO_MANIFEST_DIR"), "/src/degradation.rs"); + let path = metal2vulkan_devtools::workspace_dir() + .join("crates/metal2vulkan-runtime/src/degradation.rs"); let source = std::fs::read_to_string(path).unwrap(); let (_, invocation) = source .split_once("\ndegradations! {") diff --git a/crates/metal2vulkan-runtime/src/tests/degradation_sites.rs b/crates/metal2vulkan-runtime/src/tests/degradation_sites.rs index 57baf5fc2..f55aec45a 100644 --- a/crates/metal2vulkan-runtime/src/tests/degradation_sites.rs +++ b/crates/metal2vulkan-runtime/src/tests/degradation_sites.rs @@ -25,11 +25,9 @@ use crate::Degradation; use std::collections::{BTreeMap, BTreeSet}; use std::path::{Path, PathBuf}; -/// The lane's module tree: `runtime_lane.rs` and every `.rs` file below `runtime_lane/`. -const LANE: &str = concat!( - env!("CARGO_MANIFEST_DIR"), - "/../metal2vulkan-validation/src/runtime_lane" -); +/// The lane's module tree: `runtime_lane.rs` and every `.rs` file below `runtime_lane/`, under +/// the validation crate. +const LANE: &str = "src/runtime_lane"; /// The device test whose site list this test reads, and the `let` binding that holds it. const DEVICE_TEST: &str = "fn every_kind_has_a_site_a_lane_test_takes()"; @@ -48,7 +46,7 @@ struct Site { /// Each lane source as (path relative to the lane's directory, text): `runtime_lane.rs` beside the /// directory, then every `.rs` file below it, in sorted order. fn lane_sources() -> Vec<(String, String)> { - let lane = PathBuf::from(LANE); + let lane = metal2vulkan_devtools::validation_dir().join(LANE); let module = lane.with_extension("rs"); let mut files = vec![module]; collect(&lane, &mut files); diff --git a/crates/metal2vulkan-runtime/src/tests/derived_once.rs b/crates/metal2vulkan-runtime/src/tests/derived_once.rs index b75923f94..7a6a01a93 100644 --- a/crates/metal2vulkan-runtime/src/tests/derived_once.rs +++ b/crates/metal2vulkan-runtime/src/tests/derived_once.rs @@ -37,15 +37,12 @@ use crate::{Function, Library}; use metal2vulkan::library::{FunctionConstantValue, FunctionConstantValues}; use metal2vulkan::metal::DataType; -use std::path::Path; /// The runtime library of the fixture `name`, loaded as the device API loads AIR: through the /// translator, so every function is module-sourced and its properties, constants and reflection /// come from its AIR, which is the shape that pays for a per-call derivation. fn library(device: &crate::Device, name: &str) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine") - .join(format!("{name}.ll")); + let ll = metal2vulkan_devtools::engine_dir().join(format!("{name}.ll")); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); device.new_library_with_compile_library( metal2vulkan::library::Library::from_air(&bitcode).unwrap(), diff --git a/crates/metal2vulkan-runtime/src/tests/descriptor_key_once.rs b/crates/metal2vulkan-runtime/src/tests/descriptor_key_once.rs index a5c1818a5..586ddd5b4 100644 --- a/crates/metal2vulkan-runtime/src/tests/descriptor_key_once.rs +++ b/crates/metal2vulkan-runtime/src/tests/descriptor_key_once.rs @@ -22,12 +22,10 @@ use super::blit_holds::{device, Scratch}; use crate::{Device, PipelineOption, PipelineOptions, RenderPipelineState}; use metal2vulkan::metal::PixelFormat; use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; -use std::path::Path; /// The fixture's render descriptor, one `RGBA8Unorm` target. pub(super) fn descriptor(device: &Device) -> RenderPipelineDescriptor { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/ubo_bind_offsets.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("ubo_bind_offsets.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = device.new_library_with_compile_library( metal2vulkan::library::Library::from_air(&bitcode).unwrap(), diff --git a/crates/metal2vulkan-runtime/src/tests/detach_lost.rs b/crates/metal2vulkan-runtime/src/tests/detach_lost.rs index c69958f34..c1678fb27 100644 --- a/crates/metal2vulkan-runtime/src/tests/detach_lost.rs +++ b/crates/metal2vulkan-runtime/src/tests/detach_lost.rs @@ -118,9 +118,7 @@ fn device(cache: &Path) -> Device { /// The owned fixture's kernel that loads a word no one raises until its cap /// (`kernel_spin_on_an_unraised_word`). fn spin(device: &Device) -> ComputePipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join( - "../metal2vulkan-validation/fixtures/public/engine/kernel_spin_on_an_unraised_word.ll", - ); + let ll = metal2vulkan_devtools::engine_dir().join("kernel_spin_on_an_unraised_word.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let library = device.new_library_with_compile_library(library); diff --git a/crates/metal2vulkan-runtime/src/tests/device.rs b/crates/metal2vulkan-runtime/src/tests/device.rs index fe8517ae4..d3c98bdd2 100644 --- a/crates/metal2vulkan-runtime/src/tests/device.rs +++ b/crates/metal2vulkan-runtime/src/tests/device.rs @@ -154,8 +154,7 @@ use std::ffi::{CStr, CString}; /// Every committed profile's description at the runtime's Vulkan 1.2 instance, as `(file, /// description)`. fn descriptions() -> Vec<(std::path::PathBuf, DeviceDescription)> { - let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut out = Vec::new(); for entry in std::fs::read_dir(&dir).unwrap() { let path = entry.unwrap().path(); diff --git a/crates/metal2vulkan-runtime/src/tests/direct_arguments_from_compiled.rs b/crates/metal2vulkan-runtime/src/tests/direct_arguments_from_compiled.rs index c9d8357c7..46cf3b813 100644 --- a/crates/metal2vulkan-runtime/src/tests/direct_arguments_from_compiled.rs +++ b/crates/metal2vulkan-runtime/src/tests/direct_arguments_from_compiled.rs @@ -27,7 +27,6 @@ use super::blit_holds::{device, Scratch}; use crate::pipeline::direct_arguments_from_air; use crate::PipelineOptions; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; -use std::path::Path; /// A compute state of `runtime_examples`' `scale_and_offset` kernel with /// `supportIndirectCommandBuffers`, which is what makes the creation ask: it is made, and the @@ -36,8 +35,7 @@ use std::path::Path; fn a_creation_answers_from_its_compiled_kernel() { let scratch = Scratch::new("direct-arguments-from-compiled"); let device = device(&scratch.0); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let function = device diff --git a/crates/metal2vulkan-runtime/src/tests/dirty_pages_device.rs b/crates/metal2vulkan-runtime/src/tests/dirty_pages_device.rs index 1ed08fa9e..a1d8447a7 100644 --- a/crates/metal2vulkan-runtime/src/tests/dirty_pages_device.rs +++ b/crates/metal2vulkan-runtime/src/tests/dirty_pages_device.rs @@ -92,7 +92,6 @@ use crate::{ use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureUsage}; use std::num::NonZeroU64; use std::ops::Range; -use std::path::Path; use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; use std::sync::{Arc, Mutex}; @@ -163,8 +162,7 @@ impl DirtyPages for Log { } fn state(device: &Device, kernel: &str) -> ComputePipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let library: Library = device.new_library_with_compile_library(library); diff --git a/crates/metal2vulkan-runtime/src/tests/driver_defects.rs b/crates/metal2vulkan-runtime/src/tests/driver_defects.rs index ef05b5e1f..d6707dd98 100644 --- a/crates/metal2vulkan-runtime/src/tests/driver_defects.rs +++ b/crates/metal2vulkan-runtime/src/tests/driver_defects.rs @@ -4,7 +4,6 @@ use super::super::driver_defects::{among, of, Affected, AFFECTED}; use metal2vulkan::device::DeviceDescription; use metal2vulkan::error::RuntimeDriverDefect; use metal2vulkan::vk::DriverId; -use std::path::PathBuf; const COPIES: RuntimeDriverDefect = RuntimeDriverDefect::MultisampledDepthStencilColourCopies; const STENCIL_COPIES: RuntimeDriverDefect = RuntimeDriverDefect::MultisampledStencilColourCopies; @@ -77,7 +76,7 @@ const WRAPS: RuntimeDriverDefect = RuntimeDriverDefect::VertexFetchWrapsPast4GiB /// SwiftShader none. #[test] fn the_committed_profiles_drivers_have_their_defects() { - let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut drivers = 0; for path in std::fs::read_dir(&dir).expect("validation/profiles is readable") { let path = path.expect("directory entry").path(); @@ -340,7 +339,7 @@ fn the_scheduler_waits_on_the_gpu_where_no_signal_is_lost() { /// Each clean GPU is a committed profile's GPU of the driver. #[test] fn every_clean_gpu_is_a_committed_profiles() { - let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut committed = Vec::new(); for path in std::fs::read_dir(&dir).expect("validation/profiles is readable") { let path = path.expect("directory entry").path(); @@ -409,7 +408,7 @@ fn a_set_past_the_drivers_support_is_among_its_variants_kinds() { use metal2vulkan::pipeline::{ComputePipelineDescriptor, FunctionDescriptor, StageSource}; use metal2vulkan::Budget; - let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation"); + let root = metal2vulkan_devtools::validation_dir(); let ll = root.join("fixtures/public/engine/hsw_storage_writes.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).expect("llvm-as"); let text = std::fs::read_to_string(root.join("profiles/moltenvk-m3.json")).expect("profile"); diff --git a/crates/metal2vulkan-runtime/src/tests/dynamic_multi_variable.rs b/crates/metal2vulkan-runtime/src/tests/dynamic_multi_variable.rs index 2bdde0a9f..e17172ad8 100644 --- a/crates/metal2vulkan-runtime/src/tests/dynamic_multi_variable.rs +++ b/crates/metal2vulkan-runtime/src/tests/dynamic_multi_variable.rs @@ -157,9 +157,7 @@ fn run(kernel: &Kernel, dispatches: usize, pushing: Pushing, moved: bool) -> Res let scratch = Scratch::new(); let device = device(&scratch.0, pushing); let queue = device.new_command_queue().unwrap(); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public") - .join(file); + let ll = metal2vulkan_devtools::fixtures_dir().join(file); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).map_err(|e| format!("{e:?}"))?; let library = metal2vulkan::library::Library::from_air(&bitcode).map_err(|e| format!("{e}"))?; let function = device diff --git a/crates/metal2vulkan-runtime/src/tests/enables.rs b/crates/metal2vulkan-runtime/src/tests/enables.rs index c008a7369..d30b11132 100644 --- a/crates/metal2vulkan-runtime/src/tests/enables.rs +++ b/crates/metal2vulkan-runtime/src/tests/enables.rs @@ -16,8 +16,7 @@ const V1_4: ApiVersion = ApiVersion { major: 1, minor: 4 }; /// Every committed profile's recommendation at its version capped by `instance` (an instance of /// Vulkan 1.2 caps every device at 1.2), as `(file, set, version)`. fn recommendations(instance: ApiVersion) -> Vec<(std::path::PathBuf, EnableSet, ApiVersion)> { - let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut out = Vec::new(); for entry in std::fs::read_dir(&dir).unwrap() { let path = entry.unwrap().path(); @@ -74,8 +73,7 @@ fn every_recommended_enable_has_a_member_and_a_name() { /// creation (the committed profiles' recommendations cover only the features their captures read). #[test] fn every_feature_the_rules_enable_has_a_member() { - let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/profiles/roadmap-2022.json"); + let path = metal2vulkan_devtools::validation_dir().join("profiles/roadmap-2022.json"); let text = std::fs::read_to_string(path).unwrap(); for api in [ApiVersion::V1_2, ApiVersion::V1_3, V1_4] { let mut extensions: BTreeSet = VkFeature::ALL @@ -240,8 +238,7 @@ fn members_are_unique() { /// nothing for a feature the description keeps without one. #[test] fn promotions_are_the_descriptions() { - let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/profiles/roadmap-2022.json"); + let path = metal2vulkan_devtools::validation_dir().join("profiles/roadmap-2022.json"); let text = std::fs::read_to_string(path).unwrap(); let all: BTreeSet = MEMBERS.iter().map(|member| member.feature).collect(); let none = BTreeSet::new(); diff --git a/crates/metal2vulkan-runtime/src/tests/encoder_holds.rs b/crates/metal2vulkan-runtime/src/tests/encoder_holds.rs index d85e4bf58..3fa1a6144 100644 --- a/crates/metal2vulkan-runtime/src/tests/encoder_holds.rs +++ b/crates/metal2vulkan-runtime/src/tests/encoder_holds.rs @@ -37,7 +37,6 @@ use metal2vulkan::pipeline::{ ColorAttachmentDescriptor, ComputePipelineDescriptor, RenderPipelineDescriptor, StageSource, }; use std::any::Any; -use std::path::PathBuf; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; @@ -178,15 +177,10 @@ pub(super) fn words_of(buffer: &Buffer) -> Vec { .collect() } -/// The library of the fixture at `path` under `validation/fixtures/public/`, beside the manifest -/// directory the test runner names as the test runs (a run of an archive on another machine names -/// its own), else the one the build named. +/// The library of the fixture at `path` under `validation/fixtures/public/` +/// ([`metal2vulkan_devtools::fixtures_dir`]). pub(super) fn library(device: &Device, path: &str) -> Library { - let manifest = std::env::var_os("CARGO_MANIFEST_DIR") - .map_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")), PathBuf::from); - let ll = manifest - .join("../metal2vulkan-validation/fixtures/public") - .join(path); + let ll = metal2vulkan_devtools::fixtures_dir().join(path); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); device.new_library_with_compile_library(library) diff --git a/crates/metal2vulkan-runtime/src/tests/error_kinds.rs b/crates/metal2vulkan-runtime/src/tests/error_kinds.rs index 737156440..449f58cf7 100644 --- a/crates/metal2vulkan-runtime/src/tests/error_kinds.rs +++ b/crates/metal2vulkan-runtime/src/tests/error_kinds.rs @@ -39,7 +39,7 @@ fn sources() -> Vec<(PathBuf, String)> { } let mut paths = Vec::new(); walk( - &Path::new(env!("CARGO_MANIFEST_DIR")).join("src"), + &metal2vulkan_devtools::workspace_dir().join("crates/metal2vulkan-runtime/src"), &mut paths, ); paths.sort(); diff --git a/crates/metal2vulkan-runtime/src/tests/exit_guard.rs b/crates/metal2vulkan-runtime/src/tests/exit_guard.rs index 16f341ea8..bddec838b 100644 --- a/crates/metal2vulkan-runtime/src/tests/exit_guard.rs +++ b/crates/metal2vulkan-runtime/src/tests/exit_guard.rs @@ -2033,7 +2033,7 @@ fn runtime_sources() -> Vec<(String, String)> { } } } - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src"); + let root = metal2vulkan_devtools::workspace_dir().join("crates/metal2vulkan-runtime/src"); let mut sources = Vec::new(); walk(&root, &root, &mut sources); assert!(sources.len() > 50, "the runtime's sources were not found"); diff --git a/crates/metal2vulkan-runtime/src/tests/functions_translated.rs b/crates/metal2vulkan-runtime/src/tests/functions_translated.rs index 683ef2ef7..761feda77 100644 --- a/crates/metal2vulkan-runtime/src/tests/functions_translated.rs +++ b/crates/metal2vulkan-runtime/src/tests/functions_translated.rs @@ -45,7 +45,6 @@ use metal2vulkan::pipeline::{ ComputePipelineDescriptor, StageInputAttributeDescriptor, StageInputDescriptor, StageInputLayoutDescriptor, StageSource, }; -use std::path::Path; /// The rows each sweep makes after the warm-up's one. const RUN: u64 = 16; @@ -66,8 +65,7 @@ const SPARE: u32 = 4; /// The library of the fixture's kernel, on a device with an empty cache of its own. fn opened(scratch: &Scratch) -> (crate::Device, crate::Library) { let device = device(&scratch.0); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/kernel_stage_in.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("kernel_stage_in.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = device.new_library_with_compile_library( metal2vulkan::library::Library::from_air(&bitcode).unwrap(), diff --git a/crates/metal2vulkan-runtime/src/tests/heap.rs b/crates/metal2vulkan-runtime/src/tests/heap.rs index c54a0ffd0..1973bc4f8 100644 --- a/crates/metal2vulkan-runtime/src/tests/heap.rs +++ b/crates/metal2vulkan-runtime/src/tests/heap.rs @@ -5,7 +5,6 @@ use super::texture_descriptor::APPLE; use std::collections::BTreeMap; -use std::path::PathBuf; use crate::buffer::LINEAR_IMAGE_ALIGNMENT; use crate::heap::{heap_size, Numbered, PLACEMENT_ALIGNMENT}; @@ -17,7 +16,7 @@ use metal2vulkan::device::DeviceDescription; /// Every committed profile's description: (file stem, description), sorted by stem. fn committed_descriptions() -> Vec<(String, DeviceDescription)> { - let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut out: Vec<(String, DeviceDescription)> = std::fs::read_dir(&dir) .expect("validation/profiles is readable") .map(|e| e.expect("directory entry").path()) diff --git a/crates/metal2vulkan-runtime/src/tests/icb_records_home.rs b/crates/metal2vulkan-runtime/src/tests/icb_records_home.rs index 7f614d954..cc6702ebf 100644 --- a/crates/metal2vulkan-runtime/src/tests/icb_records_home.rs +++ b/crates/metal2vulkan-runtime/src/tests/icb_records_home.rs @@ -84,9 +84,7 @@ const WRITER: &str = "kernel_icb_encode_render_commands"; /// command `t` on the GPU (`air.reset_render_command`); then an even `t` encodes what the fixture /// does (its vertex and fragment buffers and its draw), and an odd one nothing. fn reset_writer_text(reset: bool) -> String { - let path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public") - .join(format!("{WRITER}.ll")); + let path = metal2vulkan_devtools::fixtures_dir().join(format!("{WRITER}.ll")); let text = std::fs::read_to_string(path).unwrap(); let define = text.find(&format!("define void @{WRITER}(")).unwrap(); let open = define + text[define..].find("{\n").unwrap() + 2; diff --git a/crates/metal2vulkan-runtime/src/tests/image_plan.rs b/crates/metal2vulkan-runtime/src/tests/image_plan.rs index 181c38823..1e755b04a 100644 --- a/crates/metal2vulkan-runtime/src/tests/image_plan.rs +++ b/crates/metal2vulkan-runtime/src/tests/image_plan.rs @@ -34,11 +34,10 @@ use metal2vulkan::vk::{ ImageUsageFlags, SampleCountFlags, }; use std::collections::BTreeSet; -use std::path::PathBuf; /// Every committed profile's description and compile device (`validation/profiles/`). pub(super) fn committed() -> Vec<(String, DeviceDescription, Device)> { - let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut out: Vec<(String, DeviceDescription, Device)> = std::fs::read_dir(&dir) .expect("validation/profiles is readable") .map(|e| e.expect("directory entry").path()) diff --git a/crates/metal2vulkan-runtime/src/tests/interlocked_writes.rs b/crates/metal2vulkan-runtime/src/tests/interlocked_writes.rs index e9c17fffa..d0d518085 100644 --- a/crates/metal2vulkan-runtime/src/tests/interlocked_writes.rs +++ b/crates/metal2vulkan-runtime/src/tests/interlocked_writes.rs @@ -11,7 +11,6 @@ use metal2vulkan::pipeline::{ }; use metal2vulkan::vk::ShaderStage; use metal2vulkan::Budget; -use std::path::PathBuf; /// The fragment and vertex stages' facts of each fragment function of /// `ipo_primitive_order` (`validation/fixtures/public/engine`, `llvm-as`) drawn after `ipo_fan` @@ -22,7 +21,7 @@ use std::path::PathBuf; /// storage image, `ipo_mix` its attachment's. No vertex stage interlocks. #[test] fn the_translators_fragment_stages_state_their_interlocked_writes() { - let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation"); + let root = metal2vulkan_devtools::validation_dir(); let ll = root.join("fixtures/public/engine/ipo_primitive_order.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).expect("llvm-as"); let text = std::fs::read_to_string(root.join("profiles/moltenvk-m3.json")).expect("profile"); diff --git a/crates/metal2vulkan-runtime/src/tests/kept_heap_uses.rs b/crates/metal2vulkan-runtime/src/tests/kept_heap_uses.rs index 4655d9302..706ab375f 100644 --- a/crates/metal2vulkan-runtime/src/tests/kept_heap_uses.rs +++ b/crates/metal2vulkan-runtime/src/tests/kept_heap_uses.rs @@ -31,7 +31,6 @@ use metal2vulkan::metal::{ }; use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; use std::collections::BTreeSet; -use std::path::Path; use std::time::Duration; /// The commands the page encodes and executes: two chunks' (`kept_commands::CHUNK` is 256). @@ -63,9 +62,7 @@ fn buffer_with(device: &Device, bytes: &[u8]) -> Buffer { impl Page { fn new(device: &Device) -> Page { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join( - "../metal2vulkan-validation/fixtures/public/engine/icb_vertex_encode_textured.ll", - ); + let ll = metal2vulkan_devtools::engine_dir().join("icb_vertex_encode_textured.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = device.new_library_with_compile_library( metal2vulkan::library::Library::from_air(&bitcode).unwrap(), diff --git a/crates/metal2vulkan-runtime/src/tests/kept_variants.rs b/crates/metal2vulkan-runtime/src/tests/kept_variants.rs index 489eead82..b1d87ab31 100644 --- a/crates/metal2vulkan-runtime/src/tests/kept_variants.rs +++ b/crates/metal2vulkan-runtime/src/tests/kept_variants.rs @@ -35,7 +35,6 @@ use crate::{Device, Function, Library, PipelineOptions, WorkCounts}; use metal2vulkan::library::{FunctionConstantValue, FunctionConstantValues}; use metal2vulkan::metal::{DataType, PixelFormat}; use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; -use std::path::Path; use std::time::{Duration, Instant}; /// The distinct states each round makes: past a guest's median reuse distance (51), well past @@ -44,9 +43,7 @@ const STATES: usize = 64; /// The library of the owned fixture `name` on `device`. pub(super) fn library(device: &Device, name: &str) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine") - .join(format!("{name}.ll")); + let ll = metal2vulkan_devtools::engine_dir().join(format!("{name}.ll")); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); device.new_library_with_compile_library( metal2vulkan::library::Library::from_air(&bitcode).unwrap(), diff --git a/crates/metal2vulkan-runtime/src/tests/memo.rs b/crates/metal2vulkan-runtime/src/tests/memo.rs index 9d1ba6fec..f36794882 100644 --- a/crates/metal2vulkan-runtime/src/tests/memo.rs +++ b/crates/metal2vulkan-runtime/src/tests/memo.rs @@ -11,7 +11,6 @@ use metal2vulkan::library::{CompiledFunction, Library}; use metal2vulkan::pipeline::{ComputePipelineDescriptor, FunctionDescriptor, Stage, StageSource}; use metal2vulkan::Budget; use std::collections::HashSet; -use std::path::Path; use std::sync::{Arc, Mutex}; /// A fixed sequence of pseudo-random numbers (xorshift). @@ -252,12 +251,12 @@ fn using_the_latest_entry_again_keeps_the_order() { /// The owned `ob3_texture_array` kernel, from its committed AIR, compiled for the committed /// MoltenVK profile, and that device. fn texture_array() -> (Device, CompiledFunction) { - let root = Path::new(env!("CARGO_MANIFEST_DIR")); - let air = root.join("../metal2vulkan-validation/fixtures/public/engine/ob3_texture_array.air"); + let air = metal2vulkan_devtools::engine_dir().join("ob3_texture_array.air"); let bitcode = std::fs::read(air).expect("the committed AIR"); - let text = - std::fs::read_to_string(root.join("../metal2vulkan-validation/profiles/moltenvk-m3.json")) - .expect("profile"); + let text = std::fs::read_to_string( + metal2vulkan_devtools::validation_dir().join("profiles/moltenvk-m3.json"), + ) + .expect("profile"); let description = DeviceDescription::from_khronos_json(&text, None).expect("description"); let device = Device::new(description, DevicePolicy::default()).expect("device"); let function = Library::from_air(&bitcode) diff --git a/crates/metal2vulkan-runtime/src/tests/mesh_reflection_derived.rs b/crates/metal2vulkan-runtime/src/tests/mesh_reflection_derived.rs index d8b3da4fa..041a6c292 100644 --- a/crates/metal2vulkan-runtime/src/tests/mesh_reflection_derived.rs +++ b/crates/metal2vulkan-runtime/src/tests/mesh_reflection_derived.rs @@ -56,8 +56,7 @@ impl Drop for Scratch { /// with two `RGBA32Uint` targets: three module-sourced stages, so its reflection comes from their /// AIR, which is what a per-state derivation pays for. fn descriptor() -> MeshPipelineDescriptor { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/mesh_draws.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("mesh_draws.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let stage = diff --git a/crates/metal2vulkan-runtime/src/tests/mod.rs b/crates/metal2vulkan-runtime/src/tests/mod.rs index 700c0e920..de81e99cb 100644 --- a/crates/metal2vulkan-runtime/src/tests/mod.rs +++ b/crates/metal2vulkan-runtime/src/tests/mod.rs @@ -4,7 +4,9 @@ //! Some read the repository beside this crate: device profiles from `../validation/profiles`, //! fixtures from `../validation/fixtures`, and `../docs`. They run only from the workspace //! checkout, not from a packaged crate; the crate's build (its build script and `include_str!`) -//! reads nothing outside its own directory. +//! reads nothing outside its own directory. They find the checkout through +//! `metal2vulkan_devtools::workspace_dir` and the helpers on it, where the test runner names it, +//! so an archive built on one machine runs on another (`--workspace-remap`). #[cfg(any(m2v_gpu, m2v_cpu_icd))] mod a8_over_buffers; diff --git a/crates/metal2vulkan-runtime/src/tests/neutral_zeros_shared.rs b/crates/metal2vulkan-runtime/src/tests/neutral_zeros_shared.rs index 168e14ae3..ec30f01b5 100644 --- a/crates/metal2vulkan-runtime/src/tests/neutral_zeros_shared.rs +++ b/crates/metal2vulkan-runtime/src/tests/neutral_zeros_shared.rs @@ -152,8 +152,7 @@ fn threads_that_first_ask_at_once_share_one_zero_buffer() { } fn state(device: &Device, fragment: &str) -> RenderPipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/tob_renders.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("tob_renders.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let library = device.new_library_with_compile_library(library); @@ -281,8 +280,7 @@ fn dispatched(dispatches: usize, unbound: u64) -> (u64, crate::WorkCounts, crate let scratch = Scratch::new(); let device = device(&scratch.0); let queue = device.new_command_queue().unwrap(); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let function = device diff --git a/crates/metal2vulkan-runtime/src/tests/pipeline.rs b/crates/metal2vulkan-runtime/src/tests/pipeline.rs index 289af9fbe..22fa0f6e6 100644 --- a/crates/metal2vulkan-runtime/src/tests/pipeline.rs +++ b/crates/metal2vulkan-runtime/src/tests/pipeline.rs @@ -23,13 +23,10 @@ use metal2vulkan::library::{FunctionConstantValue, FunctionConstantValues, Libra use metal2vulkan::metal::DataType; use metal2vulkan::pipeline::{LinkedFunction, LinkedFunctions, SpecKey}; use metal2vulkan::vk::SpecializationMapEntry; -use std::path::Path; /// The one function of committed AIR fixture `stem`, as a linked function. fn linked(stem: &str) -> LinkedFunction { - let path = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine") - .join(format!("{stem}.air")); + let path = metal2vulkan_devtools::engine_dir().join(format!("{stem}.air")); let bitcode = std::fs::read(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display())); let library = Library::from_air(&bitcode).expect("library"); LinkedFunction::new(library.function(stem).expect("function")) @@ -231,8 +228,7 @@ fn a_pipelines_constants_take_the_keys_values_else_their_defaults() { /// bind offset. #[test] fn every_committed_driver_reads_its_uniform_views_at_their_residuals() { - let dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/profiles"); + let dir = metal2vulkan_devtools::validation_dir().join("profiles"); let mut read = 0; for entry in std::fs::read_dir(&dir).expect("validation/profiles is readable") { let path = entry.expect("directory entry").path(); diff --git a/crates/metal2vulkan-runtime/src/tests/pipeline_wait_order.rs b/crates/metal2vulkan-runtime/src/tests/pipeline_wait_order.rs index 0e0c597b1..42749bb43 100644 --- a/crates/metal2vulkan-runtime/src/tests/pipeline_wait_order.rs +++ b/crates/metal2vulkan-runtime/src/tests/pipeline_wait_order.rs @@ -97,8 +97,7 @@ fn state(device: &Device) -> RenderPipelineState { /// [`state`]'s, its target blended where `blended`: a state of other pipelines. fn blended_state(device: &Device, blended: bool) -> RenderPipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let library = device.new_library_with_compile_library(library); diff --git a/crates/metal2vulkan-runtime/src/tests/pool_room_creations.rs b/crates/metal2vulkan-runtime/src/tests/pool_room_creations.rs index f39b8b399..d30ce77ad 100644 --- a/crates/metal2vulkan-runtime/src/tests/pool_room_creations.rs +++ b/crates/metal2vulkan-runtime/src/tests/pool_room_creations.rs @@ -21,7 +21,6 @@ use metal2vulkan::pipeline::{ ComputePipelineDescriptor, StageInputAttributeDescriptor, StageInputDescriptor, StageInputLayoutDescriptor, StageSource, }; -use std::path::Path; /// The creations the warm-up makes: the first makes the blocks the pools lack, the second finds /// them and derives each pool's longest free range, and the third reads what the second held. @@ -66,8 +65,7 @@ fn create(device: &crate::Device, library: &crate::Library, step: u32) { #[test] fn a_run_of_creations_derives_the_pools_room_no_further() { let device = crate::Device::system_default().unwrap(); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/kernel_stage_in.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("kernel_stage_in.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = device.new_library_with_compile_library( metal2vulkan::library::Library::from_air(&bitcode).unwrap(), diff --git a/crates/metal2vulkan-runtime/src/tests/released_programs.rs b/crates/metal2vulkan-runtime/src/tests/released_programs.rs index 0eab9d911..c0cc3afec 100644 --- a/crates/metal2vulkan-runtime/src/tests/released_programs.rs +++ b/crates/metal2vulkan-runtime/src/tests/released_programs.rs @@ -11,7 +11,6 @@ use super::blit_holds::{device, Scratch}; use crate::{IndirectCommandBufferDescriptor, PipelineOptions, ResourceId, ResourceOptions}; use metal2vulkan::metal::IndirectCommandType; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; -use std::path::Path; /// The states made and released on one ID. const CYCLES: usize = 1000; @@ -24,8 +23,7 @@ const CYCLES: usize = 1000; fn a_buffer_keeps_at_most_four_released_programs_of_an_id() { let scratch = Scratch::new("released-programs"); let device = device(&scratch.0); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let function = device diff --git a/crates/metal2vulkan-runtime/src/tests/rerun_arenas.rs b/crates/metal2vulkan-runtime/src/tests/rerun_arenas.rs index 3a0f3b1e5..cc7615faf 100644 --- a/crates/metal2vulkan-runtime/src/tests/rerun_arenas.rs +++ b/crates/metal2vulkan-runtime/src/tests/rerun_arenas.rs @@ -18,7 +18,6 @@ use crate::{ use ash::vk; use metal2vulkan::metal::{IndirectCommandType, ResourceUsage}; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; -use std::path::Path; use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; @@ -50,8 +49,7 @@ fn device() -> Device { /// A state of the fixture's `scale_and_offset` that an indirect command buffer's commands may /// set. fn state(device: &Device) -> ComputePipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let library = device.new_library_with_compile_library(library); diff --git a/crates/metal2vulkan-runtime/src/tests/shadow_carried_read.rs b/crates/metal2vulkan-runtime/src/tests/shadow_carried_read.rs index f6511a0e2..c4aee1b5d 100644 --- a/crates/metal2vulkan-runtime/src/tests/shadow_carried_read.rs +++ b/crates/metal2vulkan-runtime/src/tests/shadow_carried_read.rs @@ -26,7 +26,6 @@ use crate::{ ResourceOptions, Size, Texture, TextureDescriptor, }; use metal2vulkan::metal::{PixelFormat, TextureUsage}; -use std::path::Path; /// The texture: `WIDTH` texels a row, `HEIGHT` rows, rows of `ROW` bytes. const WIDTH: u64 = 68; @@ -51,9 +50,7 @@ fn inverted(x: u64, y: u64) -> [u8; 4] { /// The `invert_texels` pipeline of the owned fixture. fn invert(device: &Device) -> ComputePipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public") - .join("examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let library: Library = device.new_library_with_compile_library(library); diff --git a/crates/metal2vulkan-runtime/src/tests/shadow_host_writes.rs b/crates/metal2vulkan-runtime/src/tests/shadow_host_writes.rs index 0f67719fb..585f0516d 100644 --- a/crates/metal2vulkan-runtime/src/tests/shadow_host_writes.rs +++ b/crates/metal2vulkan-runtime/src/tests/shadow_host_writes.rs @@ -67,9 +67,7 @@ const CPU_BYTES: [u8; 4] = [1, 2, 3, 4]; /// The library of the fixture at `path` under `validation/fixtures/public/`. fn library(device: &Device, path: &str) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public") - .join(path); + let ll = metal2vulkan_devtools::fixtures_dir().join(path); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); device.new_library_with_compile_library(library) diff --git a/crates/metal2vulkan-runtime/src/tests/shadow_merge_read.rs b/crates/metal2vulkan-runtime/src/tests/shadow_merge_read.rs index 19e4f10f4..aa24f355b 100644 --- a/crates/metal2vulkan-runtime/src/tests/shadow_merge_read.rs +++ b/crates/metal2vulkan-runtime/src/tests/shadow_merge_read.rs @@ -26,7 +26,6 @@ use crate::{ ResourceOptions, Size, TextureDescriptor, }; use metal2vulkan::metal::{PixelFormat, TextureUsage}; -use std::path::Path; /// The texture: `WIDTH` texels a row (more than one workgroup of the merge's kernel, 256 /// texels), `HEIGHT` rows, rows of `ROW` bytes. @@ -71,9 +70,7 @@ fn written_before(x: u64) -> [u8; 4] { /// The library of the fixture at `path` under `validation/fixtures/public/`. fn library(device: &Device, path: &str) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public") - .join(path); + let ll = metal2vulkan_devtools::fixtures_dir().join(path); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); device.new_library_with_compile_library(library) diff --git a/crates/metal2vulkan-runtime/src/tests/stage_entries_shared.rs b/crates/metal2vulkan-runtime/src/tests/stage_entries_shared.rs index 1b0faff18..a9066409a 100644 --- a/crates/metal2vulkan-runtime/src/tests/stage_entries_shared.rs +++ b/crates/metal2vulkan-runtime/src/tests/stage_entries_shared.rs @@ -36,7 +36,6 @@ use metal2vulkan::pipeline::{ ComputePipelineDescriptor, StageInputAttributeDescriptor, StageInputDescriptor, StageInputLayoutDescriptor, StageSource, }; -use std::path::Path; /// The siblings the run makes after the warm-up's one. const RUN: u64 = 16; @@ -84,8 +83,7 @@ const ASKS: u64 = 2; fn a_run_of_compute_creations_specializes_one_kernel_once() { let scratch = Scratch::new("stage-entries-shared"); let device = device(&scratch.0); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/kernel_stage_in.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("kernel_stage_in.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = device.new_library_with_compile_library( metal2vulkan::library::Library::from_air(&bitcode).unwrap(), diff --git a/crates/metal2vulkan-runtime/src/tests/teardown_threads.rs b/crates/metal2vulkan-runtime/src/tests/teardown_threads.rs index c889cff90..9334807dc 100644 --- a/crates/metal2vulkan-runtime/src/tests/teardown_threads.rs +++ b/crates/metal2vulkan-runtime/src/tests/teardown_threads.rs @@ -230,8 +230,7 @@ fn watched(cache: &Path) -> (Device, Ending) { /// (`pipeline/predicted.rs`), which a triangle strip shares where the topology is dynamic, and not /// a line strip's, of another class. fn state(device: &Device) -> RenderPipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let library = device.new_library_with_compile_library(library); diff --git a/crates/metal2vulkan-runtime/src/tests/twin_flights.rs b/crates/metal2vulkan-runtime/src/tests/twin_flights.rs index 97895d908..cdffd5a65 100644 --- a/crates/metal2vulkan-runtime/src/tests/twin_flights.rs +++ b/crates/metal2vulkan-runtime/src/tests/twin_flights.rs @@ -62,8 +62,7 @@ fn device(cache: &Path) -> Device { /// The fixture's render pipeline state: `colored_vertex` and `colored_fragment`, writing an /// `RGBA8Unorm` color 0, beside a color 1 of `second` it does not write. fn state(device: &Device, second: PixelFormat) -> RenderPipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let library = device.new_library_with_compile_library(library); diff --git a/crates/metal2vulkan-runtime/src/tests/uniform_bind_offsets.rs b/crates/metal2vulkan-runtime/src/tests/uniform_bind_offsets.rs index a073f9a6b..a84ddace2 100644 --- a/crates/metal2vulkan-runtime/src/tests/uniform_bind_offsets.rs +++ b/crates/metal2vulkan-runtime/src/tests/uniform_bind_offsets.rs @@ -28,7 +28,6 @@ use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureUsage}; use metal2vulkan::pipeline::{ ColorAttachmentDescriptor, ComputePipelineDescriptor, RenderPipelineDescriptor, StageSource, }; -use std::path::Path; /// The target's side, in pixels. const SIDE: u64 = 4; @@ -55,8 +54,7 @@ impl Bound { } fn library(device: &Device) -> crate::Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine/ubo_bind_offsets.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("ubo_bind_offsets.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); device.new_library_with_compile_library(library) diff --git a/crates/metal2vulkan-runtime/src/tests/upload_chunk_zeros.rs b/crates/metal2vulkan-runtime/src/tests/upload_chunk_zeros.rs index b5d8785cb..64560ab3f 100644 --- a/crates/metal2vulkan-runtime/src/tests/upload_chunk_zeros.rs +++ b/crates/metal2vulkan-runtime/src/tests/upload_chunk_zeros.rs @@ -149,8 +149,7 @@ fn cleared(command_buffers: usize, dispatches: usize) -> (u64, u64) { let scratch = Scratch::new("upload-sweep"); let device = device(&scratch.0); let queue = device.new_command_queue().unwrap(); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); let function = device diff --git a/crates/metal2vulkan-runtime/src/tests/video_interop.rs b/crates/metal2vulkan-runtime/src/tests/video_interop.rs index edb35b440..0354719ae 100644 --- a/crates/metal2vulkan-runtime/src/tests/video_interop.rs +++ b/crates/metal2vulkan-runtime/src/tests/video_interop.rs @@ -557,9 +557,7 @@ fn a_raw_submission_is_ordered_by_a_shared_event_s_semaphore() { /// The library of the fixture at `path` under `validation/fixtures/public/`. fn library(device: &Device, path: &str) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public") - .join(path); + let ll = metal2vulkan_devtools::fixtures_dir().join(path); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let library = metal2vulkan::library::Library::from_air(&bitcode).unwrap(); device.new_library_with_compile_library(library) diff --git a/crates/metal2vulkan-runtime/src/tests/warm.rs b/crates/metal2vulkan-runtime/src/tests/warm.rs index 2d5b9f342..5525d828f 100644 --- a/crates/metal2vulkan-runtime/src/tests/warm.rs +++ b/crates/metal2vulkan-runtime/src/tests/warm.rs @@ -122,8 +122,7 @@ fn device( /// The compute descriptor of `runtime_examples`' `scale_and_offset`, requiring its threadgroup /// (so its creation makes its first dispatch's `VkPipeline`). fn compute(device: &Device) -> ComputePipelineDescriptor { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); let function = device .new_library_with_compile_library( diff --git a/crates/metal2vulkan-runtime/src/tests/warm_record.rs b/crates/metal2vulkan-runtime/src/tests/warm_record.rs index 73552a3cb..101808283 100644 --- a/crates/metal2vulkan-runtime/src/tests/warm_record.rs +++ b/crates/metal2vulkan-runtime/src/tests/warm_record.rs @@ -18,13 +18,10 @@ use metal2vulkan::pipeline::{ }; use sha2::{Digest, Sha256}; use std::collections::BTreeMap; -use std::path::Path; /// The library of the committed AIR of fixture `stem`. fn library(stem: &str) -> Library { - let air = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/fixtures/public/engine") - .join(format!("{stem}.air")); + let air = metal2vulkan_devtools::engine_dir().join(format!("{stem}.air")); Library::from_air(&std::fs::read(air).expect("the committed AIR")).expect("a library") } diff --git a/crates/metal2vulkan-validation/src/runtime_lane.rs b/crates/metal2vulkan-validation/src/runtime_lane.rs index 2e172b7df..68f849b69 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane.rs @@ -1599,7 +1599,7 @@ impl LaneChecks { /// The names of the committed cases whose AIR is a public fixture, in shard order. pub fn public_case_names() -> Result, String> { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let root = metal2vulkan_devtools::validation_dir().join("corpus"); let store = CorpusStore::new(&root); let public: std::collections::HashSet<(String, String)> = crate::source::public_sources()? .into_iter() @@ -1660,7 +1660,7 @@ pub type NamedCase = (String, Result); /// Each committed case `select` takes, in shard order ([`NamedCase`]); one pass over the case /// shards and the public fixtures. pub fn public_cases(select: impl Fn(&AuthoredCase) -> bool) -> Result, String> { - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let root = metal2vulkan_devtools::validation_dir().join("corpus"); let store = CorpusStore::new(&root); let mut selected = Vec::new(); for shard in 0..64 { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/amplified_draws.rs b/crates/metal2vulkan-validation/src/runtime_lane/amplified_draws.rs index d7305111b..445f79fff 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/amplified_draws.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/amplified_draws.rs @@ -55,7 +55,6 @@ use metal2vulkan_runtime::{ VisibilityResultMode, }; use std::collections::BTreeSet; -use std::path::Path; /// The kind a draw of one amplification at a time takes, announced once per device. pub(super) const AMPLIFICATION: [Degradation; 1] = [Degradation::AmplificationDraws]; @@ -272,8 +271,7 @@ struct Lane { impl Lane { /// The lane on `device`; `Err` with the device's refusal of an amplified pipeline. fn new(device: Device) -> Result { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rt6_amplified.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_amplified.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/attachment_reads.rs b/crates/metal2vulkan-validation/src/runtime_lane/attachment_reads.rs index f07b22725..10fbc1f33 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/attachment_reads.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/attachment_reads.rs @@ -78,7 +78,6 @@ use metal2vulkan_runtime::{ ResourceOptions, ResourceRef, ScissorRect, Size, StoreAction, Texture, TextureDescriptor, WorkCounts, }; -use std::path::PathBuf; use std::time::Duration; const WAIT: Duration = Duration::from_secs(60); @@ -92,12 +91,9 @@ const BEFORE: u8 = 64; /// The red draw A writes. const DRAWN: u8 = 128; -/// A function of the fixture `fixture` under `fixtures/public/engine`, of the crate's directory -/// as the test runner names it (a carried archive's run remaps it), else as the build did. +/// A function of the engine fixture `fixture` ([`metal2vulkan_devtools::engine_dir`]). pub(super) fn function(device: &Device, name: &str, fixture: &str) -> StageSource { - let manifest = std::env::var_os("CARGO_MANIFEST_DIR") - .map_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")), PathBuf::from); - let ll = manifest.join("fixtures/public/engine").join(fixture); + let ll = metal2vulkan_devtools::engine_dir().join(fixture); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/attachmentless.rs b/crates/metal2vulkan-validation/src/runtime_lane/attachmentless.rs index b98f366eb..93f42c398 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/attachmentless.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/attachmentless.rs @@ -20,12 +20,10 @@ use metal2vulkan_runtime::{ CommandBufferError, CommandBufferStatus, CommandQueue, Device, Error, EventRef, Library, PipelineOptions, RenderPassDescriptor, RenderPipelineState, ScissorRect, }; -use std::path::Path; /// The fixture's library on `device`. fn library(device: &Device) -> Library { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rt6_attachmentless.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_attachmentless.ll"); device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_renders.rs b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_renders.rs index acd21415d..e25177008 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_renders.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_renders.rs @@ -49,7 +49,6 @@ use metal2vulkan_runtime::{ PipelineOptions, Region, RenderCommandEncoder, RenderPassDescriptor, RenderPipelineState, ResourceOptions, RuntimeGap, SamplerState, Size, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; /// The probe's usage of the textures it renders. const RT: TextureUsage = TextureUsage::SHADER_READ @@ -173,8 +172,7 @@ struct Lane { impl Lane { fn new(device: &Device) -> Lane { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/tob_renders.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("tob_renders.ll"); let bitcode = llvm_assemble(&ll).unwrap(); Lane { queue: device.new_command_queue().unwrap(), @@ -1099,8 +1097,7 @@ fn executed(lane: &Lane, kind: Kind, before: Before, bpr: u64) { let device = &lane.device; let rgba = PixelFormat::RGBA8Unorm; let read = lane.pipeline(("tob_rect", "tob_read"), rgba, 1); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/icb_render_replay_template.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("icb_render_replay_template.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/commit_costs.rs b/crates/metal2vulkan-validation/src/runtime_lane/commit_costs.rs index d59ca7fed..fa36acae0 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/commit_costs.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/commit_costs.rs @@ -73,7 +73,6 @@ use metal2vulkan_runtime::{ }; use std::cell::Cell; use std::collections::BTreeMap; -use std::path::Path; use std::time::Instant; /// The program's live buffers of the working set, each [`BUFFER_BYTES`] long. @@ -173,8 +172,7 @@ const RECT: [f32; 4] = [-0.5, -0.5, 0.5, 0.5]; impl Workload { pub(super) fn new(device: Device) -> Workload { let queue = device.new_command_queue().unwrap(); - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/tob_renders.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("tob_renders.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/coverage_loop.rs b/crates/metal2vulkan-validation/src/runtime_lane/coverage_loop.rs index 3ff545c42..b34202696 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/coverage_loop.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/coverage_loop.rs @@ -38,11 +38,10 @@ use metal2vulkan_runtime::{ CommandBufferStatus, CommandQueue, Device, Error, Library, PipelineOptions, RenderPassDescriptor, RenderPipelineState, }; -use std::path::Path; /// The fixture's library on `device`. fn library(device: &Device) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/coverage_loop.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("coverage_loop.ll"); device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/cross_queue_shadows.rs b/crates/metal2vulkan-validation/src/runtime_lane/cross_queue_shadows.rs index 30bb1d2e9..f7bf0c3a7 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/cross_queue_shadows.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/cross_queue_shadows.rs @@ -72,8 +72,6 @@ use metal2vulkan_runtime::{ }; #[cfg(any(m2v_cpu_icd, m2v_gpu_hazards))] use metal2vulkan_runtime::{ComputeCommandEncoder, ComputePipelineState, PipelineOptions, Size}; -#[cfg(any(m2v_cpu_icd, m2v_gpu_hazards))] -use std::path::Path; use std::sync::Arc; use std::time::{Duration, Instant}; @@ -114,8 +112,7 @@ impl Spin { /// commit to completion, until one takes [`MEASURED`], scaled to [`SLICE`]. The first, not /// timed, makes the pipeline's `VkPipeline`, so no later dispatch of it waits at a host step. fn new(device: &Device) -> Spin { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/kernel_spin_on_an_unraised_word.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("kernel_spin_on_an_unraised_word.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/cubic_reach_costs.rs b/crates/metal2vulkan-validation/src/runtime_lane/cubic_reach_costs.rs index 978fb4e6f..6fa6e4e03 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/cubic_reach_costs.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/cubic_reach_costs.rs @@ -46,7 +46,6 @@ use metal2vulkan_runtime::{ LoadAction, PipelineOptions, Region, RenderPassDescriptor, RenderPipelineState, ResourceOptions, SamplerState, Size, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; use std::time::Instant; /// The timed runs of each case. @@ -69,9 +68,7 @@ const DISPATCHES: usize = 16; /// The engine fixture `stem`'s library on `device`. fn library(device: &Device, stem: &str) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine") - .join(format!("{stem}.ll")); + let ll = metal2vulkan_devtools::engine_dir().join(format!("{stem}.ll")); device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/depth_costs.rs b/crates/metal2vulkan-validation/src/runtime_lane/depth_costs.rs index d0ac7a1a5..1921183bf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/depth_costs.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/depth_costs.rs @@ -39,7 +39,6 @@ use metal2vulkan_runtime::{ PipelineOptions, RenderPassDescriptor, RenderPipelineState, ResourceOptions, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; use std::time::Instant; /// The timed frames of each case, and the untimed ones before them. @@ -69,8 +68,7 @@ impl Kit { /// The kit of `samples`, its depth a heap's where `in_heap`, and of `ShaderRead` usage too /// where `read` (so that binding it for reading takes no image of its own). fn new(device: &Device, samples: u64, in_heap: bool, read: bool) -> Kit { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/rt6_render_state.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_render_state.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/discard_counts.rs b/crates/metal2vulkan-validation/src/runtime_lane/discard_counts.rs index b00dcb49a..f99865093 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/discard_counts.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/discard_counts.rs @@ -35,7 +35,6 @@ use metal2vulkan_runtime::{ BlitOption, ClearColor, LoadAction, PipelineOptions, RenderPassDescriptor, RenderPipelineState, ResourceOptions, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; /// The target's width and height. const W: u64 = 8; @@ -46,8 +45,7 @@ const CLEAR: i32 = -7; /// The fixture's pipeline on `lane`'s device, drawing an `RGBA32Sint` target. fn pipeline(lane: &Lane) -> RenderPipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/fragment_discard_counts.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("fragment_discard_counts.ll"); let library = lane .device .new_library_with_air(&llvm_assemble(&ll).unwrap()) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/discard_hoist.rs b/crates/metal2vulkan-validation/src/runtime_lane/discard_hoist.rs index 948946270..7466edfc6 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/discard_hoist.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/discard_hoist.rs @@ -48,7 +48,6 @@ use metal2vulkan_runtime::{ BlitOption, ClearColor, Degradation, LoadAction, PipelineOptions, Region, RenderPassDescriptor, RenderPipelineState, ResourceOptions, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; /// The target's width and height. const W: u64 = 8; @@ -112,8 +111,7 @@ fn expected(shape: &str, metals: Answer, gap: bool) -> Answer { /// The fixture's pipeline of fragment function `fragment` on `lane`'s device, drawing an /// `RGBA32Sint` target. fn pipeline(lane: &Lane, fragment: &str) -> RenderPipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/fragment_discard_hoist.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("fragment_discard_hoist.ll"); let library = lane .device .new_library_with_air(&llvm_assemble(&ll).unwrap()) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/draw_bases.rs b/crates/metal2vulkan-validation/src/runtime_lane/draw_bases.rs index afa9eaaee..5a3c039f9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/draw_bases.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/draw_bases.rs @@ -46,7 +46,7 @@ enum Issued { /// observation in the lane's environment. fn cases() -> Vec<(AuthoredCase, Vec)> { let source = format!("{}/engine/{FIXTURE}", crate::source::PUBLIC_FIXTURE_DIR); - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let root = metal2vulkan_devtools::validation_dir().join("corpus"); let store = CorpusStore::new(&root); let mut out = Vec::new(); for shard in 0..64 { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs b/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs index 3ee16e55f..cfca8f242 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs @@ -143,13 +143,11 @@ use metal2vulkan_runtime::{ Error as RuntimeError, LoadAction, Origin, PipelineOptions, RenderPassDescriptor, ResourceOptions, Size, StoreAction, TextureDescriptor, }; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; /// The owned fixture at `name` under `validation/fixtures/public/engine`. fn fixture(name: &str) -> PathBuf { - Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine") - .join(name) + metal2vulkan_devtools::engine_dir().join(name) } /// Whether `device`'s profile takes `deviation`. @@ -470,7 +468,7 @@ const LANES: u64 = 72; /// The output of `case`'s Metal row in `environment`. fn metal_row(case: &PublicCase, environment: &str) -> Vec { - let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let root = metal2vulkan_devtools::validation_dir().join("corpus"); let store = CorpusStore::new(&root); let row = MetalObservation::current( store.read_metal_of_case(&case.case).unwrap(), @@ -2331,7 +2329,7 @@ const VERTEX_SIMDGROUP_FIXTURES: [&str; 3] = [ /// lane's environment (the M3 Max's; the M4 drew the same words). fn fixture_cases(name: &str) -> Vec<(AuthoredCase, Vec)> { let source = format!("{}/engine/{name}", crate::source::PUBLIC_FIXTURE_DIR); - let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let root = metal2vulkan_devtools::validation_dir().join("corpus"); let store = CorpusStore::new(&root); let mut out = Vec::new(); for shard in 0..64 { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/fence_stages.rs b/crates/metal2vulkan-validation/src/runtime_lane/fence_stages.rs index 20f9058b7..1943b8148 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/fence_stages.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/fence_stages.rs @@ -32,7 +32,6 @@ use metal2vulkan_runtime::{ BlitOption, Device, LoadAction, Origin, PipelineOptions, RenderPassDescriptor, ResourceOptions, Size, StoreAction, TextureDescriptor, }; -use std::path::Path; /// The target's side. const SIDE: u64 = 64; @@ -51,8 +50,7 @@ const FILLED: u32 = 0x3e3e_3e3e; /// How many of the target's texels held [`FILLED`] and [`BEFORE`] after one wait before /// `stages`, on `device`. fn run(device: &Device, stages: RenderStages) -> (usize, usize) { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rt6_render_state.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_render_state.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/fetch_costs.rs b/crates/metal2vulkan-validation/src/runtime_lane/fetch_costs.rs index ed314f5c8..67644bd9d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/fetch_costs.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/fetch_costs.rs @@ -43,7 +43,6 @@ use metal2vulkan_runtime::{ LoadAction, Origin, PipelineOptions, RenderPassDescriptor, RenderPipelineState, ResourceOptions, SamplerState, Size, StorageMode, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; use std::time::Instant; /// The timed runs of each case. @@ -61,9 +60,7 @@ const Z: f32 = 0.5; /// The engine fixture `stem`'s library on `device`. fn library(device: &Device, stem: &str) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine") - .join(format!("{stem}.ll")); + let ll = metal2vulkan_devtools::engine_dir().join(format!("{stem}.ll")); device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/first_use.rs b/crates/metal2vulkan-validation/src/runtime_lane/first_use.rs index 6f0576983..9c0cccfd7 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/first_use.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/first_use.rs @@ -87,7 +87,6 @@ use metal2vulkan_runtime::{ }; use std::collections::{BTreeMap, BTreeSet}; use std::num::NonZeroU64; -use std::path::Path; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; use std::time::{Duration, Instant}; @@ -163,8 +162,7 @@ impl Busy { /// master's gate at 409546f2: a test of a 0.5 s busy work took 0.35 s whole, and its calls /// saw the end mark). pub(super) fn new(device: &Device, queue: &CommandQueue) -> Busy { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rfs_agx_yield.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rfs_agx_yield.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/first_vertex.rs b/crates/metal2vulkan-validation/src/runtime_lane/first_vertex.rs index 4b75f746c..56f49d733 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/first_vertex.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/first_vertex.rs @@ -37,7 +37,6 @@ use metal2vulkan_runtime::{ ExecutedPipeline, LoadAction, Origin, PipelineOptions, RenderPassDescriptor, RenderPipelineState, ResourceOptions, Size, StoreAction, Texture, TextureDescriptor, Viewport, }; -use std::path::Path; /// The target's width and height. const SIDE: u64 = 8; @@ -198,8 +197,7 @@ struct Lane { impl Lane { /// The lane on `device`, or the device's refusal of the fixture's pipelines. fn new(device: Device) -> Result { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/rt6_first_vertex.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_first_vertex.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/function_tables.rs b/crates/metal2vulkan-validation/src/runtime_lane/function_tables.rs index bbe083011..3a6b135f0 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/function_tables.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/function_tables.rs @@ -1647,8 +1647,7 @@ fn binary_functions_link_as_plain_metal_links_them() { not_precompiled("new_render_pipeline_state", "") ); // A mesh pipeline's mesh and object stages. - let ll = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/examples/icb_direct_arguments.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/icb_direct_arguments.ll"); let mesh_library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/generic_pointers.rs b/crates/metal2vulkan-validation/src/runtime_lane/generic_pointers.rs index 14ff44d1d..a61ed691a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/generic_pointers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/generic_pointers.rs @@ -21,7 +21,6 @@ use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{ CommandBufferStatus, CommandQueue, ComputePipelineState, Device, PipelineOptions, Size, }; -use std::path::Path; /// The threads, all in one threadgroup. const THREADS: usize = 8; @@ -55,8 +54,7 @@ const NULL: [[f32; 4]; THREADS] = [ /// The fixture's `entry`, made into a pipeline. fn pipeline(device: &Device, entry: &str) -> ComputePipelineState { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/generic_pointers.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("generic_pointers.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/global_builtins.rs b/crates/metal2vulkan-validation/src/runtime_lane/global_builtins.rs index cc9f43840..d497ca53d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/global_builtins.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/global_builtins.rs @@ -18,12 +18,10 @@ use metal2vulkan::metal::PixelFormat; use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{Error, Function, GpuFamily, PipelineOptions, RenderPipelineState}; -use std::path::Path; /// The function `name` of the owned fixture `stem` on `lane`'s device. fn function(lane: &Lane, stem: &str, name: &str) -> Function { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join(format!("fixtures/public/engine/{stem}.ll")); + let ll = metal2vulkan_devtools::engine_dir().join(format!("{stem}.ll")); lane.device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/guarded_effects.rs b/crates/metal2vulkan-validation/src/runtime_lane/guarded_effects.rs index a26b15e3c..2415362be 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/guarded_effects.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/guarded_effects.rs @@ -39,7 +39,6 @@ use metal2vulkan_runtime::{ RenderPassDescriptor, RenderPipelineState, ResourceOptions, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; /// The target's width and height. pub(super) const W: u64 = 32; @@ -279,8 +278,7 @@ fn compare( fn side_effects_after_a_discard_land_at_the_kept_pixels_alone() { let (messages, _cache, lane) = lane(); let name = lane.device.name().to_owned(); - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rch_guarded_effects.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rch_guarded_effects.ll"); let library = lane .device .new_library_with_air(&llvm_assemble(&ll).unwrap()) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heap_layouts.rs b/crates/metal2vulkan-validation/src/runtime_lane/heap_layouts.rs index b10ac4955..8b64d8762 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heap_layouts.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heap_layouts.rs @@ -54,7 +54,6 @@ use metal2vulkan_runtime::{ RenderPassDescriptor, ResourceOptions, RuntimeGap, Size, StoreAction, Texture, TextureDescriptor, WorkCounts, }; -use std::path::Path; /// The kinds a texture in a heap over host pages laid out otherwise than Metal's tiles takes, each /// counted per texture and announced once per device with the first's ID. @@ -672,8 +671,7 @@ fn a_texture_made_again_beside_dispatches_takes_its_moves_pool_back() { fn a_command_writing_a_tiled_texture_two_ways_keeps_both_writes() { on_device(|device, messages| { let queue = device.new_command_queue().unwrap(); - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/tob_renders.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("tob_renders.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); @@ -768,8 +766,7 @@ fn a_command_writing_a_tiled_texture_two_ways_keeps_both_writes() { fn a_tiled_texture_s_merges_take_kept_scratches_unzeroed() { on_device(|device, _| { let queue = device.new_command_queue().unwrap(); - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/tob_renders.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("tob_renders.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/helper_select.rs b/crates/metal2vulkan-validation/src/runtime_lane/helper_select.rs index 48231e7f3..c6df3f96f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/helper_select.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/helper_select.rs @@ -39,7 +39,6 @@ use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{ BlitOption, Library, PipelineOptions, RenderPassDescriptor, RenderPipelineState, }; -use std::path::Path; /// The sampled texture's side. const TILE: u64 = 8; @@ -64,8 +63,7 @@ const DRAWS: usize = 32; const RUNS: usize = 5; fn library(lane: &Lane) -> Library { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rch_helper_select.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rch_helper_select.ll"); lane.device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/helper_tangle.rs b/crates/metal2vulkan-validation/src/runtime_lane/helper_tangle.rs index 3206b4b46..0e8bc6322 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/helper_tangle.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/helper_tangle.rs @@ -36,7 +36,6 @@ use metal2vulkan::vk; use metal2vulkan::Budget; use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{BlitOption, Library, PipelineOptions, RenderPassDescriptor}; -use std::path::Path; /// The sampled texture's side. const TILE: u64 = 8; @@ -192,8 +191,7 @@ fn a_write_after_a_helper_branch_is_lost_only_where_noted() { .contains(&DriverWorkaround::DiscardDropsSimdgroupStores); let fragment = &profile.subgroups().fragment; let shuffles = fragment.supported && fragment.ops.contains(OpBits::SHUFFLE); - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rch_helper_tangle.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rch_helper_tangle.ll"); let library = lane .device .new_library_with_air(&llvm_assemble(&ll).unwrap()) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/indirect_command_buffers.rs b/crates/metal2vulkan-validation/src/runtime_lane/indirect_command_buffers.rs index 647259e62..e1f873ebf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/indirect_command_buffers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/indirect_command_buffers.rs @@ -3182,8 +3182,7 @@ fn the_indexed_patch_setter_refuses_what_metal_refuses() { #[test] fn states_whose_functions_use_a_direct_texture_or_sampler_are_refused_as_metal_refuses_them() { on_device(|device| { - let ll = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/examples/icb_direct_arguments.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/icb_direct_arguments.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); @@ -3463,8 +3462,7 @@ fn the_gpu_written_flag_is_set_by_a_write_use_beside_an_encoding_state_or_a_blit #[test] fn states_whose_arguments_reflection_is_unmeasured_are_answered_from_their_roles() { on_device(|device| { - let ll = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/examples/icb_direct_arguments.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/icb_direct_arguments.ll"); let text = std::fs::read_to_string(&ll).unwrap(); let mut unmeasured = text.clone(); for (from, to) in [ @@ -3590,8 +3588,7 @@ fn linked_vertex_and_mesh_functions_are_refused_where_metal_keeps_their_texture( } use Answer::{Made, Refused, Unrasterized}; on_device(|device| { - let ll = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/examples/icb_linked_arguments.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/icb_linked_arguments.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); @@ -3840,8 +3837,7 @@ fn fragment_functions_are_refused_where_metal_keeps_their_texture_and_unproven_u } use Answer::{Made, Refused, Unproven}; on_device(|device| { - let ll = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/examples/icb_linked_arguments.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/icb_linked_arguments.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); @@ -4107,8 +4103,7 @@ fn fragment_functions_are_linked_with_or_without_rasterization_as_metal_links_th } use Answer::{Depth, Made, Refused, Unwritten}; on_device(|device| { - let ll = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/examples/icb_linked_arguments.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/icb_linked_arguments.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/kept_textured.rs b/crates/metal2vulkan-validation/src/runtime_lane/kept_textured.rs index d17048f80..4790983e6 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/kept_textured.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/kept_textured.rs @@ -48,7 +48,6 @@ use metal2vulkan_runtime::{ BlitOption, Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, ComputePipelineState, Device, Origin, PipelineOptions, Size, Texture, WorkCounts, }; -use std::path::Path; use std::time::{Duration, Instant}; /// The commands each page encodes and executes: two chunks' (the runtime's @@ -306,8 +305,7 @@ impl Spin { /// `queue`, from commit to completion, until one takes [`MEASURED`], scaled to [`SLICE`]. The /// first, not timed, makes the pipeline's `VkPipeline`. fn new(device: &Device, queue: &CommandQueue) -> Spin { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/kernel_spin_on_an_unraised_word.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("kernel_spin_on_an_unraised_word.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/kept_variants.rs b/crates/metal2vulkan-validation/src/runtime_lane/kept_variants.rs index b5614785b..8d070d2fb 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/kept_variants.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/kept_variants.rs @@ -26,7 +26,6 @@ use metal2vulkan_runtime::{ ResourceOptions, Size, StoreAction, Texture, TextureDescriptor, WorkCounts, }; use std::alloc::Layout; -use std::path::Path; use std::ptr::NonNull; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; @@ -51,9 +50,7 @@ fn library(device: &Device) -> Library { /// The library of the owned fixture `fixtures/public/` on `device`. fn fixture_library(device: &Device, path: &str) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public") - .join(path); + let ll = metal2vulkan_devtools::fixtures_dir().join(path); let bitcode = llvm_assemble(&ll).unwrap(); device.new_library_with_air(&bitcode).unwrap() } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/layered_passes.rs b/crates/metal2vulkan-validation/src/runtime_lane/layered_passes.rs index 67a70683e..d0a6d4291 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/layered_passes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/layered_passes.rs @@ -49,7 +49,6 @@ use metal2vulkan_runtime::{ ResolveTarget, ResourceOptions, Size, StorageMode, StoreAction, Texture, TextureDescriptor, VertexAmplificationViewMapping, }; -use std::path::Path; /// The targets' width and height. const SIDE: u64 = 4; @@ -175,8 +174,7 @@ impl Lane { /// The lane on `device` drawing with `fragment`; `Err` with the device's refusal of the /// fixture's pipeline. fn new(device: Device, fragment: Fragment) -> Result { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rt6_layered.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_layered.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); @@ -1114,9 +1112,7 @@ impl Steps { /// The lane on `device`; `Err` with the device's refusal of the fixtures' pipelines. fn new(device: Device) -> Result { let library = |name: &str| { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine") - .join(name); + let ll = metal2vulkan_devtools::engine_dir().join(name); device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/made_at_creation.rs b/crates/metal2vulkan-validation/src/runtime_lane/made_at_creation.rs index 0d0ff3b57..ac81cb3fe 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/made_at_creation.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/made_at_creation.rs @@ -31,7 +31,6 @@ use metal2vulkan_runtime::{ ResourceOptions, SamplerState, Size, StoreAction, Texture, TextureDescriptor, WorkCounts, }; use std::collections::BTreeSet; -use std::path::Path; /// The render target's side, and the color `colored_fragment` draws with its `RGBA8Unorm` bytes. const SIDE: u64 = 8; @@ -42,8 +41,7 @@ const HALF_DRAWN: [u8; 8] = [0x00, 0x3c, 0x66, 0x32, 0x00, 0x00, 0x00, 0x3c]; /// The owned fixture's library on `device`. fn library(device: &Device) -> Library { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = llvm_assemble(&ll).unwrap(); device.new_library_with_air(&bitcode).unwrap() } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/math_routines.rs b/crates/metal2vulkan-validation/src/runtime_lane/math_routines.rs index 82a6ad497..9d55a10f5 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/math_routines.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/math_routines.rs @@ -22,7 +22,6 @@ use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{ CommandBufferStatus, ComputePipelineState, Device, PipelineOptions, Size, }; -use std::path::Path; /// The `float` inputs: zeros, normals, denormals, the extremes, infinities, quiet and signaling /// NaNs with payloads. @@ -131,8 +130,7 @@ fn pipeline(device: &Device, name: &str) -> ComputePipelineState { /// The owned fixture's bitcode. fn fixture() -> Vec { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/kernel_frexp_ilogb.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("kernel_frexp_ilogb.ll"); llvm_assemble(&ll).unwrap() } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/moved_writers.rs b/crates/metal2vulkan-validation/src/runtime_lane/moved_writers.rs index 4a5c0f610..737ed611e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/moved_writers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/moved_writers.rs @@ -49,7 +49,6 @@ use metal2vulkan_runtime::{ BlitOption, ClearColor, Library, LoadAction, PipelineOptions, RenderPassDescriptor, RenderPipelineState, StoreAction, }; -use std::path::Path; /// The pass's color format. const COLOR: PixelFormat = PixelFormat::RGB10A82PXR10; @@ -67,7 +66,7 @@ const SECOND: [u32; 3] = [894, 639, 384]; /// `smw_writers`' library on `lane`'s device. fn library(lane: &Lane) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/smw_writers.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("smw_writers.ll"); lane.device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/msaa_depth_moves.rs b/crates/metal2vulkan-validation/src/runtime_lane/msaa_depth_moves.rs index ee4fb21fa..e83605884 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/msaa_depth_moves.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/msaa_depth_moves.rs @@ -40,7 +40,6 @@ use metal2vulkan_runtime::{ Origin, PipelineOptions, RenderCommandEncoder, RenderPassDescriptor, RenderPipelineState, ResourceOptions, SharedEvent, Size, StoreAction, Texture, TextureDescriptor, WorkCounts, }; -use std::path::Path; /// The targets' side. const SIDE: u32 = 16; @@ -121,8 +120,7 @@ struct Kit { impl Kit { fn new(device: &Device) -> Kit { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/rt6_render_state.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_render_state.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/normalized_vertex_fetch.rs b/crates/metal2vulkan-validation/src/runtime_lane/normalized_vertex_fetch.rs index e7ee9a0b2..31cf9fea0 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/normalized_vertex_fetch.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/normalized_vertex_fetch.rs @@ -551,11 +551,10 @@ fn every_normalized_code_reads_metal_s_value() { /// bits. fn recorded_rows(case: &str, site: &str) -> Vec<[u32; 4]> { use base64::Engine as _; - let path = format!( - "{}/../metal2vulkan-conformance/recordings/{case}.json", - env!("CARGO_MANIFEST_DIR") - ); - let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{path}: {e}")); + let path = metal2vulkan_devtools::workspace_dir().join(format!( + "crates/metal2vulkan-conformance/recordings/{case}.json" + )); + let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display())); let recording: serde_json::Value = serde_json::from_str(&text).unwrap(); let answer = recording["answers"] .as_array() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/nullable_private.rs b/crates/metal2vulkan-validation/src/runtime_lane/nullable_private.rs index b323ce865..6af8e588a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/nullable_private.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/nullable_private.rs @@ -16,7 +16,6 @@ use crate::gpu::TEST_DEVICE; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{CommandBufferStatus, PipelineOptions, Size}; -use std::path::Path; /// The threads, all in one threadgroup. const THREADS: usize = 8; @@ -47,8 +46,7 @@ fn a_thread_pointer_that_may_be_null_answers_as_metal() { let cache = ScratchCache::new().unwrap(); { let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |_| {}).unwrap(); - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/nullable_private.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("nullable_private.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs b/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs index 1ef1c5285..12004eab0 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs @@ -111,8 +111,7 @@ const MAKER_REPORT: &str = "PIPELINE-RECORDS-MAKER"; /// The owned fixture's library on `device`. fn library(device: &Device) -> Library { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = llvm_assemble(&ll).unwrap(); device.new_library_with_air(&bitcode).unwrap() } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pooled_cells.rs b/crates/metal2vulkan-validation/src/runtime_lane/pooled_cells.rs index c1d9aef98..89c495d64 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pooled_cells.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pooled_cells.rs @@ -29,7 +29,6 @@ use metal2vulkan_runtime::{ Buffer, CommandBufferStatus, ComputePipelineState, Device, Error, PipelineOptions, Region, ResourceOptions, ResourceRef, Size, Texture, TextureDescriptor, }; -use std::path::Path; /// The threads, all in one threadgroup. const THREADS: usize = 8; @@ -91,7 +90,7 @@ fn texture(device: &Device, texels: [f32; 4]) -> Texture { /// Kernel `entry`'s pipeline, or the runtime's refusal of it. fn pipeline(device: &Device, entry: &str) -> Result { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/pooled_cells.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("pooled_cells.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/post_depth_coverage.rs b/crates/metal2vulkan-validation/src/runtime_lane/post_depth_coverage.rs index b3893c1ec..b9895c9bb 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/post_depth_coverage.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/post_depth_coverage.rs @@ -30,15 +30,13 @@ use metal2vulkan_runtime::{ RenderPassDescriptor, RenderPipelineState, ResourceOptions, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; /// The pass's side in pixels. const SIDE: u64 = 8; /// The fixture's library on `device`. fn library(device: &Device) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/pdc_post_depth_coverage.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("pdc_post_depth_coverage.ll"); device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs b/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs index d4b95f52a..eb1e2f4a8 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs @@ -107,7 +107,7 @@ use metal2vulkan_runtime::{ Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, ComputePipelineState, Device, PipelineOptions, ResourceOptions, Size, }; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Mutex, PoisonError}; use std::time::{Duration, Instant}; @@ -164,9 +164,7 @@ fn moltenvk_fences(device: &Device) -> bool { /// The busy kernel's typed AIR text and its LLVM IR, the fixture's. fn fixture(extension: &str) -> PathBuf { - Path::new(env!("CARGO_MANIFEST_DIR")).join(format!( - "fixtures/public/engine/kernel_spin_on_an_unraised_word.{extension}" - )) + metal2vulkan_devtools::engine_dir().join(format!("kernel_spin_on_an_unraised_word.{extension}")) } /// What the storm needs of a side, the runtime or Metal: a busy command buffer, a light burst, diff --git a/crates/metal2vulkan-validation/src/runtime_lane/raster_orders.rs b/crates/metal2vulkan-validation/src/runtime_lane/raster_orders.rs index ce436b703..4c44faf8b 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/raster_orders.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/raster_orders.rs @@ -22,7 +22,6 @@ use metal2vulkan_runtime::{ BlitOption, ClearColor, LoadAction, PipelineOptions, RenderPassDescriptor, RenderPipelineState, StoreAction, }; -use std::path::Path; /// The triangles drawn, each three vertices. const TRIANGLES: u32 = 8; @@ -33,8 +32,7 @@ const CLEAR: [f32; 4] = [0.5, 0.25, 0.125, 1.0]; /// The fixture's pipeline on `lane`'s device: `rog_order_layers` and `rog_order_output`, drawing /// an `RGBA16Float` target blended `d' = s + d / 2`. fn pipeline(lane: &Lane) -> RenderPipelineState { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/fragment_rog_order.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("fragment_rog_order.ll"); let library = lane .device .new_library_with_air(&llvm_assemble(&ll).unwrap()) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/raster_sample_counts.rs b/crates/metal2vulkan-validation/src/runtime_lane/raster_sample_counts.rs index d44d0843d..e3a8c27cb 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/raster_sample_counts.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/raster_sample_counts.rs @@ -35,8 +35,7 @@ pub(super) fn refusal(call: &'static str, count: u32) -> Error { #[test] fn a_state_of_a_raster_sample_count_an_apple_gpu_lacks_is_metal_s_error_on_every_device() { on_device(|device| { - let ll = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/examples/icb_direct_arguments.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/icb_direct_arguments.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_passes.rs b/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_passes.rs index 1e68baaa8..ce980ec8a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_passes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_passes.rs @@ -52,7 +52,6 @@ use metal2vulkan_runtime::{ TextureDescriptor, Viewport, }; use std::collections::BTreeSet; -use std::path::Path; /// The public case whose pipeline the passes draw. const CASE: &str = "fragment-positions-in-a-half-quality-rate-mapped-pass"; @@ -72,7 +71,7 @@ struct Fixture { impl Fixture { fn new(device: &Device) -> Fixture { - let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let root = metal2vulkan_devtools::validation_dir().join("corpus"); let store = CorpusStore::new(&root); let case = (0..64) .flat_map(|shard| store.read_case_shard(shard).unwrap()) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/read_through_views.rs b/crates/metal2vulkan-validation/src/runtime_lane/read_through_views.rs index ecba0da15..1a51bf4f9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/read_through_views.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/read_through_views.rs @@ -46,7 +46,6 @@ use metal2vulkan_runtime::{ PipelineOptions, Region, RenderPassDescriptor, RenderPipelineState, ResourceOptions, Size, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; use std::time::Duration; const WAIT: Duration = Duration::from_secs(60); @@ -77,7 +76,7 @@ fn atlas(device: &Device, pf: PixelFormat, usage: TextureUsage, levels: bool) -> /// The `tob_rect` and `tob_sample` state into an unblended `RGBA8Unorm` color. pub(super) fn sampling_state(device: &Device) -> RenderPipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/tob_renders.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("tob_renders.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); @@ -257,9 +256,7 @@ fn atlas_bytes(queue: &CommandQueue, texture: &Texture) -> Vec { /// A function of the `name` fixture under `fixtures/public/engine`. fn function(device: &Device, name: &str, fixture: &str) -> StageSource { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine") - .join(fixture); + let ll = metal2vulkan_devtools::engine_dir().join(fixture); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/render_barriers.rs b/crates/metal2vulkan-validation/src/runtime_lane/render_barriers.rs index 0256838a6..4d6446b94 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/render_barriers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/render_barriers.rs @@ -54,7 +54,6 @@ use metal2vulkan_runtime::{ ResourceOptions, Size, StorageMode, StoreAction, TextureDescriptor, VertexAmplificationViewMapping, }; -use std::path::Path; /// The words after one draw: every pixel's sample 0, then the four invocations. const ONE_DRAW: [u32; 5] = [1, 1, 1, 1, 4]; @@ -92,8 +91,7 @@ fn on_device_with( /// The fixture's fullscreen triangle and sample-rate fragment, at one sample, without /// attachments. fn state(device: &Device) -> RenderPipelineState { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rt6_attachmentless.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_attachmentless.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); @@ -640,8 +638,7 @@ fn a_render_target_barrier_stays_inside_a_multiview_pass() { let messages = Messages::default(); { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rt6_amplified.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_amplified.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/render_state.rs b/crates/metal2vulkan-validation/src/runtime_lane/render_state.rs index ff855d1bf..3e8490e39 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/render_state.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/render_state.rs @@ -56,12 +56,10 @@ use metal2vulkan_runtime::{ }; use std::cell::RefCell; use std::collections::BTreeSet; -use std::path::Path; /// The fixture's library on `device`. pub(super) fn library(device: &Device) -> Library { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rt6_render_state.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_render_state.ll"); let bitcode = llvm_assemble(&ll).unwrap(); device.new_library_with_air(&bitcode).unwrap() } @@ -1678,7 +1676,7 @@ fn through_a_geometry_stage_a_vertex_function_draws_through_the_viewport_it_sele fn viewports_probe(withheld: &[VkFeature]) -> (Messages, ScratchCache, Probe) { let (messages, cache, probe) = validated_without(withheld); let Probe { device, queue, .. } = probe; - let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rt6_viewports.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rt6_viewports.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/renders.rs b/crates/metal2vulkan-validation/src/runtime_lane/renders.rs index 4cbec895f..31289171a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/renders.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/renders.rs @@ -122,7 +122,7 @@ pub(super) fn is_public_render(case: &AuthoredCase) -> bool { pub(super) fn render_cases_where( select: impl Fn(&AuthoredCase) -> bool, ) -> Vec<(String, Result)> { - let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let root = metal2vulkan_devtools::validation_dir().join("corpus"); let store = CorpusStore::new(&root); let mut cases = Vec::new(); for shard in 0..64 { @@ -153,7 +153,7 @@ pub(super) fn map_render( /// The committed public render case named `name`, mapped whatever runtime step its inputs wait /// for: a lane test that encodes those inputs itself draws it. pub(super) fn public_render(name: &str) -> PublicRender { - let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let root = metal2vulkan_devtools::validation_dir().join("corpus"); let store = CorpusStore::new(&root); let case = (0..64) .flat_map(|shard| store.read_case_shard(shard).unwrap()) @@ -1403,7 +1403,7 @@ fn passes_and_draws_are_refused_as_metal_refuses_them() { let messages = Messages::default(); let cache = ScratchCache::new().unwrap(); let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); - let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let root = metal2vulkan_devtools::validation_dir().join("corpus"); let store = CorpusStore::new(&root); let case = (0..64) .flat_map(|shard| store.read_case_shard(shard).unwrap()) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs index 6177c1105..d01e8b61e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs @@ -40,7 +40,6 @@ use metal2vulkan_runtime::{ RenderPipelineState, ResourceOptions, RuntimeGap, Size, StoreAction, Texture, TextureDescriptor, TextureProblem, }; -use std::path::Path; use std::time::Instant; const PF: PixelFormat = PixelFormat::BGRA8Unorm; @@ -74,8 +73,7 @@ struct Lane { impl Lane { fn new(device: &Device) -> Lane { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/tob_renders.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("tob_renders.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/sample_imageblocks.rs b/crates/metal2vulkan-validation/src/runtime_lane/sample_imageblocks.rs index c1e663865..cc5030118 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/sample_imageblocks.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/sample_imageblocks.rs @@ -34,7 +34,6 @@ use metal2vulkan_runtime::{ RenderPassDescriptor, RenderPipelineState, ResourceOptions, StoreAction, Texture, TextureDescriptor, }; -use std::path::Path; /// The pass's side in pixels. const SIDE: u64 = 8; @@ -65,8 +64,7 @@ const fn draw(fragment: &'static str, value: f32, corners: [f32; 6], z: f32, les /// The fixture's library on `device`. fn library(device: &Device) -> Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine/ibs_sample_imageblocks.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("ibs_sample_imageblocks.ll"); device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/sampler_tables.rs b/crates/metal2vulkan-validation/src/runtime_lane/sampler_tables.rs index 934d2adb5..781f6aedc 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/sampler_tables.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/sampler_tables.rs @@ -22,7 +22,6 @@ use metal2vulkan_runtime::{ CommandBufferStatus, CommandQueue, ComputePipelineState, Device, PipelineOptions, Region, ResourceOptions, Size, Texture, TextureDescriptor, }; -use std::path::Path; /// The threads: five coordinates through four samplers. const THREADS: usize = 20; @@ -50,7 +49,7 @@ const METAL: [[u32; 4]; THREADS] = [ /// The fixture's `entry`, made into a pipeline. fn pipeline(device: &Device, entry: &str) -> ComputePipelineState { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/sampler_table.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("sampler_table.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/stage_in_regions.rs b/crates/metal2vulkan-validation/src/runtime_lane/stage_in_regions.rs index 0d520aae3..9e161c363 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/stage_in_regions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/stage_in_regions.rs @@ -31,7 +31,6 @@ use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{ CommandBufferStatus, ComputePipelineState, Device, PipelineOptions, Region, Size, }; -use std::path::Path; /// How a case sets the stage-in region. #[derive(Clone, Copy, Debug)] @@ -377,8 +376,7 @@ const CASES: &[Case] = &[ /// The fixture's pipeline for `layouts`: attribute `i` a `UInt` at offset 0 of buffer `i + 1`, /// whose layout has stride 4 and the step and rate of `layouts[i]`; 32-bit indices at buffer 3. fn pipeline(device: &Device, layouts: &[(StepFunction, u32)]) -> ComputePipelineState { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/stage_in_regions.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("stage_in_regions.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/stage_in_strides.rs b/crates/metal2vulkan-validation/src/runtime_lane/stage_in_strides.rs index 1c84fb859..d96daec87 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/stage_in_strides.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/stage_in_strides.rs @@ -34,7 +34,7 @@ use metal2vulkan_runtime::{ }; #[cfg(any(m2v_cpu_icd, m2v_gpu_hazards))] use metal2vulkan_runtime::{Error, IndirectCommandBufferDescriptor, ResourceOptions, RuntimeGap}; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; /// The grid: 5 by 3 threads. const W: u32 = 5; @@ -45,7 +45,7 @@ const ELEMENTS: u32 = 16; /// The fixture's opaque-pointer text. fn fixture() -> PathBuf { - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/kernel_stage_in.ll") + metal2vulkan_devtools::engine_dir().join("kernel_stage_in.ll") } /// The fixture's pipeline: its layouts 1 and 2 of `MTLBufferLayoutStrideDynamic` where @@ -376,8 +376,7 @@ fn strided_pipeline(device: &Device) -> ComputePipelineState { /// `strided_pipeline` stepping by `step` (a constant step at rate 0, which reads the /// attribute's offset alone). pub(super) fn stage_in_pipeline(device: &Device, step: StepFunction) -> ComputePipelineState { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/ob3_stage_input.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("ob3_stage_input.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/teardown_holders.rs b/crates/metal2vulkan-validation/src/runtime_lane/teardown_holders.rs index 42ff46edc..89d62ede4 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/teardown_holders.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/teardown_holders.rs @@ -35,12 +35,10 @@ use metal2vulkan_runtime::{ TextureDescriptor, }; use std::any::Any; -use std::path::Path; /// The owned fixture's library on `device`. fn library(device: &Device) -> Library { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/examples/runtime_examples.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/runtime_examples.ll"); let bitcode = llvm_assemble(&ll).unwrap(); device.new_library_with_air(&bitcode).unwrap() } @@ -416,8 +414,7 @@ pub(super) fn host_step_s_shared_set( /// The descriptor of [`host_step_s_shared_set`]'s state: the fixture's `colored_vertex` and /// `argument_sampled_fragment` into an `RGBA8Unorm` color, for indirect command buffers. pub(super) fn shared_set_descriptor(device: &Device) -> RenderPipelineDescriptor { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/examples/icb_argument_sampling.ll"); + let ll = metal2vulkan_devtools::fixtures_dir().join("examples/icb_argument_sampling.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/tensors_air29.rs b/crates/metal2vulkan-validation/src/runtime_lane/tensors_air29.rs index d349546c2..180583894 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/tensors_air29.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/tensors_air29.rs @@ -14,7 +14,7 @@ use crate::gpu::TEST_DEVICE; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{CommandBufferStatus, PipelineOptions, Size}; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; /// The threads: one simdgroup in one threadgroup. const THREADS: u64 = 32; @@ -23,7 +23,7 @@ const THREADS: u64 = 32; const EXTENTS: [i32; 4] = [32, 16, 16, 32]; fn companion() -> PathBuf { - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/tns_air29.ll") + metal2vulkan_devtools::engine_dir().join("tns_air29.ll") } /// The operands of `name`'s declaration in `text`, counted at its parentheses' top level. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/vertex_strides.rs b/crates/metal2vulkan-validation/src/runtime_lane/vertex_strides.rs index 9afe99363..d67a631ea 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/vertex_strides.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/vertex_strides.rs @@ -35,7 +35,6 @@ use metal2vulkan_runtime::{ IndirectRenderCommand, PipelineOptions, RenderCommandEncoder, RenderPassDescriptor, RenderPipelineState, ResourceOptions, }; -use std::path::Path; /// The vertices each draw has. const VERTICES: u32 = 8; @@ -48,8 +47,7 @@ pub(super) fn pipeline(device: &Device, stride: Option) -> RenderPipelineSt /// [`pipeline`], made with `supportIndirectCommandBuffers` where `indirect`. fn pipeline_of(device: &Device, stride: Option, indirect: bool) -> RenderPipelineState { - let ll = - Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/ob3_vertex_input.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("ob3_vertex_input.ll"); let library = device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/view_attachments.rs b/crates/metal2vulkan-validation/src/runtime_lane/view_attachments.rs index be649a720..0932c2dc5 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/view_attachments.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/view_attachments.rs @@ -45,7 +45,6 @@ use metal2vulkan_runtime::{ RenderPipelineState, ResourceOptions, ScissorRect, Size, StorageMode, StoreAction, Texture, TextureDescriptor, TextureProblem, ViewProblem, }; -use std::path::Path; /// The probe's clear and draw colors. const CLEAR: [f64; 4] = [0.5, 0.25, 0.75, 1.0]; @@ -79,9 +78,7 @@ struct Lane { impl Lane { fn new(device: &Device) -> Lane { let library = |name: &str| { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public/engine") - .join(name); + let ll = metal2vulkan_devtools::engine_dir().join(name); device .new_library_with_air(&llvm_assemble(&ll).unwrap()) .unwrap() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/viewport_ranges.rs b/crates/metal2vulkan-validation/src/runtime_lane/viewport_ranges.rs index a71171eaf..4393f234d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/viewport_ranges.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/viewport_ranges.rs @@ -65,7 +65,6 @@ use metal2vulkan_runtime::{ StoreAction, Texture, TextureDescriptor, Viewport, }; use std::collections::BTreeSet; -use std::path::Path; /// How far a depth the device reads or stores may lie from Metal's: the rounding of an /// interpolated depth, under 2^-19. @@ -160,7 +159,7 @@ struct Case { /// The fixture's library on `device`. fn library(device: &Device) -> metal2vulkan_runtime::Library { - let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rfb_viewports.ll"); + let ll = metal2vulkan_devtools::engine_dir().join("rfb_viewports.ll"); let bitcode = llvm_assemble(&ll).unwrap(); device.new_library_with_air(&bitcode).unwrap() } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/xr_codes.rs b/crates/metal2vulkan-validation/src/runtime_lane/xr_codes.rs index b73070d10..fbcbea1b3 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/xr_codes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/xr_codes.rs @@ -214,11 +214,10 @@ pub(super) fn assert_counted(announced: &BTreeMap, moved: us /// whole, which the lanes compare value by value. pub(super) fn recorded(case: &str, path: &[&str]) -> Vec { use base64::Engine as _; - let file = format!( - "{}/../metal2vulkan-conformance/recordings/{case}.json", - env!("CARGO_MANIFEST_DIR") - ); - let text = std::fs::read_to_string(&file).unwrap_or_else(|e| panic!("{file}: {e}")); + let file = metal2vulkan_devtools::workspace_dir().join(format!( + "crates/metal2vulkan-conformance/recordings/{case}.json" + )); + let text = std::fs::read_to_string(&file).unwrap_or_else(|e| panic!("{}: {e}", file.display())); let recording: serde_json::Value = serde_json::from_str(&text).unwrap(); let answer = recording["answers"] .as_array() diff --git a/crates/metal2vulkan-validation/src/source.rs b/crates/metal2vulkan-validation/src/source.rs index ecb0c20fb..70498be46 100644 --- a/crates/metal2vulkan-validation/src/source.rs +++ b/crates/metal2vulkan-validation/src/source.rs @@ -1299,7 +1299,7 @@ pub fn public_source_path(label: &str) -> Option { /// text. `None` for a label that is not a public module's. pub fn public_metal_input(label: &str) -> Option<(PathBuf, bool)> { let name = label.strip_prefix("public/")?; - let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("fixtures/public"); + let root = metal2vulkan_devtools::fixtures_dir(); let typed = root.join(name).with_extension("air.ll"); Some(if typed.exists() { (typed, true) @@ -1328,9 +1328,7 @@ pub fn check_public_source(path: &str, air_sha256: &str) -> Result<(), String> { {PUBLIC_FIXTURE_DIR} or its engine/)" )); } - let file = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/public") - .join(relative); + let file = metal2vulkan_devtools::fixtures_dir().join(relative); let text = fs::read(&file).map_err(|error| { format!( "public_source {path} does not exist: read {}: {error}", @@ -1398,9 +1396,10 @@ pub fn public_sources() -> Result, String> { Ok(public_source_set()?.rows) } -/// The public source rows, one per entry point of each public module ([`PublicSources`]). +/// The public source rows, one per entry point of each public module ([`PublicSources`]), of the +/// fixtures where the test runner names the checkout ([`metal2vulkan_devtools::fixtures_dir`]). pub fn public_source_set() -> Result { - public_sources_under(&PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("fixtures/public")) + public_sources_under(&metal2vulkan_devtools::fixtures_dir()) } pub(crate) fn public_sources_under(root: &Path) -> Result {