diff --git a/crates/metal2vulkan-runtime/src/argument_table.rs b/crates/metal2vulkan-runtime/src/argument_table.rs index 9ff1c5535..51926b887 100644 --- a/crates/metal2vulkan-runtime/src/argument_table.rs +++ b/crates/metal2vulkan-runtime/src/argument_table.rs @@ -232,6 +232,23 @@ fn bound_texture(texture: &Texture) -> BoundTexture { } } +/// Whether `a` and `b` print alike (`{:?}`), told without printing them +/// ([`ArgumentTable::check_reading`]): every field as `==` compares it, but the descriptor's LOD +/// clamps, which print a float's sign (`0.0` and `-0.0` differ, where `==` takes them for equal) +/// and print every NaN alike (where `==` takes no NaN for equal). `tests/argument_table.rs` fails +/// when `BoundSampler` or `SamplerDescriptor` gains a field, so a new one is compared here too. +#[cfg(debug_assertions)] +pub(super) fn same_as_printed(a: &BoundSampler, b: &BoundSampler) -> bool { + let alike = |x: f32, y: f32| x.to_bits() == y.to_bits() || (x.is_nan() && y.is_nan()); + let clamps = alike(a.desc.lod_min_clamp, b.desc.lod_min_clamp) + && alike(a.desc.lod_max_clamp, b.desc.lod_max_clamp); + let [mut a, mut b] = [*a, *b]; + for desc in [&mut a.desc, &mut b.desc] { + [desc.lod_min_clamp, desc.lod_max_clamp] = [0.0; 2]; + } + clamps && a == b +} + impl ArgumentTable { /// A compute encoder's table (the module docs). pub(super) fn compute() -> ArgumentTable { @@ -783,25 +800,104 @@ impl ArgumentTable { BoundSampler::shape, ); } - // The table read whole, as before (debug builds): the same bindings, a float's sign and - // a NaN's included (compared as printed). #[cfg(debug_assertions)] - { - let mut whole = self.stage_table_reading(stage, interface); - for (&index, bound) in &mut whole.samplers { + self.check_reading(kept, read, maps); + } + + /// That `kept`, brought in place by [`refresh_reading`](Self::refresh_reading), is the table + /// `stage`'s function of `interface` reads whole + /// ([`stage_table_reading`](Self::stage_table_reading)), each sampler as `maps` binds it + /// (debug builds): the same slots, each bound alike as its value prints (a float's sign told + /// apart, every NaN alike: [`same_as_printed`]), and nothing else in the table. Compared slot + /// by slot, with no table read whole made and nothing printed unless a slot differs, so a + /// draw allocates as many times with debug assertions as without (`runtime_lane::frame_costs` + /// holds its bound in every build). A slot that differs is named in the panic. + #[cfg(debug_assertions)] + fn check_reading( + &self, + kept: &StageTable, + read: (Stage, &PipelineInterface), + maps: &SamplerMaps, + ) { + let (stage, _) = read; + const DIFFERS: &str = "a stage table brought in place that is not the table read whole"; + // A buffer slot as `stage_table_reading` reads it: inline bytes where they are bound, + // else the buffer within its length, and nothing where the function reads it unbound. + let buffer = |index: u32| { + if self.reads_unbound(read, index) { + return None; + } + match self.bytes.get(&index) { + Some(bytes) => Some(bound_bytes(bytes)), + None => self.buffers.get(&index).and_then(|(buffer, offset)| { + let stride = self.attribute_strides.get(&index).copied(); + bound_buffer(buffer, *offset, stride) + }), + } + }; + for (&index, bound) in &kept.buffers { + let whole = buffer(index); + assert!( + whole.as_ref() == Some(bound), + "{DIFFERS}: {stage:?} buffer {index} kept as {bound:?}, read whole as {whole:?}" + ); + } + for &index in self.buffers.keys().chain(self.bytes.keys()) { + if let Some(whole) = buffer(index) { + assert!( + kept.buffers.contains_key(&index), + "{DIFFERS}: {stage:?} buffer {index} not kept, read whole as {whole:?}" + ); + } + } + for (&index, bound) in &kept.textures { + let whole = self.textures.get(&index).map(bound_texture); + assert!( + whole.as_ref() == Some(bound), + "{DIFFERS}: {stage:?} texture {index} kept as {bound:?}, read whole as {whole:?}" + ); + } + for (&index, texture) in &self.textures { + assert!( + kept.textures.contains_key(&index), + "{DIFFERS}: {stage:?} texture {index} not kept, read whole as {:?}", + bound_texture(texture) + ); + } + let sampler = |index: u32| { + self.samplers.get(&index).map(|(sampler, clamps)| { let slot = SlotRef { stage, class: SlotClass::Sampler, index, }; - bound.desc = maps.sampler(slot, bound.desc); - } - debug_assert_eq!( - format!("{kept:?}"), - format!("{whole:?}"), - "a stage table brought in place that is not the table read whole" + let mut whole = BoundSampler::new(bound_sampler(sampler, *clamps)); + whole.desc = maps.sampler(slot, whole.desc); + whole + }) + }; + for (&index, bound) in &kept.samplers { + let whole = sampler(index); + assert!( + whole.is_some_and(|whole| same_as_printed(&whole, bound)), + "{DIFFERS}: {stage:?} sampler {index} kept as {bound:?}, read whole as {whole:?}" ); } + for &index in self.samplers.keys() { + assert!( + kept.samplers.contains_key(&index), + "{DIFFERS}: {stage:?} sampler {index} not kept, read whole as {:?}", + sampler(index) + ); + } + // A table read whole binds nothing else (`stage_table` starts from the empty table). + assert!( + kept.threadgroup_lengths.is_empty() && kept.acceleration_structures.is_empty(), + "{DIFFERS}: {stage:?} keeps threadgroup lengths {:?} and acceleration structures {:?}, \ + where the table read whole has none", + kept.threadgroup_lengths, + kept.acceleration_structures + ); } /// Each object bound, by slot, in the table's order: its buffers, then its textures, then diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index b1276b409..dd74ad17f 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -224,7 +224,8 @@ degradations! { /// 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 + /// for the texture's format, usage or pitch, and which the runtime makes of no depth or + /// stencil format), 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 de4490e54..ce227e927 100644 --- a/crates/metal2vulkan-runtime/src/dma_buf.rs +++ b/crates/metal2vulkan-runtime/src/dma_buf.rs @@ -907,9 +907,17 @@ impl Device { /// 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. + /// samples, or a mutable format with no list of its views; its format has a depth or stencil + /// component; 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. + /// + /// The runtime takes a modifier image's plane layout from the driver + /// (`vkGetImageSubresourceLayout`), and Vulkan has no valid such query of a format with a + /// depth or stencil component: of a DRM format modifier's tiling its aspect must be a memory + /// plane's (`VUID-vkGetImageSubresourceLayout-tiling-09433`), of a format with depth or + /// stencil it must contain that aspect (`-format-04462`, `-format-04463`), and it is one bit + /// (`-aspectMask-00997`). So it makes none of such a format, wherever a driver lists the + /// modifier for it. pub(super) fn modifier_image_checks( &self, plan: &ImagePlan, @@ -923,6 +931,15 @@ impl Device { plan.levels, plan.extent[2], plan.samples ))); } + if (plan.format.block()) + .is_some_and(|block| block.depth.is_some() || block.stencil.is_some()) + { + return Ok(Err(format!( + "{:?} has a depth or stencil component, and Vulkan has no query of where a \ + DRM_FORMAT_MOD_LINEAR plane of such a format lies", + plan.format + ))); + } // A DRM format modifier's mutable image lists its views' formats // (`VUID-VkImageCreateInfo-tiling-02353`): a plan whose views take any compatible format // lists each the runtime views a texture as (`linear_plan::viewed_formats`), its own diff --git a/crates/metal2vulkan-runtime/src/tests/argument_table.rs b/crates/metal2vulkan-runtime/src/tests/argument_table.rs new file mode 100644 index 000000000..e22300a78 --- /dev/null +++ b/crates/metal2vulkan-runtime/src/tests/argument_table.rs @@ -0,0 +1,111 @@ +//! The debug builds' check that a stage table brought in place is the table read whole +//! (`ArgumentTable::check_reading`, `argument_table.rs`), which compares a sampler as it prints +//! without printing it (`same_as_printed`). + +use super::super::argument_table::same_as_printed; +use metal2vulkan::bind::{BoundSampler, SamplerDescriptor, StageTable}; + +/// The field names of a value's `{:?}` print, `Name { a: .., b: .. }`, at its top level. +fn field_names(printed: &str) -> Vec { + let inner = &printed[printed.find('{').unwrap() + 1..printed.rfind('}').unwrap()]; + let mut names = Vec::new(); + let (mut depth, mut start) = (0, 0); + for (at, c) in inner.char_indices() { + match c { + '{' | '(' | '[' => depth += 1, + '}' | ')' | ']' => depth -= 1, + ',' if depth == 0 => { + names.push(inner[start..at].trim().to_owned()); + start = at + 1; + } + _ => {} + } + } + names.push(inner[start..].trim().to_owned()); + names + .iter() + .filter(|field| !field.is_empty()) + .map(|field| field.split(':').next().unwrap().trim().to_owned()) + .collect() +} + +/// Two bound samplers compare alike exactly where they print alike: LOD clamps of opposite zero +/// signs differ, NaN clamps of any sign and payload are alike, and every other field differs +/// where its value does. +#[test] +fn samplers_compare_as_they_print() { + let base = BoundSampler::new(SamplerDescriptor::new()); + let clamped = |min: f32, max: f32| { + let mut sampler = base; + sampler.desc.lod_min_clamp = min; + sampler.desc.lod_max_clamp = max; + sampler + }; + let other = |change: fn(&mut BoundSampler)| { + let mut sampler = base; + change(&mut sampler); + sampler + }; + let pairs = [ + (base, base), + (clamped(0.0, 1.0), clamped(-0.0, 1.0)), + (clamped(0.0, 0.0), clamped(0.0, -0.0)), + (clamped(f32::NAN, 1.0), clamped(-f32::NAN, 1.0)), + ( + clamped(0.5, f32::from_bits(0x7fc0_0001)), + clamped(0.5, f32::NAN), + ), + (clamped(f32::NAN, 1.0), clamped(0.0, 1.0)), + (clamped(0.0, f32::MAX), clamped(0.0, f32::INFINITY)), + (base, other(|s| s.desc.max_anisotropy = 4)), + (base, other(|s| s.desc.normalized_coordinates = false)), + (base, other(|s| s.resource_id = Some(7))), + ]; + for (a, b) in pairs { + assert_eq!( + same_as_printed(&a, &b), + format!("{a:?}") == format!("{b:?}"), + "{a:?} against {b:?}" + ); + } +} + +/// The fields the check compares: a field added to a stage table, a bound sampler or a sampler +/// descriptor fails this until `check_reading` and `same_as_printed` compare it as it prints. +#[test] +fn the_check_compares_every_field() { + assert_eq!( + field_names(&format!("{:?}", StageTable::default())), + [ + "buffers", + "textures", + "samplers", + "threadgroup_lengths", + "acceleration_structures" + ] + ); + let sampler = BoundSampler::new(SamplerDescriptor::new()); + assert_eq!( + field_names(&format!("{sampler:?}")), + ["desc", "resource_id"] + ); + assert_eq!( + field_names(&format!("{:?}", sampler.desc)), + [ + "min_filter", + "mag_filter", + "mip_filter", + "s_address_mode", + "t_address_mode", + "r_address_mode", + "border_color", + "normalized_coordinates", + "lod_min_clamp", + "lod_max_clamp", + "lod_average", + "max_anisotropy", + "compare_function", + "reduction_mode" + ] + ); +} diff --git a/crates/metal2vulkan-runtime/src/tests/mod.rs b/crates/metal2vulkan-runtime/src/tests/mod.rs index 4a5f23cd5..f3bc39963 100644 --- a/crates/metal2vulkan-runtime/src/tests/mod.rs +++ b/crates/metal2vulkan-runtime/src/tests/mod.rs @@ -12,6 +12,8 @@ mod amplification; mod apple_only; mod argument_buffers; mod argument_encoder; +#[cfg(debug_assertions)] +mod argument_table; mod attachmentless; mod attributes; mod batches; diff --git a/crates/metal2vulkan-validation/runtime-sources.sha256 b/crates/metal2vulkan-validation/runtime-sources.sha256 index 292a0377f..d5207651d 100644 --- a/crates/metal2vulkan-validation/runtime-sources.sha256 +++ b/crates/metal2vulkan-validation/runtime-sources.sha256 @@ -1 +1 @@ -2f7e93a9335e29d38177e561a877ec40a69994fbe733a2dd0bdff75c96a8ce3e +4a161b14058fa3e4c4b039726845c4bb221965a409dae3153e6232d213f22330 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 0d3f5f8f6..e9a210ff4 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs @@ -1402,6 +1402,68 @@ fn a_planar_surface_s_depth_or_stencil_texture_s_passes_write_metal_s_elements_a ); } +/// No depth or stencil texture over a buffer's bytes asks the driver for a +/// `DRM_FORMAT_MOD_LINEAR` image, at Metal's row pitch over host pages or over dma-buf pages, even +/// where the driver lists the modifier for its format (lavapipe does): the runtime asks the layout +/// of every such image it makes of a memory plane (`VUID-vkGetImageSubresourceLayout-tiling-09433`), +/// and Vulkan has no such query of a format with depth or stencil, whose aspect it must name +/// (`-format-04462`, `-format-04463`). Each texture of a surface's plane is made, at a padded row +/// pitch and a browser's, and the work counts show no such image made or refused. +#[test] +fn no_depth_or_stencil_texture_over_a_buffer_asks_for_a_modifier_image() { + use metal2vulkan_runtime::WorkCounts; + let asked = |counts: &WorkCounts| { + ( + counts.pitched_host_images, + counts.pitched_host_image_refusals, + counts.dma_buf_images, + ) + }; + let messages = Messages::default(); + let cache = ScratchCache::new().unwrap(); + { + let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); + eprintln!("device {}", device.name()); + for kind in [Kind::Ordinary, Kind::NoCopy] { + let Some(held) = Held::new(&device, kind) else { + eprintln!("{}: no {kind:?} buffer", device.name()); + continue; + }; + for pf in [ + PixelFormat::Depth16Unorm, + PixelFormat::Depth32Float, + PixelFormat::Depth32FloatStencil8, + PixelFormat::Stencil8, + PixelFormat::X32Stencil8, + ] { + for usage in [TextureUsage::SHADER_READ, TextureUsage::RENDER_TARGET] { + for bpr in [64, 256] { + let what = format!("{kind:?} {pf:?} {usage:?}, rows {bpr} bytes apart"); + let mut d = TextureDescriptor::texture_2d(pf, 4, 4, false); + d.usage = usage; + d.resource_options = held.buffer.resource_options(); + let before = device.work_counts(); + held.buffer + .new_texture_with_iosurface_plane(&d, IoSurfacePlane::new(0, bpr, true)) + .unwrap_or_else(|e| panic!("{what}: {e}")); + assert_eq!( + asked(&device.work_counts()), + asked(&before), + "{what}: DRM_FORMAT_MOD_LINEAR images asked of the driver (made at \ + Metal's row pitch, refused there, made over dma-bufs)" + ); + } + } + } + } + } + let messages = messages.take(); + assert!( + messages.is_empty(), + "the validation layer reported: {messages:#?}" + ); +} + /// The rows of a `w`x`h` plane `row` bytes wide, from `offset`, `pitch` bytes apart. fn plane_rows(offset: u64, pitch: u64, row: u64, h: u64) -> Vec> { (0..h) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/frame_costs.rs b/crates/metal2vulkan-validation/src/runtime_lane/frame_costs.rs index 1e1684a57..cd328276e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/frame_costs.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/frame_costs.rs @@ -68,7 +68,8 @@ //! Three checks run by default where the allocations are counted: //! `a_frame_s_draws_and_pass_ends_allocate_within_their_bounds` holds a frame's draws to //! [`DRAW_ALLOCATIONS`] on the encoding thread, a draw's state changes and its draw call -//! together, and its passes' ends to [`PASS_END_ALLOCATIONS`], each on average; +//! together ([`DRAW_ALLOCATIONS_DEBUG`] in a build with debug assertions), and its passes' ends +//! to [`PASS_END_ALLOCATIONS`], each on average; //! `a_frame_s_pass_opens_allocate_within_their_bound` its pass opens to [`OPEN_ALLOCATIONS`]; and //! `a_frame_s_commits_allocate_within_their_bound` holds a checked frame's commits to //! [`COMMIT_ALLOCATIONS`] on the encoding thread and to [`SUBMIT_ALLOCATIONS`] on the others @@ -131,6 +132,12 @@ const SHAPE_BYTES: usize = 64; /// and the format table its entries. #[cfg(not(m2v_system_alloc))] const DRAW_ALLOCATIONS: f64 = 27.0; +/// [`DRAW_ALLOCATIONS`] in a build with debug assertions, which CI's tests are: the draw path's +/// allocations and those of `LiveBind::shape`'s checks there, which build the state's whole bind +/// shape at each draw to compare the kept or found one with it. Measured: 35.93 on lavapipe +/// (llvmpipe, LLVM 23.1.1, Mesa 26.2.4), where a build without debug assertions makes 24.62. +#[cfg(not(m2v_system_alloc))] +const DRAW_ALLOCATIONS_DEBUG: f64 = 38.0; /// The most allocations a frame's pass open (`render_command_encoder`) makes on the encoding /// thread on average, once every pipeline is made. Measured: 13.0 on RADV (Radeon 780M), on /// lavapipe and on ANV (Iris Xe); 18.0 on RADV and ANV before the device kept each pass shape's @@ -1251,24 +1258,28 @@ fn allocations_each(frame: &Frame, steps: StepsOf) -> f64 { allocations as f64 / steps.len() as f64 } -/// A frame's draws allocate at most [`DRAW_ALLOCATIONS`] each on average on the encoding thread, -/// once every pipeline is made: what the draw path keeps of what it found before (each texture's -/// storage view formats, the pipeline state's routing into the pass's colors, the settles of its -/// latest bind shapes and the shapes themselves, the format table) is not made again at each -/// draw, and what a draw retains, binds and records it holds and builds without allocating where -/// the object or the list allows. Its passes' ends allocate at most [`PASS_END_ALLOCATIONS`] each: -/// a pass end retains what its commands use as one object, and makes no tile grid where a draw -/// reaches every tile, no sample planes' steps in a pass without planes, and no scrub's list for a -/// texture that is not sparse. +/// A frame's draws allocate at most [`DRAW_ALLOCATIONS`] each on average on the encoding thread +/// ([`DRAW_ALLOCATIONS_DEBUG`] with debug assertions), once every pipeline is made: what the draw +/// path keeps of what it found before (each texture's storage view formats, the pipeline state's +/// routing into the pass's colors, the settles of its latest bind shapes and the shapes +/// themselves, the format table) is not made again at each draw, and what a draw retains, binds +/// and records it holds and builds without allocating where the object or the list allows. Its +/// passes' ends allocate at most [`PASS_END_ALLOCATIONS`] each: a pass end retains what its +/// commands use as one object, and makes no tile grid where a draw reaches every tile, no sample +/// planes' steps in a pass without planes, and no scrub's list for a texture that is not sparse. #[cfg(not(m2v_system_alloc))] #[test] fn a_frame_s_draws_and_pass_ends_allocate_within_their_bounds() { let (device, frame) = counted(); let each = allocations_each(&frame, |f| &f.draws); - eprintln!("FRAME-COST {device}: {each:.2} allocations a draw, at most {DRAW_ALLOCATIONS} kept"); + let bound = match cfg!(debug_assertions) { + true => DRAW_ALLOCATIONS_DEBUG, + false => DRAW_ALLOCATIONS, + }; + eprintln!("FRAME-COST {device}: {each:.2} allocations a draw, at most {bound} kept"); assert!( - each <= DRAW_ALLOCATIONS, - "{each:.2} allocations a draw, more than {DRAW_ALLOCATIONS}" + each <= bound, + "{each:.2} allocations a draw, more than {bound}" ); let each = allocations_each(&frame, |f| &f.end); eprintln!( diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index c63c17514..35410a111 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 = 1186; +pub const RUNTIME_VERSION: u32 = 1195; /// 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/crates/metal2vulkan/src/tests/engine_handles.rs b/crates/metal2vulkan/src/tests/engine_handles.rs index 608a397b7..4b45dce25 100644 --- a/crates/metal2vulkan/src/tests/engine_handles.rs +++ b/crates/metal2vulkan/src/tests/engine_handles.rs @@ -2867,14 +2867,14 @@ fn heap_linear_kernel(through: CompareThrough, three: bool) -> String { true => ( "texture3d", format!( - "@air.sample_texture_3d.v4f32(ptr addrspace(1) %t, ptr addrspace(2) {operand}, <3 x float> , i1 true, <3 x i32> zeroinitializer, i1 true, float 0.0, float 0.0, i32 0)" + "@air.sample_texture_3d.v4f32(ptr addrspace(1) %t, ptr addrspace(2) {operand}, <3 x float> , i1 true, <3 x i32> zeroinitializer, i1 true, float 0.0, float 0.0, i32 0)" ), "declare { <4 x float>, i8 } @air.sample_texture_3d.v4f32(ptr addrspace(1), ptr addrspace(2), <3 x float>, i1, <3 x i32>, i1, float, float, i32)", ), false => ( "texture2d", format!( - "@air.sample_texture_2d.v4f32(ptr addrspace(1) %t, ptr addrspace(2) {operand}, <2 x float> , i1 true, <2 x i32> zeroinitializer, i1 true, float 0.0, float 0.0, i32 0)" + "@air.sample_texture_2d.v4f32(ptr addrspace(1) %t, ptr addrspace(2) {operand}, <2 x float> , i1 true, <2 x i32> zeroinitializer, i1 true, float 0.0, float 0.0, i32 0)" ), "declare { <4 x float>, i8 } @air.sample_texture_2d.v4f32(ptr addrspace(1), ptr addrspace(2), <2 x float>, i1, <2 x i32>, i1, float, float, i32)", ), diff --git a/docs/API.md b/docs/API.md index 13a902c1c..ec987355e 100644 --- a/docs/API.md +++ b/docs/API.md @@ -147,7 +147,9 @@ the device refuses (`HostMemory::with_dma_buf`), `VK_EXT_external_memory_dma_buf `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 +rows out otherwise (ANV packs them tight) and the driver takes that layout, of a format with no depth +or stencil component (Vulkan has no query of where such a format's memory plane lies, so the runtime +makes no `DRM_FORMAT_MOD_LINEAR` image of one) (`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`). @@ -695,7 +697,8 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. buffer's memory (over a no-copy buffer's imported 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; + pitch, which the driver may refuse for the texture's format, usage or pitch, and which the + runtime makes of no depth or stencil format; `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 diff --git a/docs/HOWTO.md b/docs/HOWTO.md index 20763935a..17f33eaf0 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -177,7 +177,9 @@ is refused (`NotImplemented(RebindTextures)`). `WorkCounts::dma_buf_imports`, 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 +otherwise, a `DRM_FORMAT_MOD_LINEAR` image at that pitch, which the driver may refuse (and which +the runtime makes of no depth or stencil format, as it makes no image over a dma-buf of one: Vulkan +has no query of where such a format's memory plane lies). Measured (`runtime_lane::surface_texture_costs::pitch_classes`, nine formats, four usages, rows padded by each power of two from 16 to 4096 bytes): diff --git a/scripts/linux-gate-ci b/scripts/linux-gate-ci index 5e67fc882..54db8cf90 100755 --- a/scripts/linux-gate-ci +++ b/scripts/linux-gate-ci @@ -48,6 +48,25 @@ cpu_icd_tests() { cargo nextest run -p metal2vulkan-validation --all-features --build-jobs "$jobs" } +feature_clippy() { + local features + for features in "" serde ash cli; do + echo "::group::features=${features:-none}" + cargo clippy -p metal2vulkan --all-targets --no-default-features --features "$features" \ + -j "$jobs" -- -D warnings + echo "::endgroup::" + done + echo "::group::metal2vulkan-runtime" + cargo clippy -p metal2vulkan-runtime --all-targets -j "$jobs" -- -D warnings + echo "::endgroup::" + for features in "" serde; do + echo "::group::metal2vulkan-air features=${features:-none}" + cargo clippy -p metal2vulkan-air --all-targets --no-default-features --features "$features" \ + -j "$jobs" -- -D warnings + echo "::endgroup::" + done +} + gpu_cfg_clippy() { # As cpu_icd_tests, a sibling target dir keeps the ordinary build warm. CARGO_TARGET_DIR="${CARGO_TARGET_DIR}-gpucfg" RUSTFLAGS='-Dwarnings --cfg m2v_gpu' \ @@ -63,10 +82,17 @@ step "Install LLVM + SPIR-V tools (probe)" tools_probe step "Format" cargo fmt --all -- --check step "Clippy (warnings denied)" \ cargo clippy --workspace --all-targets --all-features -j "$jobs" -- -D warnings +step "Clippy under each feature alone (warnings denied)" feature_clippy step "Clippy under --cfg m2v_gpu (warnings denied)" gpu_cfg_clippy step "Build public documentation (warnings denied)" \ env RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --all-features --no-deps -j "$jobs" -step "Test metal2vulkan" cargo nextest run -p metal2vulkan --all-features --build-jobs "$jobs" +step "Build the new API's consumer reference (warnings denied)" scripts/api-docs +step "Package the published crates" \ + cargo package --workspace --exclude metal2vulkan-validation --exclude metal2vulkan-devtools \ + -j "$jobs" +step "Test metal2vulkan" \ + cargo nextest run -p metal2vulkan -p metal2vulkan-air -p metal2vulkan-runtime \ + -p metal2vulkan-devtools --all-features --build-jobs "$jobs" step "Test validation suite" \ cargo nextest run -p metal2vulkan-validation --all-features --build-jobs "$jobs" step "Doc tests" cargo test --workspace --all-features --doc -j "$jobs"