diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index c5f27d59d..29a81336f 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -413,6 +413,13 @@ made, with no lock, and never rewritten for layouts. the upload of the next submission, ahead of every command buffer committed after the call, or ahead of its first copy; until then nothing holds it, so a texture released first is freed at once, with nothing submitted. +- A texture's image lists the formats Metal views the texture as that the device holds in a + viewed form of the image format's compatibility class, and is then mutable + (`VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT` with a `VkImageFormatListCreateInfo`, its own format + first): its sRGB sibling whatever its usage, as Metal views a texture as its sibling without + `PixelFormatView` usage, and with that usage every uncompressed colour format of the same bytes + a texel. A texture of no such format is not mutable. A view of another format takes the image's + usage that its format's features hold (`VkImageViewUsageCreateInfo`). - The sampled element's view is the format's, through its component mapping with the descriptor's swizzle composed over it; a depth or stencil format's view takes its depth, else its stencil. The storage element is written where the usage has shader write and the device @@ -620,8 +627,10 @@ made, with no lock, and never rewritten for layouts. command buffer's upload is seen by it; Metal on a two-copy GPU sees it only until the command buffer is scheduled. - Texture views that change what the replay streams' views keep are not built - (`Gap::TextureView`, naming the kind): another pixel format, another texture type (but a 2D - view of one slice of a 2D array), and some of a cube's faces or a cube array's cubes. + (`Gap::TextureView`, naming the kind): another pixel format the texture's image does not list, + another texture type (but a 2D view of one slice of a 2D array), and some of a cube's faces or a + cube array's cubes. A view of a pixel format Metal does not view the texture as is + `Refusal::TextureViewFormat`. - A swizzle reaches a texture's sampled element alone, as Apple defines it for reads and samples. A swizzled texture, or a view made with a swizzle or of a swizzled texture, has a storage element and attachment views that map each channel to itself, as Vulkan requires of diff --git a/crates/metal2vulkan-rt/src/error.rs b/crates/metal2vulkan-rt/src/error.rs index 69303bb97..d00efc845 100644 --- a/crates/metal2vulkan-rt/src/error.rs +++ b/crates/metal2vulkan-rt/src/error.rs @@ -499,13 +499,18 @@ pub enum Refusal { /// Its slices. slice_count: u32, }, - /// [`Texture::new_texture_view`](crate::Texture::new_texture_view) of another pixel format - /// over a texture made without `PixelFormatView` usage. + /// [`Texture::new_texture_view`](crate::Texture::new_texture_view) of a pixel format Metal does + /// not view the texture as: without `PixelFormatView` usage, any but its own, its sRGB sibling + /// and a combined depth and stencil format's stencil + /// (`metal2vulkan::metal::format::views_without_usage`); with it, any but those and the + /// uncompressed colour formats of the same bytes a texel + /// (`metal2vulkan::metal::format::views_with_usage`). /// /// Basis: metal-measured (an Apple M3 Max, macOS 27.0.1, probe `texture_view_rules.m` in the /// conformance crate, job m3-max-43677: Metal's validation layer stops an `R32Uint` view of an /// `RGBA8Unorm` texture of `ShaderRead` usage, `Texture View Validation`, and makes it where - /// the usage adds `PixelFormatView`). + /// the usage adds `PixelFormatView`; Apple's `makeTextureView` and + /// `MTLTextureUsage.pixelFormatView` pages state the rest). TextureViewFormat { /// The texture's pixel format. texture: PixelFormat, @@ -1065,7 +1070,8 @@ pub enum RenderPassKind { #[non_exhaustive] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum TextureViewKind { - /// Another pixel format, over a texture of `PixelFormatView` usage. + /// Another pixel format Metal takes that the texture's image does not list: the device holds + /// it in no viewed form of the image format's compatibility class. PixelFormat, /// Another texture type, but a 2D view of one slice of a 2D array. TextureType, diff --git a/crates/metal2vulkan-rt/src/tests/view.rs b/crates/metal2vulkan-rt/src/tests/view.rs index efb7d9c78..f531672eb 100644 --- a/crates/metal2vulkan-rt/src/tests/view.rs +++ b/crates/metal2vulkan-rt/src/tests/view.rs @@ -7,11 +7,13 @@ //! stops is `Refusal::TextureViewRange` or `Refusal::TextureViewFormat`, and each kind of view //! the runtime does not build `Gap::TextureView` naming it. A view with a swizzle holds Metal's //! combination of it over its parent's, in its descriptor and its resource ID's word, over a -//! texture of any usage. Every gauge comes back to zero with the device, the views' image views -//! among them. A view of a Managed texture writes the texture's own named bytes. A command buffer -//! keeps a view it uses after its parent, as Metal's retains every object its encoders use: -//! released while the command buffer is pending, the view keeps its image views and its element -//! of set 1 until it retires. +//! texture of any usage. A view of another pixel format Metal views the texture as (its sRGB +//! sibling, or with `PixelFormatView` usage a same-size colour format) reads its parent's bytes, +//! and one of a format Metal does not view it as is `Refusal::TextureViewFormat`. Every gauge +//! comes back to zero with the device, the views' image views among them. A view of a Managed +//! texture writes the texture's own named bytes. A command buffer keeps a view it uses after its +//! parent, as Metal's retains every object its encoders use: released while the command buffer +//! is pending, the view keeps its image views and its element of set 1 until it retires. #[cfg(any(m2v_gpu, m2v_cpu_icd))] mod on_device { @@ -241,18 +243,42 @@ mod on_device { ), "{name}: another format without PixelFormatView usage" ); + // Pixel-format views, each of its parent's bytes: the sRGB sibling of a texture made + // without `PixelFormatView` usage, and an `R32Uint` view of one made with it; a format + // of another size, or a compressed one, Metal refuses even so. let mut d = TextureDescriptor::new(Type2D, rgba, 8, 8); d.usage = TextureUsage::SHADER_READ | TextureUsage::PIXEL_FORMAT_VIEW; + d.storage_mode = StorageMode::Shared; let formats = device.new_texture(&d, Some(4112)).expect("a texture"); + let whole = Region { + origin: [0; 3], + size: [8, 8, 1], + }; + let texels: Vec = (0..256).map(|i| (i * 7 + 3) as u8).collect(); + (formats.replace_region(whole, 0, 0, &texels, 32, 256)).expect("the bytes"); + for (case, parent, format) in [ + ("an sRGB sibling", &flat, PixelFormat::RGBA8UnormSRGB), + ("a same-size format", &formats, PixelFormat::R32Uint), + ] { + let levels = 0..parent.descriptor().mipmap_level_count; + let made = (view(parent, format, Type2D, levels, 0..1)) + .unwrap_or_else(|error| panic!("{name}: {case}: {error}")); + assert_eq!(made.descriptor().pixel_format, format, "{name}: {case}"); + assert_eq!(read(&made), read(parent), "{name}: {case}: the bytes"); + } + for format in [PixelFormat::R16Float, PixelFormat::BC1RGBA] { + assert!( + matches!( + view(&formats, format, Type2D, 0..1, 0..1), + Err(Error::Refused(Refusal::TextureViewFormat { .. })) + ), + "{name}: {format:?} of an RGBA8Unorm texture" + ); + } let mut d = TextureDescriptor::new(TextureType::Cube, rgba, 4, 4); d.usage = TextureUsage::SHADER_READ; let cube = device.new_texture(&d, Some(4114)).expect("a texture"); for (case, result, kind) in [ - ( - "another format", - view(&formats, PixelFormat::R32Uint, Type2D, 0..1, 0..1), - TextureViewKind::PixelFormat, - ), ( "a 2D array of a 2D texture", view(&flat, rgba, Type2DArray, 0..3, 0..1), diff --git a/crates/metal2vulkan-rt/src/texture.rs b/crates/metal2vulkan-rt/src/texture.rs index 6132a877f..069e79bce 100644 --- a/crates/metal2vulkan-rt/src/texture.rs +++ b/crates/metal2vulkan-rt/src/texture.rs @@ -179,8 +179,11 @@ struct TextureInner { device: Device, descriptor: TextureDescriptor, image: Arc, - /// The image's format. + /// The format of its views: the image's, or a view's own. format: vk::Format, + /// The usage its views take where their format is not the image's (`VkImageViewUsageCreateInfo`): + /// the image's that the format's features hold. `None` where its views take the image's. + views_usage: Option, /// How bytes move between the image and the CPU or another image; `None` where no copy is /// built. unit: Option, @@ -339,6 +342,11 @@ pub(crate) struct Image { shadow: bool, /// Every aspect of the image's format, which a change of layout names. aspects: vk::ImageAspectFlags, + /// The image's format and usage, and the formats it lists for views of another format (empty + /// where it is not mutable). + format: vk::Format, + usage: vk::ImageUsageFlags, + view_formats: Vec, /// The layout the image is made in: undefined, or preinitialized for a texture over a buffer /// in place, whose move home keeps the bytes. first: vk::ImageLayout, @@ -443,6 +451,9 @@ impl Image { shadowing: None, shadow: true, aspects: self.aspects, + format: plan.format, + usage: plan.usage, + view_formats: plan.view_formats.clone(), first: vk::ImageLayout::UNDEFINED, homed: AtomicBool::new(false), _under: None, @@ -626,7 +637,8 @@ impl Device { ) -> Result { let (shape, plan, _) = self.prepare(descriptor)?; let core = self.core(); - let info = image_info(descriptor, &shape, &plan); + let mut list = plan.format_list(); + let info = image_info(descriptor, &shape, &plan, &mut list); let mut dedicated = vk::MemoryDedicatedRequirements::default(); let mut needs = vk::MemoryRequirements2::default().push_next(&mut dedicated); let query = vk::DeviceImageMemoryRequirements::default().create_info(&info); @@ -914,6 +926,9 @@ impl Device { shadowing, shadow: false, aspects: plan.aspects, + format: plan.format, + usage: plan.usage, + view_formats: plan.view_formats.clone(), first, homed: AtomicBool::new(false), _under: block, @@ -944,6 +959,7 @@ impl Device { descriptor: d, image, format: plan.format, + views_usage: None, unit: plan.unit, index, word: plan.word, @@ -1002,6 +1018,15 @@ struct Plan { unit: Option, word: u32, emulation: FormatEmulation, + /// The format's compatibility class, which every format the image lists shares. + class: &'static str, + /// The usage a view in the plan's format takes: of sampling, storage and attachments, those + /// the format's features hold. + supported: vk::ImageUsageFlags, + /// The formats the image lists for its views, its own first, where Metal views it as another + /// format the device holds in the image format's class (`view_formats`); empty where it has no + /// such view, and the image is not mutable. + view_formats: Vec, } impl Plan { @@ -1019,9 +1044,24 @@ impl Plan { sampled: None, storage: false, attachment_reads: false, + view_formats: self.view_formats.clone(), ..*self } } + + /// The image's create flags over `shape`'s: mutable where it lists formats for its views. + fn flags(&self, shape: &Shape) -> vk::ImageCreateFlags { + match self.view_formats.is_empty() { + true => shape.flags, + false => shape.flags | vk::ImageCreateFlags::MUTABLE_FORMAT, + } + } + + /// The image's format list, which its create info and its format queries chain where it is + /// mutable. + fn format_list(&self) -> vk::ImageFormatListCreateInfo<'_> { + vk::ImageFormatListCreateInfo::default().view_formats(&self.view_formats) + } } /// The slices of each level of a texture of descriptor `d`: a cube's six faces each a slice, and @@ -1165,12 +1205,16 @@ fn kept_features(usage: vk::ImageUsageFlags) -> vk::FormatFeatureFlags2 { /// The largest extent of a linear image of `plan`'s format and usage of `shape`'s type, where the /// device makes one. fn linear_extent(core: &Core, shape: &Shape, plan: &Plan) -> Option { - let linear = vk::PhysicalDeviceImageFormatInfo2::default() + let mut list = plan.format_list(); + let mut linear = vk::PhysicalDeviceImageFormatInfo2::default() .format(plan.format) .ty(shape.image_type) .tiling(vk::ImageTiling::LINEAR) .usage(plan.linear_usage()) - .flags(shape.flags); + .flags(plan.flags(shape)); + if !plan.view_formats.is_empty() { + linear = linear.push_next(&mut list); + } core.image_format_properties(&linear) .map(|properties| properties.max_extent) } @@ -1216,7 +1260,8 @@ fn linear_layout( if d.width > max.width || d.height > max.height { return None; } - let info = image_info(d, shape, plan) + let mut list = plan.format_list(); + let info = image_info(d, shape, plan, &mut list) .tiling(vk::ImageTiling::LINEAR) .usage(plan.linear_usage()) .initial_layout(vk::ImageLayout::PREINITIALIZED); @@ -1360,85 +1405,38 @@ fn plan( usage: TextureUsage, shape: &Shape, ) -> Result { + let mut plan = form(core, d, usage)?; let pf = d.pixel_format; let gap = || Error::Unsupported(Gap::TextureFormat { pixel_format: pf }); - let word = TextureWord::of(pf, d.swizzle).ok_or_else(gap)?.0; let profile = core.translator.profile(); - let mapping = - formats::vk_format(pf, &formats::texture_usages(pf, usage), profile).map_err(|_| gap())?; - // The forms whose view gives Metal's values with no conversion in the shader. - let viewed = matches!( - mapping.emulation, - FormatEmulation::Direct - | FormatEmulation::SwizzledView - | FormatEmulation::AlphaInRed - | FormatEmulation::RotatedView - | FormatEmulation::XChannel - | FormatEmulation::DepthInCombined - | FormatEmulation::StencilInCombined + plan.view_formats = view_formats(profile, pf, usage, &plan); + let read = plan.usage.contains(vk::ImageUsageFlags::SAMPLED); + let render = plan.usage.intersects( + vk::ImageUsageFlags::COLOR_ATTACHMENT | vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT, ); - if !viewed { - return Err(gap()); - } - let block = mapping.format.block().ok_or_else(gap)?; - let format: vk::Format = mapping.format.into(); - let metal_aspects: vk::ImageAspectFlags = mapping.aspects.into(); - let mut aspects = vk::ImageAspectFlags::empty(); - if block.depth.is_some() { - aspects |= vk::ImageAspectFlags::DEPTH; - } - if block.stencil.is_some() { - aspects |= vk::ImageAspectFlags::STENCIL; - } - if aspects.is_empty() { - aspects = vk::ImageAspectFlags::COLOR; - } - let read = usage.contains(TextureUsage::SHADER_READ); - let storage = usage.contains(TextureUsage::SHADER_WRITE) - && mapping.emulation == FormatEmulation::Direct - && profile.supports_format(mapping.format, FormatUsage::StorageImage) - && profile.supports_format(mapping.format, FormatUsage::StorageImageWriteWithoutFormat); - let render = usage.contains(TextureUsage::RENDER_TARGET); - let mut image_usage = vk::ImageUsageFlags::TRANSFER_SRC | vk::ImageUsageFlags::TRANSFER_DST; - if read { - image_usage |= vk::ImageUsageFlags::SAMPLED; - } - if storage { - image_usage |= vk::ImageUsageFlags::STORAGE; - } - if render { - image_usage |= match metal_aspects - .intersects(vk::ImageAspectFlags::DEPTH | vk::ImageAspectFlags::STENCIL) - { - true => vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT, - false => vk::ImageUsageFlags::COLOR_ATTACHMENT, - }; - } // A draw may read an attachment of its own pass through such a texture // (`crate::render_encoder`), where the device reads attachments: in the feedback layout where // it has the attachment feedback loop, else through a copy into the image's shadow. let mut attachment_reads = core.attachment_reads && read && render - && !storage - && aspects == vk::ImageAspectFlags::COLOR; + && !plan.storage + && plan.aspects == vk::ImageAspectFlags::COLOR; let looped = attachment_reads && core.feedback.is_some(); + let mut image_usage = plan.usage; if looped { image_usage |= vk::ImageUsageFlags::ATTACHMENT_FEEDBACK_LOOP_EXT; } - let home = match (storage, read, render) { - (true, _, _) => vk::ImageLayout::GENERAL, - (false, true, _) => vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL, - (false, false, true) => vk::ImageLayout::ATTACHMENT_OPTIMAL, - (false, false, false) => vk::ImageLayout::GENERAL, - }; - let samples = vk::SampleCountFlags::from_raw(d.sample_count); - let info = vk::PhysicalDeviceImageFormatInfo2::default() - .format(format) + let mut list = plan.format_list(); + let mut info = vk::PhysicalDeviceImageFormatInfo2::default() + .format(plan.format) .ty(shape.image_type) .tiling(vk::ImageTiling::OPTIMAL) .usage(image_usage) - .flags(shape.flags); + .flags(plan.flags(shape)); + if !plan.view_formats.is_empty() { + info = info.push_next(&mut list); + } let mut properties = core.image_format_properties(&info); // A format the device makes without the feedback usage alone is made so, and its draws read // no attachment of their own pass through it. @@ -1466,12 +1464,144 @@ fn plan( max_layers: properties.max_array_layers, })); } - if !d.sample_count.is_power_of_two() || !properties.sample_counts.contains(samples) { + if !d.sample_count.is_power_of_two() || !properties.sample_counts.contains(plan.samples) { return Err(Error::Limit(Limit::TextureSamples { sample_count: d.sample_count, counts: properties.sample_counts.as_raw(), })); } + plan.usage = image_usage; + plan.attachment_reads = attachment_reads; + Ok(plan) +} + +/// Whether a format held so gives Metal's values through its view, with no conversion in the +/// shader. +fn viewed(emulation: FormatEmulation) -> bool { + matches!( + emulation, + FormatEmulation::Direct + | FormatEmulation::SwizzledView + | FormatEmulation::AlphaInRed + | FormatEmulation::RotatedView + | FormatEmulation::XChannel + | FormatEmulation::DepthInCombined + | FormatEmulation::StencilInCombined + ) +} + +/// The formats an image of `plan`, of a texture of `pf` and `usage`, lists for its views, its own +/// first: those Metal views such a texture as (its sRGB sibling, and with `PixelFormatView` usage +/// every format `metal::format::views_with_usage` takes) that the device holds for the usage in a +/// viewed form of the image format's class. Empty where there is none but its own: the image is +/// then not mutable. +fn view_formats( + profile: &metal2vulkan::device::DeviceProfile, + pf: PixelFormat, + usage: TextureUsage, + plan: &Plan, +) -> Vec { + let others: Vec = match usage.contains(TextureUsage::PIXEL_FORMAT_VIEW) { + true => (PixelFormat::ALL.iter().copied()) + .filter(|&view| view != pf && formats::views_with_usage(pf, view)) + .collect(), + false => formats::srgb_sibling(pf).into_iter().collect(), + }; + let mut list = vec![plan.format]; + for view in others { + let usages = formats::texture_usages(view, usage); + let Ok(mapping) = formats::vk_format(view, &usages, profile) else { + continue; + }; + let class = mapping.format.block().map(|block| block.class); + let format: vk::Format = mapping.format.into(); + if viewed(mapping.emulation) && class == Some(plan.class) && !list.contains(&format) { + list.push(format); + } + } + if list.len() == 1 { + list.clear(); + } + list +} + +/// What a texture of `d` and `usage` holds in its views, as its own image or as a view of +/// another's: the format and how it holds Metal's, the aspects, the sampled view's components and +/// aspect, whether it has a storage view, the image usage its uses ask, its home layout, the copy +/// unit and the word. An image's own parts, its format list, the feedback usage and the format +/// query's checks, are `plan`'s. +fn form(core: &Core, d: &TextureDescriptor, usage: TextureUsage) -> Result { + let pf = d.pixel_format; + let gap = || Error::Unsupported(Gap::TextureFormat { pixel_format: pf }); + let word = TextureWord::of(pf, d.swizzle).ok_or_else(gap)?.0; + let profile = core.translator.profile(); + let mapping = + formats::vk_format(pf, &formats::texture_usages(pf, usage), profile).map_err(|_| gap())?; + if !viewed(mapping.emulation) { + return Err(gap()); + } + let block = mapping.format.block().ok_or_else(gap)?; + let format: vk::Format = mapping.format.into(); + let metal_aspects: vk::ImageAspectFlags = mapping.aspects.into(); + let mut aspects = vk::ImageAspectFlags::empty(); + if block.depth.is_some() { + aspects |= vk::ImageAspectFlags::DEPTH; + } + if block.stencil.is_some() { + aspects |= vk::ImageAspectFlags::STENCIL; + } + if aspects.is_empty() { + aspects = vk::ImageAspectFlags::COLOR; + } + let read = usage.contains(TextureUsage::SHADER_READ); + let storage = usage.contains(TextureUsage::SHADER_WRITE) + && mapping.emulation == FormatEmulation::Direct + && profile.supports_format(mapping.format, FormatUsage::StorageImage) + && profile.supports_format(mapping.format, FormatUsage::StorageImageWriteWithoutFormat); + let render = usage.contains(TextureUsage::RENDER_TARGET); + let supports = |use_| profile.supports_format(mapping.format, use_); + let mut supported = vk::ImageUsageFlags::empty(); + for (use_, flag) in [ + (FormatUsage::SampledImage, vk::ImageUsageFlags::SAMPLED), + (FormatUsage::StorageImage, vk::ImageUsageFlags::STORAGE), + ( + FormatUsage::ColorAttachment, + vk::ImageUsageFlags::COLOR_ATTACHMENT, + ), + ( + FormatUsage::DepthStencilAttachment, + vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT, + ), + ] { + if supports(use_) { + supported |= flag; + } + } + if supported.contains(vk::ImageUsageFlags::COLOR_ATTACHMENT) { + supported |= vk::ImageUsageFlags::ATTACHMENT_FEEDBACK_LOOP_EXT; + } + let mut image_usage = vk::ImageUsageFlags::TRANSFER_SRC | vk::ImageUsageFlags::TRANSFER_DST; + if read { + image_usage |= vk::ImageUsageFlags::SAMPLED; + } + if storage { + image_usage |= vk::ImageUsageFlags::STORAGE; + } + if render { + image_usage |= match metal_aspects + .intersects(vk::ImageAspectFlags::DEPTH | vk::ImageAspectFlags::STENCIL) + { + true => vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT, + false => vk::ImageUsageFlags::COLOR_ATTACHMENT, + }; + } + let home = match (storage, read, render) { + (true, _, _) => vk::ImageLayout::GENERAL, + (false, true, _) => vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL, + (false, false, true) => vk::ImageLayout::ATTACHMENT_OPTIMAL, + (false, false, false) => vk::ImageLayout::GENERAL, + }; + let samples = vk::SampleCountFlags::from_raw(d.sample_count); // A sampled view selects one aspect: depth where the format has it, else stencil. let view_aspect = if metal_aspects.contains(vk::ImageAspectFlags::DEPTH) { vk::ImageAspectFlags::DEPTH @@ -1495,11 +1625,14 @@ fn plan( sampled, storage, home, - attachment_reads, + attachment_reads: false, aspects, unit, word, emulation: mapping.emulation, + class: block.class, + supported, + view_formats: Vec::new(), }) } @@ -1564,7 +1697,9 @@ pub(crate) fn components( }) } -/// An image view of `range` of `image`, of `view_type` and `format`, with `components`. +/// An image view of `range` of `image`, of `view_type` and `format`, with `components`, and with +/// `usage` where its format is another than the image's (`VkImageViewUsageCreateInfo`: the image's +/// usage that the format's features hold), else the image's. /// /// # Safety /// @@ -1576,13 +1711,19 @@ unsafe fn image_view( format: vk::Format, components: vk::ComponentMapping, range: vk::ImageSubresourceRange, + usage: Option, ) -> Result { - let info = vk::ImageViewCreateInfo::default() + let mut usage_info = vk::ImageViewUsageCreateInfo::default(); + let mut info = vk::ImageViewCreateInfo::default() .image(image) .view_type(view_type) .format(format) .components(components) .subresource_range(range); + if let Some(usage) = usage { + usage_info = usage_info.usage(usage); + info = info.push_next(&mut usage_info); + } // SAFETY: the caller's contract. unsafe { device.create_image_view(&info, None) }.map_err(Error::vulkan("vkCreateImageView")) } @@ -1673,10 +1814,15 @@ enum Bind { } /// The image of a texture of `d`, of `shape`, as `plan` makes it. -fn image_info(d: &TextureDescriptor, shape: &Shape, plan: &Plan) -> vk::ImageCreateInfo<'static> { +fn image_info<'a, 'b: 'a>( + d: &TextureDescriptor, + shape: &Shape, + plan: &Plan, + list: &'a mut vk::ImageFormatListCreateInfo<'b>, +) -> vk::ImageCreateInfo<'a> { let [width, height, depth] = shape.extent; - vk::ImageCreateInfo::default() - .flags(shape.flags) + let info = vk::ImageCreateInfo::default() + .flags(plan.flags(shape)) .image_type(shape.image_type) .format(plan.format) .extent(vk::Extent3D { @@ -1690,7 +1836,11 @@ fn image_info(d: &TextureDescriptor, shape: &Shape, plan: &Plan) -> vk::ImageCre .tiling(vk::ImageTiling::OPTIMAL) .usage(plan.usage) .sharing_mode(vk::SharingMode::EXCLUSIVE) - .initial_layout(vk::ImageLayout::UNDEFINED) + .initial_layout(vk::ImageLayout::UNDEFINED); + match plan.view_formats.is_empty() { + true => info, + false => info.push_next(list), + } } /// A heap texture's size and alignment from its image's `requirements`: rounded to the device's @@ -1740,12 +1890,14 @@ impl Made { bind: Bind, ) -> Result { let device = &core.device; + let mut list = plan.format_list(); + let info = image_info(d, shape, plan, &mut list); let info = match bind { - Bind::InPlace { .. } => image_info(d, shape, plan) + Bind::InPlace { .. } => info .tiling(vk::ImageTiling::LINEAR) .usage(plan.linear_usage()) .initial_layout(vk::ImageLayout::PREINITIALIZED), - Bind::Pooled | Bind::Heap { .. } => image_info(d, shape, plan), + Bind::Pooled | Bind::Heap { .. } => info, }; // SAFETY: the caller's contract: the device makes such an image. let image = @@ -1866,8 +2018,9 @@ impl Made { let mut view = |components, aspect| { let (view_type, format) = (shape.view_type, plan.format); // SAFETY: the image is bound, of the view's format, and has the view's usage. + let range = whole(aspect); let view = - unsafe { image_view(device, image, view_type, format, components, whole(aspect)) }?; + unsafe { image_view(device, image, view_type, format, components, range, None) }?; self.views.push(view); Ok::<_, Error>(view) }; @@ -2347,9 +2500,15 @@ impl Texture { /// Managed texture names the texture's bytes of those levels and slices, so the CPU's reads /// and writes through either reach the same bytes, as Metal's do. /// - /// Built: the texture's own pixel format, over every slice in the texture's own type, a slice - /// subrange of a 1D or 2D array, or one slice of a 2D array as a 2D texture, each over any - /// level subrange. `index` is given exactly where shaders reach the view, as + /// Built: the texture's own pixel format or another its image lists, over every slice in the + /// texture's own type, a slice subrange of a 1D or 2D array, or one slice of a 2D array as a + /// 2D texture, each over any level subrange. A texture's image lists the formats Metal views + /// it as that the device holds in a viewed form of the image format's compatibility class: its + /// sRGB sibling whatever its usage, and with `PixelFormatView` usage every uncompressed colour + /// format of the same bytes a texel; such an image is mutable, with that format list. A view + /// of another format takes the image's usage that its format's features hold: it has no + /// storage element where the image has no storage usage, and renders where its format holds + /// an attachment, else [`Gap::TextureFormat`] at the pass. `index` is given exactly where shaders reach the view, as /// [`Device::new_texture`] takes it; its usage, storage mode, sample count and swizzle are the /// texture's. /// @@ -2422,14 +2581,16 @@ impl Texture { })); } let gap = |kind| Err(Error::Unsupported(Gap::TextureView { kind })); - if pixel_format != p.pixel_format { - if !p.usage.is_empty() && !p.usage.contains(TextureUsage::PIXEL_FORMAT_VIEW) { - return Err(Error::Refused(Refusal::TextureViewFormat { - texture: p.pixel_format, - view: pixel_format, - })); - } - return gap(TextureViewKind::PixelFormat); + let viewable = match p.usage.is_empty() || p.usage.contains(TextureUsage::PIXEL_FORMAT_VIEW) + { + true => formats::views_with_usage(p.pixel_format, pixel_format), + false => formats::views_without_usage(p.pixel_format, pixel_format), + }; + if !viewable { + return Err(Error::Refused(Refusal::TextureViewFormat { + texture: p.pixel_format, + view: pixel_format, + })); } let every_slice = slice_count == self::slices(p); match (p.texture_type, texture_type) { @@ -2450,11 +2611,27 @@ impl Texture { T::Cube | T::CubeArray => slice_count / 6, _ => slice_count, }; + d.pixel_format = pixel_format; d.swizzle = combined(p.swizzle, swizzle); // A view takes its descriptor's checks but the swizzle's with its usage, which Metal // makes of a texture's own descriptor alone. let (shape, usage) = checked(&d)?; - let plan = plan(inner.device.core(), &d, usage, &shape)?; + let mut plan = form(inner.device.core(), &d, usage)?; + // Another format is built where the image lists it; its views take the image's usage + // that the format's features hold. + let image = &inner.image; + let views_usage = match plan.format == image.format { + true => None, + false if image.view_formats.contains(&plan.format) => { + Some(image.usage & plan.supported) + } + false => return gap(TextureViewKind::PixelFormat), + }; + let usable = views_usage.unwrap_or(image.usage); + plan.storage &= usable.contains(vk::ImageUsageFlags::STORAGE); + if !usable.contains(vk::ImageUsageFlags::SAMPLED) { + plan.sampled = None; + } let reached = usage.intersects(TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE); if reached != index.is_some() { return Err(Error::Refused(Refusal::TextureIndex { index })); @@ -2470,9 +2647,10 @@ impl Texture { layer_count: shape.layers, }; let image = inner.image.image; - let make = |(components, aspect)| { + let make = |(components, aspect, role): (_, _, vk::ImageUsageFlags)| { let (view_type, format) = (shape.view_type, plan.format); - // SAFETY: the image is bound, of the view's format, has the view's usage, and holds + let usage = views_usage.map(|usage| usage & role); + // SAFETY: the image is bound, lists the view's format, has the view's usage, and holds // the range: the texture's levels and layers hold the view's. unsafe { image_view( @@ -2482,18 +2660,25 @@ impl Texture { format, components, range(aspect), + usage, ) } }; - let storage = (plan.storage) - .then_some((vk::ComponentMapping::default(), vk::ImageAspectFlags::COLOR)); + let sampled_role = + vk::ImageUsageFlags::SAMPLED | vk::ImageUsageFlags::ATTACHMENT_FEEDBACK_LOOP_EXT; + let sampled = (plan.sampled).map(|(components, aspect)| (components, aspect, sampled_role)); + let storage = (plan.storage).then_some(( + vk::ComponentMapping::default(), + vk::ImageAspectFlags::COLOR, + vk::ImageUsageFlags::STORAGE, + )); let mut views = Views { core: Arc::clone(core), sampled: None, storage: None, }; let mut made = || { - views.sampled = plan.sampled.map(make).transpose()?; + views.sampled = sampled.map(make).transpose()?; views.storage = storage.map(make).transpose()?; Ok::<_, Error>(()) }; @@ -2544,6 +2729,7 @@ impl Texture { descriptor: d, image: Arc::clone(&inner.image), format: plan.format, + views_usage, unit: plan.unit, index, word: plan.word, @@ -2629,6 +2815,7 @@ impl Texture { self.inner.format, at.components, at.range, + (self.inner.views_usage).map(|_| vk::ImageUsageFlags::SAMPLED), ) }?; *view = Some(made); @@ -2733,6 +2920,20 @@ impl Texture { let [first_level, first_layer] = self.inner.base(); let (level_in_image, layer) = (first_level + level, first_layer + slice); let image = &self.inner.image; + // A view of another format than the image's renders where the format's features hold an + // attachment. + let renders = + vk::ImageUsageFlags::COLOR_ATTACHMENT | vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT; + let looped = vk::ImageUsageFlags::ATTACHMENT_FEEDBACK_LOOP_EXT; + let usage = match self.inner.views_usage { + None => None, + Some(usage) if usage.intersects(renders) => Some(usage & (renders | looped)), + Some(_) => { + return Err(Error::Unsupported(Gap::TextureFormat { + pixel_format: d.pixel_format, + })) + } + }; let mut views = lock(&self.inner.attachments); let kept = (views.iter()) .find(|a| a.level == level_in_image && a.layer == layer) @@ -2759,6 +2960,7 @@ impl Texture { self.inner.format, vk::ComponentMapping::default(), range, + usage, ) }?; core.counters.rise(Gauge::AttachmentViews); diff --git a/crates/metal2vulkan/src/metal/format/mod.rs b/crates/metal2vulkan/src/metal/format/mod.rs index 453a6ade9..ce3f844ad 100644 --- a/crates/metal2vulkan/src/metal/format/mod.rs +++ b/crates/metal2vulkan/src/metal/format/mod.rs @@ -2059,6 +2059,74 @@ pub fn srgb_raw_twin(pf: PixelFormat) -> Option { }) } +/// The other member of `pf`'s sRGB pair, the same bits read as linear values or as sRGB codes: +/// an 8-bit format and its sRGB form, a compressed format and its sRGB form, an extended-range +/// format and its sRGB form. Metal views a texture as it whatever the texture's usage (Apple's +/// `MTLTextureUsage.pixelFormatView`: "Don't set this option if your texture view only converts +/// between linear space and sRGB"). `None` for a format with no such pair. +pub fn srgb_sibling(pf: PixelFormat) -> Option { + use PixelFormat as P; + // The pairs `srgb_raw_twin` leaves out, linear first: ASTC's LDR and sRGB forms decode the + // same blocks, and the extended-range formats are no twin of a unorm format. + const PAIRS: [(PixelFormat, PixelFormat); 17] = [ + (P::ASTC4x4LDR, P::ASTC4x4SRGB), + (P::ASTC5x4LDR, P::ASTC5x4SRGB), + (P::ASTC5x5LDR, P::ASTC5x5SRGB), + (P::ASTC6x5LDR, P::ASTC6x5SRGB), + (P::ASTC6x6LDR, P::ASTC6x6SRGB), + (P::ASTC8x5LDR, P::ASTC8x5SRGB), + (P::ASTC8x6LDR, P::ASTC8x6SRGB), + (P::ASTC8x8LDR, P::ASTC8x8SRGB), + (P::ASTC10x5LDR, P::ASTC10x5SRGB), + (P::ASTC10x6LDR, P::ASTC10x6SRGB), + (P::ASTC10x8LDR, P::ASTC10x8SRGB), + (P::ASTC10x10LDR, P::ASTC10x10SRGB), + (P::ASTC12x10LDR, P::ASTC12x10SRGB), + (P::ASTC12x12LDR, P::ASTC12x12SRGB), + (P::BGR10XR, P::BGR10XRSRGB), + (P::BGRA10XR, P::BGRA10XRSRGB), + (P::RGB10A82PXR10, P::RGB10A82PXR10SRGB), + ]; + if let Some(linear) = srgb_raw_twin(pf) { + return Some(linear); + } + if let Some(&srgb) = (P::ALL.iter()).find(|&&srgb| srgb_raw_twin(srgb) == Some(pf)) { + return Some(srgb); + } + PAIRS.iter().find_map(|&(linear, srgb)| match pf { + _ if pf == linear => Some(srgb), + _ if pf == srgb => Some(linear), + _ => None, + }) +} + +/// Whether Metal views a texture of `pf` as `view` with no usage asked: `pf` itself, its sRGB +/// sibling ([`srgb_sibling`]), or the stencil format of a combined depth and stencil format +/// (`Depth32Float_Stencil8` as `X32_Stencil8`, `Depth24Unorm_Stencil8` as `X24_Stencil8`). +pub fn views_without_usage(pf: PixelFormat, view: PixelFormat) -> bool { + use PixelFormat as P; + pf == view + || srgb_sibling(pf) == Some(view) + || matches!( + (pf, view), + (P::Depth32FloatStencil8, P::X32Stencil8) | (P::Depth24UnormStencil8, P::X24Stencil8) + ) +} + +/// Whether Metal views a texture of `pf` made with `PixelFormatView` usage as `view`: as +/// [`views_without_usage`], or both uncompressed color formats whose images hold Metal's bytes +/// ([`byte_format`]) with the same bytes a texel (Apple's `makeTextureView(pixelFormat:)`: "All +/// 8-, 16-, 32-, 64-, and 128-bit color formats are compatible with other formats with the same +/// bit length"). +pub fn views_with_usage(pf: PixelFormat, view: PixelFormat) -> bool { + let color = |pf| { + let block = byte_format(pf)?.block()?; + let color = block.texels == 1 && block.color.is_some(); + (color && block.depth.is_none() && block.stencil.is_none()).then_some(block.size) + }; + views_without_usage(pf, view) || color(pf).is_some_and(|size| color(view) == Some(size)) +} + /// The bit width of each channel of integer format `f`, red to alpha (a channel `f` lacks takes /// the first one's width; nothing is stored there): the ranges into which Metal saturates each /// channel of an integer texel's write, as the format's signedness reads the word. `None` for a diff --git a/crates/metal2vulkan/src/metal/format/tests.rs b/crates/metal2vulkan/src/metal/format/tests.rs index 8e4a97c69..62b9b47c0 100644 --- a/crates/metal2vulkan/src/metal/format/tests.rs +++ b/crates/metal2vulkan/src/metal/format/tests.rs @@ -3331,3 +3331,70 @@ fn the_packed_four_bit_straggler_converts_writes_through_a_half() { assert_eq!(half_unorm_code(f32::INFINITY, 4), 15); assert_eq!(half_unorm_code(f32::NEG_INFINITY, 4), 0); } + +/// An sRGB sibling is mutual and of one other format, linear to sRGB and back, for the 8-bit, +/// compressed (ASTC's LDR forms included) and extended-range pairs; a format of no pair has none. +#[test] +fn an_srgb_sibling_is_mutual() { + use PixelFormat as P; + for (linear, srgb) in [ + (P::BGRA8Unorm, P::BGRA8UnormSRGB), + (P::R8Unorm, P::R8UnormSRGB), + (P::BC7RGBAUnorm, P::BC7RGBAUnormSRGB), + (P::ASTC6x6LDR, P::ASTC6x6SRGB), + (P::BGR10XR, P::BGR10XRSRGB), + ] { + assert_eq!(srgb_sibling(linear), Some(srgb), "{linear:?}"); + assert_eq!(srgb_sibling(srgb), Some(linear), "{srgb:?}"); + } + for &pf in P::ALL { + if let Some(sibling) = srgb_sibling(pf) { + assert_ne!(sibling, pf, "{pf:?}"); + assert_eq!(srgb_sibling(sibling), Some(pf), "{pf:?} and {sibling:?}"); + } + } + for pf in [ + P::R32Float, + P::RGBA16Float, + P::ASTC4x4HDR, + P::BC4RUnorm, + P::Depth32Float, + ] { + assert_eq!(srgb_sibling(pf), None, "{pf:?}"); + } +} + +/// Metal's view rules: the sRGB sibling and a combined format's stencil with no usage asked; with +/// `PixelFormatView` usage, any uncompressed color format of the same bytes a texel too, and no +/// compressed, depth or other-sized one. +#[test] +fn views_follow_metals_compatibility_rules() { + use PixelFormat as P; + for (pf, view) in [ + (P::BGRA8UnormSRGB, P::BGRA8Unorm), + (P::BC1RGBA, P::BC1RGBASRGB), + (P::Depth32FloatStencil8, P::X32Stencil8), + ] { + assert!(views_without_usage(pf, view), "{pf:?} as {view:?}"); + assert!(views_with_usage(pf, view), "{pf:?} as {view:?}"); + } + for (pf, view) in [ + (P::RGBA8Unorm, P::R32Uint), + (P::BGRA8UnormSRGB, P::RG16Float), + (P::RGBA16Float, P::RG32Uint), + (P::R8Unorm, P::R8Sint), + (P::RGBA32Float, P::RGBA32Uint), + ] { + assert!(!views_without_usage(pf, view), "{pf:?} as {view:?}"); + assert!(views_with_usage(pf, view), "{pf:?} as {view:?}"); + } + for (pf, view) in [ + (P::RGBA8Unorm, P::R16Float), + (P::BC1RGBA, P::RG32Uint), + (P::Depth32Float, P::R32Float), + (P::RGBA8Unorm, P::BC1RGBA), + (P::BC1RGBA, P::BC2RGBA), + ] { + assert!(!views_with_usage(pf, view), "{pf:?} as {view:?}"); + } +} diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 43558640e..70de0be1a 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -6169,11 +6169,14 @@ fn metal2vulkan::metal::format::padded_words pub fn padded_words(pf: PixelFormat fn metal2vulkan::metal::format::rotated_channels pub fn rotated_channels(pf: PixelFormat) -> bool fn metal2vulkan::metal::format::sampled_type pub fn sampled_type(pf: PixelFormat) -> Option fn metal2vulkan::metal::format::srgb_raw_twin pub fn srgb_raw_twin(pf: PixelFormat) -> Option +fn metal2vulkan::metal::format::srgb_sibling pub fn srgb_sibling(pf: PixelFormat) -> Option fn metal2vulkan::metal::format::storage_image_choice pub fn storage_image_choice(pf: PixelFormat, profile: &DeviceProfile) -> Result fn metal2vulkan::metal::format::storage_view_formats pub fn storage_view_formats(pf: PixelFormat, profile: &DeviceProfile) -> Vec fn metal2vulkan::metal::format::swizzle_over pub fn swizzle_over(pf: PixelFormat, swizzle: TextureSwizzleChannels, own: PixelFormat, profile: &DeviceProfile) -> Option fn metal2vulkan::metal::format::texture_usages pub fn texture_usages(pf: PixelFormat, usage: TextureUsage) -> BTreeSet fn metal2vulkan::metal::format::to_rotated_image pub fn to_rotated_image(metal: [T; 4]) -> [T; 4] +fn metal2vulkan::metal::format::views_with_usage pub fn views_with_usage(pf: PixelFormat, view: PixelFormat) -> bool +fn metal2vulkan::metal::format::views_without_usage pub fn views_without_usage(pf: PixelFormat, view: PixelFormat) -> bool fn metal2vulkan::metal::format::vk_format pub fn vk_format(pf: PixelFormat, usages: &BTreeSet, profile: &DeviceProfile) -> Result fn metal2vulkan::metal::format::writes_dropped pub fn writes_dropped(pf: PixelFormat) -> bool fn metal2vulkan::metal::format::x_channel pub fn x_channel(pf: PixelFormat) -> bool diff --git a/crates/metal2vulkan/tests/api_surface.rs b/crates/metal2vulkan/tests/api_surface.rs index 134d49604..2a69494af 100644 --- a/crates/metal2vulkan/tests/api_surface.rs +++ b/crates/metal2vulkan/tests/api_surface.rs @@ -982,6 +982,9 @@ surface! { fn direct_format; fn byte_format; fn srgb_raw_twin; + fn srgb_sibling; + fn views_without_usage; + fn views_with_usage; fn block_extent; enum Footprint N; fn footprint; diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 6769065a3..2c3be03c3 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -658,7 +658,7 @@ Columns: | `BufferCopyLayout` | `BlitCommandEncoder::copy_from_buffer` or `BlitCommandEncoder::copy_from_texture_to_buffer` whose offset or row stride, for a format of single... | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, probe `blit_buffer_copy_rules.m` in the conformance crate, jobs m3-max-43541 and m3-max-43545: Metal's validation layer stops an RGBA8Unorm offset of 2, `sourceOffset (2) must be a multiple of 4 bytes`, a row stride of 18, `sourceBytesPerRow (18) must be a multiple of 4 bytes`, and the same of a copy into a buffer, a row stride of 12 for rows of 16 bytes, an image stride of 12 for images of 16, and a region 16 bytes past the buffer's end, `totalBytesUsed(4112) must be <= [sourceBuffer length](4096)`; it takes an R8Unorm offset of 2, a row stride of 0 for one row, image strides of no whole number of rows, and an image stride on a 2D texture and on a slice of a 1D array | 1: `crates/metal2vulkan-rt/src/blit.rs (buffer_copy)` | `-` | | `FillRange` | `BlitCommandEncoder::fill_buffer` of an empty range, or of one past the buffer's end | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, probe `blit_fill_rules.m` in the conformance crate, job m3-max-43573: Metal's validation layer stops both, `range.length(0) must not be 0` and `(range.location + range.length)(68) must be <= [buffer length](64)` | 1: `crates/metal2vulkan-rt/src/blit.rs (fill_range)` | `-` | | `TextureViewRange` | `Texture::new_texture_view` of an empty range of levels or slices, or of one past the texture's | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, probe `texture_view_rules.m` in the conformance crate, job m3-max-43677: Metal's validation layer stops each, `(newLevelRange.location + newLevelRange.length)(4) must be <= [texture mipmapLevelCount](3)`, `newLevelRange.length must not be 0` and `(newSliceRange.location + newSliceRange.length)(4) must be <= (3)` | 1: `crates/metal2vulkan-rt/src/texture.rs (new_texture_view_with_swizzle)` | `-` | -| `TextureViewFormat` | `Texture::new_texture_view` of another pixel format over a texture made without `PixelFormatView` usage | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, probe `texture_view_rules.m` in the conformance crate, job m3-max-43677: Metal's validation layer stops an `R32Uint` view of an `RGBA8Unorm` texture of `ShaderRead` usage, `Texture View Validation`, and makes it where the usage adds `PixelFormatView` | 1: `crates/metal2vulkan-rt/src/texture.rs (new_texture_view_with_swizzle)` | `-` | +| `TextureViewFormat` | `Texture::new_texture_view` of a pixel format Metal does not view the texture as | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, probe `texture_view_rules.m` in the conformance crate, job m3-max-43677: Metal's validation layer stops an `R32Uint` view of an `RGBA8Unorm` texture of `ShaderRead` usage, `Texture View Validation`, and makes it where the usage adds `PixelFormatView`; Apple's `makeTextureView` and `MTLTextureUsage.pixelFormatView` pages state the rest | 1: `crates/metal2vulkan-rt/src/texture.rs (new_texture_view_with_swizzle)` | `-` | | `TextureCopyMismatch` | `BlitCommandEncoder::copy_from_texture` between textures of two pixel formats, or of two sample counts | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, probe `blit_copy_format_pairs.m` in the conformance crate: Metal's validation layer stops every pair of two formats it was given, sRGB, integer, float, channel order, depth and compressed pairs among them, with `[sourceTexture pixelFormat](...) must equal [destinationTexture pixelFormat](...)`, and a source of four samples into one of one with `[sourceTexture sampleCount](4) must equal [destinationTexture sampleCount](1)` | 1: `crates/metal2vulkan-rt/src/blit.rs (texture_copy)` | `-` | | `ManagedTextureBytes` | A Managed texture's bytes the device cannot copy in place (`Device::new_managed_texture`) | every device (a public call's own check of its arguments) | `ours`: a buffer-to-image copy reads a place only so laid out, and the consumer's bytes are the place the copy reads | 5: `crates/metal2vulkan-rt/src/texture.rs (check_places)`, `crates/metal2vulkan-rt/src/texture.rs (named)` (+2) | `-` | | `BufferTextureLayout` | A texture over a buffer (`Buffer::new_texture`) whose rows are not a whole number of texels apart or are closer than a row, whose offset is not a... | every device (a public call's own check of its arguments) | `ours`: a linear image and a copy read rows whole texels apart from a texel's start, and texels past the buffer would lie in memory it does not hold | 1: `crates/metal2vulkan-rt/src/texture.rs (check_over)` | `-` | @@ -700,7 +700,7 @@ Columns: | `MemorylessTexture` | A texture of `Memoryless` storage, which only render passes use | every device (a public call's own check of its arguments) | `ours`: render passes are not built | 1: `crates/metal2vulkan-rt/src/texture.rs (checked)` | `-` | | `TextureBuffer` | A texture buffer (`MTLTextureTypeTextureBuffer`) | every device (a public call's own check of its arguments) | `ours`: no texel-buffer array; no replay stream uses one | 2: `crates/metal2vulkan-rt/src/texture.rs (shape, 2 sites)` | `-` | | `CubeArrayTexture` | A cube array texture (`MTLTextureTypeCubeArray`), and so a view of one | every device (a public call's own check of its arguments) | `ours`: no replay stream makes a cube array texture or view; built when one does | 1: `crates/metal2vulkan-rt/src/texture.rs (checked)` | `-` | -| `TextureFormat` | A texture of a pixel format the runtime makes no image of on this device for the descriptor's usage | every device (a public call's own check of its arguments) | `ours`: the device's format query, or the identity domains' shaders read every texture through its view alone | 1: `crates/metal2vulkan-rt/src/texture.rs (plan)` | `-` | +| `TextureFormat` | A texture of a pixel format the runtime makes no image of on this device for the descriptor's usage | every device (a public call's own check of its arguments) | `ours`: the device's format query, or the identity domains' shaders read every texture through its view alone | 3: `crates/metal2vulkan-rt/src/texture.rs (attachment)`, `crates/metal2vulkan-rt/src/texture.rs (form)` (+1) | `-` | | `CubicSampler` | A sampler state whose minification or magnification filter is cubic (`Device::new_sampler_state`) | every device (a public call's own check of its arguments) | `ours`: the translator's identity domains do not filter bicubically, and Vulkan's cubic filter is not Metal's | 1: `crates/metal2vulkan-rt/src/sampler.rs (new_sampler_state)` | `-` | | `LodClamps` | A sampler state bound with LOD clamps its samples read otherwise through (`ComputeCommandEncoder::set_sampler_state_with_lod_clamps` and the... | every device (a public call's own check of its arguments) | `ours`: no replay stream binds such clamps: every bind-time clamp the streams make reads as its state's own | 1: `crates/metal2vulkan-rt/src/sampler.rs (clamps_at_bind)` | `-` | | `TextureBytes` | `Texture::replace_region`, `Texture::get_bytes` or a blit copy between a buffer and a texture (`BlitCommandEncoder::copy_from_buffer`) of a... | every device (a public call's own check of its arguments) | `ours`: no copy between such an image and bytes is built | 3: `crates/metal2vulkan-rt/src/blit.rs (buffer_copy)`, `crates/metal2vulkan-rt/src/texture.rs (check_places)` (+1) | `-` | @@ -1281,7 +1281,7 @@ Each refusal's sites, with the function that builds it. - `rt:Gap::MemorylessTexture`: `crates/metal2vulkan-rt/src/texture.rs (checked)` - `rt:Gap::TextureBuffer`: `crates/metal2vulkan-rt/src/texture.rs (shape, 2 sites)` - `rt:Gap::CubeArrayTexture`: `crates/metal2vulkan-rt/src/texture.rs (checked)` -- `rt:Gap::TextureFormat`: `crates/metal2vulkan-rt/src/texture.rs (plan)` +- `rt:Gap::TextureFormat`: `crates/metal2vulkan-rt/src/texture.rs (attachment)`; `crates/metal2vulkan-rt/src/texture.rs (form)`; `crates/metal2vulkan-rt/src/texture.rs (plan)` - `rt:Gap::CubicSampler`: `crates/metal2vulkan-rt/src/sampler.rs (new_sampler_state)` - `rt:Gap::LodClamps`: `crates/metal2vulkan-rt/src/sampler.rs (clamps_at_bind)` - `rt:Gap::TextureBytes`: `crates/metal2vulkan-rt/src/blit.rs (buffer_copy)`; `crates/metal2vulkan-rt/src/texture.rs (check_places)`; `crates/metal2vulkan-rt/src/texture.rs (copy)`