rt docs: Metal's validation asks ShaderRead and ShaderWrite at every read_write slot; the runtime asks less where the function only writes
The runtime README's rule (Textures: Texture slots and usage), pipeline::slot_usage's doc and RESOURCE-ID.md's sentence on slot usage said the runtime asks a texture's usage at a slot as Metal's validation asks it, ShaderWrite alone at a read_write slot the function does not read. Metal's validation asks both at every read_write slot, by the declared access, whatever the function does there. Measured on an Apple M3 Max, macOS 27.0.1 (job m3-max-80068, a scratch probe of runtime-compiled MSL, R32Float 4x4): - a read_write slot the function only writes, of a ShaderWrite-alone texture, asserts "Compute Function(k_rw_write): reads texture (t[0]) whose usage (0x02) doesn't specify MTLTextureUsageShaderRead (0x01)"; - one the function only asks the width of asserts the same of 0x02 and the write of 0x01; - one it only reads asserts the write of 0x01 and the read of 0x02; - both usages run. Plain Metal runs every case, and the written one writes its texels. The runtime keeps its rule: such a slot asks ShaderWrite alone, as its write reaches the texture through its storage element alone, so a ShaderWrite-alone texture runs there as plain Metal runs it. The three texts now say what Metal's validation asks and what the runtime asks. They also name a texture atomic's slot as one that reads. Metal's validation asks both there: a 0x21 texture asserts the write and a 0x22 one the read; 0x03 runs without ShaderAtomic. Docs only; no behaviour changes. Verified: cargo fmt. Rustdoc runs as a job.
This commit is contained in:
1 parent
626da2e537
commit
f4f5cc33da
3 files changed
+31
-25
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
+5
-4
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user