diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 656b51025..2e2aab552 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -2431,19 +2431,30 @@ made, with no lock, and never rewritten for layouts. through `access::read_write` where they lack the read bit, is `Gap::StorageElement` (`VUID-vkCmdDispatch-OpTypeImage-07029`, `-07030`), whatever its format; so is, with no slot, one that may reach it beyond its slots after `use_resource` declared a write of it where they - lack the write bit. A write through an argument buffer or a resource ID with no such - declaration is outside documented Metal and is not refused: where they lack the write bit it - writes the texture buffer's storage element without a format, outside Vulkan's valid usage + lack the write bit. The slot's declaration without a format is made on every device, whatever + its formats' buffer features: the floor's Vulkan 1.3 enables the SPIR-V capabilities + `StorageImageReadWithoutFormat` and `StorageImageWriteWithoutFormat` whatever + `shaderStorageImageReadWithoutFormat` answers, so a state over such a function is made, and the + refusal is the draw's or dispatch's, per texture buffer it binds. A nil texture at the slot + reads a texel-buffer element no object owns, a null descriptor (the floor's `nullDescriptor`), + which is no view and asks no format's bit. A write through an argument buffer or a resource ID with no + such declaration is outside documented Metal and is not refused: where they lack the write bit + it writes the texture buffer's storage element without a format, outside Vulkan's valid usage (`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 it holds every format with a word - layout as words, and a texture buffer of a format without one (those Vulkan requires as a - storage texel buffer) that 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. A device - that holds a format with a word layout as its own view, which takes the write bit, and lacks - the read bit refuses a read of it through `access::read_write` alike. No further form is built - for these; 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. + layout as words, which a function writes and reads through `access::read_write` at a slot + through the words (the device test `texture_buffer_words`' + `every_device_reads_and_writes_texture_buffers_of_formats_held_as_words`), and a texture buffer + of a format without one (those Vulkan requires as a storage texel buffer) that a function writes + or reads through `access::read_write` is refused at that draw or dispatch, but at a slot a + texture atomic updates, and one it reads through `access::read` runs. On any device whose + buffer features lack `VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT` for a format held as + its own view, a read of a texture buffer of that format through `access::read_write` at a slot + is refused at the draw or dispatch alike, a format with a word layout held so (which takes the + write bit) among them. No further form is built for these; 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. - ANV on an Intel Iris Xe Graphics (RPL-P) holds `BGRA8Unorm`, `B5G6R5Unorm`, `BGR5A1Unorm` and `BGR10A2Unorm` as their own views: their Vulkan formats' buffer features take a uniform texel buffer, a storage texel buffer and `VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT`, the @@ -4422,9 +4433,9 @@ cache is answered compile-required on both. test `tests::reflection_answers` reaches it with the translator's tile pipeline of `engine/k10ts_tile_grid`, which the identity domains refuse with that text, and compares the refusal's text across every make; - - with no symbol, a storage texture access without a format that the device's - `shaderStorageImageReadWithoutFormat` or `shaderStorageImageWriteWithoutFormat` does not take - and the formats' own bits do not grant: no test yet; + - with no symbol, a storage texture's access without a format, not a texture buffer's, that the + device's `shaderStorageImageReadWithoutFormat` or `shaderStorageImageWriteWithoutFormat` does + not take and the formats' own bits do not grant: no test yet; - a bicubic sample of a 1D texture ("a bicubic filter of a 1D texture"): the translator test `a_bicubic_kernel_reads_each_slots_format_treatment_from_its_pushed_field` asserts the text; - an argument buffer's texture of a type the identity arrays hold no element of (a texture diff --git a/crates/metal2vulkan/src/lower/texture/slot.rs b/crates/metal2vulkan/src/lower/texture/slot.rs index daa87262c..26dae238f 100644 --- a/crates/metal2vulkan/src/lower/texture/slot.rs +++ b/crates/metal2vulkan/src/lower/texture/slot.rs @@ -699,11 +699,13 @@ pub(super) fn stage_stores(cx: &SelectCx<'_>) -> Result<(), Error> { /// The format a storage slot is declared with and its class: the slot's `StorageImageChoice` from /// the lowering inputs, or, without one, a formatless `Identity` declaration where the device's /// `shaderStorageImage{Read,Write}WithoutFormat` grant its accesses without a format, or, under the -/// identity domains, where the formats' own bits grant its read ([`reads_by_format_bits`]); -/// otherwise the format is an input the caller must supply (`NeedsInput`). A choice whose view -/// SPIR-V names no format for is declared without one wherever the profile accesses storage so at -/// all, by the features or by the formats' own bits (`DeviceProfile::accesses_without_format`; the -/// choice checked the view's bits). +/// identity domains, a texture buffer's wherever the profile accesses storage so at all +/// ([`texel_buffer_without_format`]) and another texture's where the formats' own bits grant its +/// read ([`reads_by_format_bits`]); otherwise the format is an input the caller must supply +/// (`NeedsInput`), and under the identity domains, which take no such input, a refusal. A choice +/// whose view SPIR-V names no format for is declared without one wherever the profile accesses +/// storage so at all, by the features or by the formats' own bits +/// (`DeviceProfile::accesses_without_format`; the choice checked the view's bits). /// /// A slot that is only queried accesses no texel, so it is declared `Unknown` with class /// `Identity` whatever the choice (queries need no format feature, and no format then pairs with @@ -752,11 +754,12 @@ fn storage_format( StorageImageClass::Identity, )); } - // Under the identity domains no input names the bound format: a read the formats' own - // bits grant is declared without one, as a heap storage class's is; any other formatless - // access the device does not take is not lowered yet. + // Under the identity domains no input names the bound format: a texture buffer's access + // the profile takes without a format at all ([`texel_buffer_without_format`]), and a read + // the formats' own bits grant, as a heap storage class's is, are declared without one; + // any other formatless access the device does not take is not lowered yet. if crate::lower::access::identity(cx.profile) { - if reads_by_format_bits(cx, s, texel) { + if texel_buffer_without_format(cx, s) || reads_by_format_bits(cx, s, texel) { return Ok(( crate::spv::ImageFormat::Unknown, StorageImageClass::Identity, @@ -835,13 +838,33 @@ fn storage_format( Ok((format, choice.class)) } +/// Whether texture-buffer storage slot `s`, which no input names the bound format of under the +/// identity domains, is declared without a format: wherever the profile reads and writes storage +/// so at all, as the slot does (`DeviceProfile::accesses_without_format`: the features, or Vulkan +/// 1.3 or `VK_KHR_format_feature_flags2`, which enable the SPIR-V capabilities). Vulkan asks the +/// format's bits of each view the access reaches (`VUID-vkCmdDispatch-OpTypeImage-07029`, +/// `-07030`), and the binder answers per texture buffer at the draw or dispatch that binds it +/// (the slot's interface states it formatless, `TextureSlot::declared_format`): one held as its own +/// view whose format's buffer features lack the access's bit is refused there, and one held as +/// words (`metal::format::texel_buffer_form`) is reached through the words' `R32ui` array, never +/// through this declaration. A device whose formats' buffer features carry neither bit (Intel's +/// Windows driver 101.2145 on the UHD Graphics 630) so runs such a slot over every texture buffer +/// it holds as words. +fn texel_buffer_without_format(cx: &SelectCx<'_>, s: &SlotPlan) -> bool { + s.shape.is_some_and(|shape| shape.dim == ImageDim::Buffer) + && cx + .profile + .accesses_without_format(s.uses.read, s.uses.write) +} + /// Whether storage slot `s` of texel class `texel`, which no input names the bound format of, is /// read without a format by the formats' own bits alone, as a heap storage class is /// (`DeviceProfile::storage_reads_by_format_bits`: ANV before Gfx12.5): the slot reads, the device /// writes without a format where the slot writes, and the class's neutral format, which an unbound /// slot reads, and the view of every read-write tier format the slot can hold, whose reads Metal /// defines, have the format's read bit (`bind::heap::tier_read_gaps`). A storage cube is the -/// binder's 2D-array view. +/// binder's 2D-array view. A texture buffer's slot is [`texel_buffer_without_format`]'s, which +/// takes every profile this would. fn reads_by_format_bits(cx: &SelectCx<'_>, s: &SlotPlan, texel: TexelClass) -> bool { let profile = cx.profile; let Some(shape) = s.shape else { @@ -858,7 +881,7 @@ fn reads_by_format_bits(cx: &SelectCx<'_>, s: &SlotPlan, texel: TexelClass) -> b ImageDim::D2 => (SymDim::D2, shape.array), ImageDim::D3 => (SymDim::D3, false), ImageDim::Cube => (SymDim::D2, true), - ImageDim::Buffer => (SymDim::Buffer, false), + ImageDim::Buffer => return false, }; let class = ImageHandleClass { dim, @@ -869,12 +892,8 @@ fn reads_by_format_bits(cx: &SelectCx<'_>, s: &SlotPlan, texel: TexelClass) -> b access: ImageAccess::Storage, format: StorageFormatClass::Unknown, }; - let usage = match shape.dim { - ImageDim::Buffer => FormatUsage::StorageTexelBufferReadWithoutFormat, - _ => FormatUsage::StorageImageReadWithoutFormat, - }; let neutral = crate::bind::neutral::storage_neutral(texel.sampled_type()); - profile.supports_format(neutral, usage) + profile.supports_format(neutral, FormatUsage::StorageImageReadWithoutFormat) && crate::bind::heap::tier_read_gaps(profile, &class).is_empty() }