From 0ad55e146860bf96dadf1de596b88e5f3e955dcf Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 15:19:40 -0800 Subject: [PATCH] Docs: the texture buffer word, the formats held as words, their notes; test vectors of the texture buffer word RESOURCE-ID.md gains the texture buffer word (TextureWord::of_texture_buffer: bits 0-1 padding, 2-7 the code, 8-9 texels per word, 10 a texel of two words; the 39 codes in order) and drops its stale line that a texture buffer has no index. The runtime's README says which formats a texture buffer holds as words and which it still refuses; the KosmicKrisp BGRA8Unorm gap is gone. API.md and PrecisionNote's docs say a texture buffer held as words records SrgbTexelDecode and DevicePackConversion for its float reads and writes, and that its other conversions are exact. tests/resource_words.rs writes texture buffer lines (format, width, word); the table is blessed in a later commit. REFUSALS.md regenerated (one more TextureFormat site). --- crates/metal2vulkan-runtime/README.md | 53 +++++++++++--------- crates/metal2vulkan/src/pipeline/artifact.rs | 15 ++++-- crates/metal2vulkan/tests/resource_words.rs | 29 ++++++++++- docs/API.md | 16 ++++-- docs/REFUSALS.md | 4 +- docs/RESOURCE-ID.md | 41 +++++++++++++-- 6 files changed, 120 insertions(+), 38 deletions(-) diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 39bd12c65..7ba30999f 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -1992,11 +1992,18 @@ made, with no lock, and never rewritten for layouts. `…TexelBufferOffsetSingleTexelAlignment` says one texel suffices), at most 256, so it divides the multiple of 256 every buffer starts at. Metal documents the alignment for the row's bytes too; a texture buffer's one row reads no other, so any `bytes_per_row` that covers the row is - taken (`Refusal::BufferTextureLayout` below it, or for texels past the buffer). The format is one - the device holds directly, of one colour texel an element, whose buffer features hold both the - uniform and the storage texel buffer (`Gap::TextureFormat` otherwise): the view is of a buffer - of both usages, so its format takes both. A width past `maxTexelBufferElements` is - `Limit::TextureSize`. Its view is the element of the uniform texel-buffer array at its index + taken (`Refusal::BufferTextureLayout` below it, or for texels past the buffer). The view is of a + buffer of both usages, so its format takes both. A colour format whose Vulkan format Vulkan + requires as a storage texel buffer (and with it a uniform one) is the view's own format. Any + other colour format with a word layout, 39 of them (docs/RESOURCE-ID.md, the texture buffer + word), is held as words on every device: the view is of `R32_UINT` over the same bytes, its last + word ending inside the buffer's block past the last texel, and shaders convert each texel + themselves; a texel of one or two bytes shares its word with its neighbours, and a write of it + is an atomic AND that clears its bits and an atomic OR that sets them, which keep the + neighbours' bits. Any other format is one the device holds directly, of one colour texel an + element, whose buffer features hold both texel buffers (`Gap::TextureFormat` otherwise). A + width whose view's elements pass `maxTexelBufferElements` is `Limit::TextureSize`. Its view is + the element of the uniform texel-buffer array at its index where shaders read it, and of the storage one where they write it (the known gaps say where a write or a read through it without a format is refused). Its texels are the buffer's bytes: the host, a blit or a shader writing the buffer writes them, `replace_region` @@ -2234,28 +2241,23 @@ made, with no lock, and never rewritten for layouts. of `TextureViewKind::TextureBuffer`, and a blit copy of one is `Gap::TextureCopy` between textures and `Gap::TextureBytes` with a buffer: no copy reads a buffer view, and none is built as the buffer copy it would be. -- A texture buffer's format needs both the uniform and the storage texel buffer in its buffer - features: its view is of a buffer of both usages, and without `VK_KHR_maintenance5`, which the - floor does not require, the view takes its buffer's usage. A format that lacks one is - `Gap::TextureFormat` (`BGRA8Unorm` on KosmicKrisp, whose storage texel buffers lack it). The - texture-buffer answer, a heap's size and alignment of one included, follows the format's +- A texture buffer's answer, a heap's size and alignment of one included, follows the format's texel-buffer features, so devices differ by that query, not by form: `BGRA4Unorm` - (`A4R4G4B4_UNORM_PACK16`) is one on the Iris Xe's ANV, whose buffer features hold both, and - `Gap::TextureFormat` on RADV, NVIDIA and lavapipe, whose hold no storage texel buffer of it. + (`A4R4G4B4_UNORM_PACK16`), which has no word layout, is one on the Iris Xe's ANV, whose buffer + features hold both texel buffers, and `Gap::TextureFormat` on RADV, NVIDIA and lavapipe, whose + hold no storage texel buffer of it. - Metal makes a texture buffer of formats the runtime refuses. Plain Metal on an Apple M3 Max under macOS 27.0.1 (jobs m3-max-79872 and m3-max-79879), asked for each of the 300 formats the runtime names, over a buffer and from the device, for reading, writing and both, made one of 99, ended the process for 125 (the compressed formats, the depth and stencil ones, and 36 that device does not - take) and answered nil for 71 (the two-plane ones among them). Of the public formats it makes, the - runtime refuses as `Gap::TextureFormat` `A8Unorm`, which it holds in `R8_UNORM` through a - component mapping, and `BGR10_XR`, `BGR10_XR_sRGB`, `BGRA10_XR` and `BGRA10_XR_sRGB`, which it - converts, on every device; `R8Unorm_sRGB`, `RG8Unorm_sRGB`, `RGBA8Unorm_sRGB`, `BGRA8Unorm_sRGB`, - `RGB9E5Float`, `A1BGR5Unorm` and `ABGR4Unorm` wherever their buffer features lack a texel buffer, - which is on every RADV, ANV, NVIDIA and lavapipe profile committed; `B5G6R5Unorm` and - `BGR5A1Unorm` on those but ANV; and `BGR10A2Unorm` on the NVIDIA and lavapipe ones. These sets are - read from the runtime's rule and the committed device profiles, not from a run on a card. Its - refusal of a compressed or a depth or stencil texture buffer matches Metal, which ends the process - for one. + take) and answered nil for 71 (the two-plane ones among them). The runtime makes a texture buffer + of each format with a word layout and of each Vulkan requires as a storage texel buffer, on every + device. Of the rest Metal makes, the two-plane `RGB10A8_2P` ones, the `YCBCR` ones, the `RGBX` + ones, the `Bfloat` ones, `BGRA4Unorm`, `ARGB8Unorm`, `ARGB8Unorm_sRGB`, and the `_X4`, `_X6`, + `_X8`, `_X12`, `_PACKED`, `_PQ`, `_HLG` and `_sRGB` forms of `R10`, `RG10`, `R12`, `RG12`, + `RGB10A2` and `BGR10A2`, it holds no word layout, and refuses each as `Gap::TextureFormat` where + the device does not hold the format directly as both texel buffers. Its refusal of a compressed + or a depth or stencil texture buffer matches Metal, which ends the process for one. - `replace_region` and `get_bytes` of a texture without named bytes go through the staging region: a copy Metal does not make, counted in `Metrics::bytes_copied`. - A blit copy between textures of a compressed region of whole blocks that ends inside one @@ -2331,7 +2333,8 @@ made, with no lock, and never rewritten for layouts. read-write tiers, so documented Metal defines no answer for that read; no Vulkan query tells the driver's answer apart, and the runtime follows the per-format bit on every device. - A texture buffer's storage texel buffer is declared without a format too, but at a slot a - texture atomic updates (`R32ui` or `R32i`), and its answers are its format's buffer features, + texture atomic updates (`R32ui` or `R32i`) and where the texture buffer is held as words + (`R32ui`, which asks neither bit below), and its answers are its format's buffer features, of which Vulkan requires neither `VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT` nor the read bit, whatever the device's features and the format. A draw or dispatch whose function writes it at a slot declared without a format where they lack the write bit, or reads it there @@ -2344,8 +2347,8 @@ made, with no lock, and never rewritten for layouts. (`VUID-vkCmdDispatch-OpTypeImage-07029`), as such a read is (`-07030`), and Vulkan does not define what it does. The UHD Graphics 630's Windows driver (101.2145) answers neither bit for any format: there a texture buffer a function writes - or reads through `access::read_write` is refused, but at a slot a texture atomic updates, and - one it reads through `access::read` runs. No second form is built for it; that changes on a + or reads through `access::read_write` is refused, but at a slot a texture atomic updates and one + held as words, and one it reads through `access::read` runs. No second form is built for it; that changes on a second device above the floor whose formats lack those buffer features, or on a guest's walk that meets the refusal on any device. - An upload into a 32-bit float depth (`Depth32Float`, or the depth of `Depth32Float_Stencil8`) diff --git a/crates/metal2vulkan/src/pipeline/artifact.rs b/crates/metal2vulkan/src/pipeline/artifact.rs index fe68a176d..f8be67f4e 100644 --- a/crates/metal2vulkan/src/pipeline/artifact.rs +++ b/crates/metal2vulkan/src/pipeline/artifact.rs @@ -900,7 +900,10 @@ pub enum PrecisionNote { /// (`lower::texture::heap_storage_conversions`). Both are recorded outright, on every device: /// Metal's table rounds the transfer to a twelve-bit step, up to half a step (`1 / 8190`) from /// it, where MoltenVK's `Pow` read within `1.83e-7` of the transfer through the alias. - /// Validation derives no tolerance from it: the class is unbounded. + /// Validation derives no tolerance from it: the class is unbounded. A `float` read of a texture + /// buffer held as words (`metal::format::texel_buffer_words`) decodes an 8-bit sRGB colour + /// code the same way, by the MSL transfer through the device's division and `Pow`, and records + /// the note outright: the routine reads every format the texture buffer's word may name. SrgbTexelDecode, /// A vertex or fragment function keeps more private memory (its `alloca`s, a call stack among /// them, or constants held as `Private` variables) than the floor, 16 KiB a thread, on a device @@ -1704,8 +1707,14 @@ pub enum PrecisionNote { /// buffer that decodes a texture the heap holds by its raw texels alone /// (`lower::texture::heap_raw`) records it as a specialized note: it holds where a texture /// the stage's handles can name is one (`SpecKey::HeapRawTextures`, which a plan gives), - /// unless the stage records it outright for another conversion. Validation derives no - /// tolerance from it. + /// unless the stage records it outright for another conversion. A texture buffer held as + /// words (`metal::format::texel_buffer_words`) converts its extended-range texels the same + /// way, and encodes a write's 8-bit sRGB colour by `unorm4x8_srgb`'s pack; its `float` read and + /// write record the note outright, the routine converting every format the texture buffer's + /// word may name. Its other conversions are exact: a normalized code to its correctly rounded + /// quotient, a value to the exact product's code rounded to nearest even, a half or small + /// float exactly, and a write's half or small float toward zero, as Metal's kernel writes. + /// Validation derives no tolerance from it. DevicePackConversion, /// A tessellation pipeline drawn through the device's tessellation stages (a device with /// `tessellationShader`), on every device (no Vulkan query tells Apple's tessellator apart): diff --git a/crates/metal2vulkan/tests/resource_words.rs b/crates/metal2vulkan/tests/resource_words.rs index 172827482..80cad0f24 100644 --- a/crates/metal2vulkan/tests/resource_words.rs +++ b/crates/metal2vulkan/tests/resource_words.rs @@ -24,6 +24,7 @@ use metal2vulkan::metal::{ const HEADER: &str = "\ # gpuResourceID high words (docs/RESOURCE-ID.md): one Metal descriptor per line, raw Metal values. # texture\tpixelFormat\tswizzleRed\tswizzleGreen\tswizzleBlue\tswizzleAlpha\tword +# texturebuffer\tpixelFormat\twidth\tword # sampler\tminFilter\tmagFilter\tmipFilter\tsAddressMode\ttAddressMode\trAddressMode\tborderColor\tnormalizedCoordinates\tlodMinClamp\tlodMaxClamp\tlodAverage\tmaxAnisotropy\tcompareFunction\treductionMode\tword # lodMinClamp and lodMaxClamp are a float's IEEE-754 bits; booleans are 0 or 1; words are hex. "; @@ -176,10 +177,31 @@ fn samplers(out: &mut String) { }); } -/// The file: the header, then the texture and sampler lines, each line once. +/// The texture buffer lines: every pixel format with a texture buffer word at width 1, and at +/// widths 2 to 4 too where its word changes with the width (a texture buffer held as words of +/// more than one texel a word, whose padding the word carries). +fn texture_buffers(out: &mut String) { + for &pf in PixelFormat::ALL { + let Some(TextureWord(first)) = TextureWord::of_texture_buffer(pf, 1) else { + continue; + }; + let _ = writeln!(out, "texturebuffer\t{}\t1\t{first:#010x}", pf.as_raw()); + let words: Vec<_> = (2..=4) + .filter_map(|w| Some((w, TextureWord::of_texture_buffer(pf, w)?.0))) + .collect(); + if words.iter().any(|&(_, word)| word != first) { + for (w, word) in words { + let _ = writeln!(out, "texturebuffer\t{}\t{w}\t{word:#010x}", pf.as_raw()); + } + } + } +} + +/// The file: the header, then the texture, texture buffer and sampler lines, each line once. fn generate() -> String { let mut lines = String::new(); textures(&mut lines); + texture_buffers(&mut lines); samplers(&mut lines); let mut seen = BTreeSet::new(); let mut out = String::from(HEADER); @@ -222,6 +244,11 @@ fn word_of(fields: &[&str]) -> u32 { let channels = TextureSwizzleChannels::new(s(r), s(g), s(b), s(a)); TextureWord::of(pf, channels).expect("a word").0 } + ["texturebuffer", pf, width] => { + let pf = raw(PixelFormat::ALL, PixelFormat::as_raw, pf); + let width = width.parse().expect("width"); + TextureWord::of_texture_buffer(pf, width).expect("a word").0 + } ["sampler", min, mag, mip, sa, ta, ra, border, normalized, lo, hi, average, aniso, compare, reduction] => { let mut d = SamplerDescriptor::new(); diff --git a/docs/API.md b/docs/API.md index d9e7708d0..fc9028d18 100644 --- a/docs/API.md +++ b/docs/API.md @@ -269,7 +269,9 @@ and so do the command line, the compile worker and every validation tool. It hol `first` its run's first element, `PushField::TextureLevelBase`: [RESOURCE-ID.md](RESOURCE-ID.md)), reads, writes and updates atomically its texture buffers, slots and argument buffers' members alike (a uniform texel buffer where it reads one, a storage texel - buffer where it writes one, the element of set 1's texel-buffer array at its ID's index), and + buffer where it writes one, the element of set 1's texel-buffer array at its ID's index; where + the ID's word says the texture buffer is held as words, that element is a view of `R32_UINT` + and the function converts its texels itself: RESOURCE-ID.md, the texture buffer word), and samples its texture slots through its runtime sampler slots and its constexpr samplers and reads them through those (MSL 4.1's `read(sampler, coord)`, its border texel from bits 0-11 of the ID's word). Any other @@ -2061,7 +2063,9 @@ bound. device holds the format as its UNORM twin, or a storage texture holds it through its UNORM alias (at a slot, or held by an argument buffer), the module decodes the codes (or the device's filter of them) by the MSL transfer through the device's `Pow`, at every such access on - every device. + every device. A `float` read of a texture buffer held as words decodes an 8-bit sRGB colour code + the same way, and records the note outright: its routine reads every format the texture + buffer's word may name. - `metal2vulkan-degrade-function-storage-assumed` (precision). `PrecisionNote::FunctionStorageAssumed`: A vertex or fragment function keeps more private memory (its `alloca`s, a call stack among them, or constants held as `Private` variables) than the floor, @@ -2548,7 +2552,13 @@ bound. function decodes the same way: such a stage records the note as a specialized note, holding where a texture its handles can name is one (`SpecKey::HeapRawTextures`, which a runtime gives from the textures the command makes resident or binds), so a reading of the module alone - holds it, and so does a command that can name one. + holds it, and so does a command that can name one. A texture buffer held as words converts its + extended-range texels the same way, and encodes a write's 8-bit sRGB colour by + `unorm4x8_srgb`'s pack; its `float` read and write record the note outright, the routine + converting every format the texture buffer's word may name. Its other conversions are exact: a + normalized code to its correctly rounded quotient, a value to the exact product's code rounded + to nearest even, a half or small float exactly, and a write's half or small float toward zero, + as Metal's kernel writes. - `metal2vulkan-degrade-device-fragment-runs` (precision). `PrecisionNote::DeviceFragmentRuns`: A fragment function that writes memory (`StageInterface::writes_memory`) in a render pipeline of more than one sample, which the pipeline's compile records on its fragment stage, decided by the diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 10933723b..4a4f7f6a1 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -363,7 +363,7 @@ Columns: | `IndirectPrivateArena` | `dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:` of a kernel whose private memory lives in the runtime's... | every device (a public call's own check of its arguments) | `ours`: no replay stream dispatches such a kernel indirectly | 1: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)` | `-` | | `MemorylessTexture` | A texture of `Memoryless` storage, which only render passes use | every device (a public call's own check of its arguments) | `ours`: render passes are built, but a memoryless attachment keeps its contents for the whole render encoder, across the renderings the runtime ends and restarts inside it, and the image that would hold them is not built | 1: `crates/metal2vulkan-runtime/src/texture.rs (checked)` | `-` | | `TextureBufferSwizzle` | A texture buffer (`MTLTextureTypeTextureBuffer`) with a swizzle other than each channel's own (`Buffer::new_texture`), which Metal applies to its... | every device (a public call's own check of its arguments) | `ours`: a texel buffer view has no component mapping, and a texture's resource ID carries no swizzle to the shader; no recorded stream makes one | 1: `crates/metal2vulkan-runtime/src/texture.rs (texel_shape)` | `-` | -| `TextureFormat` | A texture of a pixel format the runtime makes no image of on this device for the descriptor's usage | every device (a public call's own check of its arguments) | `ours`: the device's format query, or the identity domains' shaders read every texture through its view alone | 4: `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`, `crates/metal2vulkan-runtime/src/texture.rs (form)` (+2) | `-` | +| `TextureFormat` | A texture of a pixel format the runtime makes no image of on this device for the descriptor's usage | every device (a public call's own check of its arguments) | `ours`: the device's format query, or the identity domains' shaders read every texture through its view alone | 5: `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`, `crates/metal2vulkan-runtime/src/texture.rs (form)` (+3) | `-` | | `MipmapFilter` | `BlitCommandEncoder::generate_mipmaps` of a texture whose image the device's blits do not filter | every device (a public call's own check of its arguments) | `ours`: the device's format query; the levels are the device's blit chain alone | 1: `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)` | `-` | | `CubicSampler` | A sampler state whose minification or magnification filter is cubic (`Device::new_sampler_state`) | every device (a public call's own check of its arguments) | `ours`: the translator's identity domains do not filter bicubically, and Vulkan's cubic filter is not Metal's | 1: `crates/metal2vulkan-runtime/src/sampler.rs (new_sampler_state)` | `-` | | `TextureBytes` | `Texture::replace_region`, `Texture::get_bytes` or a blit copy between a buffer and a texture (`BlitCommandEncoder::copy_from_buffer`) of a... | every device (a public call's own check of its arguments) | `ours`: no copy between such an image and bytes is built | 4: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`, `crates/metal2vulkan-runtime/src/blit.rs (with_option)` (+2) | `-` | @@ -660,7 +660,7 @@ Each refusal's sites, with the function that builds it. - `rt:Gap::IndirectPrivateArena`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)` - `rt:Gap::MemorylessTexture`: `crates/metal2vulkan-runtime/src/texture.rs (checked)` - `rt:Gap::TextureBufferSwizzle`: `crates/metal2vulkan-runtime/src/texture.rs (texel_shape)` -- `rt:Gap::TextureFormat`: `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`; `crates/metal2vulkan-runtime/src/texture.rs (form)`; `crates/metal2vulkan-runtime/src/texture.rs (planned)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_form)` +- `rt:Gap::TextureFormat`: `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`; `crates/metal2vulkan-runtime/src/texture.rs (form)`; `crates/metal2vulkan-runtime/src/texture.rs (planned)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_form)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` - `rt:Gap::MipmapFilter`: `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)` - `rt:Gap::CubicSampler`: `crates/metal2vulkan-runtime/src/sampler.rs (new_sampler_state)` - `rt:Gap::TextureBytes`: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`; `crates/metal2vulkan-runtime/src/blit.rs (with_option)`; `crates/metal2vulkan-runtime/src/texture.rs (check_places)`; `crates/metal2vulkan-runtime/src/texture.rs (copy)` diff --git a/docs/RESOURCE-ID.md b/docs/RESOURCE-ID.md index 81f47f65d..c83913cbf 100644 --- a/docs/RESOURCE-ID.md +++ b/docs/RESOURCE-ID.md @@ -29,8 +29,8 @@ texture writes its sampled-image element and leaves its storage-image element nu render target made for neither shader reads nor writes leaves both null; a draw that reads it as an attachment of its own pass (`[[color(n)]]`) reads the runtime's second element at its index plus 65,536, which no resource ID reaches. A texture no shader reaches, a depth or stencil target made -for neither, has no index. A texture view takes its own index of the texture class. A texture -buffer has no index: it is a typed refusal under these domains. +for neither, has no index. A texture view takes its own index of the texture class, and so does +a texture buffer, whose elements are the texel-buffer arrays' (below). A slot reaches its texture's elements only where the texture's usage holds what the function's access there asks: `ShaderRead` for a `sample` or `read` slot, a size query alone included, @@ -91,7 +91,8 @@ A shader takes a texture slot's ID from the slot's push field (`PushField::SlotG argument buffer's texture's ID from the member's 8 bytes, with no table between. It indexes the arrays with the low word, answers `is_null_texture` by whether the index is 0, and, where it checks a `read` itself (a device without `robustImageAccess2`), takes an out-of-bounds -alpha of 1 from bit 12 of the word. A slot's `read` through a sampler (MSL 4.1) takes the border +alpha of 1 from bit 12 of the word. A texture buffer held as words takes its format, its texels per +word, whether a texel is two words and its padding from bits 0-10 of its word. A slot's `read` through a sampler (MSL 4.1) takes the border texel an index outside the level reads on a border axis from bits 0-11 of the word, for the sampler's border color. The runtime writes a slot's ID, so its index is an element; the program writes an argument buffer's, so the shader masks its index to its low 16 bits: a bad @@ -146,6 +147,37 @@ Every pixel format's raw value is above 0, so a texture's word is never 0. The p (`Invalid`, `Unspecialized`) and the formats the translator holds no texture of or only copies have no word. +## The texture buffer word + +`metal2vulkan::metal::resource_word::TextureWord::of_texture_buffer(pixelFormat, width)`: the +texture word of its format under each channel's own swizzle, with bits 0-11 replaced, as no +texture buffer is sampled or read through a sampler: + +| Bits | Field | +|---|---| +| 0-1 | held as words: the texels the view's last word holds past `width`, 0 to 3; otherwise 0 | +| 2-7 | held as words: the format's code, 1 to 39 (below); 0 where the format's own view holds the texels | +| 8-9 | held as words: the base-2 logarithm of the texels one word holds, 0, 1 or 2; otherwise 0 | +| 10 | held as words: a texel is two words, the low word first; otherwise 0 | +| 11 | 0 | +| 12 | the format has no alpha, as in the texture word | +| 13-15 | 0 | +| 16-31 | the `MTLPixelFormat` raw value | + +A texture buffer is held as words where its format is a colour format whose Vulkan format Vulkan +does not require as a storage texel buffer (its mandatory format tables), or that has no Vulkan +format of its own, by the format alone and on every device (`metal::format::texel_buffer_words`). +Its view is then of `R32_UINT`, its texels packed in the buffer's bytes as Metal lays them out: a +texel of `b` bytes, `w` texels wide, views `⌈w · b / 4⌉` words, and its width is the words times +its texels per word, halved where a texel is two words, less its padding. The codes, from 1: +`A8Unorm`, `R8Unorm`, `R8Unorm_sRGB`, `R8Snorm`, `R8Uint`, `R8Sint`, `R16Unorm`, `R16Snorm`, +`R16Uint`, `R16Sint`, `R16Float`, `RG8Unorm`, `RG8Unorm_sRGB`, `RG8Snorm`, `RG8Uint`, `RG8Sint`, +`B5G6R5Unorm`, `A1BGR5Unorm`, `ABGR4Unorm`, `BGR5A1Unorm`, `RG16Unorm`, `RG16Snorm`, `RG16Uint`, +`RG16Sint`, `RG16Float`, `RGBA8Unorm_sRGB`, `BGRA8Unorm`, `BGRA8Unorm_sRGB`, `RGB10A2Unorm`, +`RGB10A2Uint`, `BGR10A2Unorm`, `RG11B10Float`, `RGB9E5Float`, `RGBA16Unorm`, `RGBA16Snorm`, +`BGR10_XR`, `BGR10_XR_sRGB`, `BGRA10_XR` and `BGRA10_XR_sRGB` (`metal::format::WORD_FORMATS`). A +format keeps its code. A texture buffer whose words overflow a `u32` has no word. + ## The sampler word `metal2vulkan::metal::sampler::SamplerWord::of(descriptor)`. Each field holds its @@ -177,7 +209,8 @@ Vulkan sampler applies them. [`crates/metal2vulkan/tests/resource_words.tsv`](../crates/metal2vulkan/tests/resource_words.tsv) holds one descriptor per line with its word, in tab-separated raw Metal values; its header names -the columns. A texture line is a pixel format and its four swizzle sources; a sampler line is every +the columns. A texture line is a pixel format and its four swizzle sources; a texture buffer line a +pixel format and a width; a sampler line is every `MTLSamplerDescriptor` field above, with `lodMinClamp` and `lodMaxClamp` as the float's IEEE-754 bits. Words are hexadecimal.