diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index c43c5213b..f97c4713d 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -157,6 +157,10 @@ the runtime made. - `Device::raw()` gives the entry, instance, physical device, `ash::Device` and queue family. `CommandQueue::with_vk_queue` lends a queue's `VkQueue` under the runtime's lock. - `Texture::vk_image`, `Buffer::vk_buffer` and `SharedEvent::vk_semaphore` give an object's handle. + A texture over a buffer's bytes that aliases them gives a linear image, which over a no-copy + buffer's or dma-buf host pages may be of `VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT` + (`DRM_FORMAT_MOD_LINEAR`, its one memory plane at the texture's `bytes_per_row`): ask its layout + of memory plane 0. - `CommandBuffer::encode_wait_for_vk_semaphore` and `encode_signal_vk_semaphore` order a command buffer against the consumer's own work. - `Device::new_texture_with_vk_image` makes a `Private` texture over the consumer's `VkImage` (a diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 6282298f5..b1276b409 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -221,7 +221,10 @@ degradations! { runtime { /// A 2D texture over a buffer is a shadow image: no linear image of the device lays its /// texels out as Metal does in the buffer's memory (over a no-copy buffer's imported - /// host memory, no linear image made for host allocations does), or the buffer is over + /// host memory, no linear image made for host allocations does: neither the driver's own + /// nor, where the device enables `VK_EXT_image_drm_format_modifier`, a + /// `DRM_FORMAT_MOD_LINEAR` image laid out at Metal's row pitch, which the driver may refuse + /// for the texture's format, usage or pitch), or the buffer is over /// the caller's `VkBuffer`, whose memory backs no image of the runtime's, or over host /// pages imported as dma-bufs (`HostMemory::with_dma_buf`) where the device makes no image /// over a dma-buf of the texture's own pages (the notice names why). Also a heap's depth diff --git a/crates/metal2vulkan-runtime/src/dma_buf.rs b/crates/metal2vulkan-runtime/src/dma_buf.rs index f1341101a..de4490e54 100644 --- a/crates/metal2vulkan-runtime/src/dma_buf.rs +++ b/crates/metal2vulkan-runtime/src/dma_buf.rs @@ -43,7 +43,20 @@ //! other layout (`VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT`): the runtime asks the //! driver and takes its answer, never a rule of its own. The source is called only once the image //! is made and checked; the import keeps it, and goes after the image. Counted: -//! `WorkCounts::dma_buf_images`. +//! `WorkCounts::dma_buf_images`. Over pages imported by their pointer, a texture over a buffer +//! whose rows the driver's linear image lays out otherwise (ANV packs them tight) is likewise a +//! `DRM_FORMAT_MOD_LINEAR` image, its plane at the texture's pitches, made for host allocations +//! ([`ModifierMemory::Host`]) and bound in the buffer's import, its features and limits checked +//! the same way (`texture.rs`'s `host_pitched_image`; counted: +//! `WorkCounts::pitched_host_images`), where the driver takes that layout. Measured +//! (`runtime_lane::surface_texture_costs::pitch_classes`): ANV of Mesa 26.2.4 takes every pitch +//! of every format and usage asked; NVIDIA 615.71.09 a pitch at least its own linear image's row +//! (128-byte aligned), for a texture it samples or writes and not one it renders to, and not in +//! `R16Float`, `R32Float` or `RGBA32Float`, whose `DRM_FORMAT_MOD_LINEAR` tiling it gives no +//! sampling or transfers; RADV of Mesa 26.2.4 refuses a pitch that is not a multiple of 256 +//! bytes and asks a dedicated allocation of an image at any other, so none but its own row. The +//! driver's refusal of an image is kept and not asked again (`texture/pitch_refusals.rs`; +//! `WorkCounts::pitched_host_image_refusals`). //! - **Their layouts.** The image is made `UNDEFINED`, as Vulkan makes an image of external //! memory (`VUID-VkImageCreateInfo-pNext-01443`), and the first submission that uses it acquires //! it from `VK_QUEUE_FAMILY_FOREIGN_EXT` into `GENERAL` (`texture/first_move.rs`), from @@ -582,7 +595,7 @@ impl Device { /// `DRM_FORMAT_MOD_LINEAR` of Linux's `drm_fourcc.h`: one plane of rows one after another, each /// the plane's pitch from the last. -const DRM_FORMAT_MOD_LINEAR: u64 = 0; +pub(super) const DRM_FORMAT_MOD_LINEAR: u64 = 0; /// Where a texture's texels lie in dma-buf pages, for its image over them /// ([`Device::dma_buf_image`]). @@ -618,7 +631,7 @@ pub(super) struct NaturalLayout { /// The one memory plane of an image of `DRM_FORMAT_MOD_LINEAR`, whose layout Vulkan reports /// (`VUID-vkGetImageSubresourceLayout-tiling-09433`). -fn memory_plane_0() -> vk::ImageSubresource { +pub(super) fn memory_plane_0() -> vk::ImageSubresource { vk::ImageSubresource { aspect_mask: vk::ImageAspectFlags::MEMORY_PLANE_0_EXT, mip_level: 0, @@ -715,7 +728,8 @@ impl Device { let mut explicit = vk::ImageDrmFormatModifierExplicitCreateInfoEXT::default() .drm_format_modifier(DRM_FORMAT_MOD_LINEAR) .plane_layouts(&planes); - let raw = match self.drm_linear_image(plan, &view_formats, &mut explicit)? { + let dma_buf = ModifierMemory::DmaBuf; + let raw = match self.drm_linear_image(plan, &view_formats, &mut explicit, dma_buf)? { Ok(raw) => raw, Err(error) => { return Ok(Err(format!( @@ -886,6 +900,22 @@ impl Device { )) } }; + let checked = self.modifier_image_checks(plan, facts, ModifierMemory::DmaBuf)?; + Ok(checked.map(|view_formats| (page, view_formats))) + } + + /// What a `DRM_FORMAT_MOD_LINEAR` image of `plan` for `memory` takes before its plane is laid + /// out, on a device that enables `VK_EXT_image_drm_format_modifier`: the formats it lists for + /// its views; why not where the device makes none: the plan has several levels, depth or + /// samples, or a mutable format with no list of its views; the modifier's tiling lacks a + /// feature the plan's optimal tiling has for its usage; the format query refuses such an + /// image for `memory`, or the plan passes its limits. + pub(super) fn modifier_image_checks( + &self, + plan: &ImagePlan, + facts: &ImageFacts<'_>, + memory: ModifierMemory, + ) -> Result, String>, Error> { if plan.levels != 1 || plan.extent[2] != 1 || plan.samples != SampleCountFlags::COUNT_1 { return Ok(Err(format!( "its image has {} levels, a depth of {} and {:?} samples, where a \ @@ -913,18 +943,19 @@ impl Device { ))); } let view_formats: Vec = formats.iter().map(|&format| format.into()).collect(); - let limits = match self.dma_buf_image_limits(plan, &view_formats) { + let limits = match self.modifier_image_limits(plan, &view_formats, memory) { Ok(limits) => limits, Err(why) => return Ok(Err(why)), }; if let Err(need) = check_linear_limits(plan, &limits) { return Ok(Err(format!( "its image passes the device's limits for a DRM_FORMAT_MOD_LINEAR image of \ - {:?} for dma-bufs: {need:?}", - plan.format + {:?} for {}: {need:?}", + plan.format, + memory.words() ))); } - Ok(Ok((page, view_formats))) + Ok(Ok(view_formats)) } /// The layout the driver gives a `DRM_FORMAT_MOD_LINEAR` image of `plan` for dma-bufs where it @@ -946,7 +977,8 @@ impl Device { let modifiers = [DRM_FORMAT_MOD_LINEAR]; let mut chosen = vk::ImageDrmFormatModifierListCreateInfoEXT::default().drm_format_modifiers(&modifiers); - let raw = match self.drm_linear_image(plan, &view_formats, &mut chosen)? { + let dma_buf = ModifierMemory::DmaBuf; + let raw = match self.drm_linear_image(plan, &view_formats, &mut chosen, dma_buf)? { Ok(raw) => raw, Err(error) => { return Ok(Err(format!( @@ -971,18 +1003,20 @@ impl Device { })) } - /// A `DRM_FORMAT_MOD_LINEAR` image of `plan` for dma-bufs, viewed as `view_formats`, its + /// A `DRM_FORMAT_MOD_LINEAR` image of `plan` for `memory`, viewed as `view_formats`, its /// plane laid out as `modifier` says (an explicit layout, or the modifier listed for the driver /// to lay out), made `UNDEFINED` as Vulkan makes an image of external memory; or the driver's /// refusal of it. - fn drm_linear_image( + pub(super) fn drm_linear_image( &self, plan: &ImagePlan, view_formats: &[vk::Format], modifier: &mut impl vk::ExtendsImageCreateInfo, + memory: ModifierMemory, ) -> Result, Error> { let shared = self.shared(); - let mut external = vk::ExternalMemoryImageCreateInfo::default().handle_types(DMA_BUF); + let mut external = + vk::ExternalMemoryImageCreateInfo::default().handle_types(memory.handle_type()); let mut list = vk::ImageFormatListCreateInfo::default(); let info = plan .create_info(shared.sharing(), view_formats, &mut list) @@ -991,7 +1025,7 @@ impl Device { .push_next(&mut external) .push_next(modifier); // SAFETY: the device is live and enables the extension; `info` and its chain are valid - // and within the device's limits for such an image (`dma_buf_image_limits`), its one + // and within the device's limits for such an image (`modifier_image_limits`), its one // plane the modifier's one (`modifier_features`), made `UNDEFINED` for external memory. unsafe { crate::creation::image_or_refusal(shared.vk(), &info) } } @@ -1001,8 +1035,22 @@ impl Device { /// (`VkDrmFormatModifierPropertiesList2EXT`) where the device has `format_feature_flags2`, as /// the optimal tiling's features come from it: the 32-bit list cannot carry the storage bits /// above bit 31 (`STORAGE_READ_WITHOUT_FORMAT` and `STORAGE_WRITE_WITHOUT_FORMAT`), so a - /// writable texture would always lack them. + /// writable texture would always lack them. Asked of the driver once per format and kept + /// (`TextureState::modifier_features`): a physical device's answer does not change, and ANV's + /// took most of the making of a texture over host pages at Metal's row pitch. fn modifier_features(&self, format: Format) -> FormatFeatureFlags2 { + let kept = &self.shared().textures.modifier_features; + if let Some(&features) = lock(kept).get(&format) { + return features; + } + let features = self.modifier_features_asked(format); + self.shared().counts.modifier_features_asked(); + lock(kept).insert(format, features); + features + } + + /// [`Device::modifier_features`]' answer, asked of the driver. + fn modifier_features_asked(&self, format: Format) -> FormatFeatureFlags2 { let shared = self.shared(); let format: vk::Format = format.into(); let query = |list: &mut dyn vk::ExtendsFormatProperties2| { @@ -1057,13 +1105,15 @@ impl Device { features.map_or(FormatFeatureFlags2::empty(), FormatFeatureFlags2::from_raw) } - /// The device's limits for a `DRM_FORMAT_MOD_LINEAR` image of `plan` for dma-bufs, viewed as - /// `view_formats`; why not where its format query refuses such an image or it imports no - /// dma-buf for one. - fn dma_buf_image_limits( + /// The device's limits for a `DRM_FORMAT_MOD_LINEAR` image of `plan` for `memory`, viewed as + /// `view_formats`; why not where its format query refuses such an image or it imports no such + /// memory for one (for host allocations, none but a dedicated one: such an image is bound at + /// an offset of a buffer's import). + fn modifier_image_limits( &self, plan: &ImagePlan, view_formats: &[vk::Format], + memory: ModifierMemory, ) -> Result { let shared = self.shared(); let families = &shared.queue_families; @@ -1076,7 +1126,7 @@ impl Device { false => modifier.sharing_mode(vk::SharingMode::EXCLUSIVE), }; let mut external = - vk::PhysicalDeviceExternalImageFormatInfo::default().handle_type(DMA_BUF); + vk::PhysicalDeviceExternalImageFormatInfo::default().handle_type(memory.handle_type()); let mut list = vk::ImageFormatListCreateInfo::default().view_formats(view_formats); let mut query = vk::PhysicalDeviceImageFormatInfo2::default() .format(plan.format.into()) @@ -1106,18 +1156,54 @@ impl Device { if let Err(error) = queried { return Err(format!( "the device's image format query reports no DRM_FORMAT_MOD_LINEAR image of {:?}, \ - usage {:?}, flags {:?} for dma-bufs ({error:?})", - plan.format, plan.usage, plan.flags + usage {:?}, flags {:?} for {} ({error:?})", + plan.format, + plan.usage, + plan.flags, + memory.words() )); } let limits = properties.image_format_properties; let features = imported.external_memory_properties.external_memory_features; - if !features.contains(vk::ExternalMemoryFeatureFlags::IMPORTABLE) { + let dedicated_only = memory == ModifierMemory::Host + && features.contains(vk::ExternalMemoryFeatureFlags::DEDICATED_ONLY); + if !features.contains(vk::ExternalMemoryFeatureFlags::IMPORTABLE) || dedicated_only { return Err(format!( - "it imports no dma-buf for a DRM_FORMAT_MOD_LINEAR image of {:?}", - plan.format + "it imports no {} for a DRM_FORMAT_MOD_LINEAR image of {:?} (importable {}, \ + dedicated only {})", + memory.words(), + plan.format, + features.contains(vk::ExternalMemoryFeatureFlags::IMPORTABLE), + features.contains(vk::ExternalMemoryFeatureFlags::DEDICATED_ONLY) )); } Ok(limits) } } + +/// The memory a `DRM_FORMAT_MOD_LINEAR` image is made for: a dma-buf of its own pages +/// ([`Device::dma_buf_image`]), or a no-copy buffer's host pages imported by their pointer, where +/// the image lays its rows out at Metal's pitch (`texture.rs`'s `host_pitched_image`). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(super) enum ModifierMemory { + DmaBuf, + Host, +} + +impl ModifierMemory { + /// The external memory handle type the image is made for. + fn handle_type(self) -> vk::ExternalMemoryHandleTypeFlags { + match self { + ModifierMemory::DmaBuf => DMA_BUF, + ModifierMemory::Host => vk::ExternalMemoryHandleTypeFlags::HOST_ALLOCATION_EXT, + } + } + + /// The memory, in words. + fn words(self) -> &'static str { + match self { + ModifierMemory::DmaBuf => "dma-bufs", + ModifierMemory::Host => "host allocations", + } + } +} diff --git a/crates/metal2vulkan-runtime/src/host_memory.rs b/crates/metal2vulkan-runtime/src/host_memory.rs index 100a531c3..3dc905cdc 100644 --- a/crates/metal2vulkan-runtime/src/host_memory.rs +++ b/crates/metal2vulkan-runtime/src/host_memory.rs @@ -619,6 +619,14 @@ impl Importer { self.dma_buf_images } + /// Whether the device enables `VK_EXT_image_drm_format_modifier` (with the dma-buf route's + /// image extensions, `create.rs`'s `dma_buf_image_names`): a texture over host pages imported + /// by their pointer may then be a `DRM_FORMAT_MOD_LINEAR` image at Metal's row pitch + /// (`texture.rs`'s `host_pitched_image`). + pub(super) fn makes_modifier_images(&self) -> bool { + self.dma_buf_images + } + /// The memory types the dma-buf `fd` can be imported into (`vkGetMemoryFdPropertiesKHR`); /// `ERROR_FEATURE_NOT_PRESENT` where the device imports no dma-bufs. /// diff --git a/crates/metal2vulkan-runtime/src/interop.rs b/crates/metal2vulkan-runtime/src/interop.rs index 71744ca99..caabb8cd4 100644 --- a/crates/metal2vulkan-runtime/src/interop.rs +++ b/crates/metal2vulkan-runtime/src/interop.rs @@ -104,6 +104,16 @@ impl Texture { /// reinterpret none). A texture with a depth twin gives its `R32_SFLOAT` image, which holds its /// texels; its comparisons read the twin, which a write into the image does not reach. /// + /// A texture over a buffer's bytes whose image aliases them gives a linear image: of + /// `VK_IMAGE_TILING_LINEAR`, or of `VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT` with + /// `DRM_FORMAT_MOD_LINEAR` and one memory plane laid out at the texels' offset and the + /// texture's `bytes_per_row`. The second is the image over host pages imported as dma-bufs + /// (`HostMemory::with_dma_buf`), and over a no-copy buffer's host pages where the driver's own + /// linear image lays its rows out otherwise than `bytes_per_row` (ANV packs them tight; + /// `WorkCounts::pitched_host_images` counts them). Ask such an image's layout of its memory + /// plane (`VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT`, not the color aspect), and its modifier + /// with `vkGetImageDrmFormatModifierPropertiesEXT`. + /// /// # Safety /// /// The image stays its owner's: the caller does not destroy one the runtime made or bind its diff --git a/crates/metal2vulkan-runtime/src/tests/mod.rs b/crates/metal2vulkan-runtime/src/tests/mod.rs index 263a01f92..4a5f23cd5 100644 --- a/crates/metal2vulkan-runtime/src/tests/mod.rs +++ b/crates/metal2vulkan-runtime/src/tests/mod.rs @@ -86,6 +86,8 @@ mod own; mod pipeline; #[cfg(any(m2v_gpu, m2v_cpu_icd))] mod pipeline_wait_order; +#[cfg(unix)] +mod pitch_refusals; mod pixel_format_info; mod private_properties; mod queue; diff --git a/crates/metal2vulkan-runtime/src/tests/pitch_refusals.rs b/crates/metal2vulkan-runtime/src/tests/pitch_refusals.rs new file mode 100644 index 000000000..bc9b687e7 --- /dev/null +++ b/crates/metal2vulkan-runtime/src/tests/pitch_refusals.rs @@ -0,0 +1,68 @@ +//! The kept refusals of `DRM_FORMAT_MOD_LINEAR` images at Metal's row pitch +//! (`texture/pitch_refusals.rs`): which later images a refusal answers, and how many are kept. + +use super::super::image_plan::{plan_image, ImagePlan}; +use super::super::texture::pitch_refusals::{PitchRefusals, PitchedLayout, KEPT}; +use super::super::texture_descriptor::TextureDescriptor; +use super::image_plan::{committed, facts}; +use super::texture_descriptor::APPLE; +use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; + +/// The image plan of a `BGRA8Unorm` texture of `width`x`height`, `layers` slices and `usage` on +/// the first committed profile. +fn plan(width: u64, height: u64, layers: u64, usage: TextureUsage) -> ImagePlan { + let (_, desc, device) = committed().into_iter().next().unwrap(); + let layout = TextureDescriptor { + pixel_format: PixelFormat::BGRA8Unorm, + texture_type: if layers > 1 { + TextureType::Type2DArray + } else { + TextureType::Type2D + }, + width, + height, + array_length: layers, + usage, + ..TextureDescriptor::default() + } + .check(APPLE) + .unwrap(); + plan_image(&layout, usage, false, &facts(&desc, &device)).unwrap() +} + +/// A kept refusal answers the same image at the same row pitch only: another pitch of the same +/// power-of-two class, another extent or another usage is asked again (NVIDIA answers pitches of +/// one class both ways), and an image of several slices is never kept. +#[test] +fn a_refusal_answers_the_same_image_at_the_same_pitch_alone() { + let read = TextureUsage::SHADER_READ; + let tile = plan(1307, 512, 1, read); + let refusals = PitchRefusals::default(); + let refused = PitchedLayout::of(&tile, 5248).unwrap(); + assert!(!refusals.refused(&refused)); + refusals.keep(refused.clone()); + assert!(refusals.refused(&refused)); + assert!(refusals.refused(&PitchedLayout::of(&tile, 5248).unwrap())); + // 5376 = 42 x 128, the class of 5248 = 41 x 128. + assert!(!refusals.refused(&PitchedLayout::of(&tile, 5376).unwrap())); + let taller = plan(1307, 513, 1, read); + assert!(!refusals.refused(&PitchedLayout::of(&taller, 5248).unwrap())); + let rendered = plan(1307, 512, 1, read | TextureUsage::RENDER_TARGET); + assert!(!refusals.refused(&PitchedLayout::of(&rendered, 5248).unwrap())); + assert_eq!(PitchedLayout::of(&plan(1307, 512, 2, read), 5248), None); +} + +/// At most [`KEPT`] refusals are kept: past them a refusal is not, and the driver is asked again. +#[test] +fn at_most_the_bound_of_refusals_is_kept() { + let tile = plan(300, 200, 1, TextureUsage::SHADER_READ); + let refusals = PitchRefusals::default(); + let pitch = |k: usize| 1216 + 16 * k as u64; + for k in 0..KEPT { + refusals.keep(PitchedLayout::of(&tile, pitch(k)).unwrap()); + } + assert!((0..KEPT).all(|k| refusals.refused(&PitchedLayout::of(&tile, pitch(k)).unwrap()))); + let past = PitchedLayout::of(&tile, pitch(KEPT)).unwrap(); + refusals.keep(past.clone()); + assert!(!refusals.refused(&past)); +} diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs index 4eb021def..f0743b11d 100644 --- a/crates/metal2vulkan-runtime/src/texture.rs +++ b/crates/metal2vulkan-runtime/src/texture.rs @@ -148,6 +148,8 @@ pub(super) mod heap; pub(super) mod heap_tiled; pub(super) mod heap_two_planes; pub(crate) mod host_copy; +#[cfg(unix)] +pub(crate) mod pitch_refusals; mod rotation; mod shared; mod staging_copy; @@ -187,6 +189,16 @@ pub(super) struct TextureState { /// Each pixel format's texture capabilities, worked out at its first query /// (`families/formats.rs`). pub(super) format_answers: Mutex>, + /// Each Vulkan format's `DRM_FORMAT_MOD_LINEAR` tiling features, asked of the driver at the + /// first image of that tiling planned in it (`dma_buf.rs`'s `modifier_features`): one entry + /// per format at most. + #[cfg(unix)] + pub(super) modifier_features: Mutex>, + /// The layouts the driver refused a `DRM_FORMAT_MOD_LINEAR` image for host allocations at + /// Metal's row pitch (`texture/pitch_refusals.rs`): a texture of a kept layout is not tried at + /// its pitch again. + #[cfg(unix)] + pitch_refusals: pitch_refusals::PitchRefusals, /// The memory types a heap's buffer and its textures' images take, worked out at the first /// heap's (`texture/heap.rs`). pub(super) heap_types: std::sync::OnceLock, @@ -220,6 +232,10 @@ impl TextureState { neutrals: Mutex::new(Neutrals::default()), usage_answers: Mutex::new(UsageAnswers::default()), format_answers: Mutex::new(HashMap::new()), + #[cfg(unix)] + modifier_features: Mutex::new(HashMap::new()), + #[cfg(unix)] + pitch_refusals: pitch_refusals::PitchRefusals::default(), heap_types: std::sync::OnceLock::new(), storage_forms: storage_form::StorageForms::default(), first_moves: first_move::FirstMoves::default(), @@ -606,13 +622,16 @@ pub(super) struct ImageSwap { } /// A linear image for a texture over a buffer's bytes, made and not yet bound -/// ([`Device::linear_image`], [`Device::host_linear_image`]): its memory requirements, the -/// layout of its first subresource, and the layout it starts in. +/// ([`Device::linear_image`], [`Device::host_linear_image`], [`Device::host_pitched_image`]): its +/// memory requirements, the layout of its first subresource, and the layout it starts in. struct LinearMade { raw: vk::Image, requirements: vk::MemoryRequirements, report: vk::SubresourceLayout, initial: vk::ImageLayout, + /// It is a `DRM_FORMAT_MOD_LINEAR` image laid out at Metal's pitches + /// ([`Device::host_pitched_image`]), not the driver's linear image. + pitched: bool, } /// Why a texture over a buffer takes no linear image: the need that failed, which the @@ -1976,15 +1995,26 @@ impl Device { return Err(Error::NotImplemented(RuntimeGap::Textures)); } let hazard = texels.options().hazard_tracking_mode()?; - let image = self.new_image(plan, layout, descriptor, hazard)?; // A depth or stencil texture over a surface's plane copies the aspect the plane holds // alone (`copy_plan::surface_depth_unit`); its image's other aspect stays the zeros it // was made with, as Metal reads the stencil of `Depth32Float_Stencil8` there. - let aspects = texture_aspects(image.plan()); + let every = texture_aspects(&plan); let held = surface_depth_unit(layout.pixel_format).map(|unit| unit.aspect.into()); let aspects = match held { - Some(held) if aspects.contains(held) => held, - _ => aspects, + Some(held) if every.contains(held) => held, + _ => every, + }; + // Every other shadow's copy in writes each of its texels before any command reads it + // (`shadow.rs`), so it starts as its memory lies: zeros there would never be read, and + // writing them took most of the making (the host's zeros copied into a 1307x512 image + // took 0.9 ms of 1 ms on ANV). + let image = match aspects == every { + true => { + let identity = Identity::new(hazard, false); + let owner = Device::runtime_owner; + self.new_image_as_it_lies(plan, layout, descriptor, identity, owner)? + } + false => self.new_image(plan, layout, descriptor, hazard)?, }; let copies = texels.shadow_copies(image.raw.get(), image.identity, aspects)?; // Its copies keep its own image, which it presents again once the bytes lie in pages. @@ -1999,6 +2029,7 @@ impl Device { ); (object, why) }); + self.shared().counts.shadowed_texture_made(aspects != every); Ok(Storage::Shadow { image: image.shared(), texels, @@ -2195,27 +2226,29 @@ impl Device { } else { "the device" }; - let made = if let Some(LinearLack { format, features }) = linear_lack(&plan, facts) { - Err(LinearRefusal::Need(LinearNeed::Features { - format, - features, - })) - } else if host { - self.host_linear_image(&plan)? + let made = if host { + let (row_pitch, slice_pitch) = (texels.layout.row_pitch, texels.layout.slice_pitch); + self.host_alias_unbound(&plan, row_pitch, slice_pitch, facts)? + } else if let Some(LinearLack { format, features }) = linear_lack(&plan, facts) { + Err( + LinearRefusal::Need(LinearNeed::Features { format, features }) + .describe(&plan, host), + ) } else { self.linear_image(&plan)? + .map_err(|refusal| refusal.describe(&plan, host)) }; let LinearMade { raw, requirements, report, initial, + pitched, } = match made { Ok(made) => made, - Err(refusal) => { + Err(why) => { return Ok(Err(format!( - "{who} makes no linear image of the texture: {}", - refusal.describe(&plan, host) + "{who} makes no linear image of the texture: {why}" ))); } }; @@ -2257,6 +2290,9 @@ impl Device { unsafe { release::object(raw_device, raw) }; return Err(vulkan(error)); } + if pitched { + self.shared().counts.pitched_host_image_made(); + } let image = Image { device: self.clone(), raw: Raw::new(raw), @@ -2606,6 +2642,7 @@ impl Device { requirements, report, initial: vk::ImageLayout::PREINITIALIZED, + pitched: false, })) } @@ -2661,9 +2698,197 @@ impl Device { requirements, report, initial: vk::ImageLayout::UNDEFINED, + pitched: false, })) } + /// The unbound image of `plan` made for host allocations whose texels lie at Metal's layout + /// in a no-copy buffer's pages, its rows `row_pitch` apart (and slices `slice_pitch`): the + /// driver's linear image ([`Device::host_linear_image`]) where it lays them out so, its + /// subresource at offset 0; else, where the device enables `VK_EXT_image_drm_format_modifier`, + /// a `DRM_FORMAT_MOD_LINEAR` image whose one plane the runtime lays out at those pitches + /// ([`Device::host_pitched_image`]). Why not, each attempt's refusal named, where the device + /// makes neither. The caller checks the image's alignment, size and memory types against the + /// buffer's. + fn host_alias_unbound( + &self, + plan: &ImagePlan, + row_pitch: u64, + slice_pitch: u64, + facts: &ImageFacts<'_>, + ) -> Result, Error> { + let slices = plan.layers.max(plan.extent[2]); + let lies = |report: &vk::SubresourceLayout| { + report.offset == 0 + && report.row_pitch == row_pitch + && (slices == 1 || report.array_pitch == slice_pitch) + }; + let made = match linear_lack(plan, facts) { + Some(LinearLack { format, features }) => { + Err(LinearRefusal::Need(LinearNeed::Features { + format, + features, + })) + } + None => self.host_linear_image(plan)?, + }; + let linear = match made { + Ok(made) if lies(&made.report) => return Ok(Ok(made)), + Ok(made) => { + // SAFETY: the image is live and unbound, and no command uses it. + unsafe { release::object(self.shared().vk(), made.raw) }; + format!( + "its linear image for host allocations lays rows {} bytes apart (slices {}) \ + from offset {}", + made.report.row_pitch, made.report.array_pitch, made.report.offset + ) + } + Err(refusal) => refusal.describe(plan, true), + }; + Ok(self + .host_pitched_image(plan, row_pitch, slice_pitch, facts)? + .map_err(|pitched| format!("{linear}; and {pitched}"))) + } + + /// A `DRM_FORMAT_MOD_LINEAR` image of `plan` made for host allocations, unbound, whose one + /// plane lies at offset 0 with rows `row_pitch` apart (and slices `slice_pitch`, for a plan of + /// several layers): a texture over a no-copy buffer's host pages where the driver's own linear + /// image lays its rows out otherwise than Metal (ANV packs them tight, where a surface's rows + /// are padded). Its memory requirements and its plane's layout as the driver reports them, + /// starting `UNDEFINED` as Vulkan has an image of external memory made. Why not where the + /// device does not enable the extension, makes no such image for host allocations + /// (`Device::modifier_image_checks`), refuses the layout, lays it out otherwise (NVIDIA lays + /// rows closer than its own linear image's at its own), or asks a dedicated allocation of it: + /// the runtime asks the driver and takes its answer, never a rule of its own. A layout the + /// driver refused is kept and refused again unasked (`texture/pitch_refusals.rs`). + #[cfg(unix)] + fn host_pitched_image( + &self, + plan: &ImagePlan, + row_pitch: u64, + slice_pitch: u64, + facts: &ImageFacts<'_>, + ) -> Result, Error> { + use crate::dma_buf::{memory_plane_0, ModifierMemory, DRM_FORMAT_MOD_LINEAR}; + let raw_device = self.shared().vk(); + let enabled = (self.shared().host_import.as_ref()) + .is_ok_and(|importer| importer.makes_modifier_images()); + if !enabled { + return Ok(Err( + "the device enables no VK_EXT_image_drm_format_modifier for an image at Metal's \ + row pitch" + .to_owned(), + )); + } + // A layout the driver refused before is refused again, unasked. + let layout = pitch_refusals::PitchedLayout::of(plan, row_pitch); + let refusals = &self.shared().textures.pitch_refusals; + if layout + .as_ref() + .is_some_and(|layout| refusals.refused(layout)) + { + self.shared().counts.pitched_host_image_refusal_recalled(); + return Ok(Err(format!( + "the driver refused this DRM_FORMAT_MOD_LINEAR image for host allocations with \ + rows {row_pitch} bytes apart before" + ))); + } + let host = ModifierMemory::Host; + let view_formats = match self.modifier_image_checks(plan, facts, host)? { + Ok(view_formats) => view_formats, + Err(why) => return Ok(Err(why)), + }; + let array_pitch = if plan.layers > 1 { slice_pitch } else { 0 }; + let planes = [vk::SubresourceLayout { + offset: 0, + size: 0, + row_pitch, + array_pitch, + depth_pitch: 0, + }]; + let mut explicit = vk::ImageDrmFormatModifierExplicitCreateInfoEXT::default() + .drm_format_modifier(DRM_FORMAT_MOD_LINEAR) + .plane_layouts(&planes); + // The driver's refusal of the image itself (of its layout, or of an allocation it is not + // dedicated) is kept (`texture/pitch_refusals.rs`), and counted. + let refused_image = |layout: Option| { + self.shared().counts.pitched_host_image_refused(); + if let Some(layout) = layout { + refusals.keep(layout); + } + }; + let raw = match self.drm_linear_image(plan, &view_formats, &mut explicit, host)? { + Ok(raw) => raw, + Err(error) => { + if error == vk::Result::ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT { + refused_image(layout); + } + return Ok(Err(format!( + "the driver refuses a DRM_FORMAT_MOD_LINEAR image for host allocations with \ + rows {row_pitch} bytes apart ({error:?})" + ))); + } + }; + let mut dedicated = vk::MemoryDedicatedRequirements::default(); + let requirements = { + let mut requirements = vk::MemoryRequirements2::default().push_next(&mut dedicated); + let query = vk::ImageMemoryRequirementsInfo2::default().image(raw); + // SAFETY: `raw` is a live image of this device; the query is core in Vulkan 1.1. + unsafe { raw_device.get_image_memory_requirements2(&query, &mut requirements) }; + requirements.memory_requirements + }; + // SAFETY: `raw` is a live image of a DRM format modifier's tiling, whose one memory plane + // is plane 0 (`VUID-vkGetImageSubresourceLayout-tiling-09433`). + let report = unsafe { raw_device.get_image_subresource_layout(raw, memory_plane_0()) }; + let why = if dedicated.requires_dedicated_allocation != vk::FALSE { + refused_image(layout); + Some(format!( + "it asks a dedicated allocation of a DRM_FORMAT_MOD_LINEAR image of {:?} for \ + host allocations, which one bound at an offset of the buffer's import is not", + plan.format + )) + } else if report.offset != 0 + || report.row_pitch != row_pitch + || (plan.layers > 1 && report.array_pitch != array_pitch) + { + refused_image(layout); + Some(format!( + "the driver lays a DRM_FORMAT_MOD_LINEAR plane for host allocations out at offset \ + {}, rows {} and slices {} bytes apart, where the texels lie at offset 0, rows \ + {row_pitch} and slices {array_pitch} apart", + report.offset, report.row_pitch, report.array_pitch + )) + } else { + None + }; + if let Some(why) = why { + // SAFETY: the image is live and unbound, and no command uses it. + unsafe { release::object(raw_device, raw) }; + return Ok(Err(why)); + } + Ok(Ok(LinearMade { + raw, + requirements, + report, + initial: vk::ImageLayout::UNDEFINED, + pitched: true, + })) + } + + /// No image is laid out by DRM format modifier on this system. + #[cfg(not(unix))] + fn host_pitched_image( + &self, + _plan: &ImagePlan, + _row_pitch: u64, + _slice_pitch: u64, + _facts: &ImageFacts<'_>, + ) -> Result, Error> { + Ok(Err( + "the system lays out no image by DRM format modifier".to_owned() + )) + } + /// The aliasing images of `watches`, over a no-copy buffer's (or a no-copy heap's) host /// pages, made again over a rebind's new `pages` (`rebind.rs`): each of the same plan, made /// as the new pages take it, its texels as far from the new pages' first byte as they were @@ -2688,6 +2913,10 @@ impl Device { let (memory, base) = pages.memory(); let type_index = pages.type_index(); let raw_device = self.shared().vk(); + let facts = self + .shared() + .textures + .facts(self.compile_device().profile()); let mut swaps: Vec = Vec::new(); for watch in watches { let Some(image) = watch.image.upgrade() else { @@ -2728,25 +2957,22 @@ impl Device { continue; } }; - let made = self.host_linear_image(image.plan())?; + // Its rows (and slices) lie as the old image's did: the texture's, in the driver's + // linear image where it lays them out so, else in a `DRM_FORMAT_MOD_LINEAR` image + // at those pitches. + let made = self.host_alias_unbound(image.plan(), row_pitch, slice_pitch, &facts)?; let Ok(LinearMade { raw, requirements, - report, initial, + pitched, + .. }) = made else { return Err(Error::NotImplemented(RuntimeGap::RebindTextures)); }; - // Its rows (and slices) must lie as the old image's did: a `DRM_FORMAT_MOD_LINEAR` - // image's are the texture's, which the driver's linear image may not take. - let plan = image.plan(); - let slices = plan.layers.max(plan.extent[2]); if requirements.memory_type_bits & (1 << type_index) == 0 || !at.is_multiple_of(requirements.alignment.max(1)) - || report.offset != 0 - || report.row_pitch != row_pitch - || (slices > 1 && report.array_pitch != slice_pitch) { // SAFETY: the image is live and unbound, and no command uses it. unsafe { release::object(raw_device, raw) }; @@ -2760,6 +2986,9 @@ impl Device { unsafe { release::object(raw_device, raw) }; return Err(vulkan(error)); } + if pitched { + self.shared().counts.pitched_host_image_made(); + } // Dropped on a later failure, the images made so far go. swaps.push(ImageSwap::new( Arc::clone(&image), @@ -3012,7 +3241,8 @@ impl Device { /// [`new_image_owned`](Self::new_image_owned)'s image holding what its memory held, whatever /// its storage mode: a heap texture's in memory of its own where its bytes in the heap are no /// layout of its texels (`texture/heap.rs`, `AliasRoute::Lossless`), as a heap's textures hold - /// what their bytes held. + /// what their bytes held; and the shadow of a texture over a buffer whose copy in writes every + /// texel of every aspect before any command reads it (`storage_over_buffer`). fn new_image_as_it_lies( &self, plan: ImagePlan, diff --git a/crates/metal2vulkan-runtime/src/texture/pitch_refusals.rs b/crates/metal2vulkan-runtime/src/texture/pitch_refusals.rs new file mode 100644 index 000000000..d01d130b7 --- /dev/null +++ b/crates/metal2vulkan-runtime/src/texture/pitch_refusals.rs @@ -0,0 +1,79 @@ +//! The layouts a device's driver refused a texture's `DRM_FORMAT_MOD_LINEAR` image at Metal's row +//! pitch, kept so that it is not asked again (`texture.rs`'s `host_pitched_image`). +//! +//! A texture over a no-copy buffer's host pages whose rows the driver's own linear image lays out +//! otherwise than Metal is tried as a `DRM_FORMAT_MOD_LINEAR` image laid out at Metal's row pitch, +//! which the driver may refuse: it refuses the layout +//! (`VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT`; RADV of Mesa 26.2.4 at a pitch that is +//! not a multiple of 256 bytes), lays the plane out at another pitch than asked (NVIDIA 615.71.09 +//! below its own linear image's row), or asks a dedicated allocation of the image, which one bound +//! in a buffer's import is not (RADV at every other pitch). The driver answers the same image the +//! same way while the device lives, so a refusal is kept by everything the image is made of that a +//! texture varies: its format, extent, usage, flags and view formats, and the row pitch. A consumer +//! making the same surface's texture each frame asks the driver once. +//! +//! Not kept by the pitch's class (the largest power of two dividing it) alone: measured +//! (`runtime_lane::surface_texture_costs::pitch_classes`, nine formats, four usages, five widths, +//! two pitches of each class from 16 to 4096 bytes), NVIDIA takes a pitch of any class at least its +//! own linear image's row and refuses one below it, so one class holds both answers. +//! +//! Kept only for a refusal of the image itself, never one that may pass another time (the driver +//! out of memory, which the caller reports as it is); and only for a plan of one slice and depth, +//! whose plane has no array pitch. At most [`KEPT`] refusals are kept; past them the driver is +//! asked again each time. + +use crate::device::lock; +use crate::image_plan::ImagePlan; +use metal2vulkan::vk::{Format, ImageCreateFlags, ImageUsageFlags}; +use std::collections::HashSet; +use std::sync::Mutex; + +/// The most refusals a device keeps. +pub(crate) const KEPT: usize = 256; + +/// What a `DRM_FORMAT_MOD_LINEAR` image at a row pitch is made of, of what a texture varies. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub(crate) struct PitchedLayout { + format: Format, + extent: [u32; 3], + usage: ImageUsageFlags, + flags: ImageCreateFlags, + view_formats: Vec, + row_pitch: u64, +} + +impl PitchedLayout { + /// The layout of an image of `plan` with rows `row_pitch` apart; `None` for a plan of several + /// slices or depths, whose refusals are not kept. + pub(crate) fn of(plan: &ImagePlan, row_pitch: u64) -> Option { + (plan.layers == 1 && plan.extent[2] == 1).then(|| PitchedLayout { + format: plan.format, + extent: plan.extent, + usage: plan.usage, + flags: plan.flags, + view_formats: plan.view_formats.clone(), + row_pitch, + }) + } +} + +/// A device's kept refusals of `DRM_FORMAT_MOD_LINEAR` layouts at a row pitch. +#[derive(Debug, Default)] +pub(crate) struct PitchRefusals { + refused: Mutex>, +} + +impl PitchRefusals { + /// Whether the driver refused `layout` before. + pub(crate) fn refused(&self, layout: &PitchedLayout) -> bool { + lock(&self.refused).contains(layout) + } + + /// Keep the driver's refusal of `layout`, while fewer than [`KEPT`] are kept. + pub(crate) fn keep(&self, layout: PitchedLayout) { + let mut refused = lock(&self.refused); + if refused.len() < KEPT { + refused.insert(layout); + } + } +} diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index ffecda142..b1993b2b3 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -89,6 +89,12 @@ pub(crate) struct Counters { dma_buf_sparse_buffers: AtomicU64, dma_buf_images: AtomicU64, dma_buf_image_fallbacks: AtomicU64, + pitched_host_images: AtomicU64, + pitched_host_image_refusals: AtomicU64, + pitched_host_image_refusals_recalled: AtomicU64, + modifier_feature_queries: AtomicU64, + shadowed_textures: AtomicU64, + shadows_zeroed: AtomicU64, replay_logs_kept: AtomicU64, replay_log_bytes: AtomicU64, encoders_reencoded: AtomicU64, @@ -480,6 +486,46 @@ impl Counters { self.dma_buf_image_fallbacks.fetch_add(1, Ordering::Relaxed); } + /// A texture's image over a no-copy buffer's host pages imported by their pointer was made a + /// `DRM_FORMAT_MOD_LINEAR` image at Metal's row pitch and bound there (`texture.rs`'s + /// `host_pitched_image`). + pub(crate) fn pitched_host_image_made(&self) { + self.pitched_host_images.fetch_add(1, Ordering::Relaxed); + } + + /// The driver refused a `DRM_FORMAT_MOD_LINEAR` image at Metal's row pitch (`texture.rs`'s + /// `host_pitched_image`). + #[cfg(unix)] + pub(crate) fn pitched_host_image_refused(&self) { + self.pitched_host_image_refusals + .fetch_add(1, Ordering::Relaxed); + } + + /// A texture's image at Metal's row pitch was not asked of the driver, which refused the same + /// image before (`texture/pitch_refusals.rs`). + #[cfg(unix)] + pub(crate) fn pitched_host_image_refusal_recalled(&self) { + self.pitched_host_image_refusals_recalled + .fetch_add(1, Ordering::Relaxed); + } + + /// The driver was asked a format's `DRM_FORMAT_MOD_LINEAR` tiling features (`dma_buf.rs`'s + /// `modifier_features`). + #[cfg(unix)] + pub(crate) fn modifier_features_asked(&self) { + self.modifier_feature_queries + .fetch_add(1, Ordering::Relaxed); + } + + /// A texture over a buffer's bytes was made a shadow of them (`shadow.rs`), its image zeroed + /// first where `zeroed` (its copies leave an aspect out). + pub(crate) fn shadowed_texture_made(&self, zeroed: bool) { + self.shadowed_textures.fetch_add(1, Ordering::Relaxed); + if zeroed { + self.shadows_zeroed.fetch_add(1, Ordering::Relaxed); + } + } + /// A command buffer kept an ended encoder's log of `bytes` bytes (`replay.rs`). pub(crate) fn replay_log_kept(&self, bytes: usize) { self.replay_logs_kept.fetch_add(1, Ordering::Relaxed); @@ -855,6 +901,32 @@ pub struct WorkCounts { /// driver refused the import): each takes the path of a texture over memory no image aliases /// (`shadowed-texture`). pub dma_buf_image_fallbacks: u64, + /// Images of textures over no-copy buffers' host pages imported by their pointer made + /// `DRM_FORMAT_MOD_LINEAR` images at Metal's row pitch, where the driver's own linear image + /// lays the rows out otherwise (ANV packs them tight), each bound in the buffer's import and + /// aliasing its bytes: one per image made, a rebind's too. + pub pitched_host_images: u64, + /// Images at Metal's row pitch the driver refused (with + /// `VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT`, by laying the plane out at another + /// offset or pitch, or by asking a dedicated allocation of it): one per image asked of the + /// driver, and a texture asks up to two (with a usage it did not declare, then without). + pub pitched_host_image_refusals: u64, + /// Images at Metal's row pitch not asked of the driver, which refused the same image (format, + /// extent, usage, flags, view formats and row pitch) before (`texture/pitch_refusals.rs`). + pub pitched_host_image_refusals_recalled: u64, + /// Formats whose `DRM_FORMAT_MOD_LINEAR` tiling features the driver was asked, for an image + /// over dma-bufs or one at Metal's row pitch over host pages: each format once at most, as + /// the answer is kept. + pub modifier_feature_queries: u64, + /// Textures over a buffer's bytes (a 2D texture or array over a buffer, a no-copy buffer or an + /// IOSurface plane, or a view of another layout of one) that no image aliases, each an image + /// of its own that the encoders copy the bytes into and back (`shadowed-texture`). + pub shadowed_textures: u64, + /// Of `shadowed_textures`, those whose image was zeroed as it was made: its copies leave an + /// aspect out (a depth texture over a surface's plane, whose image's stencil reads zero). + /// Every other shadow's copy in writes each texel before any command reads it, so its image + /// starts as its memory lies. + pub shadows_zeroed: u64, /// Ended compute and blit encoders whose logs their command buffers kept, as a rebind before /// the first submission may encode them again (`replay.rs`), and the bytes of those logs. pub replay_logs_kept: u64, @@ -1001,6 +1073,16 @@ impl Device { dma_buf_sparse_buffers: counters.dma_buf_sparse_buffers.load(Ordering::Relaxed), dma_buf_images: counters.dma_buf_images.load(Ordering::Relaxed), dma_buf_image_fallbacks: counters.dma_buf_image_fallbacks.load(Ordering::Relaxed), + pitched_host_images: counters.pitched_host_images.load(Ordering::Relaxed), + pitched_host_image_refusals: counters + .pitched_host_image_refusals + .load(Ordering::Relaxed), + pitched_host_image_refusals_recalled: counters + .pitched_host_image_refusals_recalled + .load(Ordering::Relaxed), + modifier_feature_queries: counters.modifier_feature_queries.load(Ordering::Relaxed), + shadowed_textures: counters.shadowed_textures.load(Ordering::Relaxed), + shadows_zeroed: counters.shadows_zeroed.load(Ordering::Relaxed), replay_logs_kept: counters.replay_logs_kept.load(Ordering::Relaxed), replay_log_bytes: counters.replay_log_bytes.load(Ordering::Relaxed), encoders_reencoded: counters.encoders_reencoded.load(Ordering::Relaxed), diff --git a/crates/metal2vulkan-validation/runtime-sources.sha256 b/crates/metal2vulkan-validation/runtime-sources.sha256 index 513c52bdb..f638ef028 100644 --- a/crates/metal2vulkan-validation/runtime-sources.sha256 +++ b/crates/metal2vulkan-validation/runtime-sources.sha256 @@ -1 +1 @@ -1bbe379e845c25efa74ffdd0256e63edef72c27cb9ace422eac12610f6dff16a +461560f3a5e23c3e3c0fc300f5cc00f724854555e242468f6a2ea88726d6c00d diff --git a/crates/metal2vulkan-validation/src/runtime_lane.rs b/crates/metal2vulkan-validation/src/runtime_lane.rs index 471193aeb..ace9e0add 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane.rs @@ -433,6 +433,8 @@ mod pipeline_creation; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod pipeline_records; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] +mod pitched_surfaces; +#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod pixel_downscales; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod pixel_samplers; @@ -532,6 +534,8 @@ mod submit_costs; mod sum_regroup; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod surface_aliases; +#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd), target_os = "linux"))] +mod surface_texture_costs; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod swizzled_storage; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] diff --git a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs index 05fcb5e04..0d3f5f8f6 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs @@ -1177,7 +1177,10 @@ fn tiled_at(unit: u64, [w, h]: [u64; 2], x: u64, y: u64) -> u64 { /// same bytes; and the stencil of `Depth32Float_Stencil8`, which is not in the plane, loads as 0 /// whatever a pass stored, through the texture and its `X32_Stencil8` view alike (a draw testing /// it equal to 0 draws every texel, equal to the stored value none), the depth loaded and stored -/// again unchanged and no byte changed by the view's pass. +/// again unchanged and no byte changed by the view's pass. A shadow of such a texture is zeroed as +/// it is made for `Depth32Float_Stencil8` (`WorkCounts::shadows_zeroed`), and never for +/// `Depth16Unorm` or `Depth32Float`, whose making starts no image on the host +/// (`images_started_on_the_host`). #[test] fn a_planar_surface_s_depth_or_stencil_texture_s_passes_write_metal_s_elements_alone() { use super::render_state::{library, stencil, Probe, WHITE}; @@ -1216,10 +1219,36 @@ fn a_planar_surface_s_depth_or_stencil_texture_s_passes_write_metal_s_elements_a _ => TextureUsage::RENDER_TARGET, }; d.resource_options = held.buffer.resource_options(); + let before = device.work_counts(); let t = held .buffer .new_texture_with_iosurface_plane(&d, IoSurfacePlane::new(0, bpr, true)) .unwrap_or_else(|e| panic!("{what}: {e}")); + // A shadow's image is zeroed as it is made only where its copies leave an + // aspect out: always the stencil of `Depth32Float_Stencil8`, which reads 0; + // never a one-aspect depth format's, nor is any image started on the host + // for one. (`Stencil8` and `X32Stencil8` leave out the depth of an image of + // both aspects where the device holds them in one: ANV's `X32Stencil8`.) + let counted = device.work_counts(); + let shadowed = counted.shadowed_textures - before.shadowed_textures; + let zeroed = counted.shadows_zeroed - before.shadows_zeroed; + let hosted = + counted.images_started_on_the_host - before.images_started_on_the_host; + match pf { + PixelFormat::Depth32FloatStencil8 => assert_eq!( + zeroed, shadowed, + "{what}: the shadows zeroed as made ({shadowed} shadows)" + ), + PixelFormat::Depth16Unorm | PixelFormat::Depth32Float => { + assert_eq!( + (zeroed, hosted), + (0, 0), + "{what}: the shadows zeroed as made, and the images started on \ + the host ({shadowed} shadows)" + ) + } + _ => {} + } let depth = !matches!(pf, PixelFormat::Stencil8 | PixelFormat::X32Stencil8); let has_stencil = !matches!(pf, PixelFormat::Depth16Unorm | PixelFormat::Depth32Float); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/dma_buf_imports.rs b/crates/metal2vulkan-validation/src/runtime_lane/dma_buf_imports.rs index 0b817ef18..b8e1b4ebe 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/dma_buf_imports.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/dma_buf_imports.rs @@ -135,7 +135,7 @@ fn udmabuf(memfd: BorrowedFd<'_>, pieces: &[(u64, u64)]) -> std::io::Result bool { +pub(super) fn udmabuf_openable(test: &str) -> bool { match std::fs::OpenOptions::new() .read(true) .write(true) @@ -152,7 +152,7 @@ fn udmabuf_openable(test: &str) -> bool { /// Guest RAM: a sealed `memfd` of `len` bytes and one scratch page past them, which no view maps /// and which pads a source's last chunk where it makes several; and the file's own whole shared /// mapping of the `len` bytes. -struct Memfd { +pub(super) struct Memfd { fd: OwnedFd, len: usize, pub(super) whole: View, @@ -160,10 +160,10 @@ struct Memfd { /// What a test's source saw: each request, with the number of chunks it answered (0 for an /// `Err`). -type Calls = Arc>>; +pub(super) type Calls = Arc>>; impl Memfd { - fn new(len: usize) -> Memfd { + pub(super) fn new(len: usize) -> Memfd { // SAFETY: a new anonymous file, owned at once. let fd = unsafe { let fd = libc::memfd_create( @@ -185,7 +185,7 @@ impl Memfd { } /// A view of the file's `pieces` `(offset, size)`, mapped contiguously in that order. - fn view(&self, pieces: &[(usize, usize)]) -> View { + pub(super) fn view(&self, pieces: &[(usize, usize)]) -> View { assert!(pieces .iter() .all(|&(offset, size)| offset + size <= self.len)); @@ -196,7 +196,7 @@ impl Memfd { /// the request, split at multiples of its granule into as few chunks as keep each within the /// host's udmabuf limits (an `Err` where one granule alone exceeds them), the last of several /// padded with the scratch page. It records each request in `calls`. - fn source(&self, view: &View, calls: &Calls) -> DmaBufSource { + pub(super) fn source(&self, view: &View, calls: &Calls) -> DmaBufSource { self.source_split(view, calls, false) } @@ -324,7 +324,7 @@ fn file_pieces(pieces: &[(usize, usize)], at: usize, len: usize) -> Option, len: usize, pieces: Vec<(usize, usize)>, @@ -376,7 +376,7 @@ impl View { } /// The view's address `offset` bytes in. - fn pointer(&self, offset: usize) -> NonNull { + pub(super) fn pointer(&self, offset: usize) -> NonNull { assert!(offset < self.len); // SAFETY: inside the view. unsafe { NonNull::new_unchecked(self.at.as_ptr().add(offset)) } @@ -1208,11 +1208,13 @@ fn check_texture_request( /// fallback. Each reads the bytes the CPU wrote; the CPU's later writes, with no call between, are /// what the next command buffer reads (the image rests in `GENERAL` after its one acquire from the /// foreign queue family); a blit's write into it lands in the file's pages at the texels' places, -/// the padding past each row keeping the CPU's bytes. The one over three pages, `BGRA8Unorm` made -/// without `PixelFormatView` usage, is read and written through a view in `RGBA8Unorm` -/// (`texture/view_shadow.rs`), an image over a dma-buf of its own pages too, counted, whose write -/// the texture then reads. Where the device imports the pointer (NVIDIA, lavapipe) the textures -/// take the path they took before: the source uncalled, nothing counted. +/// the padding past each row keeping the CPU's bytes; the same texture made again asks the driver +/// no format's modifier features (`WorkCounts::modifier_feature_queries`, which RADV's images +/// ask). The one over three pages, `BGRA8Unorm` made without `PixelFormatView` usage, is read and +/// written through a view in `RGBA8Unorm` (`texture/view_shadow.rs`), an image over a dma-buf of +/// its own pages too, counted, whose write the texture then reads. Where the device imports the +/// pointer (NVIDIA, lavapipe) the textures take the path they took before: the source uncalled, +/// nothing counted. #[test] fn a_texture_over_dma_buf_pages_is_an_image_over_its_own_pages() { const TEST: &str = "dma-buf texture"; @@ -1342,6 +1344,19 @@ fn a_texture_over_dma_buf_pages_is_an_image_over_its_own_pages() { _ => "an image over a dma-buf of its own pages", } ); + // A format's modifier features are asked of the driver once: the same texture made + // again asks none. + let queries = device.work_counts().modifier_feature_queries; + drop( + buffer + .new_texture(&descriptor, offset as u64, pitch as u64) + .unwrap(), + ); + assert_eq!( + device.work_counts().modifier_feature_queries, + queries, + "{test}: the same texture made again asked the driver's modifier features" + ); } drop(buffer); }); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/no_copy_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/no_copy_textures.rs index d66f6cfdd..8f70d1337 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/no_copy_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/no_copy_textures.rs @@ -7,25 +7,35 @@ //! //! - [`textures_over_no_copy_buffers_read_and_write_the_caller_s_pages`], under the validation //! layer: the consumer's surface formats (and `BGR10_XR`, an extended-range format held in an -//! integer image) at 1920x1080 with packed rows, as render targets the shaders read (and write), -//! and as textures the shaders only read (and write): the bytes the caller wrote before the -//! texture was made are what a blit reads out of it (a linear image made for host allocations +//! integer image) at 1920x1080 with packed rows, and with rows padded by 64 bytes as a guest +//! browser's surfaces have them (the `_padded` tests), as render targets the shaders read (and +//! write), and as textures the shaders only read (and write): the bytes the caller wrote before +//! the texture was made are what a blit reads out of it (a linear image made for host allocations //! starts `UNDEFINED`, and its move to `GENERAL` must keep them); a render pass's clear (a blit's //! write, without render target usage) lands in the pages, as the next blit reads the texture; //! the caller's later writes are what the next blit reads; and a blit's write through the texture //! read through the buffer by a blit, and the other way round, in one blit encoder and in two of //! one command buffer, read the write (the texture and its buffer are one resource to hazard -//! tracking, which on MoltenVK leaves blits to Metal's tracking). Each texture's form is printed -//! (`NOCOPY-TEXTURE`): aliased where `vk_image` answers its own image over the pages, shadowed -//! where it answers none. +//! tracking, which on MoltenVK leaves blits to Metal's tracking). Padded rows' bytes between +//! the rows are never written. Each texture's form is printed (`NOCOPY-TEXTURE`): aliased where +//! `vk_image` answers its own image over the pages, shadowed where it answers none, and the +//! images the making counted (`WorkCounts::pitched_host_images`, `shadowed_textures`). A shadow +//! is made without zeroing its image (`shadows_zeroed`, `images_started_on_the_host`: its copy +//! in writes every texel first); on ANV, whose own linear images pack rows tight, a padded +//! texture is an image at Metal's row pitch (`DRM_FORMAT_MOD_LINEAR`), never a shadow; and +//! making the same texture again asks the driver no format's modifier features +//! (`modifier_feature_queries`), nor a layout at Metal's row pitch it refused +//! (`pitched_host_image_refusals`, `pitched_host_image_refusals_recalled`), and takes the same +//! form. //! - [`two_slice_arrays_over_no_copy_buffers_read_and_write_the_caller_s_pages`], under the //! validation layer: two-slice `RGBA8Unorm` 2D arrays made by the linear call, a 4x4 sampled one //! and an 8x8 render target, read and written a slice at a time at Metal's slice places //! (`NOCOPY-ARRAY`: the form, and a shadow's reason). //! - [`passes_blend_load_and_store_as_private_textures`], under the validation layer, one process -//! per format: render passes over the texture that load, blend and store, and clear and blend, -//! match a private texture of the same bytes byte for byte, read through the texture and -//! through the buffer (`NOCOPY-BLEND`). +//! per format and row pitch (packed, and padded by 64 bytes): render passes over the texture that +//! load, blend and store, and clear and blend, match a private texture of the same bytes byte +//! for byte, read through the texture and through the buffer, the bytes between padded rows +//! untouched (`NOCOPY-BLEND`). //! - [`surface_frame_costs`], without the validation layer, report only (built in release for the //! numbers): the consumer's display surface, a 1920x1080 `RGBA16Float` or `BGRA8Unorm` texture //! of an IOSurface plane over a no-copy buffer of the surface's pages, written each frame by a @@ -43,6 +53,7 @@ use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{BlendFactor, PixelFormat, PrimitiveType, TextureType, TextureUsage}; use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; +use metal2vulkan::vk::DriverId; use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{ BlitOption, Buffer, ClearColor, CommandQueue, Degradation, Device, IoSurfacePlane, LoadAction, @@ -149,19 +160,47 @@ fn clear(queue: &CommandQueue, texture: &Texture, color: [f64; 4]) { assert_eq!(command_buffer.error(), None); } -/// A test of each of the consumer's surface formats, with its texels' bytes, each in a process of -/// its own: `$test(pf, texel)` as `$name_`. +/// A test of each of the consumer's surface formats, with its texels' bytes and the bytes its rows +/// are padded by, each in a process of its own: `$test(pf, texel, pad)` as `$name`. macro_rules! per_format { - ($test:ident: $($name:ident => $pf:ident, $texel:expr;)*) => { + ($test:ident: $($name:ident => $pf:ident, $texel:expr, $pad:expr;)*) => { $( #[test] fn $name() { - $test(PixelFormat::$pf, $texel); + $test(PixelFormat::$pf, $texel, $pad); } )* }; } +/// The texels of `bytes` laid out in rows `bpr` apart, each row's `row` bytes of texels, of the +/// [`H`] rows: what a texture over them reads and writes. +fn texel_rows(bytes: &[u8], bpr: u64, row: u64) -> Vec { + bytes + .chunks(bpr as usize) + .take(H as usize) + .flat_map(|r| &r[..row as usize]) + .copied() + .collect() +} + +/// The bytes of `bytes` between rows `bpr` apart of `row` bytes of texels, of the [`H`] rows: what +/// no texture over them writes. +fn padding(bytes: &[u8], bpr: u64, row: u64) -> Vec { + bytes + .chunks(bpr as usize) + .take(H as usize) + .flat_map(|r| &r[(row as usize).min(r.len())..]) + .copied() + .collect() +} + +/// Whether the device is ANV, whose own linear images pack rows tight: a texture over host +/// pages with padded rows is there an image at Metal's row pitch. +fn anv(device: &Device) -> bool { + device.properties().description.driver_id == Some(DriverId::INTEL_OPEN_SOURCE_MESA) +} + /// A `Shared` buffer holding `bytes`. pub(super) fn staged(device: &Device, bytes: &[u8]) -> Buffer { let buffer = device @@ -180,11 +219,18 @@ fn bytes_of(buffer: &Buffer) -> Vec { unsafe { std::slice::from_raw_parts(contents.as_ptr(), buffer.length() as usize) }.to_vec() } -/// A write of `texture` (rows `bpr` bytes apart) through a blit, then a read of `under`, the -/// no-copy buffer it lies over, by a blit, and the other way round (a write of `under`, then a -/// read of `texture`), each pair in one blit encoder when `one_encoder`, else in two encoders of -/// one command buffer: each read sees its write, as one resource's accesses are ordered. -fn ordered(queue: &CommandQueue, texture: &Texture, under: &Buffer, bpr: u64, one_encoder: bool) { +/// A write of `texture` (rows `bpr` bytes apart, `row` bytes of texels each) through a blit, then +/// a read of `under`, the no-copy buffer it lies over, by a blit, and the other way round (a write +/// of `under`, then a read of `texture`), each pair in one blit encoder when `one_encoder`, else in +/// two encoders of one command buffer: each read sees its write's texels, as one resource's +/// accesses are ordered. +fn ordered( + queue: &CommandQueue, + texture: &Texture, + under: &Buffer, + (bpr, row): (u64, u64), + one_encoder: bool, +) { let device = queue.device(); let n = bpr * H; let (origin, size) = whole(); @@ -239,7 +285,7 @@ fn ordered(queue: &CommandQueue, texture: &Texture, under: &Buffer, bpr: u64, on command_buffer.wait_until_completed_for(WAIT).unwrap(); assert_eq!(command_buffer.error(), None); assert!( - bytes_of(&out) == pattern, + texel_rows(&bytes_of(&out), bpr, row) == texel_rows(&pattern, bpr, row), "a {} write read through the {} in {}: stale bytes", if texture_first { "texture" } else { "buffer" }, if texture_first { "buffer" } else { "texture" }, @@ -252,11 +298,13 @@ fn ordered(queue: &CommandQueue, texture: &Texture, under: &Buffer, bpr: u64, on } } -/// A texture over a no-copy buffer reads the caller's bytes and writes into them as Metal's -/// does, aliased or shadowed (the module docs), as a render target or not; a write through it -/// read through the buffer, and the other way round, in one blit encoder and in two, each see -/// the write. The form of each is printed. One test a format, each its own process. -fn read_and_write_the_caller_s_pages(pf: PixelFormat, texel: u64) { +/// A texture over a no-copy buffer, its rows padded by `pad` bytes, reads the caller's bytes and +/// writes into them as Metal's does, aliased or shadowed (the module docs), as a render target or +/// not, never the bytes between its rows; a write through it read through the buffer, and the +/// other way round, in one blit encoder and in two, each see the write. A shadow is made without +/// zeroing its image; on ANV a padded texture is an image at Metal's row pitch. The form of each +/// is printed. One test a format and pitch, each its own process. +fn read_and_write_the_caller_s_pages(pf: PixelFormat, texel: u64, pad: u64) { let cache = ScratchCache::new().unwrap(); let messages = Messages::default(); { @@ -269,7 +317,9 @@ fn read_and_write_the_caller_s_pages(pf: PixelFormat, texel: u64) { TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE, ]; for usage in usages { - let bpr = W * texel; + let row = W * texel; + let bpr = row + pad; + let rows = |bytes: &[u8]| texel_rows(bytes, bpr, row); let n = (bpr * H) as usize; let len = n.next_multiple_of(GUEST_PAGE); let mapping = Mapping::anonymous(len); @@ -280,20 +330,79 @@ fn read_and_write_the_caller_s_pages(pf: PixelFormat, texel: u64) { let mut d = TextureDescriptor::texture_2d(pf, W, H, false); d.usage = usage; d.resource_options = buffer.resource_options(); + let before = device.work_counts(); let texture = buffer.new_texture(&d, 0, bpr).unwrap(); + let counted = device.work_counts(); let made = aliased(&texture); - let what = format!("{} usage {usage:?}", pf.name()); + let what = format!("{} usage {usage:?}, rows of {bpr} bytes", pf.name()); + let pitched = counted.pitched_host_images - before.pitched_host_images; + let shadowed = counted.shadowed_textures - before.shadowed_textures; + if made { + assert_eq!( + shadowed, 0, + "{what}: an aliased texture counted as shadowed" + ); + } else { + // Its copy in writes every texel before any command reads it: no zeros first. + assert_eq!(shadowed, 1, "{what}: a shadow not counted"); + assert_eq!( + counted.shadows_zeroed - before.shadows_zeroed, + 0, + "{what}: the shadow's image was zeroed" + ); + assert_eq!( + counted.images_started_on_the_host - before.images_started_on_the_host, + 0, + "{what}: the shadow's image was zeroed on the host" + ); + } + if pad != 0 && anv(&device) { + assert!( + made && pitched == 1, + "{what}: on ANV not an image at Metal's row pitch (aliased {made}, pitched \ + images {pitched})" + ); + } + // A format's modifier features are asked of the driver once, and a layout it refused + // is not asked again: making the same texture again asks neither, and takes the same + // form. + let again = buffer.new_texture(&d, 0, bpr).unwrap(); + let asked = device.work_counts(); + assert_eq!( + asked.modifier_feature_queries - counted.modifier_feature_queries, + 0, + "{what}: the same texture's making asked the driver's modifier features again" + ); + // The first making's refusal was asked or recalled (an earlier usage's image may be + // this one's); the second recalls it. + let refused = (counted.pitched_host_image_refusals + - before.pitched_host_image_refusals) + + (counted.pitched_host_image_refusals_recalled + - before.pitched_host_image_refusals_recalled); + assert_eq!( + ( + asked.pitched_host_image_refusals - counted.pitched_host_image_refusals, + asked.pitched_host_image_refusals_recalled + - counted.pitched_host_image_refusals_recalled, + ), + (0, refused), + "{what}: the same texture's making asked the driver a layout it refused (refused \ + or recalled at first {refused})" + ); + assert_eq!(aliased(&again), made, "{what}: made again in another form"); + drop(again); + let between = padding(&mapping.read(0..n), bpr, row); // The caller's bytes from before the texture was made. assert!( - blit_out(&queue, &texture, bpr) == mapping.read(0..n), + rows(&blit_out(&queue, &texture, bpr)) == rows(&mapping.read(0..n)), "{what}: a blit does not read the caller's bytes" ); if usage.contains(TextureUsage::RENDER_TARGET) { // A render pass's clear, in the pages. clear(&queue, &texture, [0.25, 0.5, 0.75, 1.0]); - let cleared = blit_out(&queue, &texture, bpr); + let cleared = rows(&blit_out(&queue, &texture, bpr)); assert!( - cleared == mapping.read(0..n), + cleared == rows(&mapping.read(0..n)), "{what}: the clear is not in the pages" ); let first = &cleared[..texel as usize]; @@ -331,21 +440,26 @@ fn read_and_write_the_caller_s_pages(pf: PixelFormat, texel: u64) { command_buffer.wait_until_completed_for(WAIT).unwrap(); assert_eq!(command_buffer.error(), None); assert!( - mapping.read(0..n) == written, + rows(&mapping.read(0..n)) == rows(&written), "{what}: the blit's write is not in the pages" ); } + assert!( + padding(&mapping.read(0..n), bpr, row) == between, + "{what}: a write through the texture reached the bytes between its rows" + ); // The caller's later bytes. mapping.write(0, &counting(len, 11)); assert!( - blit_out(&queue, &texture, bpr) == mapping.read(0..n), + rows(&blit_out(&queue, &texture, bpr)) == rows(&mapping.read(0..n)), "{what}: a blit does not read the caller's later bytes" ); // Writes through the texture and the buffer, read the other way. - ordered(&queue, &texture, &buffer, bpr, true); - ordered(&queue, &texture, &buffer, bpr, false); + ordered(&queue, &texture, &buffer, (bpr, row), true); + ordered(&queue, &texture, &buffer, (bpr, row), false); eprintln!( - "NOCOPY-TEXTURE on {}: {what} {W}x{H}, rows of {bpr} bytes: {}", + "NOCOPY-TEXTURE on {}: {what} {W}x{H}: {} (pitched host images {pitched}, \ + refused {refused}, shadows {shadowed})", device.name(), form(made) ); @@ -362,11 +476,16 @@ fn read_and_write_the_caller_s_pages(pf: PixelFormat, texel: u64) { per_format! { read_and_write_the_caller_s_pages: - textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_bgra8 => BGRA8Unorm, 4; - textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_rgba16f => RGBA16Float, 8; - textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_rgb10a2 => RGB10A2Unorm, 4; - textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_rgba8 => RGBA8Unorm, 4; - textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_bgr10_xr => BGR10XR, 4; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_bgra8 => BGRA8Unorm, 4, 0; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_rgba16f => RGBA16Float, 8, 0; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_rgb10a2 => RGB10A2Unorm, 4, 0; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_rgba8 => RGBA8Unorm, 4, 0; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_bgr10_xr => BGR10XR, 4, 0; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_bgra8_padded => BGRA8Unorm, 4, 64; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_rgba16f_padded => RGBA16Float, 8, 64; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_rgb10a2_padded => RGB10A2Unorm, 4, 64; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_rgba8_padded => RGBA8Unorm, 4, 64; + textures_over_no_copy_buffers_read_and_write_the_caller_s_pages_bgr10_xr_padded => BGR10XR, 4, 64; } /// `texture`'s slice `slice`, `w`x`h` texels with rows `bpr` bytes apart, blitted out into a new @@ -769,22 +888,23 @@ fn differing(a: &[u8], b: &[u8], texel: u64) -> (usize, Option) { (count, first) } -/// A render pass over a texture over a no-copy buffer (a surface's render target) loads, blends -/// and stores as one over a private texture of the same bytes does, byte for byte on the same -/// device, aliased or shadowed: a pass that loads the caller's bytes and blends over the left -/// half, read through the texture and through the buffer in the same command buffer; a blit's -/// write of the buffer, then a pass that loads it and blends over the right half, in one command -/// buffer; and a pass that clears and blends over the left half. The pages hold the reference's -/// bytes after each. The form is printed (`NOCOPY-BLEND`). One test a format, each its own -/// process. -fn passes_blend_load_and_store_as_private_textures(pf: PixelFormat, texel: u64) { +/// A render pass over a texture over a no-copy buffer (a surface's render target), its rows padded +/// by `pad` bytes, loads, blends and stores as one over a private texture of the same bytes does, +/// byte for byte on the same device, aliased or shadowed: a pass that loads the caller's bytes and +/// blends over the left half, read through the texture and through the buffer in the same command +/// buffer; a blit's write of the buffer, then a pass that loads it and blends over the right half, +/// in one command buffer; and a pass that clears and blends over the left half. The pages hold the +/// reference's texels after each, and the bytes between the rows stay the caller's. The form is +/// printed (`NOCOPY-BLEND`). One test a format and pitch, each its own process. +fn passes_blend_load_and_store_as_private_textures(pf: PixelFormat, texel: u64, pad: u64) { let cache = ScratchCache::new().unwrap(); let messages = Messages::default(); { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); let queue = device.new_command_queue().unwrap(); let pipeline = blending(&device, pf); - let bpr = W * texel; + let row = W * texel; + let bpr = row + pad; let n = (bpr * H) as usize; let len = n.next_multiple_of(GUEST_PAGE); let mapping = Mapping::anonymous(len); @@ -799,15 +919,27 @@ fn passes_blend_load_and_store_as_private_textures(pf: PixelFormat, texel: u64) let texture = buffer.new_texture(&d, 0, bpr).unwrap(); d.resource_options = ResourceOptions::private(); let private = device.new_texture(&d).unwrap(); - let what = format!("{} {W}x{H} ({})", pf.name(), form(aliased(&texture))); + let what = format!( + "{} {W}x{H}, rows of {bpr} bytes ({})", + pf.name(), + form(aliased(&texture)) + ); let check = |round: &str, ours: &[u8], reference: &[u8]| { - let (count, first) = differing(ours, reference, texel); + let (ours, reference) = (texel_rows(ours, bpr, row), texel_rows(reference, bpr, row)); + let (count, first) = differing(&ours, &reference, texel); assert!( count == 0, "{what}, {round}: {count} texels differ from the private texture's, the first \ at texel {first:?}" ); }; + // The bytes between the rows, which no pass or blit through the texture writes. + let between = |round: &str, expected: &[u8]| { + assert!( + padding(&mapping.read(0..n), bpr, row) == padding(expected, bpr, row), + "{what}, {round}: the bytes between the rows changed" + ); + }; let second = texels_of(texel, n, 2); let blue = [0.2, 0.4, 0.6, 0.5]; let amber = [0.9, 0.6, 0.1, 0.25]; @@ -853,6 +985,7 @@ fn passes_blend_load_and_store_as_private_textures(pf: PixelFormat, texel: u64) &mapping.read(0..n), &reference, ); + between("the first pass", &initial); // A blit's write of the buffer, then a pass that loads it, in one command buffer. let (reference, _) = round( &queue, @@ -884,6 +1017,7 @@ fn passes_blend_load_and_store_as_private_textures(pf: PixelFormat, texel: u64) &reference, ); check("that pass, in the pages", &mapping.read(0..n), &reference); + between("the blit's write and the pass", &second); // A pass that clears and blends. let (reference, _) = round( &queue, @@ -911,6 +1045,7 @@ fn passes_blend_load_and_store_as_private_textures(pf: PixelFormat, texel: u64) ); check("a pass that clears and blends", &ours, &reference); check("that pass, in the pages", &mapping.read(0..n), &reference); + between("the pass that clears", &second); eprintln!( "NOCOPY-BLEND on {}: {what}: every round as a private texture's", device.name() @@ -927,10 +1062,14 @@ fn passes_blend_load_and_store_as_private_textures(pf: PixelFormat, texel: u64) per_format! { passes_blend_load_and_store_as_private_textures: - passes_over_no_copy_textures_blend_load_and_store_as_private_ones_bgra8 => BGRA8Unorm, 4; - passes_over_no_copy_textures_blend_load_and_store_as_private_ones_rgba16f => RGBA16Float, 8; - passes_over_no_copy_textures_blend_load_and_store_as_private_ones_rgb10a2 => RGB10A2Unorm, 4; - passes_over_no_copy_textures_blend_load_and_store_as_private_ones_rgba8 => RGBA8Unorm, 4; + passes_over_no_copy_textures_blend_load_and_store_as_private_ones_bgra8 => BGRA8Unorm, 4, 0; + passes_over_no_copy_textures_blend_load_and_store_as_private_ones_rgba16f => RGBA16Float, 8, 0; + passes_over_no_copy_textures_blend_load_and_store_as_private_ones_rgb10a2 => RGB10A2Unorm, 4, 0; + passes_over_no_copy_textures_blend_load_and_store_as_private_ones_rgba8 => RGBA8Unorm, 4, 0; + passes_over_no_copy_textures_blend_load_and_store_as_private_ones_bgra8_padded => BGRA8Unorm, 4, 64; + passes_over_no_copy_textures_blend_load_and_store_as_private_ones_rgba16f_padded => RGBA16Float, 8, 64; + passes_over_no_copy_textures_blend_load_and_store_as_private_ones_rgb10a2_padded => RGB10A2Unorm, 4, 64; + passes_over_no_copy_textures_blend_load_and_store_as_private_ones_rgba8_padded => RGBA8Unorm, 4, 64; } /// How a frame's render pass writes the surface. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pitched_surfaces.rs b/crates/metal2vulkan-validation/src/runtime_lane/pitched_surfaces.rs new file mode 100644 index 000000000..4678df2d9 --- /dev/null +++ b/crates/metal2vulkan-validation/src/runtime_lane/pitched_surfaces.rs @@ -0,0 +1,604 @@ +//! Device tests of textures over no-copy buffers at a guest browser's padded row pitches, on the +//! device the cfg selects, under the validation layer. Each texture is made as the consumer makes +//! a surface's (`new_texture_with_iosurface_plane`, render target and shader read usage) over a +//! no-copy buffer of private anonymous pages, at one of [`LAYOUTS`]: the browser's 1307x512 +//! `BGRA8Unorm` tile with rows of 5248 bytes (its texels 5228), and the same tile and others with +//! rows padded to 16, 256 and 512 bytes, a small tile, a full-width strip, and an `RGBA16Float` +//! tile, so the rows' padding takes each power of two from 16 to 512 bytes. +//! +//! Whatever form the device gives the texture (its own linear image, a `DRM_FORMAT_MOD_LINEAR` +//! image laid out at Metal's row pitch, or a shadow), every step reads and writes Metal's bytes at +//! Metal's places, and no write reaches the bytes between the rows: +//! +//! - **reads**: a blit out, `get_bytes`, a fragment function's `read`, and its `sample` through a +//! nearest sampler give the caller's texels; a linear sampler gives what it gives over a private +//! texture of the same texels, byte for byte; the caller's later writes are what the next read +//! reads; +//! - **writes**: a blit of a buffer into the texture, `replace_region` of a box at an odd origin, +//! and a blit of a private texture's box into it land in the pages; +//! - **renders**: a pass that loads, blends a rectangle and stores, and one that clears, blends and +//! stores, leave in the pages what they leave in a private texture of the same texels; +//! - **blits out**: a box at an odd origin copied into a private texture holds the pages' texels. +//! +//! Printed per layout (`PITCHED-SURFACE`): the form, the images the making counted +//! (`WorkCounts::pitched_host_images`, `shadowed_textures`), and a shadow's reason. On ANV, whose +//! own linear images pack rows tight, every layout is an image at Metal's row pitch, never a +//! shadow. + +use super::host_memory::{counting, no_copy, not_importable, Mapping, GUEST_PAGE}; +use super::no_copy_textures::{blending, floats, staged}; +use super::{validated_device, Messages, ScratchCache, WAIT}; +use crate::air_library::AirLibrary; +use crate::gpu::TEST_DEVICE; +use metal2vulkan::bind::SamplerDescriptor; +use metal2vulkan::metal::{PixelFormat, PrimitiveType, SamplerMinMagFilter, TextureUsage}; +use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; +use metal2vulkan::vk::DriverId; +use metal2vulkan_devtools::{engine_dir, llvm_assemble}; +use metal2vulkan_runtime::{ + BlitOption, Buffer, ClearColor, CommandQueue, Degradation, Device, IoSurfacePlane, LoadAction, + Origin, PipelineOptions, Region, RenderPassDescriptor, RenderPipelineState, ResourceOptions, + SamplerState, Size, StoreAction, Texture, TextureDescriptor, +}; + +/// A surface's plane: its name, pixel format and texel bytes, width, height and bytes per row. +#[derive(Clone, Copy, Debug)] +struct Layout { + name: &'static str, + pf: PixelFormat, + texel: u64, + w: u64, + h: u64, + bpr: u64, +} + +impl Layout { + const fn bgra8(name: &'static str, w: u64, h: u64, bpr: u64) -> Layout { + Layout { + name, + pf: PixelFormat::BGRA8Unorm, + texel: 4, + w, + h, + bpr, + } + } + + /// The bytes of a row's texels. + fn row(&self) -> u64 { + self.w * self.texel + } + + /// The bytes the texels span, the last row's padding with them. + fn len(&self) -> usize { + (self.bpr * self.h) as usize + } +} + +/// The layouts, each its own test. +const LAYOUTS: [Layout; 8] = [ + // The browser's tile: rows padded to 64 bytes (5248 = 41 x 128). + Layout::bgra8("1307x512/5248", 1307, 512, 5248), + // Rows padded to 16 bytes (5232 = 327 x 16). + Layout::bgra8("1307x512/5232", 1307, 512, 5232), + // Rows padded to 256 bytes (5376 = 21 x 256). + Layout::bgra8("1307x512/5376", 1307, 512, 5376), + // Rows padded past 256, to 512 bytes (5632 = 11 x 512). + Layout::bgra8("1307x512/5632", 1307, 512, 5632), + // A small tile, rows padded to 64 bytes (1216 = 19 x 64). + Layout::bgra8("300x200/1216", 300, 200, 1216), + // A full-width strip, rows padded to 256 bytes (7680 = 15 x 512; 7652 of texels). + Layout::bgra8("1913x96/7680", 1913, 96, 7680), + // A narrow tile, rows padded to 32 bytes (1056 = 33 x 32). + Layout::bgra8("257x64/1056", 257, 64, 1056), + // An `RGBA16Float` tile, rows padded to 64 bytes (5312 = 83 x 64). + Layout { + name: "657x128/5312 RGBA16Float", + pf: PixelFormat::RGBA16Float, + texel: 8, + w: 657, + h: 128, + bpr: 5312, + }, +]; + +/// Texels of `layout` for `n` bytes, varied by `k`, each a value every read, sample and blend +/// keeps: `RGBA16Float` halves in [2^-7, 1), other formats any bits. +fn texels_of(layout: &Layout, n: usize, k: usize) -> Vec { + if layout.texel == 8 { + (0..n / 2) + .flat_map(|i| (0x2000u16 + ((i * 97 + k * 13) % 0x1c00) as u16).to_le_bytes()) + .collect() + } else { + counting(n, k) + } +} + +/// The texels of `bytes`, rows `layout.bpr` apart: what a texture over them reads and writes, row +/// after row. +fn rows(layout: &Layout, bytes: &[u8]) -> Vec { + bytes + .chunks(layout.bpr as usize) + .take(layout.h as usize) + .flat_map(|r| &r[..layout.row() as usize]) + .copied() + .collect() +} + +/// `texels` (rows of `layout.row()` bytes) laid into `bytes` at rows `layout.bpr` apart, the bytes +/// between the rows left. +fn lay(layout: &Layout, bytes: &mut [u8], texels: &[u8]) { + let row = layout.row() as usize; + for (y, texels) in texels.chunks(row).enumerate() { + let at = y * layout.bpr as usize; + bytes[at..at + row].copy_from_slice(texels); + } +} + +/// The texels (`texel` bytes each) of `a` and `b` that differ, and the first. +fn differing(a: &[u8], b: &[u8], texel: u64) -> (usize, Option) { + let mut count = 0; + let mut first = None; + for (i, (x, y)) in a + .chunks_exact(texel as usize) + .zip(b.chunks_exact(texel as usize)) + .enumerate() + { + if x != y { + count += 1; + first.get_or_insert(i); + } + } + (count, first) +} + +/// The bytes of a `Shared` buffer, which no command uses now. +fn bytes_of(buffer: &Buffer) -> Vec { + let contents = buffer.contents().unwrap(); + // SAFETY: the buffer's `length` bytes, which no command uses now. + unsafe { std::slice::from_raw_parts(contents.as_ptr(), buffer.length() as usize) }.to_vec() +} + +/// Commit `command_buffer` and wait for it, which must complete without an error. +fn run(command_buffer: &metal2vulkan_runtime::CommandBuffer) { + command_buffer.commit().unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + assert_eq!(command_buffer.error(), None); +} + +/// `texture`'s texels, blitted out into a new `Shared` buffer at tight rows. +fn blit_out(queue: &CommandQueue, layout: &Layout, texture: &Texture) -> Vec { + let (row, len) = (layout.row(), layout.row() * layout.h); + let out = queue + .device() + .new_buffer(len, ResourceOptions::shared()) + .unwrap(); + let command_buffer = queue.command_buffer().unwrap(); + let mut blit = command_buffer.blit_command_encoder().unwrap(); + blit.copy_from_texture_to_buffer( + texture, + 0, + 0, + Origin::new(0, 0, 0), + Size::new(layout.w, layout.h, 1), + &out, + 0, + row, + len, + BlitOption::None, + ) + .unwrap(); + blit.end_encoding().unwrap(); + run(&command_buffer); + bytes_of(&out) +} + +/// `texels` (tight rows) blitted into `texture` from a `Shared` buffer. +fn blit_in(queue: &CommandQueue, layout: &Layout, texture: &Texture, texels: &[u8]) { + let source = staged(queue.device(), texels); + let command_buffer = queue.command_buffer().unwrap(); + let mut blit = command_buffer.blit_command_encoder().unwrap(); + blit.copy_from_buffer_to_texture( + &source, + 0, + layout.row(), + texels.len() as u64, + Size::new(layout.w, layout.h, 1), + texture, + 0, + 0, + Origin::new(0, 0, 0), + BlitOption::None, + ) + .unwrap(); + blit.end_encoding().unwrap(); + run(&command_buffer); +} + +/// A blit of `size` texels from `source` at `from` into `destination` at `to`. +fn blit_box( + queue: &CommandQueue, + (source, from): (&Texture, Origin), + (destination, to): (&Texture, Origin), + size: Size, +) { + let command_buffer = queue.command_buffer().unwrap(); + let mut blit = command_buffer.blit_command_encoder().unwrap(); + blit.copy_from_texture_to_texture(source, 0, 0, from, size, destination, 0, 0, to) + .unwrap(); + blit.end_encoding().unwrap(); + run(&command_buffer); +} + +/// A private texture of `layout`'s format and size holding `texels` (tight rows). +fn private_with(queue: &CommandQueue, layout: &Layout, texels: &[u8]) -> Texture { + let mut d = TextureDescriptor::texture_2d(layout.pf, layout.w, layout.h, false); + d.usage = TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ; + d.resource_options = ResourceOptions::private(); + let texture = queue.device().new_texture(&d).unwrap(); + blit_in(queue, layout, &texture, texels); + texture +} + +/// The owned fixture's `tob_rect` over the whole target with `fragment` (`tob_read` or +/// `tob_sample`), into one attachment of `pf`. +fn reading(device: &Device, pf: PixelFormat, fragment: &str) -> RenderPipelineState { + let library = device + .new_library_with_air(&llvm_assemble(&engine_dir().join("tob_renders.ll")).unwrap()) + .unwrap(); + let function = |name: &str| { + StageSource::Function( + library + .new_function_with_name(name) + .unwrap() + .function_descriptor(), + ) + }; + let mut d = RenderPipelineDescriptor::new(function("tob_rect")); + d.fragment = Some(function(fragment)); + d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(pf)); + device + .new_render_pipeline_state(&d, &PipelineOptions::default()) + .unwrap() +} + +/// What a draw of `pipeline` over a whole target of `layout`'s format and size reads from +/// `texture` (through `sampler`, where given): the target's texels, tight rows. +fn drawn( + queue: &CommandQueue, + layout: &Layout, + pipeline: &RenderPipelineState, + texture: &Texture, + sampler: Option<&SamplerState>, +) -> Vec { + let device = queue.device(); + let mut d = TextureDescriptor::texture_2d(layout.pf, layout.w, layout.h, false); + d.usage = TextureUsage::RENDER_TARGET; + d.resource_options = ResourceOptions::private(); + let target = device.new_texture(&d).unwrap(); + let corners = staged(device, &floats([-1.0, -1.0, 1.0, 1.0])); + let mut pass = RenderPassDescriptor::new(); + let color = &mut pass.color_attachments[0]; + color.texture = Some(target.clone()); + color.load_action = LoadAction::Clear; + color.store_action = StoreAction::Store; + color.clear_color = ClearColor::new(0.0, 0.0, 0.0, 0.0); + let command_buffer = queue.command_buffer().unwrap(); + let mut encoder = command_buffer.render_command_encoder(&pass).unwrap(); + encoder.set_render_pipeline_state(pipeline).unwrap(); + encoder.set_vertex_buffer(Some(&corners), 0, 0).unwrap(); + encoder.set_fragment_texture(Some(texture), 0).unwrap(); + if let Some(sampler) = sampler { + encoder + .set_fragment_sampler_state(Some(sampler), 0) + .unwrap(); + } + encoder + .draw_primitives(PrimitiveType::Triangle, 0, 6, 1, 0) + .unwrap(); + encoder.end_encoding().unwrap(); + run(&command_buffer); + blit_out(queue, layout, &target) +} + +/// A pass over `texture` that loads it (clears it to (0.1, 0.2, 0.3, 0.4) where `clear`), blends +/// `color` over the rectangle `corners` and stores. +fn blend_pass( + queue: &CommandQueue, + pipeline: &RenderPipelineState, + texture: &Texture, + clear: bool, + (corners, color): ([f32; 4], [f32; 4]), +) { + let device = queue.device(); + let corners = staged(device, &floats(corners)); + let color = staged(device, &floats(color)); + let mut pass = RenderPassDescriptor::new(); + let attachment = &mut pass.color_attachments[0]; + attachment.texture = Some(texture.clone()); + attachment.load_action = if clear { + LoadAction::Clear + } else { + LoadAction::Load + }; + attachment.store_action = StoreAction::Store; + attachment.clear_color = ClearColor::new(0.1, 0.2, 0.3, 0.4); + let command_buffer = queue.command_buffer().unwrap(); + let mut encoder = command_buffer.render_command_encoder(&pass).unwrap(); + encoder.set_render_pipeline_state(pipeline).unwrap(); + encoder.set_vertex_buffer(Some(&corners), 0, 0).unwrap(); + encoder.set_fragment_buffer(Some(&color), 0, 0).unwrap(); + encoder + .draw_primitives(PrimitiveType::Triangle, 0, 6, 1, 0) + .unwrap(); + encoder.end_encoding().unwrap(); + run(&command_buffer); +} + +/// A sampler of `filter`, clamped to the edge. +fn sampler(device: &Device, filter: SamplerMinMagFilter) -> SamplerState { + let mut d = SamplerDescriptor::new(); + d.min_filter = filter; + d.mag_filter = filter; + device.new_sampler_state(&d).unwrap() +} + +/// Whether the device is ANV, whose own linear images pack rows tight: a texture over host pages +/// with padded rows is there an image at Metal's row pitch. +fn anv(device: &Device) -> bool { + device.properties().description.driver_id == Some(DriverId::INTEL_OPEN_SOURCE_MESA) +} + +/// The module docs' steps over a texture of `layout` over a no-copy buffer: each read gives the +/// pages' texels (or the private texture's answer), each write lands in the pages, and the bytes +/// between the rows stay the caller's. +fn reads_writes_and_renders_as_metal(layout: Layout) { + let cache = ScratchCache::new().unwrap(); + let messages = Messages::default(); + { + let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); + let queue = device.new_command_queue().unwrap(); + let (n, texel) = (layout.len(), layout.texel); + let len = n.next_multiple_of(GUEST_PAGE); + let mapping = Mapping::anonymous(len); + // The pages: texels a blend keeps finite, and the bytes between the rows a pattern of + // their own, which no write through the texture reaches. + let mut pages = counting(len, 7); + lay( + &layout, + &mut pages, + &texels_of(&layout, (layout.row() * layout.h) as usize, 1), + ); + mapping.write(0, &pages); + // SAFETY: the mapping outlives the buffer and the texture (dropped first, below). + let made = unsafe { + no_copy( + &device, + mapping.pointer(), + len, + ResourceOptions::default(), + None, + ) + }; + let buffer = match made { + Ok(buffer) => buffer, + Err(error) if not_importable(&error) => { + eprintln!("PITCHED-SURFACE: the device imports no host memory: {error:?}"); + return; + } + Err(error) => panic!("new_buffer_with_bytes_no_copy: {error:?}"), + }; + let mut d = TextureDescriptor::texture_2d(layout.pf, layout.w, layout.h, false); + d.usage = TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ; + d.resource_options = buffer.resource_options(); + let before = device.work_counts(); + let texture = buffer + .new_texture_with_iosurface_plane(&d, IoSurfacePlane::new(0, layout.bpr, false)) + .unwrap(); + let counted = device.work_counts(); + let pitched = counted.pitched_host_images - before.pitched_host_images; + let shadowed = counted.shadowed_textures - before.shadowed_textures; + // SAFETY: the handle is only compared, while the texture lives. + let aliased = unsafe { texture.vk_image() }.is_some(); + let what = format!("{} ({})", layout.name, layout.pf.name()); + assert_eq!( + u64::from(!aliased), + shadowed, + "{what}: aliased {aliased}, but {shadowed} shadows counted" + ); + if anv(&device) { + assert!( + aliased && pitched == 1, + "{what}: on ANV not an image at Metal's row pitch (aliased {aliased}, pitched \ + images {pitched})" + ); + } + // The pages as Metal leaves them, after each step. + let mut expected = pages.clone(); + let check = |step: &str, expected: &[u8]| { + let now = mapping.read(0..len); + let (count, first) = differing(&rows(&layout, &now), &rows(&layout, expected), texel); + assert!( + count == 0, + "{what}, {step}: {count} texels in the pages differ from Metal's, the first at \ + texel {first:?}" + ); + assert!( + now == expected, + "{what}, {step}: the bytes between the rows (or past the last) changed" + ); + }; + let read = |step: &str, ours: &[u8], theirs: &[u8]| { + let (count, first) = differing(ours, theirs, texel); + assert!( + count == 0, + "{what}, {step}: {count} texels differ, the first at texel {first:?}" + ); + }; + + // Reads of the caller's bytes as they were before the texture was made. + let texels = rows(&layout, &expected); + read("a blit out", &blit_out(&queue, &layout, &texture), &texels); + let mut got = vec![0u8; texels.len()]; + let whole = Region::new_2d(0, 0, layout.w, layout.h); + texture + .get_bytes(&mut got, layout.row(), 0, whole, 0, 0) + .unwrap(); + read("get_bytes", &got, &texels); + let reads = reading(&device, layout.pf, "tob_read"); + read( + "a fragment function's read", + &drawn(&queue, &layout, &reads, &texture, None), + &texels, + ); + let samples = reading(&device, layout.pf, "tob_sample"); + let nearest = sampler(&device, SamplerMinMagFilter::Nearest); + let linear = sampler(&device, SamplerMinMagFilter::Linear); + read( + "a nearest sample", + &drawn(&queue, &layout, &samples, &texture, Some(&nearest)), + &texels, + ); + let private = private_with(&queue, &layout, &texels); + read( + "a linear sample, against a private texture's", + &drawn(&queue, &layout, &samples, &texture, Some(&linear)), + &drawn(&queue, &layout, &samples, &private, Some(&linear)), + ); + check("the reads", &expected); + + // The caller's later bytes, read by a sample and a blit. + let later = texels_of(&layout, texels.len(), 2); + lay(&layout, &mut expected, &later); + mapping.write(0, &expected); + read( + "a nearest sample of the caller's later bytes", + &drawn(&queue, &layout, &samples, &texture, Some(&nearest)), + &later, + ); + read( + "a blit out of the caller's later bytes", + &blit_out(&queue, &layout, &texture), + &later, + ); + + // Writes: a blit of a buffer, `replace_region` of a box, a blit of a private texture's box. + let written = texels_of(&layout, later.len(), 3); + blit_in(&queue, &layout, &texture, &written); + lay(&layout, &mut expected, &written); + check("a blit's write", &expected); + let (bx, by, bw, bh) = (3, 5, layout.w / 2 + 1, layout.h / 3 + 1); + let boxed = texels_of(&layout, (bw * bh * texel) as usize, 4); + texture + .replace_region(Region::new_2d(bx, by, bw, bh), 0, 0, &boxed, bw * texel, 0) + .unwrap(); + for (y, row) in boxed.chunks((bw * texel) as usize).enumerate() { + let at = ((by + y as u64) * layout.bpr + bx * texel) as usize; + expected[at..at + row.len()].copy_from_slice(row); + } + check("replace_region", &expected); + let source = private_with(&queue, &layout, &texels_of(&layout, later.len(), 5)); + let (fx, fy, tx, ty) = (7, 1, layout.w / 3, 2); + let size = Size::new(layout.w / 2, layout.h / 2, 1); + blit_box( + &queue, + (&source, Origin::new(fx, fy, 0)), + (&texture, Origin::new(tx, ty, 0)), + size, + ); + let from = blit_out(&queue, &layout, &source); + for y in 0..size.height { + let start = ((fy + y) * layout.row() + fx * texel) as usize; + let row = &from[start..start + (size.width * texel) as usize]; + let at = ((ty + y) * layout.bpr + tx * texel) as usize; + expected[at..at + row.len()].copy_from_slice(row); + } + check("a blit of a private texture's box", &expected); + + // Renders that store, against a private texture of the same texels. + let blend = blending(&device, layout.pf); + let reference = private_with(&queue, &layout, &rows(&layout, &expected)); + let left = ([-1.0, -1.0, 0.0, 1.0], [0.2, 0.4, 0.6, 0.5]); + let right = ([0.0, -1.0, 1.0, 1.0], [0.9, 0.6, 0.1, 0.25]); + for (step, clear, rect) in [ + ("a pass that loads, blends and stores", false, left), + ("a pass that clears, blends and stores", true, right), + ] { + blend_pass(&queue, &blend, &reference, clear, rect); + blend_pass(&queue, &blend, &texture, clear, rect); + lay( + &layout, + &mut expected, + &blit_out(&queue, &layout, &reference), + ); + check(step, &expected); + } + + // A blit of the texture's box out into a private texture. + let (fx, fy) = (layout.w / 4 + 1, 3); + let size = Size::new(layout.w / 2, layout.h / 2, 1); + let out = private_with(&queue, &layout, &vec![0; later.len()]); + blit_box( + &queue, + (&texture, Origin::new(fx, fy, 0)), + (&out, Origin::new(0, 0, 0)), + size, + ); + let copied = blit_out(&queue, &layout, &out); + let pages = rows(&layout, &expected); + for y in 0..size.height { + let at = (y * layout.row()) as usize; + let from = ((fy + y) * layout.row() + fx * texel) as usize; + let width = (size.width * texel) as usize; + assert!( + copied[at..at + width] == pages[from..from + width], + "{what}: a blit of the texture's box out: row {y} differs from the pages'" + ); + } + check("the last blit", &expected); + // A shadow's reason, as the device announced it. + let reason = messages + .take_notices() + .into_iter() + .filter_map(|message| message.degradation) + .find(|notice| notice.degradation == Degradation::ShadowedTexture) + .map(|notice| format!(": {}", notice.reason)) + .unwrap_or_default(); + eprintln!( + "PITCHED-SURFACE on {}: {what}: {} (pitched host images {pitched}, shadows \ + {shadowed}){reason}", + device.name(), + if aliased { "aliased" } else { "shadowed" }, + ); + drop((texture, buffer)); + drop(mapping); + } + let messages = messages.take(); + assert!( + messages.is_empty(), + "the validation layer reported: {messages:#?}" + ); +} + +/// One test a layout, each its own process: `$name` runs [`LAYOUTS`]`[$index]`. +macro_rules! per_layout { + ($($name:ident => $index:expr;)*) => { + $( + #[test] + fn $name() { + reads_writes_and_renders_as_metal(LAYOUTS[$index]); + } + )* + }; +} + +per_layout! { + a_browser_tile_at_5248_byte_rows_reads_writes_and_renders_as_metal => 0; + a_tile_at_16_byte_padded_rows_reads_writes_and_renders_as_metal => 1; + a_tile_at_256_byte_padded_rows_reads_writes_and_renders_as_metal => 2; + a_tile_at_512_byte_padded_rows_reads_writes_and_renders_as_metal => 3; + a_small_tile_reads_writes_and_renders_as_metal => 4; + a_full_width_strip_reads_writes_and_renders_as_metal => 5; + a_narrow_tile_reads_writes_and_renders_as_metal => 6; + a_half_float_tile_reads_writes_and_renders_as_metal => 7; +} diff --git a/crates/metal2vulkan-validation/src/runtime_lane/surface_texture_costs.rs b/crates/metal2vulkan-validation/src/runtime_lane/surface_texture_costs.rs new file mode 100644 index 000000000..513fe8b18 --- /dev/null +++ b/crates/metal2vulkan-validation/src/runtime_lane/surface_texture_costs.rs @@ -0,0 +1,637 @@ +//! What making textures over no-copy buffers costs on the device the cfg selects, the way a +//! consumer's guest browser makes them each frame: report only, in release builds, to weigh the +//! runtime's texture-over-buffer path before and after a change to it. +//! +//! The workload is a guest browser's while it scrolls, as the consumer replays it: each frame, for +//! each of a few IOSurfaces, a new no-copy buffer over the surface's pages and a texture of its +//! plane over that buffer (`new_texture_with_iosurface_plane`, the consumer's +//! `newTextureWithDescriptor:iosurface:plane:`), a render pass that loads and stores the texture +//! and a blit that reads it into a private texture, one command buffer for the frame, waited for; +//! then the textures and buffers are released. The surfaces are `BGRA8Unorm`, of the layouts in +//! [`LAYOUTS`]: the browser's 1307x512 tile with rows padded to 64 bytes (5248, its tight row +//! 5228), a tight-row tile, and other padded rows. Their pages are: +//! +//! - **`anonymous`**: private anonymous memory, whose pointer every measured driver imports; +//! - **`guest-ram`**: a sealed `memfd` mapped shared, as QEMU's guest RAM is, with a dma-buf +//! source (`HostMemory::with_dma_buf`, `udmabuf`s of the file's pages): RADV refuses the pointer +//! and imports dma-bufs, ANV and NVIDIA import the pointer. Skipped where `/dev/udmabuf` cannot +//! be opened. +//! +//! Each case also runs with the buffer kept across frames (`kept`), a new texture over it each +//! frame. Printed per case (`SURFTEX-COST`): the texture's form (aliased or shadowed), the median +//! and 90th percentile of the host's time making the buffer, making the texture and releasing +//! both, per texture; per frame, the encoding and the commit-to-completion wall time and the +//! process's CPU time; and the device's work counts per frame that the path moves (dma-buf images +//! and fallbacks, shadows and those zeroed as made, images at Metal's row pitch over host pages +//! and the driver's refusals of them, asked and recalled, images started on the host, internal +//! submissions). `SURFTEX-QUERY` lines print what the driver answers for a `DRM_FORMAT_MOD_LINEAR` +//! image of host allocations. +//! +//! [`pitch_classes`] asks which row pitches the device lays a texture over a no-copy buffer's +//! host pages at: for each of a few formats and usages (a device each), widths, and pitches of +//! each power-of-two class from 16 bytes up (a pitch's class is the largest power of two dividing +//! it; two pitches a class, the smallest odd multiples of the class that cover the row), each +//! texture made twice, the form its making took (the driver's own linear image, an image at +//! Metal's row pitch, a shadow where the driver refused that image, asked or recalled, or a shadow +//! for another reason) and the median time of each form's making. Printed per format, usage and +//! class (`SURFTEX-PITCH`): the forms, and whether every texture of the class that the driver's +//! own linear image does not alias took one answer; per format and usage (`SURFTEX-PITCH-RULE`) +//! the classes at Metal's pitch, shadowed and mixed, and the reason the first shadow announced. +//! +//! Both are ignored by default: measurements, not checks. Run them by name with `--run-ignored all`, in a +//! build with `--cfg m2v_system_alloc`, whose lib test binary keeps the system allocator as a +//! consumer's process does. + +use super::dma_buf_imports::{udmabuf_openable, Calls, Memfd, View}; +use super::host_memory::{host_page, Mapping, GUEST_PAGE}; +use super::{validated_device_with, Messages, ScratchCache, WAIT}; +use crate::gpu::TEST_DEVICE; +use ash::vk; +use metal2vulkan::metal::{PixelFormat, TextureUsage}; +use metal2vulkan_runtime::{ + Buffer, CommandQueue, Device, HostMemory, IoSurfacePlane, LoadAction, Origin, + RenderPassDescriptor, ResourceOptions, Size, StoreAction, Texture, TextureDescriptor, + WorkCounts, +}; +use std::time::Instant; + +/// The untimed and the timed frames of each case. +const WARM: usize = 10; +const FRAMES: usize = 100; + +/// A surface's plane: its name, width, height and bytes per row (`BGRA8Unorm`, 4 bytes a texel). +const LAYOUTS: [(&str, u64, u64, u64); 5] = [ + // The browser's tile: rows padded to 64 bytes. + ("1307x512/5248", 1307, 512, 5248), + // Tight rows, a multiple of 256 bytes. + ("1024x512/4096", 1024, 512, 4096), + // Rows padded to 256 bytes. + ("1307x512/5376", 1307, 512, 5376), + // A small tile, rows padded to 64 bytes. + ("300x200/1216", 300, 200, 1216), + // A full-width strip, rows padded to 64 bytes. + ("1913x96/7680", 1913, 96, 7680), +]; + +/// Where a case's surfaces' pages lie. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Pages { + Anonymous, + GuestRam, +} + +/// The process's CPU time so far, every thread's, in microseconds. +fn process_cpu_us() -> f64 { + let mut now = libc::timespec { + tv_sec: 0, + tv_nsec: 0, + }; + // SAFETY: `now` is a valid timespec for the call to fill. + let read = unsafe { libc::clock_gettime(libc::CLOCK_PROCESS_CPUTIME_ID, &mut now) }; + assert_eq!(read, 0, "the process's CPU clock"); + now.tv_sec as f64 * 1e6 + now.tv_nsec as f64 / 1e3 +} + +/// Microseconds since `at`. +fn since(at: Instant) -> f64 { + at.elapsed().as_secs_f64() * 1e6 +} + +/// The median and 90th percentile of `values`. +fn median_p90(mut values: Vec) -> (f64, f64) { + values.sort_by(f64::total_cmp); + let at = |p: usize| values[(values.len() * p / 100).min(values.len() - 1)]; + (at(50), at(90)) +} + +/// A surface's pages, and how a no-copy buffer is made over them. +enum Surface { + Anonymous(Mapping), + GuestRam { + view: View, + /// The memfd the view maps (it outlives the view's buffers). + _memfd: std::rc::Rc, + calls: Calls, + }, +} + +impl Surface { + fn len(width_bytes: u64, height: u64) -> usize { + ((width_bytes * height) as usize).next_multiple_of(GUEST_PAGE) + } + + /// A no-copy buffer of `len` bytes over the surface's first byte, of default options, as the + /// consumer makes one over a surface's pages for each texture of it. + fn buffer(&self, device: &Device, len: usize, memfd: Option<&Memfd>) -> Buffer { + let memory = match self { + // SAFETY: the mapping outlives every buffer over it (the test drops them first). + Surface::Anonymous(mapping) => unsafe { HostMemory::new(mapping.pointer()) }, + Surface::GuestRam { view, calls, .. } => { + let memfd = memfd.expect("the guest RAM's file"); + // SAFETY: the view outlives every buffer over it, and the source makes dma-bufs of + // its pages. + unsafe { HostMemory::with_dma_buf(view.pointer(0), memfd.source(view, calls)) } + } + }; + // SAFETY: as above. + unsafe { + device.new_buffer_with_bytes_no_copy( + memory, + len as u64, + ResourceOptions::default(), + None, + ) + } + .unwrap() + } +} + +/// The texture of a surface's plane, `width`x`height` with rows `bpr` bytes apart, over `buffer`. +fn plane_texture(buffer: &Buffer, width: u64, height: u64, bpr: u64) -> Texture { + let mut d = TextureDescriptor::texture_2d(PixelFormat::BGRA8Unorm, width, height, false); + d.usage = TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ; + d.resource_options = buffer.resource_options(); + buffer + .new_texture_with_iosurface_plane(&d, IoSurfacePlane::new(0, bpr, false)) + .unwrap() +} + +/// Whether `texture`'s texels are its own image over the buffer's memory: aliased, not shadowed. +fn aliased(texture: &Texture) -> bool { + // SAFETY: the handle is only compared, while the texture lives. + unsafe { texture.vk_image() }.is_some() +} + +/// One frame's work over `textures`: a pass loading and storing each, and a blit reading each into +/// its private texture of `privates`, in one command buffer, committed and waited for. The host's +/// time encoding, and from the commit until the wait returned. +fn frame(queue: &CommandQueue, textures: &[Texture], privates: &[Texture]) -> (f64, f64) { + let began = Instant::now(); + let command_buffer = queue.command_buffer().unwrap(); + for texture in textures { + let mut pass = RenderPassDescriptor::new(); + let attachment = &mut pass.color_attachments[0]; + attachment.texture = Some(texture.clone()); + attachment.load_action = LoadAction::Load; + attachment.store_action = StoreAction::Store; + let encoder = command_buffer.render_command_encoder(&pass).unwrap(); + encoder.end_encoding().unwrap(); + } + let mut blit = command_buffer.blit_command_encoder().unwrap(); + for (texture, private) in textures.iter().zip(privates) { + let size = Size::new(texture.width(), texture.height(), 1); + let origin = Origin::new(0, 0, 0); + blit.copy_from_texture_to_texture(texture, 0, 0, origin, size, private, 0, 0, origin) + .unwrap(); + } + blit.end_encoding().unwrap(); + let encoded = since(began); + let committed = Instant::now(); + command_buffer.commit().unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + assert_eq!(command_buffer.error(), None); + (encoded, since(committed)) +} + +/// The work counts the texture path moves, `after` less `before`, per frame of `frames`. +fn counts_per_frame(before: &WorkCounts, after: &WorkCounts, frames: usize) -> String { + let per = |a: u64, b: u64| (a - b) as f64 / frames as f64; + format!( + "shadowed textures {:.2} (zeroed {:.2}), pitched host images {:.2} (refused {:.2}, \ + recalled {:.2}), dma-buf images {:.2}, dma-buf image fallbacks {:.2}, dma-buf imports \ + {:.2}, images started on the host {:.2}, internal submissions {:.2}, staging submissions \ + {:.2}", + per(after.shadowed_textures, before.shadowed_textures), + per(after.shadows_zeroed, before.shadows_zeroed), + per(after.pitched_host_images, before.pitched_host_images), + per( + after.pitched_host_image_refusals, + before.pitched_host_image_refusals + ), + per( + after.pitched_host_image_refusals_recalled, + before.pitched_host_image_refusals_recalled + ), + per(after.dma_buf_images, before.dma_buf_images), + per( + after.dma_buf_image_fallbacks, + before.dma_buf_image_fallbacks + ), + per(after.dma_buf_imports, before.dma_buf_imports), + per( + after.images_started_on_the_host, + before.images_started_on_the_host + ), + per(after.internal_submissions, before.internal_submissions), + per(after.staging_submissions, before.staging_submissions), + ) +} + +/// What the driver answers for a `B8G8R8A8_UNORM` image of `DRM_FORMAT_MOD_LINEAR` tiling made for +/// host allocations, at each usage the runtime may ask of a surface's texture: whether it makes +/// one, and whether it imports host memory for it (`SURFTEX-QUERY`). +fn print_host_modifier_queries(device: &Device) { + // SAFETY: read while the device lives; nothing is made. + let raw = unsafe { device.raw() }; + let sampled = vk::ImageUsageFlags::SAMPLED + | vk::ImageUsageFlags::TRANSFER_SRC + | vk::ImageUsageFlags::TRANSFER_DST; + for (name, usage) in [ + ("sampled", sampled), + ( + "sampled+color", + sampled | vk::ImageUsageFlags::COLOR_ATTACHMENT, + ), + ( + "sampled+color+storage", + sampled | vk::ImageUsageFlags::COLOR_ATTACHMENT | vk::ImageUsageFlags::STORAGE, + ), + ] { + for (tiling, modifier, tiling_name) in [ + (vk::ImageTiling::LINEAR, false, "LINEAR"), + ( + vk::ImageTiling::DRM_FORMAT_MODIFIER_EXT, + true, + "DRM_FORMAT_MOD_LINEAR", + ), + ] { + let mut drm = vk::PhysicalDeviceImageDrmFormatModifierInfoEXT::default() + .drm_format_modifier(0) + .sharing_mode(vk::SharingMode::EXCLUSIVE); + let mut host = vk::PhysicalDeviceExternalImageFormatInfo::default() + .handle_type(vk::ExternalMemoryHandleTypeFlags::HOST_ALLOCATION_EXT); + let mut info = vk::PhysicalDeviceImageFormatInfo2::default() + .format(vk::Format::B8G8R8A8_UNORM) + .ty(vk::ImageType::TYPE_2D) + .tiling(tiling) + .usage(usage) + .push_next(&mut host); + if modifier { + info = info.push_next(&mut drm); + } + let mut external = vk::ExternalImageFormatProperties::default(); + let mut properties = vk::ImageFormatProperties2::default().push_next(&mut external); + // SAFETY: the physical device is the instance's; the chains live for the call. + let answer = unsafe { + raw.instance.get_physical_device_image_format_properties2( + raw.physical_device, + &info, + &mut properties, + ) + }; + let limits = properties.image_format_properties; + let features = external.external_memory_properties.external_memory_features; + println!( + "SURFTEX-QUERY on {}: B8G8R8A8_UNORM {tiling_name} {name} for host allocations: \ + {answer:?}, max extent {}x{}, external features {:#x}", + device.name(), + limits.max_extent.width, + limits.max_extent.height, + features.as_raw(), + ); + } + } +} + +#[test] +#[ignore = "a release-mode measurement: run by name"] +fn surface_texture_costs() { + let cache = ScratchCache::new().unwrap(); + let messages = Messages::default(); + let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |options| { + options.layers.clear(); + }) + .unwrap(); + messages.take_notices(); + print_host_modifier_queries(&device); + let queue = device.new_command_queue().unwrap(); + let page = host_page(); + let lens: Vec = LAYOUTS + .iter() + .map(|&(_, _, h, bpr)| Surface::len(bpr, h)) + .collect(); + let privates: Vec = LAYOUTS + .iter() + .map(|&(_, w, h, _)| { + let mut d = TextureDescriptor::texture_2d(PixelFormat::BGRA8Unorm, w, h, false); + d.usage = TextureUsage::SHADER_READ; + d.resource_options = ResourceOptions::private(); + device.new_texture(&d).unwrap() + }) + .collect(); + for pages in [Pages::Anonymous, Pages::GuestRam] { + let memfd = match pages { + Pages::GuestRam if !udmabuf_openable("surface_texture_costs") => continue, + Pages::GuestRam => Some(std::rc::Rc::new(Memfd::new( + lens.iter().sum::() + page, + ))), + Pages::Anonymous => None, + }; + let mut at = 0; + let surfaces: Vec = lens + .iter() + .map(|&len| match &memfd { + None => Surface::Anonymous(Mapping::anonymous(len)), + Some(memfd) => { + let view = memfd.view(&[(at, len)]); + at += len; + Surface::GuestRam { + view, + _memfd: std::rc::Rc::clone(memfd), + calls: Calls::default(), + } + } + }) + .collect(); + for kept in [false, true] { + // Each layout's buffer, kept across frames where `kept`. + let mut held: Vec> = vec![None; LAYOUTS.len()]; + let mut times = vec![(Vec::new(), Vec::new(), Vec::new()); LAYOUTS.len()]; + let mut forms = vec![false; LAYOUTS.len()]; + let (mut encodes, mut waits, mut cpus) = (Vec::new(), Vec::new(), Vec::new()); + let mut before = device.work_counts(); + for k in 0..WARM + FRAMES { + if k == WARM { + before = device.work_counts(); + } + let cpu = process_cpu_us(); + let mut textures = Vec::new(); + let mut buffers = Vec::new(); + for (index, &(_, w, h, bpr)) in LAYOUTS.iter().enumerate() { + let began = Instant::now(); + let buffer = match &held[index] { + Some(buffer) => buffer.clone(), + None => surfaces[index].buffer(&device, lens[index], memfd.as_deref()), + }; + let made_buffer = since(began); + if kept { + held[index] = Some(buffer.clone()); + } + let began = Instant::now(); + let texture = plane_texture(&buffer, w, h, bpr); + let made_texture = since(began); + // Asked once, untimed: handing the image out moves it to `GENERAL` by a + // waited submission of its own. + if k == 0 { + forms[index] = aliased(&texture); + } + if k >= WARM { + times[index].0.push(made_buffer); + times[index].1.push(made_texture); + } + textures.push(texture); + buffers.push(buffer); + } + let (encoded, waited) = frame(&queue, &textures, &privates); + for (index, (texture, buffer)) in textures.into_iter().zip(buffers).enumerate() { + let began = Instant::now(); + drop((texture, buffer)); + if k >= WARM { + times[index].2.push(since(began)); + } + } + if k >= WARM { + encodes.push(encoded); + waits.push(waited); + cpus.push(process_cpu_us() - cpu); + } + } + let after = device.work_counts(); + drop(held); + let mode = if kept { "kept buffer" } else { "new buffer" }; + for (index, (buffers, textures, releases)) in times.into_iter().enumerate() { + let name = LAYOUTS[index].0; + let (buffer, buffer90) = median_p90(buffers); + let (texture, texture90) = median_p90(textures); + let (release, release90) = median_p90(releases); + println!( + "SURFTEX-COST on {}: {pages:?} pages, {mode}, {name}: {}; per texture: buffer \ + {buffer:.0} us (p90 {buffer90:.0}), texture {texture:.0} us (p90 \ + {texture90:.0}), release {release:.0} us (p90 {release90:.0})", + device.name(), + if forms[index] { "aliased" } else { "shadowed" }, + ); + } + let (encode, encode90) = median_p90(encodes); + let (wait, wait90) = median_p90(waits); + let (cpu, cpu90) = median_p90(cpus); + println!( + "SURFTEX-FRAME on {}: {pages:?} pages, {mode}, {} textures a frame: encode \ + {encode:.0} us (p90 {encode90:.0}), commit to completion {wait:.0} us (p90 \ + {wait90:.0}), process CPU {cpu:.0} us (p90 {cpu90:.0}); per frame: {}", + device.name(), + LAYOUTS.len(), + counts_per_frame(&before, &after, FRAMES), + ); + } + let calls: usize = surfaces + .iter() + .map(|surface| match surface { + Surface::GuestRam { calls, .. } => calls.lock().unwrap().len(), + Surface::Anonymous(_) => 0, + }) + .sum(); + println!( + "SURFTEX-SOURCE on {}: {pages:?} pages: the dma-buf sources were called {calls} times", + device.name() + ); + drop(surfaces); + } + let notices = super::degrade_notices::counts(&messages.take_notices()); + println!("SURFTEX-NOTICES on {}: {notices:?}", device.name()); +} + +/// The formats [`pitch_classes`] asks about, with their texel bytes. +const SWEPT_FORMATS: [(PixelFormat, u64); 9] = [ + (PixelFormat::BGRA8Unorm, 4), + (PixelFormat::RGBA8Unorm, 4), + (PixelFormat::RGB10A2Unorm, 4), + (PixelFormat::RGBA16Float, 8), + (PixelFormat::R8Unorm, 1), + (PixelFormat::RG8Unorm, 2), + (PixelFormat::R16Float, 2), + (PixelFormat::R32Float, 4), + (PixelFormat::RGBA32Float, 16), +]; + +/// The widths [`pitch_classes`] makes textures of, and their height. +const SWEPT_WIDTHS: [u64; 5] = [5, 64, 300, 1307, 1913]; +const SWEPT_HEIGHT: u64 = 16; + +/// The largest power-of-two class [`pitch_classes`] asks about: 2^12 bytes. +const SWEPT_CLASSES: std::ops::RangeInclusive = 4..=12; + +/// The form a texture over host pages took, by what its making counted. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +enum Form { + /// The driver's own linear image lies at the pitch. + Own, + /// A `DRM_FORMAT_MOD_LINEAR` image at Metal's row pitch. + Pitched, + /// A shadow: the driver refused the image at Metal's row pitch, asked. + Refused, + /// A shadow: the driver refused the same image before, and was not asked again. + Recalled, + /// A shadow for another reason (the modifier's features or the format query). + Shadowed, + /// The texture was refused. + Failed, +} + +/// The two smallest odd multiples of `class` (a power of two) at least `row`: two pitches whose +/// class is exactly `class`. +fn pitches_of_class(row: u64, class: u64) -> [u64; 2] { + let mut first = row.next_multiple_of(class); + if (first / class).is_multiple_of(2) { + first += class; + } + [first, first + 2 * class] +} + +/// A texture of `d` over a new no-copy buffer of `len` bytes of `mapping`, rows `bpr` apart: the +/// form its making took, and the host's time making it. +fn swept( + device: &Device, + mapping: &Mapping, + len: usize, + d: &TextureDescriptor, + bpr: u64, +) -> (Form, f64) { + // SAFETY: the mapping outlives the buffer, dropped here. + let buffer = unsafe { + device.new_buffer_with_bytes_no_copy( + HostMemory::new(mapping.pointer()), + len as u64, + ResourceOptions::default(), + None, + ) + } + .unwrap(); + let mut d = *d; + d.resource_options = buffer.resource_options(); + let before = device.work_counts(); + let began = Instant::now(); + let made = buffer.new_texture(&d, 0, bpr); + let took = since(began); + let after = device.work_counts(); + let moved = |count: fn(&WorkCounts) -> u64| count(&after) > count(&before); + let form = match made { + Err(_) => Form::Failed, + Ok(_) if moved(|c| c.pitched_host_images) => Form::Pitched, + Ok(_) if moved(|c| c.pitched_host_image_refusals) => Form::Refused, + Ok(_) if moved(|c| c.pitched_host_image_refusals_recalled) => Form::Recalled, + Ok(_) if moved(|c| c.shadowed_textures) => Form::Shadowed, + Ok(_) => Form::Own, + }; + (form, took) +} + +#[test] +#[ignore = "a release-mode measurement: run by name"] +fn pitch_classes() { + let cache = ScratchCache::new().unwrap(); + let messages = Messages::default(); + let largest = SWEPT_FORMATS.iter().map(|&(_, texel)| texel).max().unwrap(); + let widest = SWEPT_WIDTHS.iter().max().unwrap() * largest + (4 << *SWEPT_CLASSES.end()); + let len = Surface::len(widest, SWEPT_HEIGHT); + let mapping = Mapping::anonymous(len); + let usages = [ + ("read", TextureUsage::SHADER_READ), + ( + "read+render", + TextureUsage::SHADER_READ | TextureUsage::RENDER_TARGET, + ), + ( + "read+write", + TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE, + ), + ( + "read+write+render", + TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE | TextureUsage::RENDER_TARGET, + ), + ]; + let mut times: std::collections::BTreeMap> = Default::default(); + let mut name = String::new(); + for &(pf, texel) in &SWEPT_FORMATS { + for &(usage_name, usage) in &usages { + // A device for each format and usage, which announces its first shadow's reason. + let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |options| { + options.layers.clear(); + }) + .unwrap(); + messages.take_notices(); + name = device.name().to_owned(); + let (mut pitched_classes, mut refused_classes, mut mixed) = + (Vec::new(), Vec::new(), Vec::new()); + for class in SWEPT_CLASSES.map(|bits| 1u64 << bits) { + let mut forms = Vec::new(); + for &w in &SWEPT_WIDTHS { + for bpr in pitches_of_class(w * texel, class) { + let mut d = TextureDescriptor::texture_2d(pf, w, SWEPT_HEIGHT, false); + d.usage = usage; + // Made twice: the second making of a refused image recalls the refusal. + for _ in 0..2 { + let (form, took) = swept(&device, &mapping, len, &d, bpr); + times.entry(form).or_default().push(took); + forms.push((w, bpr, form)); + } + } + } + // Every texture the driver's own linear image does not alias took one answer + // (a recalled refusal is the driver's earlier one). + let answers: std::collections::BTreeSet
= forms + .iter() + .map(|&(_, _, form)| match form { + Form::Recalled => Form::Refused, + form => form, + }) + .filter(|&form| form != Form::Own) + .collect(); + let one = answers.len() <= 1; + match answers.iter().next() { + _ if !one => mixed.push(class), + Some(Form::Pitched) => pitched_classes.push(class), + Some(_) => refused_classes.push(class), + None => {} + } + let count = |form: Form| forms.iter().filter(|&&(_, _, f)| f == form).count(); + println!( + "SURFTEX-PITCH on {}: {} {usage_name} class {class}: own linear {}, pitched \ + {}, refused {} (recalled {}), shadowed {}, failed {}; one answer {one}{}", + device.name(), + pf.name(), + count(Form::Own), + count(Form::Pitched), + count(Form::Refused), + count(Form::Recalled), + count(Form::Shadowed), + count(Form::Failed), + if one { + String::new() + } else { + format!(" ({forms:?})") + }, + ); + } + let reason = messages + .take_notices() + .into_iter() + .find_map(|message| message.degradation.map(|notice| notice.reason)) + .unwrap_or_else(|| "no shadow".to_owned()); + println!( + "SURFTEX-PITCH-RULE on {}: {} {usage_name}: at Metal's pitch {pitched_classes:?}, \ + shadowed {refused_classes:?}, mixed {mixed:?}; the first shadow: {reason}", + device.name(), + pf.name(), + ); + } + } + for (form, took) in times { + let count = took.len(); + let (median, p90) = median_p90(took); + println!( + "SURFTEX-PITCH-TIME on {name}: {form:?}: {count} textures, making {median:.1} us (p90 \ + {p90:.1})" + ); + } +} diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 76af84fa9..c63c17514 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 399; /// changes no behaviour, and then updates that hash alone with the commit saying why, or changes /// behaviour and also bumps this version. The commit that bumps it says what changed; this comment /// keeps no history. -pub const RUNTIME_VERSION: u32 = 1185; +pub const RUNTIME_VERSION: u32 = 1186; /// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex, /// of the manifest, the build script, and exactly the files the crate roots' module tree compiles diff --git a/docs/API.md b/docs/API.md index 3f9f9f4b2..13a902c1c 100644 --- a/docs/API.md +++ b/docs/API.md @@ -144,7 +144,13 @@ What the runtime enables for itself outside the vocabulary enters no enable set, or fingerprint: among it the extensions of its dma-buf fallback for no-copy memory whose pointer the device refuses (`HostMemory::with_dma_buf`), `VK_EXT_external_memory_dma_buf` with `VK_KHR_external_memory_fd`, and `VK_EXT_image_drm_format_modifier` with -`VK_EXT_queue_family_foreign` beside them, wherever a device lists them. +`VK_EXT_queue_family_foreign` beside them, wherever a device lists them. With them enabled, a +texture over a no-copy buffer's pages imported by their pointer is also a `DRM_FORMAT_MOD_LINEAR` +image made for host allocations at Metal's row pitch where the driver's own linear image lays its +rows out otherwise (ANV packs them tight) and the driver takes that layout +(`WorkCounts::pitched_host_images`; HOWTO.md section 6 lists what each measured driver takes). +`Texture::vk_image` then gives that image. A layout the driver refused is kept per device and not +asked again (`pitched_host_image_refusals`, `pitched_host_image_refusals_recalled`). ## 2. A library @@ -687,7 +693,11 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. - `metal2vulkan-degrade-shadowed-texture` (performance). `ShadowedTexture`: A 2D texture over a buffer is a shadow image: no linear image of the device lays its texels out as Metal does in the buffer's memory (over a no-copy buffer's imported host memory, no linear image made for host - allocations does), or the buffer is over the caller's `VkBuffer`, whose memory backs no image of + allocations does: neither the driver's own nor, where the device enables + `VK_EXT_image_drm_format_modifier`, a `DRM_FORMAT_MOD_LINEAR` image laid out at Metal's row + pitch, which the driver may refuse for the texture's format, usage or pitch; + `WorkCounts::pitched_host_images` counts those made, `pitched_host_image_refusals` those the + driver refused), or the buffer is over the caller's `VkBuffer`, whose memory backs no image of the runtime's, or over host pages imported as dma-bufs (`HostMemory::with_dma_buf`) where the device makes no image over a dma-buf of the texture's own pages (the notice names why; `WorkCounts::dma_buf_image_fallbacks` counts it). Cost: its texels are copied into an image before diff --git a/docs/HOWTO.md b/docs/HOWTO.md index 0db3e74c2..20763935a 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -175,6 +175,25 @@ the bytes, announced (`shadowed-texture`, naming why), and a rebind that cannot is refused (`NotImplemented(RebindTextures)`). `WorkCounts::dma_buf_imports`, `dma_buf_sparse_buffers`, `dma_buf_images` and `dma_buf_image_fallbacks` count what the route did. +A texture over pages imported by their pointer aliases them where the device lays an image's rows +at the texture's `bytes_per_row`: the driver's own linear image, or, where that lays its rows +otherwise, a `DRM_FORMAT_MOD_LINEAR` image at that pitch, which the driver may refuse. Measured +(`runtime_lane::surface_texture_costs::pitch_classes`, nine formats, four usages, rows padded by +each power of two from 16 to 4096 bytes): + +- ANV (Mesa 26.2.4) packs its own rows tight and takes every pitch asked. +- NVIDIA (615.71.09) aligns its own rows to 128 bytes and takes any larger pitch for a texture it + samples or writes, in `BGRA8Unorm`, `RGBA8Unorm`, `RGB10A2Unorm`, `RGBA16Float`, `R8Unorm` and + `RG8Unorm`; not for a render target, and not in `R16Float`, `R32Float` or `RGBA32Float`, whose + `DRM_FORMAT_MOD_LINEAR` tiling it gives no sampling or transfers. +- RADV (Mesa 26.2.4) aligns its own rows to 256 bytes, refuses a pitch that is not a multiple of + 256, and asks a dedicated allocation of an image at any other, so it takes no pitch but its own. + +The own rows' alignments are as measured for `BGRA8Unorm`. Elsewhere the texture is a shadow +(`shadowed-texture`): a `BGRA8Unorm` surface whose rows are its texels' bytes rounded up to 256 +bytes on RADV, or 128 on NVIDIA, is aliased. `WorkCounts::pitched_host_images` and +`pitched_host_image_refusals` count the images at Metal's pitch made and refused. + ## 7. Check the integration `spirv-val` checks structural validity, not agreement with Metal: diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index c9bb2851e..68583b92f 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -14,7 +14,7 @@ Columns: - `none`: no public API path: malformed or non-Metal input, Apple-private calls, or a cap no valid program of ordinary size meets; - `?`: not assessed yet. -Generated at `8f3edd5a6`. +Generated at `f28f418da`. ## Totals @@ -121,7 +121,7 @@ Generated at `8f3edd5a6`. | `SamplerBicubicFilter` | A use of Metal's bicubic filter that no Metal reading establishes | every device (not implemented) | 4: `crates/metal2vulkan/src/bind/heap.rs:977`, `crates/metal2vulkan/src/bind/plan/resources.rs:1768` (+2) | `system`: bicubic filtering forms Metal does not establish; macOS 26.6.2 makes a runtime sampler with MTLSamplerMinMagFilterCubic (the consumer's boots), whose mip-filtered form is refused | | `GroupCount` | A dispatch whose threadgroup count on `axis` exceeds `maxComputeWorkGroupCount` by more than the binder splits into regions (`None` | every device (no Vulkan mechanism) | 5: `crates/metal2vulkan/src/bind/dispatch.rs:379`, `crates/metal2vulkan/src/bind/dispatch.rs:461` (+3) | `rare`: more threadgroups than a device dispatches, past the binder's split | | `IntersectionFunctionTable` | A ray intersection through intersection functions | every device (no Vulkan mechanism); every device (not implemented) | 9: `crates/metal2vulkan/src/bind/acceleration.rs:177`, `crates/metal2vulkan/src/bind/acceleration.rs:183` (+7) | `rare`: ray tracing (out of scope by ruling) | -| `IndependentBlending` | Color attachments whose write masks or blend states differ, as Metal sets them per attachment, on a device without `independentBlend`, where no... | devices without VkFeature::IndependentBlend | 2: `crates/metal2vulkan-runtime/src/render.rs:5148`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:874` | `rare`: per-attachment blending on a device without independentBlend | +| `IndependentBlending` | Color attachments whose write masks or blend states differ, as Metal sets them per attachment, on a device without `independentBlend`, where no... | devices without VkFeature::IndependentBlend | 2: `crates/metal2vulkan-runtime/src/render.rs:5181`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:874` | `rare`: per-attachment blending on a device without independentBlend | | `RasterSampleCount` | A `rasterSampleCount` outside the device's framebuffer sample counts for the pipeline's attachments (`framebuffer*SampleCounts`), and, for a color... | devices short of a Vulkan property the site names; devices without a capability the site computes | 2: `crates/metal2vulkan-runtime/src/families/limits.rs:1055`, `crates/metal2vulkan/src/pipeline/graphics.rs:467` | `app`: a sample count a device lacks for the attachments | | `TriangleFillLines` | The render encoder's `MTLTriangleFillModeLines` (`polygonMode` `LINE`) on a device without `fillModeNonSolid` | - | via a helper: 1: `crates/metal2vulkan/src/metal/state.rs:339` | `app`: wireframe on a device without fillModeNonSolid | | `DepthClipClamp` | The render encoder's `MTLDepthClipModeClamp` (`depthClampEnable`) on a device without `depthClamp` | - | via a helper: 1: `crates/metal2vulkan/src/metal/state.rs:355` | `app`: depth clamp on a device without depthClamp | @@ -131,10 +131,10 @@ Generated at `8f3edd5a6`. | `TextureSize` | A texture whose extent, array layers, or level count is past what the device takes for its format, type, and usage (`Capability::Limit` names the... | devices short of a device limit the site names | 1: `crates/metal2vulkan-runtime/src/image_plan.rs:1062` | `app`: a texture past a device's image limits | | `TextureSampleCount` | A texture sample count the device does not take for its format, type, and usage | devices short of a Vulkan property the site names; devices without VkFeature::MultisampleArrayImage; every device (no Vulkan mechanism) | 3: `crates/metal2vulkan-runtime/src/image_plan.rs:1110`, `crates/metal2vulkan-runtime/src/image_plan.rs:570` (+1) | `app`: a sample count a device lacks for the texture | | `TextureView` | A texture view Vulkan cannot make exactly on this image | every device (no Vulkan mechanism); every device (not implemented) | 5: `crates/metal2vulkan-runtime/src/binding_view.rs:156`, `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:184` (+3) | `app`: a texture view Vulkan cannot make exactly | -| `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | devices short of a Vulkan feature the site names; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:167`, `crates/metal2vulkan-runtime/src/texture.rs:885` (+5) | `app`: texture swizzles whose Metal behaviour is unmeasured | +| `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | devices short of a Vulkan feature the site names; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:167`, `crates/metal2vulkan-runtime/src/texture.rs:911` (+5) | `app`: texture swizzles whose Metal behaviour is unmeasured | | `MipmapGeneration` | `generateMipmapsForTexture:` where the device's filter is not shown to give Metal's answer | devices without VkFeature::ShaderInt64; devices without a format's usage; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/blit_texture.rs:1702`, `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37` (+5) | `app`: generateMipmapsForTexture: where the device's filter is not Metal's | | `HostMemory` | A buffer over the caller's host memory without a copy (`newBufferWithBytesNoCopy:`) | devices without VkExtension::ExtExternalMemoryHost; every device (no Vulkan mechanism); every device (not implemented) | 5: `crates/metal2vulkan-runtime/src/host_memory.rs:329`, `crates/metal2vulkan-runtime/src/host_memory.rs:361` (+3) | `system`: newBufferWithBytesNoCopy: where the device cannot import the memory | -| `GpuTimes` | A command buffer's GPU times (`GPUStartTime`, `GPUEndTime`) on a device whose queue family writes no timestamps (`timestampValidBits` 0) | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:1830` | `rare`: GPU times on a queue without timestamps | +| `GpuTimes` | A command buffer's GPU times (`GPUStartTime`, `GPUEndTime`) on a device whose queue family writes no timestamps (`timestampValidBits` 0) | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:1832` | `rare`: GPU times on a queue without timestamps | | `CountingVisibility` | A `Counting` visibility result (`MTLVisibilityResultModeCounting`) on a device without `occlusionQueryPrecise` | devices without VkFeature::OcclusionQueryPrecise | 1: `crates/metal2vulkan-runtime/src/visibility.rs:447` | `rare`: counting occlusion queries on a device without precise queries | | `ViewFormatReinterpretation` | A texture view whose format has other components, or components of other widths, than its texture's (`RGBA8Unorm` as `R32Uint`), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/view_plan.rs:547` | `app`: a view of another component layout on a portability subset (MoltenVK) | | `SeparateMultisampledDepthStencil` | A render pass whose depth and stencil attachments are separate multisampled textures that it loads or may store, on a device without maintenance8,... | - | via a helper: 5: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:187`, `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:293` (+3) | `rare`: separate multisampled depth and stencil textures | @@ -164,7 +164,7 @@ Generated at `8f3edd5a6`. |---|---|---|---|---| | `Textures` | Textures and texture buffers | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:159`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:1525` (+7) | `rare`: texture forms the runtime has not built (texture buffers of some forms, X24Stencil8 views) | | `ResourceHeap` | The resource-ID heap, descriptor set 1 | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/binding.rs:1358` | `rare`: the resource-ID heap's remaining forms | -| `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458`, `crates/metal2vulkan-runtime/src/texture.rs:1476` (+1) | `rare`: sparse heaps | +| `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458`, `crates/metal2vulkan-runtime/src/texture.rs:1502` (+1) | `rare`: sparse heaps | | `SparseTileMaps` | What the runtime's emulation of sparse textures does not build yet | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/binding.rs:428`, `crates/metal2vulkan-runtime/src/sparse/texture.rs:30` (+1) | `rare`: sparse texture emulation's unbuilt pieces | | `HeapPastMaxBufferSize` | A heap larger than the device's `maxBufferSize`, which the device can allocate | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/heap.rs:689` | `rare`: a heap past maxBufferSize | | `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (256 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:956` | `rare`: a heap texture needing more than 256 KiB alignment | @@ -183,15 +183,15 @@ Generated at `8f3edd5a6`. | `OverlappingSurfaceRows` | A texture of an IOSurface plane (`Buffer::new_texture_with_iosurface_plane`, the stand-in for `newTextureWithDescriptor:iosurface:plane:`) whose... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/buffer_texture.rs:255` | `rare`: an IOSurface plane whose rows overlap | | `SamplePositionsAtBegin` | A render pass whose custom sample positions Vulkan takes only through what the runtime does not build | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:144`, `crates/metal2vulkan-runtime/src/render_pass.rs:1717` (+1) | `rare`: custom sample positions Vulkan takes only at begin | | `SharedEventAcrossDevices` | A shared event handle opened on a device other than its event's | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/event.rs:326` | `rare`: a shared event opened on another device | -| `ViewportDepthRange` | A viewport depth range past `[0, 1]`, which Metal takes, on a device without the features to take it natively or by the vertex stage's... | every device (runtime piece not built) | 7: `crates/metal2vulkan-runtime/src/render.rs:7283`, `crates/metal2vulkan-runtime/src/render_state.rs:1027` (+5) | `rare`: viewport depth outside [0, 1] without the device features | +| `ViewportDepthRange` | A viewport depth range past `[0, 1]`, which Metal takes, on a device without the features to take it natively or by the vertex stage's... | every device (runtime piece not built) | 7: `crates/metal2vulkan-runtime/src/render.rs:7312`, `crates/metal2vulkan-runtime/src/render_state.rs:1027` (+5) | `rare`: viewport depth outside [0, 1] without the device features | | `NonFiniteDepthBias` | NaN or infinite depth bias factors whose effect differs between flat and sloped triangles, or a draw whose bias adds a clamp that moves a... | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/render_state.rs:1426`, `crates/metal2vulkan-runtime/src/render_state.rs:1429` (+3) | `rare`: NaN or infinite depth bias | | `DepthNeverWithoutAttachment` | A draw under a depth compare of `Never` in a pass without a depth attachment, which fails every fragment, whose fragment function writes color... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/depth_stencil.rs:147` | `rare`: depth compare Never with no depth attachment | -| `HiddenDepthStencil` | A draw whose depth/stencil state uses depth or the stencil that the pass lacks, which plain Metal tests against a hidden `float` depth of 1.0 and... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:415`, `crates/metal2vulkan-runtime/src/render.rs:4814` | `app`: a depth-stencil state using depth or stencil the pass lacks | -| `IndirectDrawArguments` | An indirect draw whose arguments the binding plan asks to read on the CPU (`DrawCommands::indirect_needs_arguments`) | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/index_bounds.rs:89`, `crates/metal2vulkan-runtime/src/render.rs:2399` (+3) | `rare`: indirect draws whose arguments the CPU must read | +| `HiddenDepthStencil` | A draw whose depth/stencil state uses depth or the stencil that the pass lacks, which plain Metal tests against a hidden `float` depth of 1.0 and... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:415`, `crates/metal2vulkan-runtime/src/render.rs:4835` | `app`: a depth-stencil state using depth or stencil the pass lacks | +| `IndirectDrawArguments` | An indirect draw whose arguments the binding plan asks to read on the CPU (`DrawCommands::indirect_needs_arguments`) | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/index_bounds.rs:89`, `crates/metal2vulkan-runtime/src/render.rs:2420` (+3) | `rare`: indirect draws whose arguments the CPU must read | | `DepthStencilResolve` | A depth/stencil resolve no Vulkan resolve mode of the device states | every device (runtime piece not built) | 7: `crates/metal2vulkan-runtime/src/depth_stencil_resolve.rs:441`, `crates/metal2vulkan-runtime/src/resolve.rs:1231` (+5) | `rare`: depth/stencil resolve modes a device lacks | | `TileAtSampleCount` | The tile memory of a render pass of a sample count Apple's GPUs lack (theirs are 1, 2 and 4), which a Vulkan device may have | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:578`, `crates/metal2vulkan-runtime/src/render_pass.rs:1480` | `none`: tile memory at a sample count Apple's GPUs lack | -| `ImageblockMasters` | A draw or tile dispatch whose imageblock is of another size than the pass's, or a draw whose fragment function's layouts are of another alignment... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render.rs:5826`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:935` | `rare`: imageblocks of mixed sizes in one pass | -| `TileAndFragmentImageblocks` | A render pass that reaches its imageblock storage, from a draw whose fragment function declares an explicit imageblock or a tile dispatch whose... | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/render.rs:5818`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:802` (+1) | `rare`: explicit imageblocks shared by tile and fragment functions | +| `ImageblockMasters` | A draw or tile dispatch whose imageblock is of another size than the pass's, or a draw whose fragment function's layouts are of another alignment... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render.rs:5855`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:935` | `rare`: imageblocks of mixed sizes in one pass | +| `TileAndFragmentImageblocks` | A render pass that reaches its imageblock storage, from a draw whose fragment function declares an explicit imageblock or a tile dispatch whose... | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/render.rs:5847`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:802` (+1) | `rare`: explicit imageblocks shared by tile and fragment functions | | `Metal4Api` | Metal 4's API (`MTL4CommandQueue`, `MTL4CommandBuffer`, `MTL4ArgumentTable`, `MTL4Compiler` and the rest), with the features only its programming... (not scheduled) | every device (runtime piece not built) | family audit only: 3: `crates/metal2vulkan-runtime/src/families/features.rs:1431`, `crates/metal2vulkan-runtime/src/families/limits.rs:1018` (+1) | `app`: Metal 4 (the API is missing: METAL-COVERAGE.md) | | `CounterSampleBuffers` | Counter sample buffers (`MTLCounterSampleBuffer`) and the commands that sample into them (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/limits.rs:1009` | `app`: GPU counters and timestamps by sample buffer (missing API) | | `ResidencySets` | Residency sets (`MTLResidencySet`) (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1413`, `crates/metal2vulkan-runtime/src/families/limits.rs:1011` | `app`: residency sets (missing API) | @@ -207,18 +207,18 @@ Generated at `8f3edd5a6`. | `LayeredPass` | A layered render pass (`renderTargetArrayLength` 2 or more) that needs a step of one layer | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/color_resolve.rs:517` | `rare`: layered passes needing a per-layer color resolve | | `FunctionOptions` | A function descriptor's options beyond `CompileToBinary` and `StoreFunctionInMetalPipelinesScript` (`Library::new_function_with_descriptor`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:215` | `rare`: function descriptor options beyond CompileToBinary | | `OverlappingTextureCopies` | A blit copy between overlapping regions of one texture's texels (`copyFromTexture:...` with the source's region meeting the destination's, through... (not scheduled) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/blit_texture.rs:1205` | `rare`: overlapping texture copies (Metal races) | -| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 10: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:567`, `crates/metal2vulkan-runtime/src/texture.rs:2696` (+8) | `none`: a runtime extension's rebind with a live texture | -| `PvrtcBlockOrder` | A PVRTC texture's blocks in a Metal block order the runtime does not lay out | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5473` | `rare`: PVRTC regions off whole levels | +| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 10: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:567`, `crates/metal2vulkan-runtime/src/texture.rs:2932` (+8) | `none`: a runtime extension's rebind with a live texture | +| `PvrtcBlockOrder` | A PVRTC texture's blocks in a Metal block order the runtime does not lay out | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5714` | `rare`: PVRTC regions off whole levels | | `VertexFetchPast4GiB` | A draw (`drawPrimitives:` and its forms, or an indirect command buffer's command) that may read a vertex attribute the pipeline fetches in its... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72` | `rare`: vertex fetch past 4 GiB of a bind offset | | `StageInFetchPast4GiB` | A dispatch (`dispatchThreads:threadsPerThreadgroup:` and its forms, or an indirect command buffer's command) whose kernel may read a... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126` | `rare`: stage-in fetch past 4 GiB of a bind offset | | `MappedTextureSampling` | A command that would sample a texture of an address-mode map (`TextureDescriptor::address_mode_map`) where the runtime cannot map it at bind... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/address_map.rs:158` | `none`: a runtime extension's texture (address_mode_map) sampled where the runtime cannot map it; no Metal API path | | `LibrarySource` | A library compiled from Metal Shading Language source | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:107` | `app`: a library compiled from Metal source (newLibraryWithSource:); the runtime takes metallibs and AIR | -| `RestartedStrip` | An indexed strip after `set_primitive_restart_enabled` with an index Vulkan does not restart at, which the runtime draws as a list an index... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/index_rewrite.rs:109`, `crates/metal2vulkan-runtime/src/render.rs:5912` | `none`: a strip after the Apple-private setPrimitiveRestartEnabled:index: whose rewrite pass cannot run as Metal draws | +| `RestartedStrip` | An indexed strip after `set_primitive_restart_enabled` with an index Vulkan does not restart at, which the runtime draws as a list an index... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/index_rewrite.rs:109`, `crates/metal2vulkan-runtime/src/render.rs:5941` | `none`: a strip after the Apple-private setPrimitiveRestartEnabled:index: whose rewrite pass cannot run as Metal draws | | `RotatedTexture` | A rotated texture (`TextureDescriptor::rotation`) where the runtime does not build what Metal does | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:1521`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:706` (+7) | `rare`: a rotated drawable's views, blits with images over overlapping rows, rows past its buffer | | `DetachTextures` | A texture over a no-copy buffer's or heap's bytes (a heap's texture, or a texture over the buffer or over one of the heap's buffers) that no... | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/buffer.rs:2012`, `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:572` (+7) | `none`: a runtime extension's detach with a texture no stand-in presents exactly | | `TextureBufferLevels` | A texture buffer of more than one level (`TextureDescriptor::mipmap_level_count`, up to its width's full chain) from the device's, a heap's or the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:531` | `rare`: a texture buffer of more than one level (public, unusual) | | `WriteSwizzle` | A texture of `TextureDescriptor::write_swizzle_enabled` whose swizzle is not the default, with `ShaderWrite` or `RenderTarget` usage, from the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:538` | `none`: Apple-private writeSwizzleEnabled with a swizzle that writes | -| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4767` | `none`: CPU texel access while a runtime extension detached the bytes | +| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5008` | `none`: CPU texel access while a runtime extension detached the bytes | | `SurfaceDepthStencil` | A use of a texture of a depth or stencil format (`Depth16Unorm`, `Depth32Float`, `Depth32Float_Stencil8`, `Stencil8`, `X32_Stencil8`) over a plane... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:232`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:56` | `rare`: a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 | | `HostHeapUncompressedMultisample` | A multisample texture in a heap over host pages (`Device::new_heap_with_bytes_no_copy`) that Metal keeps uncompressed | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1734` | `none`: a multisample texture Metal keeps uncompressed in a runtime extension's heap over host pages | | `PredicationUnbalanced` | An unbalanced command-predication record (`ComputeCommandEncoder::encode_end_if` and the other ends, or `encode_start_else`, with no block open;... | every device (runtime piece not built) | 4: `crates/metal2vulkan-runtime/src/predication.rs:354`, `crates/metal2vulkan-runtime/src/predication.rs:386` (+2) | `none`: an unbalanced Apple-private command-predication record, whose dropped work Metal decides by no rule measured | @@ -331,7 +331,7 @@ Each refusal's sites, with the function that builds it. - `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs:575 (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs:2911 (patch_draw)`; `crates/metal2vulkan/src/bind/graphics.rs:2957 (patch_draw)`; `crates/metal2vulkan/src/bind/graphics.rs:2986 (patch_draw)`; `crates/metal2vulkan/src/bind/instantiate.rs:578 (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs:226 (select)`; `crates/metal2vulkan/src/lower/access/mod.rs:1155 (place_slots)` - `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs:582 (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs:1117 (selector_form)` - `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs:230 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs:587 (check_scalar)` -- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:455 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:469 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:526 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:1997 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:512 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:576 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:608 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:841 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:345 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:525 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1555 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1640 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:228 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:272 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:292 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:307 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:365 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:404 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:486 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:520 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:534 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:516 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:628 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:713 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:826 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:5267 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1259 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1578 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1657 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:926 (check_target)`; `crates/metal2vulkan-runtime/src/resolve.rs:387 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:295 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:352 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:359 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:1833 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3644 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1625 (new_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:79 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:275 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:378 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:115 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:359 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:372 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:379 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:389 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:399 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:271 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1708 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:192 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:953 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/unused_bits.rs:545 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:154 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1358 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1384 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:680 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:701 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:707 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:713 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:738 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:920 (plan)`; `crates/metal2vulkan/src/lower/sampler/select.rs:1004 (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs:716 (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1795 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:776 (zeroed_output)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2279 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2893 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3065 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3235 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3272 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3596 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1015 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1027 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1033 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:733 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:736 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:747 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:761 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:778 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:802 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:813 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:853 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:888 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:897 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1500 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1502 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1545 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2475 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2493 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2501 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2573 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:345 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:453 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:830 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:847 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:956 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:450 (rotated_blend)` +- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:455 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:469 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:526 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:1997 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:512 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:576 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:608 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:841 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:345 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:525 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1555 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1640 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:228 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:272 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:292 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:307 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:365 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:404 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:486 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:520 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:534 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:516 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:628 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:713 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:826 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:5300 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1259 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1578 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1657 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:926 (check_target)`; `crates/metal2vulkan-runtime/src/resolve.rs:387 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:295 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:352 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:359 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:1859 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3881 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1625 (new_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:79 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:275 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:378 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:115 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:359 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:372 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:379 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:389 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:399 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:271 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1708 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:192 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:953 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/unused_bits.rs:545 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:154 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1358 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1384 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:680 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:701 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:707 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:713 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:738 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:920 (plan)`; `crates/metal2vulkan/src/lower/sampler/select.rs:1004 (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs:716 (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1795 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:776 (zeroed_output)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2279 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2893 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3065 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3235 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3272 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3596 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1015 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1027 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1033 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:733 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:736 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:747 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:761 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:778 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:802 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:813 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:853 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:888 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:897 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1521 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1523 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1566 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2496 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2514 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2522 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2594 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:345 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:453 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:830 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:847 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:956 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:450 (rotated_blend)` - `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs:377 (select_sampling)` - `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:136 (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs:254 (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs:280 (query_min_level)` - `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs:1349 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:891 (min_lod)` @@ -347,7 +347,7 @@ Each refusal's sites, with the function that builds it. - `feature::PixelSamplerCompare`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:115 (lowered)` - `feature::TexelBuffer`: `crates/metal2vulkan/src/bind/instantiate.rs:731 (texel_ranges)`; `crates/metal2vulkan/src/bind/instantiate.rs:737 (texel_ranges)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1113 (plain_texture)` - `feature::RasterOrderGroups`: `crates/metal2vulkan/src/device/metal.rs:242 (unsupported_features)`; `crates/metal2vulkan/src/lower/fragment/rog.rs:151 (mode)`; `crates/metal2vulkan/src/lower/fragment/rog.rs:172 (mode)` -- `feature::FramebufferFetch`: `crates/metal2vulkan-runtime/src/families/features.rs:1007 (state)`; `crates/metal2vulkan-runtime/src/framebuffer_fetch.rs:354 (ordered)`; `crates/metal2vulkan-runtime/src/render.rs:4359 (next_instance)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:110 (lacks)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:137 (new)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:496 (planes_merge)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:190 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/graphics.rs:1034 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1071 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1090 (plan)`; `crates/metal2vulkan/src/bind/sample_planes.rs:431 (finish)`; `crates/metal2vulkan/src/device/metal.rs:255 (unsupported_features)`; `crates/metal2vulkan/src/lower/fragment/color.rs:208 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:257 (unordered)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:196 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:271 (depth_test_form)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:317 (stencil_test_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1209 (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:383 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:591 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:657 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:693 (extended_range_blend)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs:159 (storage_attachments)` +- `feature::FramebufferFetch`: `crates/metal2vulkan-runtime/src/families/features.rs:1007 (state)`; `crates/metal2vulkan-runtime/src/framebuffer_fetch.rs:354 (ordered)`; `crates/metal2vulkan-runtime/src/render.rs:4380 (next_instance)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:110 (lacks)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:137 (new)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:496 (planes_merge)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:190 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/graphics.rs:1034 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1071 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1090 (plan)`; `crates/metal2vulkan/src/bind/sample_planes.rs:431 (finish)`; `crates/metal2vulkan/src/device/metal.rs:255 (unsupported_features)`; `crates/metal2vulkan/src/lower/fragment/color.rs:208 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:257 (unordered)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:196 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:271 (depth_test_form)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:317 (stencil_test_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1209 (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:383 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:591 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:657 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:693 (extended_range_blend)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs:159 (storage_attachments)` - `feature::PrimitiveId`: `crates/metal2vulkan/src/device/metal.rs:264 (unsupported_features)` - `feature::VertexAmplification`: `crates/metal2vulkan/src/bind/graphics.rs:3130 (multiview_instances)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:646 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:219 (vertex_amplification)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:238 (control_plan)` - `feature::LayeredRendering`: `crates/metal2vulkan-runtime/src/render_pass.rs:1538 (target)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:736 (target_index)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:755 (target_index)` @@ -384,7 +384,7 @@ Each refusal's sites, with the function that builds it. - `feature::SamplerBicubicFilter`: `crates/metal2vulkan/src/bind/heap.rs:977 (new)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1768 (bicubic_texels)`; `crates/metal2vulkan/src/lower/sampler/bicubic.rs:121 (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs:35 (bicubic_refused)` - `feature::GroupCount`: `crates/metal2vulkan/src/bind/dispatch.rs:379 (product)`; `crates/metal2vulkan/src/bind/dispatch.rs:461`; `crates/metal2vulkan/src/bind/dispatch.rs:963 (instantiate)`; `crates/metal2vulkan/src/bind/graphics.rs:2623 (mesh_draw)`; `crates/metal2vulkan/src/bind/graphics.rs:2674 (emulated_draw)` - `feature::IntersectionFunctionTable`: `crates/metal2vulkan/src/bind/acceleration.rs:177 (geometry_table_offset)`; `crates/metal2vulkan/src/bind/acceleration.rs:183 (geometry_table_offset)`; `crates/metal2vulkan/src/bind/acceleration.rs:188 (geometry_table_offset)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1222 (null_table)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1251 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1272 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:406 (table_of)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:422 (select_table)`; `crates/metal2vulkan/src/lower/select.rs:869 (route_air)` -- `feature::IndependentBlending`: `crates/metal2vulkan-runtime/src/render.rs:5148 (check_pipeline)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:874 (uniform_blend)` +- `feature::IndependentBlending`: `crates/metal2vulkan-runtime/src/render.rs:5181 (check_pipeline)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:874 (uniform_blend)` - `feature::RasterSampleCount`: `crates/metal2vulkan-runtime/src/families/limits.rs:1055 (sample_count)`; `crates/metal2vulkan/src/pipeline/graphics.rs:467 (sample_count_properties)` - `feature::TriangleFillLines`: `crates/metal2vulkan/src/metal/state.rs:339 (polygon_mode)` - `feature::DepthClipClamp`: `crates/metal2vulkan/src/metal/state.rs:355 (depth_clamp_enable)` @@ -394,10 +394,10 @@ Each refusal's sites, with the function that builds it. - `feature::TextureSize`: `crates/metal2vulkan-runtime/src/image_plan.rs:1062 (check_image_limits)` - `feature::TextureSampleCount`: `crates/metal2vulkan-runtime/src/image_plan.rs:1110 (check_image_limits)`; `crates/metal2vulkan-runtime/src/image_plan.rs:570 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:580 (plan_held)` - `feature::TextureView`: `crates/metal2vulkan-runtime/src/binding_view.rs:156 (binding_view)`; `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:184 (apart_refusal)`; `crates/metal2vulkan-runtime/src/view_plan.rs:411 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:461 (check_view)`; `crates/metal2vulkan-runtime/src/view_plan.rs:483 (check_view)` -- `feature::TextureSwizzle`: `crates/metal2vulkan-runtime/src/binding_view.rs:167 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:885 (view)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1088 (plain_texture)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2313 (select_one)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3300 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3637 (select_write)`; `crates/metal2vulkan/src/lower/texture/slice.rs:294 (select)` +- `feature::TextureSwizzle`: `crates/metal2vulkan-runtime/src/binding_view.rs:167 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:911 (view)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1088 (plain_texture)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2313 (select_one)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3300 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3637 (select_write)`; `crates/metal2vulkan/src/lower/texture/slice.rs:294 (select)` - `feature::MipmapGeneration`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1702 (generate_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37 (pick_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:264 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:272 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:277 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:306 (plan_mipmaps)`; `crates/metal2vulkan/src/bind/mipmap_filter.rs:915 (mipmap_filter_module)` - `feature::HostMemory`: `crates/metal2vulkan-runtime/src/host_memory.rs:329 (not_importable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:361 (refuse_unwritable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:557 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:562 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:580 (new)` -- `feature::GpuTimes`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:1830 (gpu_times)` +- `feature::GpuTimes`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:1832 (gpu_times)` - `feature::CountingVisibility`: `crates/metal2vulkan-runtime/src/visibility.rs:447 (check_mode)` - `feature::ViewFormatReinterpretation`: `crates/metal2vulkan-runtime/src/view_plan.rs:547 (reinterpretation_refused)` - `feature::SeparateMultisampledDepthStencil`: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:187 (sampled_candidate)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:293 (by_draws)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:335 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:375 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:776 (plan)` @@ -420,36 +420,36 @@ Each refusal's sites, with the function that builds it. - `feature::CommandPredication`: `crates/metal2vulkan/src/bind/replay/predication.rs:415 (predication_step_module)` - `feature::ProgramScopeBinding`: `crates/metal2vulkan-air/src/abi/module.rs:77 (decode)`; `crates/metal2vulkan/src/error/mod.rs:268 (from)` - `feature::SeqCstFence`: `crates/metal2vulkan/src/lower/sync/barrier.rs:443 (require_seq_cst)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:449 (require_seq_cst)` -- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs:159 (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:1525 (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1406 (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1292 (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1969 (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture.rs:3116 (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs:4125 (image)`; `crates/metal2vulkan-runtime/src/texture.rs:5400 (host_copy)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:206 (new_surface_planes_texture)` +- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs:159 (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:1525 (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1406 (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1318 (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1995 (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture.rs:3353 (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs:4363 (image)`; `crates/metal2vulkan-runtime/src/texture.rs:5641 (host_copy)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:206 (new_surface_planes_texture)` - `gap::ResourceHeap`: `crates/metal2vulkan-runtime/src/binding.rs:1358 (descriptor)` -- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1476 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4697 (make_aliasable)` -- `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:428 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1501 (plan_sparse_texture)` +- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1502 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4938 (make_aliasable)` +- `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:428 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1527 (plan_sparse_texture)` - `gap::HeapPastMaxBufferSize`: `crates/metal2vulkan-runtime/src/heap.rs:689 (heap_size)` - `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:956 (check_heap_base)` - `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1279 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1286 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1729 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1942 (memory_shadow)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:475 (memory_refusal)` - `gap::FunctionTablePastMaxBufferLength`: `crates/metal2vulkan-runtime/src/function_table.rs:628 (past_limit)` - `gap::IndirectCommandBufferPastMaxBufferLength`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:522 (new_indirect_command_buffer)` -- `gap::IndirectRenderCommands`: `crates/metal2vulkan-runtime/src/compute.rs:1026 (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/compute.rs:1076 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/depth_stencil.rs:85 (gpu_resource_id)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3495 (render_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:517 (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1413 (compile_error)`; `crates/metal2vulkan-runtime/src/render.rs:5737 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6027 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6306 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6668 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1773 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2438 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:361 (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/render/executions.rs:419 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/render/executions.rs:432 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/render/executions.rs:876 (back_memoryless)` +- `gap::IndirectRenderCommands`: `crates/metal2vulkan-runtime/src/compute.rs:1026 (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/compute.rs:1076 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/depth_stencil.rs:85 (gpu_resource_id)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3495 (render_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:517 (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1413 (compile_error)`; `crates/metal2vulkan-runtime/src/render.rs:5766 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6056 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6335 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6697 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1773 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2439 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:361 (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/render/executions.rs:419 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/render/executions.rs:432 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/render/executions.rs:876 (back_memoryless)` - `gap::IndirectImageblockSize`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:2654 (set_imageblock_size)` - `gap::CommandReplay`: `crates/metal2vulkan-runtime/src/binding.rs:566 (bind)`; `crates/metal2vulkan-runtime/src/binding.rs:569 (bind)` - `gap::RenderAttachments`: `crates/metal2vulkan-runtime/src/binding.rs:1198 (unexpected)` - `gap::AccelerationStructures`: `crates/metal2vulkan-runtime/src/binding.rs:1201 (unexpected)` - `gap::FeatureEnable`: `crates/metal2vulkan-runtime/src/enables.rs:1127 (of)` - `gap::ExtensionEnable`: `crates/metal2vulkan-runtime/src/enables.rs:1118 (of)` -- `gap::Render`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:257 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:312 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:536 (check_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:787 (attachment_twin)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:282 (check_sizes)`; `crates/metal2vulkan-runtime/src/linear_attachment.rs:293 (settle)`; `crates/metal2vulkan-runtime/src/nan_clear.rs:165 (plan)`; `crates/metal2vulkan-runtime/src/pipeline/render.rs:1071 (imageblock_sample_length)`; `crates/metal2vulkan-runtime/src/render.rs:4409 (next_instance)`; `crates/metal2vulkan-runtime/src/render.rs:5198 (check_pipeline)`; `crates/metal2vulkan-runtime/src/render.rs:6079 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:493 (scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1208 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1545 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1599 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1645 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1839 (depth_stencil)`; `crates/metal2vulkan-runtime/src/resolve.rs:1011 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1075 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:885 (attach)`; `crates/metal2vulkan-runtime/src/resolve.rs:953 (color_copy)`; `crates/metal2vulkan-runtime/src/resolve.rs:994 (destination)` +- `gap::Render`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:257 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:312 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:536 (check_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:787 (attachment_twin)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:282 (check_sizes)`; `crates/metal2vulkan-runtime/src/linear_attachment.rs:293 (settle)`; `crates/metal2vulkan-runtime/src/nan_clear.rs:165 (plan)`; `crates/metal2vulkan-runtime/src/pipeline/render.rs:1077 (imageblock_sample_length)`; `crates/metal2vulkan-runtime/src/render.rs:4430 (next_instance)`; `crates/metal2vulkan-runtime/src/render.rs:5231 (check_pipeline)`; `crates/metal2vulkan-runtime/src/render.rs:6108 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:493 (scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1208 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1545 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1599 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1645 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1839 (depth_stencil)`; `crates/metal2vulkan-runtime/src/resolve.rs:1011 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1075 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:885 (attach)`; `crates/metal2vulkan-runtime/src/resolve.rs:953 (color_copy)`; `crates/metal2vulkan-runtime/src/resolve.rs:994 (destination)` - `gap::TexelsPastBufferLength`: `crates/metal2vulkan-runtime/src/buffer_texture.rs:253 (refusal_error)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:104 (surface_depth_twin)` - `gap::OverlappingSurfaceRows`: `crates/metal2vulkan-runtime/src/buffer_texture.rs:255 (refusal_error)` - `gap::SamplePositionsAtBegin`: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:144 (stencil_scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1717 (positioned_stand_in)`; `crates/metal2vulkan-runtime/src/sample_positions.rs:185 (grid)` - `gap::SharedEventAcrossDevices`: `crates/metal2vulkan-runtime/src/event.rs:326 (new_shared_event_with_handle)` -- `gap::ViewportDepthRange`: `crates/metal2vulkan-runtime/src/render.rs:7283 (draw_settings)`; `crates/metal2vulkan-runtime/src/render_state.rs:1027 (depth_ranges_refused)`; `crates/metal2vulkan-runtime/src/render_state.rs:1398 (bias_holds)`; `crates/metal2vulkan-runtime/src/render_state.rs:1417 (collapses)`; `crates/metal2vulkan-runtime/src/render_state.rs:434 (depth_range)`; `crates/metal2vulkan-runtime/src/render_state.rs:656 (compensation)`; `crates/metal2vulkan-runtime/src/render_state.rs:916` +- `gap::ViewportDepthRange`: `crates/metal2vulkan-runtime/src/render.rs:7312 (draw_settings)`; `crates/metal2vulkan-runtime/src/render_state.rs:1027 (depth_ranges_refused)`; `crates/metal2vulkan-runtime/src/render_state.rs:1398 (bias_holds)`; `crates/metal2vulkan-runtime/src/render_state.rs:1417 (collapses)`; `crates/metal2vulkan-runtime/src/render_state.rs:434 (depth_range)`; `crates/metal2vulkan-runtime/src/render_state.rs:656 (compensation)`; `crates/metal2vulkan-runtime/src/render_state.rs:916` - `gap::NonFiniteDepthBias`: `crates/metal2vulkan-runtime/src/render_state.rs:1426 (collapses)`; `crates/metal2vulkan-runtime/src/render_state.rs:1429 (collapses)`; `crates/metal2vulkan-runtime/src/render_state.rs:278 (set_depth_bias)`; `crates/metal2vulkan-runtime/src/render_state.rs:370 (draw_viewports)`; `crates/metal2vulkan-runtime/src/render_state.rs:512 (compensation)` - `gap::DepthNeverWithoutAttachment`: `crates/metal2vulkan-runtime/src/depth_stencil.rs:147 (failing_draw)` -- `gap::HiddenDepthStencil`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:415 (hidden)`; `crates/metal2vulkan-runtime/src/render.rs:4814 (hidden_depth_stencil)` -- `gap::IndirectDrawArguments`: `crates/metal2vulkan-runtime/src/index_bounds.rs:89 (new)`; `crates/metal2vulkan-runtime/src/render.rs:2399 (draw_indexed_primitives_indirect)`; `crates/metal2vulkan-runtime/src/render.rs:5885 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:5939 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:5970 (draw_resident)` +- `gap::HiddenDepthStencil`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:415 (hidden)`; `crates/metal2vulkan-runtime/src/render.rs:4835 (hidden_depth_stencil)` +- `gap::IndirectDrawArguments`: `crates/metal2vulkan-runtime/src/index_bounds.rs:89 (new)`; `crates/metal2vulkan-runtime/src/render.rs:2420 (draw_indexed_primitives_indirect)`; `crates/metal2vulkan-runtime/src/render.rs:5914 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:5968 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:5999 (draw_resident)` - `gap::DepthStencilResolve`: `crates/metal2vulkan-runtime/src/depth_stencil_resolve.rs:441 (draws_run)`; `crates/metal2vulkan-runtime/src/resolve.rs:1231 (plan)`; `crates/metal2vulkan-runtime/src/resolve.rs:637 (depth_stencil)`; `crates/metal2vulkan-runtime/src/resolve.rs:735 (steps)`; `crates/metal2vulkan-runtime/src/resolve.rs:755 (steps)`; `crates/metal2vulkan-runtime/src/resolve.rs:796 (split_steps)`; `crates/metal2vulkan-runtime/src/resolve.rs:808 (split_steps)` - `gap::TileAtSampleCount`: `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:578`; `crates/metal2vulkan-runtime/src/render_pass.rs:1480 (layout)` -- `gap::ImageblockMasters`: `crates/metal2vulkan-runtime/src/render.rs:5826 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:935 (dispatch_tiles_resident)` -- `gap::TileAndFragmentImageblocks`: `crates/metal2vulkan-runtime/src/render.rs:5818 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:802 (dispatch_tiles_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:927 (dispatch_tiles_resident)` +- `gap::ImageblockMasters`: `crates/metal2vulkan-runtime/src/render.rs:5855 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:935 (dispatch_tiles_resident)` +- `gap::TileAndFragmentImageblocks`: `crates/metal2vulkan-runtime/src/render.rs:5847 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:802 (dispatch_tiles_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:927 (dispatch_tiles_resident)` - `gap::Metal4Api`: `crates/metal2vulkan-runtime/src/families/features.rs:1431 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1018 (state)`; `crates/metal2vulkan-runtime/src/families/mod.rs:362 (audit)` - `gap::CounterSampleBuffers`: `crates/metal2vulkan-runtime/src/families/limits.rs:1009 (state)` - `gap::ResidencySets`: `crates/metal2vulkan-runtime/src/families/features.rs:1413 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1011 (state)` @@ -465,18 +465,18 @@ Each refusal's sites, with the function that builds it. - `gap::LayeredPass`: `crates/metal2vulkan-runtime/src/color_resolve.rs:517 (plan)` - `gap::FunctionOptions`: `crates/metal2vulkan-runtime/src/library.rs:215 (new_function_with_descriptor)` - `gap::OverlappingTextureCopies`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1205 (texture_copies_of_bytes)` -- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:567 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture.rs:2696 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2712 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2732 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2746 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2817 (dma_buf_images_again)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2232 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2247 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2258 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2304 (dma_buf_heap_images_again)` -- `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5473 (host_copy)` +- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:567 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture.rs:2932 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2948 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2972 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2979 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:3053 (dma_buf_images_again)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2232 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2247 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2258 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2304 (dma_buf_heap_images_again)` +- `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5714 (host_copy)` - `gap::VertexFetchPast4GiB`: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72 (check_vertex_reach)` - `gap::StageInFetchPast4GiB`: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126 (check_stage_in_reach)` - `gap::MappedTextureSampling`: `crates/metal2vulkan-runtime/src/address_map.rs:158 (resolve)` - `gap::LibrarySource`: `crates/metal2vulkan-runtime/src/library.rs:107 (new_library_with_source)` -- `gap::RestartedStrip`: `crates/metal2vulkan-runtime/src/index_rewrite.rs:109 (new)`; `crates/metal2vulkan-runtime/src/render.rs:5912 (draw_resident)` -- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1521 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:706 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:184 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:200 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:346 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:4937 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:102 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:317 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:188 (new_usage_shadow)` +- `gap::RestartedStrip`: `crates/metal2vulkan-runtime/src/index_rewrite.rs:109 (new)`; `crates/metal2vulkan-runtime/src/render.rs:5941 (draw_resident)` +- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1521 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:706 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:184 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:200 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:346 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:5178 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:102 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:317 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:188 (new_usage_shadow)` - `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer.rs:2012 (pages_base)`; `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:572 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:616 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:144 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2436 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:297 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:303 (stand_ins)` - `gap::TextureBufferLevels`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:531 (check_made)` - `gap::WriteSwizzle`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:538 (check_made)` -- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4767 (refuse_detached_texels)` +- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:5008 (refuse_detached_texels)` - `gap::SurfaceDepthStencil`: `crates/metal2vulkan-runtime/src/blit_texture.rs:232 (unit)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:56 (surface_depth_twin)` - `gap::HostHeapUncompressedMultisample`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1734 (host_heap_plan)` - `gap::PredicationUnbalanced`: `crates/metal2vulkan-runtime/src/predication.rs:354 (nil)`; `crates/metal2vulkan-runtime/src/predication.rs:386 (start_else)`; `crates/metal2vulkan-runtime/src/predication.rs:438 (end_if)`; `crates/metal2vulkan-runtime/src/predication.rs:558 (end_loop)`