Files
metal2vulkan/docs
Anees Iqbal 72152b3d29 rt: pixel-format views over mutable images that list Metal's formats
newTextureViewWithPixelFormat: and its forms of another pixel format were a
gap. glbench makes 1,524 (780M stream) and 2,970 (3090 stream)
BGRA8Unorm_sRGB textures' BGRA8Unorm views; Metal views a texture as its sRGB
sibling with no usage asked (MTLTextureUsage.pixelFormatView: "Don't set this
option if your texture view only converts between linear space and sRGB"), and
with PixelFormatView usage as any colour format of the same bit length
(makeTextureView(pixelFormat:)).

The translator states Metal's rules: metal::format::srgb_sibling (srgb_raw_twin
both ways, ASTC's LDR and sRGB forms, the extended-range pairs),
views_without_usage (itself, the sibling, a combined format's stencil) and
views_with_usage (those, and uncompressed colour formats of the same bytes a
texel by byte_format).

An image lists, its own format first, the formats Metal views its texture as
that the device holds for the usage in a viewed form of the image format's
compatibility class: the sibling always, and with PixelFormatView every such
format. Such an image is MUTABLE_FORMAT with a VkImageFormatListCreateInfo, in
its creation, its format queries (optimal and linear) and its heap size query;
any other image is unchanged. plan() splits into form() (what a texture holds
in its views) and the image's own part, so a view takes form() alone, with no
image query.

A view of another format is built where the image lists it, else
Gap::TextureView{PixelFormat}; a format Metal does not view the texture as is
Refusal::TextureViewFormat, which no longer refuses the sRGB sibling of a texture
without PixelFormatView usage. Its image views take the image's usage that the
view format's features hold (VkImageViewUsageCreateInfo,
VUID-VkImageViewCreateInfo-usage-02274/02275/08931): it has a storage element
only where the image has storage usage, and renders where its format holds an
attachment, else Gap::TextureFormat at the pass.

Tests: the translator's sibling is mutual over every format and its view rules
take and refuse as Apple's pages say; on devices, an sRGB view of a texture
without PixelFormatView usage and an R32Uint view of one with it each read
their parent's bytes, and R16Float and BC1 views are refused.
2026-11-18 18:36:50 -08:00
..