Files
metal2vulkan/scripts/linux-gate-ci
T
Anees Iqbal 374e29a988 metal2vulkan-rt: the floor's shader features, queue family, timestamps and memory types
The floor now also requires what the translator's shaders and the runtime's
core need of every device:

- shaderInt16, shaderInt8, storageBuffer16BitAccess (Vulkan 1.1 features,
  now read and enabled through Features::vulkan11), storageBuffer8BitAccess,
  scalarBlockLayout, vulkanMemoryModel and vulkanMemoryModelDeviceScope. The
  translator emits 8- and 16-bit access only in storage and physical storage
  buffers in practice (uniform views are u32 or uvec4, push fields are 32- or
  64-bit), so the uniform and push-constant 8/16-bit features stay out; it
  does use device scope.
- timestampComputeAndGraphics, and timestampValidBits of at least 36 on the
  first queue family with graphics and compute, which Capabilities names
  (queue_family). A device with no such family is Missing::QueueFamily.
- a host-visible, host-coherent, host-cached memory type (Shared storage)
  and a device-local, host-visible, host-coherent one (the parameter ring),
  each usable by a buffer of BUFFER_USAGE: every Vulkan 1.3 buffer usage plus
  device addresses. Vulkan answers buffer memory types only for a created
  device, so check() finds a type with each set of flags and carries the
  memory properties, and memory_types(device, &capabilities) chooses the
  first usable type of each with vkGetDeviceBufferMemoryRequirements.
  Missing::MemoryType names the flags.

Each shortfall is named in BelowFloor, with a unit case; the README's Floor
section states every item and tests::floor holds it to the code. The device
test now also creates each device with the floor's features and extensions
and chooses its memory types on it.

CI's lavapipe step (ci.yml and scripts/linux-gate-ci) runs the rt crate's
device tests too. refusal_surface.py reads metal2vulkan-rt and writes the
floor's Missing as section 10 of docs/REFUSALS.md; signatures.py pins
metal2vulkan-rt's public surface in api_signatures.tsv.

Verified: see the lane report (compile job, device legs on every lab GPU,
lavapipe and the Windows UHD 630).
2026-11-17 05:33:25 -08:00

103 lines
4.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# The Linux job of .github/workflows/ci.yml, step for step, for `scripts/linux-gate` to run inside
# its container (the default command). Not meant to run on the host: it expects the container's
# environment (a writable source copy as the working directory, CARGO_TARGET_DIR on the slot
# volume, CARGO_BUILD_JOBS set to the share, lavapipe as the only Vulkan ICD).
#
# Keep it in step with ci.yml: every Linux `run:` there has one `step` here, with the same command
# plus the explicit build share (`-j`, or `--build-jobs` for nextest, whose `-j` is its test-thread
# count), which ci.yml leaves to Cargo's default on a dedicated runner. Tests run with nextest's
# default parallelism, as in ci.yml.
set -euo pipefail
: "${CARGO_BUILD_JOBS:?linux-gate-ci runs inside scripts/linux-gate}"
: "${CARGO_TARGET_DIR:?linux-gate-ci runs inside scripts/linux-gate}"
jobs=$CARGO_BUILD_JOBS
# ci.yml job-level env.
export CARGO_TERM_COLOR=always
export RUSTFLAGS=-Dwarnings
# ci.yml's Ubuntu tool step exports this to every later step (GITHUB_ENV).
export METAL2VULKAN_TEST_REQUIRE_PINNED_LLVM=1
gate_start=$SECONDS
step() {
local name=$1
shift
local start=$SECONDS
echo "::: linux-gate step: ${name}"
"$@"
echo "::: linux-gate step ok: ${name} ($((SECONDS - start)) s)"
}
tools_probe() {
command -v llvm-dis
command -v spirv-val
command -v spirv-as
shopt -s nullglob
local icds=(/usr/share/vulkan/icd.d/*.json /etc/vulkan/icd.d/*.json)
echo "Vulkan ICDs: ${icds[*]:-none}"
test "${#icds[@]}" -gt 0
}
cpu_icd_tests() {
# A separate target dir keeps the ordinary (`-Dwarnings`) build warm: a RUSTFLAGS change would
# otherwise rebuild the whole tree in place on every run.
CARGO_TARGET_DIR="${CARGO_TARGET_DIR}-cpu-icd" \
RUSTFLAGS='-Dwarnings --cfg m2v_cpu_icd' LP_NUM_THREADS=1 \
cargo nextest run -p metal2vulkan-validation -p metal2vulkan-rt --all-features \
--build-jobs "$jobs"
}
feature_clippy() {
local features
for features in "" serde ash cli; do
echo "::group::features=${features:-none}"
cargo clippy -p metal2vulkan --all-targets --no-default-features --features "$features" \
-j "$jobs" -- -D warnings
echo "::endgroup::"
done
echo "::group::metal2vulkan-runtime"
cargo clippy -p metal2vulkan-runtime --all-targets -j "$jobs" -- -D warnings
echo "::endgroup::"
for features in "" serde; do
echo "::group::metal2vulkan-air features=${features:-none}"
cargo clippy -p metal2vulkan-air --all-targets --no-default-features --features "$features" \
-j "$jobs" -- -D warnings
echo "::endgroup::"
done
}
gpu_cfg_clippy() {
# As cpu_icd_tests, a sibling target dir keeps the ordinary build warm.
CARGO_TARGET_DIR="${CARGO_TARGET_DIR}-gpucfg" RUSTFLAGS='-Dwarnings --cfg m2v_gpu' \
cargo clippy --workspace --all-targets --all-features -j "$jobs" -- -D warnings
}
qualify_public_cases() {
cargo build -p metal2vulkan-validation --bins -j "$jobs"
LP_NUM_THREADS=1 bash scripts/qualify-public-cases "${CARGO_TARGET_DIR}/debug"
}
step "Install LLVM + SPIR-V tools (probe)" tools_probe
step "Format" cargo fmt --all -- --check
step "Clippy (warnings denied)" \
cargo clippy --workspace --all-targets --all-features -j "$jobs" -- -D warnings
step "Clippy under each feature alone (warnings denied)" feature_clippy
step "Clippy under --cfg m2v_gpu (warnings denied)" gpu_cfg_clippy
step "Build public documentation (warnings denied)" \
env RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --all-features --no-deps -j "$jobs"
step "Build the new API's consumer reference (warnings denied)" scripts/api-docs
step "Package the published crates" \
cargo package --workspace --exclude metal2vulkan-validation --exclude metal2vulkan-devtools \
-j "$jobs"
step "Test metal2vulkan" \
cargo nextest run -p metal2vulkan -p metal2vulkan-air -p metal2vulkan-runtime \
-p metal2vulkan-devtools --all-features --build-jobs "$jobs"
step "Test validation suite" \
cargo nextest run -p metal2vulkan-validation --all-features --build-jobs "$jobs"
step "Doc tests" cargo test --workspace --all-features --doc -j "$jobs"
step "Test validation suite and the runtime on the CPU Vulkan ICD (Linux)" cpu_icd_tests
step "Qualify public cases on native Vulkan (Linux)" qualify_public_cases
echo "::: linux-gate: all ci.yml Linux steps passed ($((SECONDS - gate_start)) s)"