Runtime: rt's own copy into a texture over a buffer's image of its own discards first

A texture over a buffer that the device's linear image does not hold lives in an optimal image of
the runtime's (the copied form, crate::over), refreshed by one vkCmdCopyBufferToImage of the
texture's whole level and slice. Its move to the transfer layout started from the image's home,
which keeps the image's earlier contents: the whole-refill shape that leaves a stale 4 x 2 cell on
a Radeon 780M under RADV (Mesa 26.2.6; 7 of 4,000 R8Unorm 1920 x 1080 refills in plain Vulkan).
The landed form (TextureObject::away_into) covered only the blit encoder's copies.

A copy into the image now moves it from the undefined layout, discarding what it held, as the
copy writes every texel of the image's one level, slice and aspect: texture::over_texel refuses
any texture over a buffer but a 2D one of one level, sample and slice of a colour format of one
texel an element (texture.rs over_texel, the unit's aspect COLOR), so the region always covers the
barrier's one aspect. A copy back keeps the move from home. The runtime README's gap sentence and
over.rs's module doc say so.

Verified: the layouts test an_over_image_is_copied_in_from_undefined_and_back_from_home, red at
the commit before, green here, on lavapipe (jobs in the next report).
This commit is contained in:
Anees Iqbal committed 2026-11-27 01:20:31 -08:00
1 parent 3df886d8f1
commit a473ab8c92
2 files changed
+19 -8

No files matched your search

+3 -1
View File
@@ -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;
+16 -7
View File
@@ -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)