From 0bb4e9f42b21d10eec7fa3e148fc4a369e91a87b Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 12 Nov 2026 13:14:54 -0800 Subject: [PATCH] Pipeline log: a refused kernel's compile takes a line naming its function A compute state whose kernel's compile is refused, at its creation or at a dispatch's variant, printed nothing under METAL2VULKAN_LOG_PIPELINES, and the refusal itself (compile failed: LimitExceeded(SpirvWords)) names no function, so a consumer's log could not say which kernel it was. The log now prints, at both compile sites, a line with the kernel's function name, the refusal, and the descriptor it was made from, as a made pipeline's line names them. Diagnostics only: nothing else changes. --- .../src/pipeline/creation_log.rs | 29 +++++++++++++++++-- .../metal2vulkan-runtime/src/pipeline/mod.rs | 10 +++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/pipeline/creation_log.rs b/crates/metal2vulkan-runtime/src/pipeline/creation_log.rs index e52b9c626..8b56fda0b 100644 --- a/crates/metal2vulkan-runtime/src/pipeline/creation_log.rs +++ b/crates/metal2vulkan-runtime/src/pipeline/creation_log.rs @@ -9,8 +9,10 @@ //! what the kernel was made from (`descriptor:`, as a render state's first line names each //! function: its name, its bitcode's SHA-256 and the constant values it was made with). A //! compute state's pipelines differ by their specialization alone (the threadgroup size, an -//! edge region), so each line prints it whole: no numbering, no diff and no split. The rest of -//! this log is the render pipelines'. +//! edge region), so each line prints it whole: no numbering, no diff and no split. A kernel +//! whose compile is refused, at its state's creation or at a dispatch's variant, takes a line of +//! its own ([`compute_refused`]): its function name, the refusal, and its `descriptor:`. The +//! rest of this log is the render pipelines'. //! //! - **What it prints.** One line per render `VkPipeline` a device makes for a draw (or a host //! step's draw), through the device's message sink at `Info` severity (id name @@ -749,6 +751,29 @@ pub(crate) fn compute( ); } +/// Deliver the line of a compute pipeline of `function` whose compile `device` refused with +/// `error`, at its creation or at a dispatch's variant (the module's documentation, "Compute +/// pipelines"): the kernel's function name, the refusal, and what the kernel was made from, where +/// the log is on. +pub(crate) fn compute_refused( + device: &Device, + function: &FunctionDescriptor, + error: &metal2vulkan::error::Error, +) { + if !enabled() { + return; + } + deliver( + device, + format!( + "metal2vulkan: pipeline creation: compute pipeline `{}`: refused: {error:?}; \ + descriptor: {}", + function.function.info().name, + super::render::logged_function(function), + ), + ); +} + /// Hand `line` to the device's message sink, else to stderr. fn deliver(device: &Device, line: String) { device.inform("metal2vulkan-pipeline-creation", line); diff --git a/crates/metal2vulkan-runtime/src/pipeline/mod.rs b/crates/metal2vulkan-runtime/src/pipeline/mod.rs index 148bb00f7..b07ce2622 100644 --- a/crates/metal2vulkan-runtime/src/pipeline/mod.rs +++ b/crates/metal2vulkan-runtime/src/pipeline/mod.rs @@ -859,7 +859,10 @@ impl ComputePipelineState { let ((found, compiled), key) = stand_in::compile_with_stand_ins(profile, |key| { Variant::compiled(&sources, function, &kernel, key) }) - .map_err(|error| compile_error(device, error))?; + .map_err(|error| { + creation_log::compute_refused(device, function, &error); + compile_error(device, error) + })?; additions::check_kernel_maximum(&compiled, call)?; // Metal fails the creation over a binary function not compiled to a binary once the // stage links, after a reference it leaves unresolved (`additions.rs`). @@ -1819,7 +1822,10 @@ impl Variant { ) -> Result, Error> { let _noted = NoteEntries(device); let (found, _) = Variant::compiled(&Sources::later(device), function, descriptor, &key) - .map_err(|error| compile_error(device, error))?; + .map_err(|error| { + creation_log::compute_refused(device, function, &error); + compile_error(device, error) + })?; Variant::of(device, key, found, function) }