diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 7f4e4e975..539dac7ee 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -1055,15 +1055,20 @@ created with external memory handle types listed in the external image implied l accessed outside of Vulkan, they must be in the layout specified in the table, and can be assumed to be in that layout when they are accessed in Vulkan after external access", and the table's row for `VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT` is `VK_IMAGE_LAYOUT_GENERAL`. Each -submission whose command buffers or uploads use a plane acquires it from -`VK_QUEUE_FAMILY_EXTERNAL` in a command buffer of rt's own ahead of everything, and releases it -to that family in another after everything, both in the general layout: one barrier each, counted -in `Metrics::external_acquires` and `Metrics::external_releases`. The acquire follows a global -barrier from and to every stage, so an earlier submission's release on rt's one queue happens -before it (Vulkan 1.4, section 7.7.6). The submission counts in +`vkQueueSubmit2` whose command buffers or uploads use a plane acquires it from +`VK_QUEUE_FAMILY_EXTERNAL` in a command buffer of rt's own ahead of everything in it, and releases +it to that family in another after everything in it, both in the general layout: one barrier +each, counted in `Metrics::external_acquires` and `Metrics::external_releases`. The acquire +follows a global barrier from and to every stage, so an earlier submission's release on rt's one +queue happens before it (Vulkan 1.4, section 7.7.6). The call counts in `Metrics::d3d11_plane_submissions` and the two command buffers in -`Metrics::runtime_command_buffers`. The release takes the submission's last signals, so it adds -no `VkSubmitInfo2`, and no submission or semaphore wait is added. Direct3D 11 thus owns the +`Metrics::runtime_command_buffers`. The release takes the call's last signals, its progress value +among them, so it adds no `VkSubmitInfo2`, no submission or semaphore wait is added, and a command +buffer that uses a plane is seen complete only once the plane's release has run. A group of +command buffers rt sends member by member, one `vkQueueSubmit2` a member, each signalling its own +progress value, hands each member's planes over in that member's call, so a member ahead of the +last is seen complete after its own planes' release and not before it; each such call counts in +`Metrics::d3d11_plane_parts` too. Direct3D 11 thus owns the planes' memory between rt's submissions, and `Surface::external_writes_done()` and `BlitCommandEncoder::release_surface_to_external(&surface)` record nothing for such a surface. So the consumer's precondition is that Direct3D 11's work that accesses a plane has completed before diff --git a/crates/metal2vulkan-runtime/src/blit.rs b/crates/metal2vulkan-runtime/src/blit.rs index d278c1140..3891aeacf 100644 --- a/crates/metal2vulkan-runtime/src/blit.rs +++ b/crates/metal2vulkan-runtime/src/blit.rs @@ -1256,8 +1256,8 @@ impl BlitCommandEncoder { /// the consumer's next write into the surface through the runtime or the next /// [`Surface::external_writes_done`](crate::Surface::external_writes_done), the consumer /// encodes no read of its planes. For a Direct3D 11 import (`Device::import_d3d11_surface`, - /// on Windows) the call records nothing: each submission that uses its planes releases them - /// itself + /// on Windows) the call records nothing: each `vkQueueSubmit2` that uses its planes releases + /// them itself, after its last command and before its signals /// ([`Metrics::d3d11_plane_submissions`](crate::Metrics::d3d11_plane_submissions)). /// /// Err: [`Refusal::OtherDevice`] for another device's surface; [`Error::Vulkan`] where the @@ -1270,7 +1270,7 @@ impl BlitCommandEncoder { if !surface.is_of(core) { return Err(Error::Refused(Refusal::OtherDevice)); } - // Each submission that uses a Direct3D 11 import's planes releases them itself. + // Each `vkQueueSubmit2` that uses a Direct3D 11 import's planes releases them itself. if surface.handle().is_none() { return Ok(()); } diff --git a/crates/metal2vulkan-runtime/src/command.rs b/crates/metal2vulkan-runtime/src/command.rs index e12c5cbd8..e3f501cf9 100644 --- a/crates/metal2vulkan-runtime/src/command.rs +++ b/crates/metal2vulkan-runtime/src/command.rs @@ -395,8 +395,9 @@ pub(crate) struct Segment { /// before it (`crate::over::ManagedOvers`). pub(crate) managed_reached: Vec>, /// The images of the Direct3D 11 planes its commands use (`Device::import_d3d11_surface`, on - /// Windows): its submission acquires them from `VK_QUEUE_FAMILY_EXTERNAL` at its start and - /// releases them to it at its end (`crate::submit`). + /// Windows): the `vkQueueSubmit2` that carries it acquires them from + /// `VK_QUEUE_FAMILY_EXTERNAL` at its start and releases them to it at its end, before its + /// signals (`crate::submit::parts`). pub(crate) planes: Vec>, /// The checks at its head and its writes of heap placements with links (`crate::alias`), /// where it has any: staged, a command buffer of moves leads it where the checks find one @@ -1627,7 +1628,7 @@ impl Building { /// Keeps `texture` until the command buffer retires, as Metal's command buffer retains every /// object its encoders bind: each object once, a view apart from its parent. A Direct3D 11 - /// plane's image is kept by the current segment too, whose submission hands it over + /// plane's image is kept by the current segment too, whose `vkQueueSubmit2` hands it over /// ([`Segment::planes`]). pub(crate) fn keep_texture(&mut self, texture: &Texture) { if self.gpu.kept.textures.hold(texture) { diff --git a/crates/metal2vulkan-runtime/src/counters.rs b/crates/metal2vulkan-runtime/src/counters.rs index 2a7672450..dd5e78247 100644 --- a/crates/metal2vulkan-runtime/src/counters.rs +++ b/crates/metal2vulkan-runtime/src/counters.rs @@ -323,6 +323,8 @@ pub(crate) enum Metric { ExternalReleases, /// [`Metrics::d3d11_plane_submissions`]. D3d11PlaneSubmissions, + /// [`Metrics::d3d11_plane_parts`]. + D3d11PlaneParts, /// [`Metrics::surfaces_in_place`]. SurfacesInPlace, /// [`Metrics::surfaces_copied`]. @@ -420,6 +422,7 @@ const METRIC_ORDER: [Metric; METRICS] = [ Metric::ExternalAcquires, Metric::ExternalReleases, Metric::D3d11PlaneSubmissions, + Metric::D3d11PlaneParts, Metric::SurfacesInPlace, Metric::SurfacesCopied, Metric::ExportedBlocksAddressed, @@ -868,6 +871,7 @@ struct Atomics { external_acquires: AtomicU64, external_releases: AtomicU64, d3d11_plane_submissions: AtomicU64, + d3d11_plane_parts: AtomicU64, surfaces_in_place: AtomicU64, surfaces_copied: AtomicU64, exported_blocks_addressed: AtomicU64, @@ -1075,6 +1079,7 @@ impl Counters { Metric::ExternalAcquires => &a.external_acquires, Metric::ExternalReleases => &a.external_releases, Metric::D3d11PlaneSubmissions => &a.d3d11_plane_submissions, + Metric::D3d11PlaneParts => &a.d3d11_plane_parts, Metric::SurfacesInPlace => &a.surfaces_in_place, Metric::SurfacesCopied => &a.surfaces_copied, Metric::ExportedBlocksAddressed => &a.exported_blocks_addressed, @@ -2133,6 +2138,7 @@ impl Counters { external_acquires: a.external_acquires.load(Relaxed), external_releases: a.external_releases.load(Relaxed), d3d11_plane_submissions: a.d3d11_plane_submissions.load(Relaxed), + d3d11_plane_parts: a.d3d11_plane_parts.load(Relaxed), surfaces_in_place: a.surfaces_in_place.load(Relaxed), surfaces_copied: a.surfaces_copied.load(Relaxed), exported_blocks_addressed: a.exported_blocks_addressed.load(Relaxed), @@ -3197,7 +3203,7 @@ pub struct Metrics { /// Also one for each texture in place over a buffer in a dma-buf's import /// (`Device::import_dma_buf`, on Unix), whose move home acquires its image and the buffer's /// range under it from the foreign queue family, in the barrier of the upload's moves home. - /// Also one for each submission that uses a Direct3D 11 plane + /// Also one for each `vkQueueSubmit2` that uses a Direct3D 11 plane /// ([`d3d11_plane_submissions`](Self::d3d11_plane_submissions)), in a command buffer of its /// own. pub external_acquires: u64, @@ -3205,17 +3211,20 @@ pub struct Metrics { /// ([`BlitCommandEncoder::release_to_external`](crate::BlitCommandEncoder::release_to_external), /// [`BlitCommandEncoder::release_surface_to_external`](crate::BlitCommandEncoder::release_surface_to_external)): /// one barrier each, in the command buffer's work, also counted in - /// [`barriers`](Self::barriers). Also one for each submission that uses a Direct3D 11 plane - /// ([`d3d11_plane_submissions`](Self::d3d11_plane_submissions)), in a command buffer of its - /// own. + /// [`barriers`](Self::barriers). Also one for each `vkQueueSubmit2` that uses a Direct3D 11 + /// plane ([`d3d11_plane_submissions`](Self::d3d11_plane_submissions)), in a command buffer of + /// its own. pub external_releases: u64, - /// Submissions whose command buffers keep a plane of a Direct3D 11 surface + /// `vkQueueSubmit2` calls whose command buffers keep a plane of a Direct3D 11 surface /// (`Device::import_d3d11_surface`, on Windows), or whose uploads copy into or out of one: /// each acquires those planes from `VK_QUEUE_FAMILY_EXTERNAL` in a command buffer of the - /// runtime's own ahead of everything and releases them to it in another after everything, - /// which takes the submission's last signals, both in the general layout, so Direct3D 11 - /// owns the planes' memory between the runtime's submissions. A group that goes member by - /// member counts once, its first `vkQueueSubmit2` acquiring and its last releasing. Each + /// runtime's own ahead of everything in it and releases them to it in another after + /// everything, which takes its last signals, its progress value among them, both in the + /// general layout, so Direct3D 11 owns the planes' memory between them and a command buffer + /// is seen complete only after the release of the planes it used. A group sent as one + /// submission counts once; a group that goes member by member, one `vkQueueSubmit2` a member, + /// counts once for each of its calls that uses a plane, each handing over its own planes + /// ([`d3d11_plane_parts`](Self::d3d11_plane_parts)), the uploads' going with its first. Each /// acquire and release is one barrier, also counted in /// [`external_acquires`](Self::external_acquires), /// [`external_releases`](Self::external_releases) and [`barriers`](Self::barriers); the @@ -3224,6 +3233,11 @@ pub struct Metrics { /// [`runtime_command_buffers`](Self::runtime_command_buffers). No Metal counterpart: an /// IOSurface needs no hand-over between APIs. pub d3d11_plane_submissions: u64, + /// Of those [`d3d11_plane_submissions`](Self::d3d11_plane_submissions), the ones that are a + /// part of a group sent member by member: each such `vkQueueSubmit2` whose command buffers + /// or uploads use a Direct3D 11 plane acquires and releases that part's planes itself. 0 where + /// no group with a plane went member by member. No Metal counterpart, as above. + pub d3d11_plane_parts: u64, /// Surfaces made in place /// ([`Device::new_exported_surface`](crate::Device::new_exported_surface), /// [`SurfaceForm::InPlace`](crate::SurfaceForm::InPlace)). diff --git a/crates/metal2vulkan-runtime/src/d3d11.rs b/crates/metal2vulkan-runtime/src/d3d11.rs index f44342101..70813de16 100644 --- a/crates/metal2vulkan-runtime/src/d3d11.rs +++ b/crates/metal2vulkan-runtime/src/d3d11.rs @@ -4,8 +4,9 @@ //! //! The import makes no submission and waits for nothing: Vulkan takes such an image as already //! in the general layout once Direct3D 11 has accessed it (section 12.5.2, below), so no move out -//! of the undefined layout comes before its first use. Each submission that uses a plane takes it -//! from `VK_QUEUE_FAMILY_EXTERNAL` at its start and gives it back at its end (`crate::submit`). +//! of the undefined layout comes before its first use. Each `vkQueueSubmit2` that uses a plane +//! takes it from `VK_QUEUE_FAMILY_EXTERNAL` at its start and gives it back at its end, before its +//! signals (`crate::submit::parts`). use crate::counters::Gauge; use crate::device::{Core, Device}; @@ -114,14 +115,18 @@ impl Device { /// when they are accessed in Vulkan after external access", and its Table 17 gives /// `VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT` the layout `VK_IMAGE_LAYOUT_GENERAL`. /// - /// **Ownership.** Each submission whose command buffers or uploads use a plane acquires it - /// from `VK_QUEUE_FAMILY_EXTERNAL` in a command buffer of rt's own ahead of everything, from - /// and to the general layout (`VUID-VkImageMemoryBarrier-srcQueueFamilyIndex-12332`), and - /// releases it to that family in another after everything, in the general layout - /// (`...-dstQueueFamilyIndex-12331`), which takes the submission's last signals, so it adds - /// no submit info: Direct3D 11 owns the planes' memory between rt's submissions, each counted - /// in [`Metrics::d3d11_plane_submissions`](crate::Metrics::d3d11_plane_submissions). The - /// acquire follows a global barrier from and to every stage, so an earlier submission's + /// **Ownership.** Each `vkQueueSubmit2` whose command buffers or uploads use a plane acquires + /// it from `VK_QUEUE_FAMILY_EXTERNAL` in a command buffer of rt's own ahead of everything in + /// it, from and to the general layout (`VUID-VkImageMemoryBarrier-srcQueueFamilyIndex-12332`), + /// and releases it to that family in another after everything in it, in the general layout + /// (`...-dstQueueFamilyIndex-12331`), which takes that call's last signals, its progress value + /// among them, so it adds no submit info and a command buffer that uses a plane is seen + /// complete only once the plane's release has run: Direct3D 11 owns the planes' memory + /// between rt's submissions, each counted in + /// [`Metrics::d3d11_plane_submissions`](crate::Metrics::d3d11_plane_submissions). A group of + /// command buffers rt sends member by member, one `vkQueueSubmit2` a member, hands each + /// member's planes over in that member's call + /// ([`Metrics::d3d11_plane_parts`](crate::Metrics::d3d11_plane_parts)). The acquire follows a global barrier from and to every stage, so an earlier submission's /// release on rt's one queue happens before it (Vulkan 1.4, section 7.7.6). /// [`Surface::external_writes_done`] and /// [`release_surface_to_external`](crate::BlitCommandEncoder::release_surface_to_external) diff --git a/crates/metal2vulkan-runtime/src/submit.rs b/crates/metal2vulkan-runtime/src/submit.rs index 6f32a544e..94dd28271 100644 --- a/crates/metal2vulkan-runtime/src/submit.rs +++ b/crates/metal2vulkan-runtime/src/submit.rs @@ -552,8 +552,10 @@ struct Batch { /// The Managed buffers with textures over their device copies its segments reach, to which /// its upload takes the copies back owed by writes submitted before (`crate::over`). reached: Vec>, - /// The images of the Direct3D 11 planes its segments use (`Segment::planes`). - planes: Vec>, + /// The images of the Direct3D 11 planes its segments use (`Segment::planes`), by the part + /// each segment is in where it goes member by member: the leads before it, 0 for the part + /// ahead of the first lead's ([`parts`]). Empty where none uses one. + planes: Vec>>, /// What it flushes before it is submitted, where the Shared type is not host-coherent and /// a command buffer with a segment in it or a copy-in it carries reaches Shared memory /// (`crate::coherence`); `None` where none does. @@ -1963,8 +1965,14 @@ impl WorkState { group.overs.push(copy); } } - for image in &segment.planes { - image.keep_plane(&mut group.planes); + if !segment.planes.is_empty() { + let part = group.starts.len(); + if group.planes.len() <= part { + group.planes.resize_with(part + 1, Vec::new); + } + for image in &segment.planes { + image.keep_plane(&mut group.planes[part]); + } } // The moves its checks find owed lead it, in its submit info (`crate::alias`). if let Some(part) = &segment.aliased { @@ -2558,10 +2566,11 @@ pub(crate) fn put_ahead( /// /// `planes[p]` holds the Direct3D 11 planes part `p` uses, and `hand` the command buffer that /// acquires (`true`) or releases (`false`) such planes ([`Upload::hand_over`]), None where its -/// make failed: the planes of every part are acquired ahead of everything and released after -/// everything, the release taking the last part's last signals, so it adds no submit info -/// ([`infos`]). -pub(crate) fn parts( +/// make failed: each part that uses planes acquires them at its head, ahead of its uploads +/// where it has them, and releases them at its end, the release taking that part's last +/// signals, its progress value among them, so it adds no submit info ([`infos`]) and the part's +/// command buffers are seen complete only after it. A part that uses none takes neither. +pub(crate) fn parts

( mut segments: Vec, ahead: usize, leads: &[usize], @@ -2573,16 +2582,6 @@ pub(crate) fn parts( command: Some(vk::CommandBufferSubmitInfo::default().command_buffer(command)), ..Staged::default() }; - let all: Vec

= planes.iter().flatten().cloned().collect(); - let (head, tail) = match all.is_empty() { - true => (None, None), - false => (hand(&all, true), hand(&all, false)), - }; - let mut ahead = ahead; - if let Some(head) = head { - segments.insert(0, staged(head)); - ahead += 1; - } // Each part's progress value: the part ahead of the first lead's `value` less the leads, // each lead's one above the one before. let count = leads.len(); @@ -2593,29 +2592,33 @@ pub(crate) fn parts( } parts.push((value - count as u64, segments)); parts.reverse(); - for (_, part) in &mut parts { + for ((_, part), used) in parts.iter_mut().zip(planes) { + part.retain(|staged| staged.command.is_some() || !staged.signals.is_empty()); + if used.is_empty() { + continue; + } + let (head, tail) = (hand(used, true), hand(used, false)); + if let Some(head) = head { + part.insert(0, staged(head)); + } + // The release goes after every segment of the part and takes its last signals. + if let Some(tail) = tail { + let last = part.pop().unwrap_or_default(); + let release = Staged { + signals: last.signals, + ..staged(tail) + }; + let last = Staged { + signals: Vec::new(), + ..last + }; + part.extend([last, release]); + } + } + for (_, part) in parts.iter_mut().skip(planes.len()) { part.retain(|staged| staged.command.is_some() || !staged.signals.is_empty()); } parts.retain(|(_, part)| !part.is_empty()); - // The release goes after every segment and takes its last signals, so it adds no submit info - // (`infos`). - if let Some(tail) = tail { - let last = (parts.last_mut()) - .and_then(|(_, part)| part.pop()) - .unwrap_or_default(); - let release = Staged { - signals: last.signals, - ..staged(tail) - }; - let last = Staged { - signals: Vec::new(), - ..last - }; - match parts.last_mut() { - Some((_, part)) => part.extend([last, release]), - None => parts.push((value, vec![last, release])), - } - } match parts.last_mut() { Some((last, _)) => *last = value, None => parts.push((value, vec![Staged::default()])), @@ -2749,14 +2752,25 @@ fn submit(core: &Core, value: u64, uploads: Vec, batch: Batch) { let ended = unsafe { device.end_command_buffer(last.command) }; ok = ok.and(ended.map_err(DeviceLoss::of("vkEndCommandBuffer"))); } - // Each Direct3D 11 plane its command buffers or uploads use is the runtime's from the - // submission's start to its end: acquired from `VK_QUEUE_FAMILY_EXTERNAL` in a command buffer - // of its own ahead of everything, and released to it in another after everything, which holds - // the images (`Metrics::d3d11_plane_submissions`). + // Each Direct3D 11 plane a part's command buffers or uploads use is the runtime's from that + // part's start to its end: acquired from `VK_QUEUE_FAMILY_EXTERNAL` in a command buffer of its + // own ahead of everything in the part, and released to it in another after everything, which + // holds the images (`Metrics::d3d11_plane_submissions`). The uploads' planes go with the first + // part, and where the group goes as one part, every segment's go with it. + if !apart && planes.len() > 1 { + let mut one = Vec::new(); + for image in planes.iter().flatten() { + image.keep_plane(&mut one); + } + planes = vec![one]; + } for upload in &uploads { for held in &upload.held { if let Held::Texture(image) = held { - image.keep_plane(&mut planes); + if planes.is_empty() { + planes.push(Vec::new()); + } + image.keep_plane(&mut planes[0]); } } } @@ -2772,7 +2786,6 @@ fn submit(core: &Core, value: u64, uploads: Vec, batch: Batch) { false => &[][..], }; let mut handed = Vec::new(); - let planes = [planes]; let mut parts = self::parts( segments, uploads.len(), @@ -2785,9 +2798,13 @@ fn submit(core: &Core, value: u64, uploads: Vec, batch: Batch) { ok = Err(loss); } let mut upload = upload?; - match acquire { - true => core.counters.count(Metric::D3d11PlaneSubmissions), - false => (upload.held).extend(planes.iter().cloned().map(Held::Texture)), + match (acquire, apart) { + (true, false) => core.counters.count(Metric::D3d11PlaneSubmissions), + (true, true) => { + core.counters.count(Metric::D3d11PlaneSubmissions); + core.counters.count(Metric::D3d11PlaneParts); + } + (false, _) => (upload.held).extend(planes.iter().cloned().map(Held::Texture)), } let command = upload.command; handed.push(upload); diff --git a/crates/metal2vulkan-runtime/src/surface.rs b/crates/metal2vulkan-runtime/src/surface.rs index 0f9dfb70f..498076b09 100644 --- a/crates/metal2vulkan-runtime/src/surface.rs +++ b/crates/metal2vulkan-runtime/src/surface.rs @@ -1649,8 +1649,8 @@ impl Surface { /// [`Metrics::external_acquires`](crate::Metrics::external_acquires). In the copy form it is /// the block's acquire, and the submissions copy the bytes into the planes' images. The /// contract is the block's. For a Direct3D 11 import (`Device::import_d3d11_surface`, on - /// Windows) the call records nothing: each submission that uses its planes acquires them - /// itself ([`Metrics::d3d11_plane_submissions`](crate::Metrics::d3d11_plane_submissions)). + /// Windows) the call records nothing: each `vkQueueSubmit2` that uses its planes acquires + /// them itself ([`Metrics::d3d11_plane_submissions`](crate::Metrics::d3d11_plane_submissions)). /// /// Err: [`Refusal::InScheduledHandler`] in a scheduled handler; [`Error::Quiesced`]; and /// [`Error::Vulkan`] where the upload's command buffer cannot be made. @@ -1658,7 +1658,7 @@ impl Surface { if let Kind::Copy(block, _) = &self.kind { return block.external_writes_done(); } - // Each submission that uses a Direct3D 11 import's planes acquires them itself. + // Each `vkQueueSubmit2` that uses a Direct3D 11 import's planes acquires them itself. if self.handle.is_none() { return Ok(()); } diff --git a/crates/metal2vulkan-runtime/src/tests/d3d11.rs b/crates/metal2vulkan-runtime/src/tests/d3d11.rs index a37573104..9c6ddbcb8 100644 --- a/crates/metal2vulkan-runtime/src/tests/d3d11.rs +++ b/crates/metal2vulkan-runtime/src/tests/d3d11.rs @@ -559,8 +559,10 @@ mod on_device { /// one `vkQueueSubmit2` a member and none more: A and B each acquire the planes at their /// part's head and release them at its end, two of each; A and F acquire and release /// once, in A's part, so A, seen complete at its own part's value, is seen complete after - /// the planes' release. Every read is picture 1's exactly. The order within each part is - /// the part builder's (`plane_parts`). + /// the planes' release. Each such call of a group sent apart counts in + /// `Metrics::d3d11_plane_parts`, two and one, and the group sent as one part counts none + /// there. Every read is picture 1's exactly. The order within each part is the part + /// builder's (`plane_parts`). #[test] fn every_device_hands_direct3d_11_planes_over_in_each_part_of_a_group_sent_apart() { each_device("import_d3d11_surface_apart", |name, _, device| { @@ -577,13 +579,14 @@ mod on_device { let ahead = IN_FLIGHT as u64; let counters = device.counters(); // Each case: its name, whether the second member reads the planes, whether the - // group goes member by member, and the hand-overs and submissions it makes. + // group goes member by member, and the hand-overs, submissions and hand-overs of + // parts sent apart it makes. let cases = [ - ("A and B as one part", true, false, 1, 1), - ("A and B apart", true, true, 2, 2), - ("A and F apart", false, true, 1, 2), + ("A and B as one part", true, false, 1, 1, 0), + ("A and B apart", true, true, 2, 2, 2), + ("A and F apart", false, true, 1, 2, 1), ]; - for (case, reads, apart, hands, parts) in cases { + for (case, reads, apart, hands, parts, part_hands) in cases { let outs = [picture_buffer(&device), picture_buffer(&device)]; let from = picture_buffer(&device); let queue = device.new_command_queue(64).expect("a queue"); @@ -629,9 +632,11 @@ mod on_device { metrics.external_releases - before.external_releases, ]; let group = sent() - ahead; + let part_handed = metrics.d3d11_plane_parts - before.d3d11_plane_parts; println!( "d3d11-apart: {name}: {case}: the group's vkQueueSubmit2 calls {group}; \ - plane-keeping submissions, acquires, releases {handed:?}" + plane-keeping submissions, acquires, releases {handed:?}; \ + d3d11_plane_parts {part_handed}" ); assert_eq!( compare(&one, &got[0]).0, @@ -657,6 +662,10 @@ mod on_device { group, parts, "{name}: {case}: one vkQueueSubmit2 a part, and no more" ); + assert_eq!( + part_handed, part_hands, + "{name}: {case}: the parts of a group sent apart that hand planes over" + ); }); } }); diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs index c2c92f2a5..de3a19b56 100644 --- a/crates/metal2vulkan-runtime/src/texture.rs +++ b/crates/metal2vulkan-runtime/src/texture.rs @@ -739,8 +739,8 @@ impl Zeroing { impl Image { /// Adds the image to `planes` where it is a Direct3D 11 texture's plane - /// (`Device::import_d3d11_surface`, on Windows) not yet there: each submission that reaches - /// such an image hands it over at its start and its end ([`handed`](Self::handed)). + /// (`Device::import_d3d11_surface`, on Windows) not yet there: each `vkQueueSubmit2` that + /// reaches such an image hands it over at its start and its end ([`handed`](Self::handed)). pub(crate) fn keep_plane(self: &Arc, planes: &mut Vec>) { let plane = matches!(self._under, Some(Under::Surface { d3d11: true, .. })); if plane && !planes.iter().any(|kept| Arc::ptr_eq(kept, self)) { diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 66bded54e..0a7440fef 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -1422,6 +1422,7 @@ field metal2vulkan-runtime::Metrics.consumer_allocation_max_nanos pub consumer_a field metal2vulkan-runtime::Metrics.consumer_allocation_nanos pub consumer_allocation_nanos: u64 field metal2vulkan-runtime::Metrics.consumer_allocations pub consumer_allocations: u64 field metal2vulkan-runtime::Metrics.creations_before_seed pub creations_before_seed: u64 +field metal2vulkan-runtime::Metrics.d3d11_plane_parts pub d3d11_plane_parts: u64 field metal2vulkan-runtime::Metrics.d3d11_plane_submissions pub d3d11_plane_submissions: u64 field metal2vulkan-runtime::Metrics.dispatch_after_write_barriers pub dispatch_after_write_barriers: u64 field metal2vulkan-runtime::Metrics.dispatch_arena_piece_barriers pub dispatch_arena_piece_barriers: u64