Files
metal2vulkan/crates/metal2vulkan-runtime/Cargo.toml
T
Anees Iqbal 8c09b7c2c0 Link a warm render creation from its recorded stages, and key the shader cache by its translator
A warm render state creation spent most of its own time in
Device::render_variant_key, decoding and specializing every Function
stage's AIR to learn its stages' compile keys, because the directory's
variant record named only the pipeline's key and a sweep stores no
pipeline artifact where the directory holds its stages. The record (v2:
new tag and magic) now also names the stages' function compile keys
(VariantStages); a creation that finds the record but not the pipeline
finds the functions by those keys alone (Sources::found_function: memo,
archives, disk, no translation) and links them (RenderVariant::link),
decoding nothing. Every creation writes its record. The keys are valid
exactly as long as the pipeline key beside them. (Ports dev-perf
f4d864d160; development's lookup has no warm-pass Prior/Found and no
fit_render_variant, and the bench it extended is gone.)

The shader cache's build directory was named by the runtime's version,
both artifact versions, the translator's SOURCE_DIGEST and the runtime's
own source digest (its build.rs over every file under src/, tests
included), so any runtime edit started the cache cold. Every translated
entry is the translator's answer for the inputs its key and profile
hash, so the runtime's digest goes (with build.rs, its sha2
build-dependency and the validation fingerprint's reference to it). The
translator's SOURCE_DIGEST stays, as its doc promises: an unbumped
translator change still starts afresh. The runtime's own creation
records (linked-use answers, reflection, variant record) are runtime
logic, so their names now hash RUNTIME_VERSION with their tag and key
(creation.rs record_name): a runtime change that bumps it reads none of
an earlier runtime's records. (Ports the idea of dev-perf db5f5baa73,
narrowed: no per-entry stamp, no other_build_hits, no public API
change.)

Not ported from the same area: dev-perf's pipeline-record hook and
Device::warm from an earlier process's records (14df1fb5fe, 66fe0ada29;
~3,200 lines on per-entry stamps this packet does not take).

Verified on the M3 Max (MoltenVK): 84 device tests of the shader cache,
creation, render-stage, sibling-work, archive and pipeline areas pass;
the guard a_second_device_links_a_recorded_sweep_with_no_stage_decoded
fails with the recorded-stage link disabled ((decoded, translated) =
(2, 0)) and passes with it; a_creation_record_of_another_runtime_version
_is_not_found passes. Release render-pipeline-split,
integer-vertex-attributes, one run: warm processes decode 2 stages
before and 0 after; cold counts identical; wall within run-to-run spread
on this case's small shaders. Clippy (plain and --cfg m2v_gpu) and
rustdoc -D warnings clean; 43 + 241 plain runtime/translator tests pass.
No version bumps. Runtime-sources pin recomputed.
2026-10-28 23:18:09 +02:00

85 lines
3.1 KiB
TOML

[package]
name = "metal2vulkan-runtime"
version = "0.2.0"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
authors.workspace = true
description = "The Metal API on Vulkan: Metal's objects and calls run on a Vulkan device through ash"
readme = "README.md"
repository.workspace = true
homepage.workspace = true
documentation = "https://docs.rs/metal2vulkan-runtime"
keywords = ["metal", "vulkan", "gpu", "graphics"]
categories = ["graphics", "api-bindings"]
# No crate root can appear unannounced, so validation's product fingerprint follows exactly the
# runtime's module tree (build_support.rs). Each example is listed below.
autobins = false
autoexamples = false
# The runtime's tests read the repository's profiles, fixtures and guide beside this directory.
exclude = ["/target/", "**/*.air", "**/*.metallib", "**/*.spv"]
[lib]
name = "metal2vulkan_runtime"
path = "src/lib.rs"
# Runnable examples for consumers (README.md, "Examples"): each runs the owned fixture
# validation/fixtures/public/examples/runtime_examples.metal on the system default device, from the
# workspace checkout (its committed LLVM text, assembled by `llvm-as`), or a metallib passed as the
# first argument.
[[example]]
name = "compute_dispatch"
path = "examples/compute_dispatch.rs"
[[example]]
name = "render_to_texture"
path = "examples/render_to_texture.rs"
[[example]]
name = "indirect_command_buffer"
path = "examples/indirect_command_buffer.rs"
[[example]]
name = "heap_placement"
path = "examples/heap_placement.rs"
[[example]]
name = "adopted_buffer"
path = "examples/adopted_buffer.rs"
# Not a consumer's example: the host A/B benchmark, the same Metal workloads natively on Metal
# and through the runtime, with a table of the two (examples/host_ab/main.rs).
[[example]]
name = "host_ab"
path = "examples/host_ab/main.rs"
[dependencies]
# The translator, through its public API only: the compiler checks that the runtime
# reaches nothing else. `ash` gives `ash_interop`'s conversions and `DeviceDescription::query`.
metal2vulkan = { version = "0.2.0", path = "../metal2vulkan", features = ["ash"] }
# `ash/loaded` opens the Vulkan loader with `dlopen` when a device is created; nothing is linked at
# build time.
ash = { workspace = true, features = ["std", "loaded"] }
# No-copy buffers take the host's page size on unix; elsewhere they are
# refused typed. It also registers the exit guard's exit handler on unix.
libc.workspace = true
# The shader cache's entry names and the binary archive's keys.
sha2.workspace = true
[dev-dependencies]
serde_json.workspace = true
# `llvm-as` for the device tests' owned fixture (`tests/pipeline_wait_order.rs`).
metal2vulkan-devtools = { path = "../metal2vulkan-devtools" }
# The host A/B benchmark's native side (examples/host_ab): Metal itself, on macOS.
[target.'cfg(target_os = "macos")'.dev-dependencies]
block2 = "0.6"
objc2 = "0.6"
objc2-foundation = "0.3"
objc2-metal = "0.3"
# The device tests compile only under the validation crate's GPU safety cfgs (`tests/mod.rs`).
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(m2v_gpu)", "cfg(m2v_cpu_icd)", "cfg(m2v_no_recycle)"] }