pub enum ResourceState {
Show 13 variants
Undefined,
ShaderRead,
ShaderWrite,
ShaderReadWrite,
ColorAttachment,
DepthStencilWrite,
DepthStencilRead,
TransferSrc,
TransferDst,
IndirectArgument,
IndexBuffer,
HostRead,
Present,
}Expand description
What a resource is being used for.
The seam’s entire synchronisation vocabulary. A backend expands one of these into whatever its API needs; see the module docs for why raw stage/access masks are not exposed.
States are uses, not permissions: a resource is in exactly one state at a time from the graph’s point of view, and moving between two states is a barrier.
Variants§
Undefined
Contents are undefined. The only legal source state for a freshly
created image, and for a swapchain image just acquired. Transitioning
from Undefined discards contents, which is free; transitioning to
it is meaningless.
ShaderRead
Read as a sampled texture or a read-only storage buffer/image in any shader stage.
ShaderWrite
Written by a shader (storage buffer or storage image).
ShaderReadWrite
Both read and written by a shader in the same pass.
ColorAttachment
A colour attachment being rendered into.
DepthStencilWrite
A depth/stencil attachment being written.
DepthStencilRead
A depth/stencil attachment being tested but not written — the state for a pass drawing against an existing depth prepass.
TransferSrc
Source of a copy.
TransferDst
Destination of a copy, clear or fill.
IndirectArgument
Read as indirect draw/dispatch arguments or an indirect count. The state a culling pass’s output must reach before the draws that consume it — the single most important barrier in a GPU-driven frame, and the one whose absence produces “sometimes nothing draws”.
IndexBuffer
Read as an index buffer.
HostRead
Mapped and read by the CPU.
Present
Ready to be handed to the compositor.
Implementations§
Source§impl ResourceState
impl ResourceState
Sourcepub const fn is_write(self) -> bool
pub const fn is_write(self) -> bool
Whether this state writes the resource.
Read→read transitions need no barrier at all, so a graph asks this to skip emitting one.
Self::DepthStencilRead is a read, and every backend agrees: Vulkan
ends such a pass with VK_ATTACHMENT_STORE_OP_NONE, which stores
nothing and declares no attachment write; D3D12 has no store op at all
and runs a depth-test-only pass with a zero depth-write mask; WebGPU
takes depthReadOnly and forbids the store op entirely; and Metal,
whose MTLStoreAction has no no-op action, stores contents the pass did
not change. Two such passes in a row therefore hazard against nothing
and the barrier between them is the one to skip.
It answered true until the backends were checked one by one, which was
conservatism rather than description — see docs/notes/backends.md.
Sourcepub const fn needs_barrier(from: Self, to: Self) -> bool
pub const fn needs_barrier(from: Self, to: Self) -> bool
Whether a transition between two states requires a barrier.
false only when both states are reads and they are the same state —
two different read states still differ in image layout on Vulkan and
DX12, so they need a transition even though no memory hazard exists.