From 69af14bd22a0e08ac98478e2b4c20f4bf6323fbd Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 18 Nov 2026 10:06:09 -0800 Subject: [PATCH] rt: a texture over a buffer keeps in place where its linear tiling lacks only image blits check_over put a texture over a Shared buffer in place only where the format's linear tiling had every feature of its optimal tiling that the usage uses, and counted BLIT_SRC and BLIT_DST among them. The runtime records no image blit: a blit encoder's copies and fills are transfers. Mesa's Apple-GPU driver (KosmicKrisp, Mesa 26.3.1) on an M3 Max offers RGBA8Unorm's linear tiling every feature but BLIT_DST (linear 0x40018000d403, the optimal features the usage keeps 0xdc01, missing 0x800, job m3-max-47342), so tests::over's every_device_holds_a_texture_over_a_buffer_in_place copied at width 1 where the device's own layout fits. The kept features are now the transfers, sampling and its linear filter, a shader's storage access, and rendering. --- crates/metal2vulkan-rt/README.md | 4 ++-- crates/metal2vulkan-rt/src/texture.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index 237aaabbb..52ae48ec3 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -417,8 +417,8 @@ made, with no lock, and never rewritten for layouts. format and usage lays its rows at `bytes_per_row` from the image's start (`vkGetImageSubresourceLayout`), the place meets the image's memory alignment and memory type, and the format's linear tiling has every feature of its optimal tiling that the usage uses - (copies and blits, sampling and linear filtering, a shader's reads, writes and atomics without - a format, rendering and blending). `replace_region` writes the buffer's bytes, and copies the + (copies, which a blit encoder's copies and fills are, sampling and linear filtering, a + shader's reads, writes and atomics without a format, rendering and blending). `replace_region` writes the buffer's bytes, and copies the rows' span into a Managed buffer's device copy as `did_modify_range` does; `get_bytes` reads the buffer's bytes, with no submission; a dispatch's use of the texture is a use of the buffer in the hazard sets, and a write to it reaches the host as a write to a Shared buffer does. The texture diff --git a/crates/metal2vulkan-rt/src/texture.rs b/crates/metal2vulkan-rt/src/texture.rs index de54b7bcf..91723d7a3 100644 --- a/crates/metal2vulkan-rt/src/texture.rs +++ b/crates/metal2vulkan-rt/src/texture.rs @@ -1127,11 +1127,12 @@ fn check_over( } /// The format features an image of `usage` is used by, which a linear image is to keep where the -/// device's optimal image of its format has them: copies and blits; sampling and its linear -/// filter; a shader's reads, writes and atomics without a format; rendering and blending. +/// device's optimal image of its format has them: copies (a blit encoder's copies and fills are +/// transfers; the runtime records no image blit); sampling and its linear filter; a shader's +/// reads, writes and atomics without a format; rendering and blending. fn kept_features(usage: vk::ImageUsageFlags) -> vk::FormatFeatureFlags2 { type F = vk::FormatFeatureFlags2; - let mut kept = F::TRANSFER_SRC | F::TRANSFER_DST | F::BLIT_SRC | F::BLIT_DST; + let mut kept = F::TRANSFER_SRC | F::TRANSFER_DST; if usage.contains(vk::ImageUsageFlags::SAMPLED) { kept |= F::SAMPLED_IMAGE | F::SAMPLED_IMAGE_FILTER_LINEAR; }