From 234ea4de4e7225a4d1a69b3cc9fe95a74cc80f76 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 13 Nov 2026 11:04:48 -0800 Subject: [PATCH] RUNTIME: a failed submission's line names memory flags itself ash is built without its debug feature here, so vk::MemoryPropertyFlags has no Debug: the line names each flag (and any bit without a name by its value). Verified by the build job that failed on it (m3-max-26103) and the new unit test memory_flags_are_named_and_an_unnamed_bit_is_given_by_its_value. --- .../src/submit_failure.rs | 28 ++++++++++++++++++- .../src/tests/submit_failure.rs | 14 ++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/submit_failure.rs b/crates/metal2vulkan-runtime/src/submit_failure.rs index 2e3151ab3..97db2541e 100644 --- a/crates/metal2vulkan-runtime/src/submit_failure.rs +++ b/crates/metal2vulkan-runtime/src/submit_failure.rs @@ -172,12 +172,38 @@ impl TypeFlags { /// Memory type `index` with its flags, where known: "type 2 (DEVICE_LOCAL)". pub(crate) fn of(&self, index: u32) -> String { match (self.0.as_ref()).and_then(|types| types.get(index as usize)) { - Some(flags) => format!("type {index} ({flags:?})"), + Some(&flags) => format!("type {index} ({})", flag_names(flags)), None => format!("type {index}"), } } } +/// `flags` by their names, `|` between them, any bit without one by its value; "none" for none. +pub(crate) fn flag_names(flags: vk::MemoryPropertyFlags) -> String { + use vk::MemoryPropertyFlags as F; + let named = [ + (F::DEVICE_LOCAL, "DEVICE_LOCAL"), + (F::HOST_VISIBLE, "HOST_VISIBLE"), + (F::HOST_COHERENT, "HOST_COHERENT"), + (F::HOST_CACHED, "HOST_CACHED"), + (F::LAZILY_ALLOCATED, "LAZILY_ALLOCATED"), + (F::PROTECTED, "PROTECTED"), + ]; + let mut names: Vec = (named.iter()) + .filter(|(flag, _)| flags.contains(*flag)) + .map(|(_, name)| (*name).to_owned()) + .collect(); + let known = named.iter().fold(F::empty(), |all, (flag, _)| all | *flag); + let other = flags & !known; + if !other.is_empty() { + names.push(format!("{:#x}", other.as_raw())); + } + match names.is_empty() { + true => "none".to_owned(), + false => names.join("|"), + } +} + /// What a semaphore of a failed submission is to the runtime. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub(crate) enum Role { diff --git a/crates/metal2vulkan-runtime/src/tests/submit_failure.rs b/crates/metal2vulkan-runtime/src/tests/submit_failure.rs index 90297f69a..106d556a5 100644 --- a/crates/metal2vulkan-runtime/src/tests/submit_failure.rs +++ b/crates/metal2vulkan-runtime/src/tests/submit_failure.rs @@ -2,8 +2,8 @@ //! back from it as it was handed to the call, and the line's words for what it holds, bounded. use crate::submit_failure::{ - lists, Carried, InfoLists, InfoReport, Report, Resources, Role, SemaphoreUse, Standing, NAMED, - NAMED_SEMAPHORES, + flag_names, lists, Carried, InfoLists, InfoReport, Report, Resources, Role, SemaphoreUse, + Standing, NAMED, NAMED_SEMAPHORES, }; use ash::vk::{self, Handle}; @@ -139,6 +139,16 @@ fn the_line_names_what_the_failed_submission_held_and_flags_invalid_values() { } } +#[test] +fn memory_flags_are_named_and_an_unnamed_bit_is_given_by_its_value() { + use vk::MemoryPropertyFlags as F; + let flags = F::DEVICE_LOCAL | F::HOST_VISIBLE | F::HOST_COHERENT; + assert_eq!(flag_names(flags), "DEVICE_LOCAL|HOST_VISIBLE|HOST_COHERENT"); + assert_eq!(flag_names(F::empty()), "none"); + let unnamed = F::from_raw(0x100); + assert_eq!(flag_names(F::HOST_CACHED | unnamed), "HOST_CACHED|0x100"); +} + #[test] fn the_line_names_at_most_its_bounds_and_counts_the_rest() { let mut resources = Resources::default();