The Linux gate's work packet: CI's Linux steps now run in the gate's own container, and the failures that run found are fixed: depth and stencil formats over a DRM_FORMAT_MOD_LINEAR image, test IR that LLVM 21 rejects, and a frame-cost check that allocated. Run every Linux step of ci.yml in the Linux gate's container: What: scripts/linux-gate-ci gains the three steps ci.yml's Linux job runs and it did not: "Clippy under each feature alone" (metal2vulkan with no feature and with serde, ash and cli each alone; metal2vulkan-runtime; metal2vulkan-air with no feature and with serde), "Build the new API's consumer reference" (scripts/api-docs) and "Package the published crates". Its "Test metal2vulkan" step now tests the packages ci.yml's does (metal2vulkan, -air, -runtime and -devtools), where it tested metal2vulkan alone. The steps run in ci.yml's order, each with the container's build share. Why: the script's header says every Linux run: step of ci.yml has one step here, and docs/VALIDATION.md presents the container as ci.yml's Linux job; a change that broke only a feature-alone build, the reference, packaging, or the AIR front end's, runtime's or dev tools' tests passed the container and failed CI. Verified: bash -n; the steps compared one by one with ci.yml atfd22785008. A full container run of the script follows on msi-laptop. Make no DRM_FORMAT_MOD_LINEAR image of a depth or stencil format: What: Device::modifier_image_checks, which every DRM_FORMAT_MOD_LINEAR image the runtime makes passes (host_pitched_image's at Metal's row pitch over host pages since1cf79a9617, and dma_buf_image's and dma_buf_natural_layout's over dma-buf pages since11715e2a3f), refuses a format with a depth or stencil component (FormatBlock::depth / ::stencil of the image's format). Such a texture takes the shadow (`shadowed-texture`, naming why), as it already did on every driver that lists no linear modifier for the format. RUNTIME_VERSION 1187; the runtime-sources pin moves with it. docs/API.md (the dma-buf paragraph and the shadowed-texture notice), docs/HOWTO.md and Degradation::ShadowedTexture's rustdoc say so. Why: the runtime asks the layout of every such image of memory plane 0, and Vulkan has no valid such query of a depth or stencil format. Vulkan 1.4.357's validusage.json: of a DRM format modifier's tiling the aspect "must be VK_IMAGE_ASPECT_MEMORY_PLANE_i_BIT_EXT" (VUID-vkGetImageSubresourceLayout-tiling-09433), of a format with a depth component it "must contain VK_IMAGE_ASPECT_DEPTH_BIT" (-format-04462; stencil, -format-04463), and it "must only have a single bit set" (-aspectMask-00997). lavapipe (Mesa 26.2.4) lists the linear modifier for D16_UNORM, D32_SFLOAT and D32_SFLOAT_S8_UINT, so since1cf79a9617a depth or stencil texture over a no-copy buffer's surface plane was made at Metal's row pitch and the validation layer reported -format-04462/-04463, failing CI's CPU-ICD step: runtime_lane::buffer_texture_blits::a_planar_surface_s_depth_or_stencil_texture_reads_and_stores_the_plane and ..._s_passes_write_metal_s_elements_alone. The dma-buf paths had the same gap, reached only where a driver refuses the host pointer and lists the modifier for such a format. Test: runtime_lane::buffer_texture_blits::no_depth_or_stencil_texture_over_a_buffer_asks_for_a_modifier_image makes each depth or stencil format's texture over a surface plane (ordinary and no-copy buffers, read and render usage, rows 64 and 256 bytes apart) and checks that WorkCounts' pitched_host_images, pitched_host_image_refusals and dma_buf_images do not move (each layout query follows such an image), and that the validation layer reports nothing. Verified on msi-laptop, lavapipe (llvmpipe, LLVM 23.1.1, 256 bits; Mesa 26.2.4, validation layer 1.4.357), --cfg m2v_cpu_icd, LP_NUM_THREADS=1, VK_DRIVER_FILES=lvp_icd.json: without the modifier_image_checks change the new test fails ("NoCopy Depth16Unorm MTLTextureUsageShaderRead, rows 64 bytes apart": (1, 0, 0) against (0, 0, 0)) beside the old one; with it, every test of runtime_lane::{buffer_texture_blits, no_copy_textures, dma_buf_imports, surface_texture_costs, pitched_surfaces} passes (47 of 49 selected) except pitched_surfaces::a_half_float_tile_reads_writes_and_renders_as_metal, the known-open lavapipe padding-bytes failure1cf79a9617names (fleet/fix-pitched owns it), and the runtime-sources pin, which printed the hash written here. Write the handle tests' sample coordinates as floats LLVM 21 reads: What: tests::engine_handles' sampled-handle kernels (the 2D and 3D sample calls of heap_gathers_and_nearest_samples_fetch_by_the_handle_s_class, heap_half_texels_convert_by_the_handle_s_class and heap_linear_samples_are_emulated_by_the_handle_s_class) state their coordinates as the hex of the floats they meant, 0x3FD3333340000000, 0x3FE3333340000000 and 0x3FDCCCCCC0000000, in place of the decimals 0.3, 0.6 and 0.45. Why: LLVM 21's llvm-as, which CI's Linux job (Ubuntu 26.04) assembles with, refuses a float decimal that is not exactly a float ("floating point constant invalid for type"), so the three tests failed there; LLVM 23 rounds it to the nearest float, which is the value the hex states (checked on msi-laptop: `ret float 0.3` under llvm-as 23 and `ret float 0x3FD3333340000000` under llvm-as 21 disassemble alike), so the modules are unchanged where they assembled before. These were the only float or half decimals in crates/ that a float does not hold exactly (a scan of every .rs and .ll). Verified on msi-laptop with /opt/llvm-21.1.8 first on PATH and METAL2VULKAN_TEST_REQUIRE_PINNED_LLVM=1, as CI runs: the three tests failed atfd22785008and pass here. Check a stage table brought in place slot by slot, allocating nothing: What: the debug builds' check in ArgumentTable::refresh_reading, that the table it brought in place is the table the stage's function reads whole, is ArgumentTable::check_reading. It compares slot by slot, with no table read whole made and nothing printed unless a slot differs: every kept buffer, texture and sampler slot against the binding stage_table_reading would derive for it (and the sampler as the address maps bind it), every slot that reading has against the kept table, and the kept threadgroup lengths and acceleration structures against none. A sampler is compared as it prints (same_as_printed: every field by `==`, the LOD clamps as bits or both NaN, since `{:?}` tells -0.0 from 0.0 and prints every NaN alike). A slot that differs is named in the panic. Builds without debug assertions compile none of it: their behaviour is unchanged, so RUNTIME_VERSION stays; the runtime-sources pin moves. Why: the check read the whole table again and compared the two as format!("{:?}") strings at every draw, so a debug build's draw made several times the allocations of a release build's, and CI's CPU-ICD step (a debug build) failed runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_within_their_bounds at every sha since its bound came: 86.60 allocations a draw on lavapipe against the bound's 27, where the same build with CARGO_PROFILE_DEV_DEBUG_ASSERTIONS=false makes 24.62. With this, a debug build's draw makes 35.93; the rest of the difference is LiveBind::shape's checks, which build whole bind shapes and stay exact (the next part bounds a debug draw with them). Tests: tests::argument_table::samplers_compare_as_they_print holds same_as_printed equal to comparing the printed forms (opposite zero signs, NaNs of other sign and payload, a NaN against a number, f32::MAX against infinity, and other fields); the_check_compares_every_field fails when StageTable, BoundSampler or SamplerDescriptor gains a field, until the check compares it. Verified on msi-laptop (Linux, debug, LLVM 21): clippy --workspace --all-targets --all-features -D warnings clean; the two unit tests pass; on lavapipe (--cfg m2v_cpu_icd), the frame_costs draws count 35.93 (86.60 before) and runtime_lane::{render_state, function_tables, buffer_texture_blits}, whose draws run the check, pass (32 tests); the runtime-sources pin test passes with the hash written here. Bound a debug build's draw allocations by what its shape checks add: What: runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_within_their_bounds holds a build with debug assertions' draws to DRAW_ALLOCATIONS_DEBUG (38) and other builds' to DRAW_ALLOCATIONS (27, unchanged). The new bound states what it holds: the draw path's allocations and those of LiveBind::shape's two debug_assert!s, which build the state's whole bind shape at each draw to compare the kept or the found one with it; measured 35.93 on lavapipe (llvmpipe, LLVM 23.1.1, Mesa 26.2.4), where a build without debug assertions makes 24.62. The pass end, pass open and commit bounds hold unchanged in both builds. Why: CI's tests are debug builds, and its CPU-ICD step failed this test at every sha since the bound came (86.60 allocations a draw; 35.93 since the previous part made the stage table's check allocation-free). The shape checks stay exact: making them allocation-free would compare through BindState::has_shape, the function the found-shape check exists to cross-check, and a reusable shape would need new public API in the published crate. With a debug bound the CPU-ICD step keeps holding the draw path in CI: a new allocation in it moves both counts alike, and the bound keeps the release bound's slack (about 2.4 allocations). Verified on msi-laptop, lavapipe, --cfg m2v_cpu_icd, debug, LP_NUM_THREADS=1, twice: the four a_frame_s_ bound tests pass (draws 35.93 of 38, pass ends 38.63 of 40, opens 13.00 of 14, commits 5.00 of 6 and 17.08 / 17.24 of 20 on the other threads); the same tests with CARGO_PROFILE_DEV_DEBUG_ASSERTIONS=false atfd22785008gave 24.62, 38.63, 13.00 and 4.99; clippy --workspace --all-targets --all-features under --cfg m2v_gpu is clean. Versions: RUNTIME_VERSION 1186 -> 1195. RUNTIME_VERSION moves: a depth or stencil texture over a buffer no longer gets a linear image. crates/metal2vulkan-validation/runtime-sources.sha256 holds 4a161b14058fa3e4c4b039726845c4bb221965a409dae3153e6232d213f22330, the hash of this tree's runtime inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values the work's branch built with. Each part's Verified lines name the tree it ran at.
102 lines
4.4 KiB
Bash
Executable File
102 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 --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 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)"
|