From 2bd05d00673cd88199db0dcc11df46ae77b72a73 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 27 Nov 2026 05:14:36 -0800 Subject: [PATCH] Runtime docs: a view reports its base's usage, what it may be used with Texture::descriptor's doc comment and the README's swizzle paragraph (Known gaps of textures) state that a view's descriptor reports its base texture's usage, which is what the view may be used with, so a draw into a swizzled view and a kernel's write through it run, where Metal's usage answers only ShaderRead and PixelFormatView of a base of those, ShaderWrite and RenderTarget, for a view made with a swizzle other than the identity and for every view of such a view. Measured on the M3 Max, macOS 27.0.1, job m3-max-76856 (swizzled_view_stores.m): a base of 0x17; a view made without a swizzle and one made with the identity passed answer 0x17; a (Blue, Green, Red, Alpha) view 0x11; views of that view made without a swizzle, with the identity, with (Blue, Green, Red, Alpha) and with (Green, Blue, Red, Alpha) all 0x11; a (Blue, Green, Red, Alpha) view of the plain view 0x11; the same with MTL_DEBUG_LAYER=1. The consumer answers a guest's read of a view's usage from its own descriptor, so the runtime's answer is its own contract; nothing in the runtime changes. Docs only; refusal_surface.py --check and signatures.py --check pass. --- crates/metal2vulkan-runtime/README.md | 7 ++++++- crates/metal2vulkan-runtime/src/texture.rs | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index d8c023a36..f7bc4b6c2 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -2121,7 +2121,12 @@ made, with no lock, and never rewritten for layouts. such a texture, is `Gap::SwizzledReadWrite`, found when the pipeline state or a binding changes: its read would answer the texel unswizzled, where Metal reads it through the swizzle. A texture's own descriptor takes a swizzle only without shader-write and render-target usage - (`Refusal::TextureSwizzleWithWrites`), so this reaches views alone. + (`Refusal::TextureSwizzleWithWrites`), so this reaches views alone. A view's descriptor reports + its base texture's usage, which is what the view may be used with, so a draw into such a view + and a kernel's write through it run, where Metal reports only `ShaderRead` and + `PixelFormatView` of a base of those, `ShaderWrite` and `RenderTarget`, for a view made with a + swizzle other than the identity and for every view of such a view (M3 Max, macOS 27.0.1, + `metal2vulkan-conformance/probes/swizzled_view_stores.m`). - A kernel, a vertex function or a fragment function samples a 2D texture slot through a bicubic constexpr sampler, at normalized or at pixel coordinates, by the arm its slot's pushed word selects, which the runtime writes from the bound texture's format and swizzle diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs index 1788a7cb6..d68064967 100644 --- a/crates/metal2vulkan-runtime/src/texture.rs +++ b/crates/metal2vulkan-runtime/src/texture.rs @@ -4724,7 +4724,10 @@ impl Texture { TextureObject::gpu_resource_id(self) } - /// `textureType`, `pixelFormat`, `width` and the rest, as made. + /// `textureType`, `pixelFormat`, `width` and the rest, as made. A view's `usage` is its base + /// texture's, which is what the view may be used with, where Metal's `usage` answers only + /// `ShaderRead` and `PixelFormatView` of a base of those, `ShaderWrite` and `RenderTarget`, + /// for a view made with a swizzle other than the identity and for every view of such a view. pub fn descriptor(&self) -> &TextureDescriptor { TextureObject::descriptor(self) }