diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 18e0ed70c..47bfe7524 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -2081,19 +2081,22 @@ made, with no lock, and never rewritten for layouts. copies it has retired, and a view's image views once the view is gone. `Gauges::textures` counts images and views until then, `Gauges::descriptor_slots` the indices held. - Texture slots and usage. A function's access at a texture slot asks a usage of the texture bound - there, as Metal's validation asks it, by the access the function declares: `ShaderRead` for a - `sample` or `read` slot, whatever the function does there (a size query alone included), - `ShaderWrite` for a `write` or `read_write` slot, and both for a `read_write` slot it reads. The - usage is the texture's: Metal's unknown usage takes every access, and a view's is its texture's, a - view made with a swizzle included (Known gaps of textures: its write runs, where Metal's - validation stops it). Any texture binds, as Metal's does; a dispatch or a draw whose function uses - a slot whose texture lacks the usage is `Refusal::TextureUsageAtSlot` (the stage, the slot and the - usage), found when the pipeline state or a binding changes, and records nothing. Without the usage - the slot reaches no element of the texture's: a texture no shader reaches has no index, a colour - target made for neither shader reads nor writes has null elements, and one not made for shader - writes has no storage element. Plain Metal reads and writes such a texture all the same; its - validation asserts (M3 Max, macOS 27.0.1, jobs m3-max-78392 and m3-max-78422). A `read_write` slot - the function only writes asks `ShaderWrite` alone, as its write reaches the storage element alone. + there: `ShaderRead` for a `sample` or `read` slot, whatever the function does there (a size query + alone included), `ShaderWrite` for a `write` or `read_write` slot, and both for a `read_write` + slot it reads, a texture atomic included. Metal's validation asks the same, but asks both at every + `read_write` slot, by the declared access, one the function only writes or only asks the size of + included (M3 Max, macOS 27.0.1, job m3-max-80068); the runtime asks `ShaderWrite` alone at such a + slot, as its write reaches the storage element alone, so a texture of `ShaderWrite` alone runs + there, as plain Metal runs it. The usage is the texture's: Metal's unknown usage takes every + access, and a view's is its texture's, a view made with a swizzle included (Known gaps of + textures: its write runs, where Metal's validation stops it). Any texture binds, as Metal's does; + a dispatch or a draw whose function uses a slot whose texture lacks the usage is + `Refusal::TextureUsageAtSlot` (the stage, the slot and the usage), found when the pipeline state + or a binding changes, and records nothing. Without the usage the slot reaches no element of the + texture's: a texture no shader reaches has no index, a colour target made for neither shader reads + nor writes has null elements, and one not made for shader writes has no storage element. Plain + Metal reads and writes such a texture all the same; its validation asserts (M3 Max, macOS 27.0.1, + jobs m3-max-78392 and m3-max-78422). ### Known gaps of textures diff --git a/crates/metal2vulkan-runtime/src/pipeline.rs b/crates/metal2vulkan-runtime/src/pipeline.rs index ceb73532c..ee276ccc7 100644 --- a/crates/metal2vulkan-runtime/src/pipeline.rs +++ b/crates/metal2vulkan-runtime/src/pipeline.rs @@ -2174,14 +2174,16 @@ pub(crate) fn texture_access(used: TextureAccess) -> Access { } } -/// The usage Metal asks of the texture bound at a texture slot a function uses, by the access the -/// function declares there, whatever it does there (a size query alone included): `ShaderRead` -/// for a `sample` or `read` slot, `ShaderWrite` for a `write` or `read_write` slot -/// (`TextureSlot::storage`), and both for one it reads. Metal's validation stops a dispatch or a -/// draw whose texture lacks it (measured on an Apple M3 Max, macOS 27.0.1, jobs m3-max-78392 and -/// m3-max-78422), as [`Refusal::TextureUsageAtSlot`] does. A `read_write` slot the function only -/// writes asks `ShaderWrite` alone: the write reaches the texture through its storage element -/// alone. +/// The usage asked of the texture bound at a texture slot a function uses: `ShaderRead` for a +/// `sample` or `read` slot, whatever the function does there (a size query alone included), +/// `ShaderWrite` for a `write` or `read_write` slot (`TextureSlot::storage`), and both for one it +/// reads, a texture atomic included. Metal's validation stops a dispatch or a draw whose texture +/// lacks it (measured on an Apple M3 Max, macOS 27.0.1, jobs m3-max-78392 and m3-max-78422), as +/// [`Refusal::TextureUsageAtSlot`] does. Metal's validation asks both at every `read_write` slot, +/// by the declared access, one the function only writes or only asks the size of included (job +/// m3-max-80068); here such a slot asks `ShaderWrite` alone, as its write reaches the texture +/// through its storage element alone, so a texture of `ShaderWrite` alone runs there, as plain +/// Metal runs it. pub(crate) fn slot_usage(slot: &TextureSlot) -> TextureUsage { match (slot.storage, slot.access.read) { (false, _) => TextureUsage::SHADER_READ, diff --git a/docs/RESOURCE-ID.md b/docs/RESOURCE-ID.md index 9c0cc4de4..81f47f65d 100644 --- a/docs/RESOURCE-ID.md +++ b/docs/RESOURCE-ID.md @@ -33,10 +33,11 @@ for neither, has no index. A texture view takes its own index of the texture cla buffer has no index: it is a typed refusal under these domains. A slot reaches its texture's elements only where the texture's usage holds what the function's -access there asks, as Metal's validation asks it: `ShaderRead` for a `sample` or `read` slot, a -size query alone included, `ShaderWrite` for a `write` or `read_write` slot, and both for a -`read_write` slot the function reads (Metal's unknown usage takes every access; a view's usage is -its texture's). A runtime refuses a dispatch or draw +access there asks: `ShaderRead` for a `sample` or `read` slot, a size query alone included, +`ShaderWrite` for a `write` or `read_write` slot, and both for a `read_write` slot the function +reads (Metal's unknown usage takes every access; a view's usage is its texture's). Metal's +validation asks the same, but asks both at every `read_write` slot, by the declared access, one +the function only writes included. A runtime refuses a dispatch or draw whose function uses a slot whose texture lacks it (the runtime's `Refusal::TextureUsageAtSlot`): such a slot would read element 0's or a null element's zeros and drop its writes, where plain Metal reads and writes the texture.