diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 259bc5969..b77331ea0 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -3054,7 +3054,9 @@ while the driver's exit handler waited on a lock, with every runtime thread alre of a texture records the same copy, not measured) can leave one aligned 4 x 2 cell of the texture's earlier contents, in about 4 of 1,000 copies whose region covers the texture's last 56 rows; refilling rows 864 to 1079, the cells lay in rows 1026 to 1058. A copy of a whole - level and slice does not, as it discards the earlier contents first. A driver fault: the same + level and slice does not, as it discards the earlier contents first: a blit encoder's, and the + runtime's own copy of a texture over a buffer (`Buffer::new_texture`) into the image of its own + that the texture takes where the device's linear image does not hold it. A driver fault: the same copy in plain Vulkan does it, and the validation layer, with its synchronization checks, reports nothing on the same calls refilling the whole texture. At 1920 x 1088 and 1024 x 1024, refills of the bottom 216 rows left such a cell 10 to 18 rows below the band's top in 4 and 3 of 4,000; diff --git a/crates/metal2vulkan-runtime/src/over.rs b/crates/metal2vulkan-runtime/src/over.rs index c01436de8..b60a55b65 100644 --- a/crates/metal2vulkan-runtime/src/over.rs +++ b/crates/metal2vulkan-runtime/src/over.rs @@ -2,11 +2,13 @@ //! a texture over a buffer in place ([`Buffer::new_texture`](crate::Buffer::new_texture)), its //! texels live in an optimal image of the runtime's, and the device copies the bytes shaders //! reach (a Managed buffer's device copy, where it has one) into it and back, one -//! `vkCmdCopyBufferToImage` or `vkCmdCopyImageToBuffer` region a texture, with no CPU copy. Over a -//! Managed buffer's device copy, only Metal's Managed events copy ([`ManagedOvers`]); over any -//! other buffer, the Shared rules, but for a buffer in an exported block, whose leading copy waits -//! for an event that changes its bytes, a write through an address among them only once an address -//! of the block went out ([`ExportedOvers`]): +//! `vkCmdCopyBufferToImage` or `vkCmdCopyImageToBuffer` region a texture, with no CPU copy. A copy +//! in writes the image's whole level and slice, so its move starts from the undefined layout and +//! discards what the image held first; a copy back's move starts from the image's home layout, +//! which keeps it. Over a Managed buffer's device copy, only Metal's Managed events copy +//! ([`ManagedOvers`]); over any other buffer, the Shared rules, but for a buffer in an exported +//! block, whose leading copy waits for an event that changes its bytes, a write through an address +//! among them only once an address of the block went out ([`ExportedOvers`]): //! //! - **In, once a submission.** The upload that leads a submission copies the bytes into the //! image of every such texture a segment of the submission uses before any command of the @@ -425,7 +427,10 @@ pub(crate) unsafe fn record( } /// Records `copies` into `command`: each buffer's bytes into its image (`into`), or back, between -/// one pair of barriers, counted in `cause`, one of the barrier causes. +/// one pair of barriers, counted in `cause`, one of the barrier causes. A copy into an image moves +/// it from the undefined layout, discarding what it held: its one region writes the image's whole +/// level and slice, of its only aspect, the colour one (`texture::over_texel` refuses any other +/// texture over a buffer). A copy back moves it from home, which keeps its texels. /// /// # Safety /// @@ -462,9 +467,13 @@ pub(crate) unsafe fn record_side( layer_count: 1, }) }; + let from = |copy: &OverCopy| match into { + true => vk::ImageLayout::UNDEFINED, + false => copy.home, + }; let away: Vec<_> = (copies.iter()) .map(|copy| { - image(copy, copy.home, layout) + image(copy, from(copy), layout) .src_stage_mask(S::ALL_COMMANDS) .src_access_mask(A::MEMORY_WRITE) .dst_stage_mask(S::COPY)