Table of Contents

Enum GraphicsResourceState

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

Defines constants that specify the state of a Graphics Resource regarding how the resource is being used.

[Flags]
public enum GraphicsResourceState
Extension Methods

Fields

AllShaderResource = NonPixelShaderResource | PixelShaderResource

The Graphics Resource can be used in both Pixel and non-Pixel Shaders.

This value is a combination of the NonPixelShaderResource and PixelShaderResource flags, allowing it to be used in scenarios where both types of Shader Resources are required.

Common = 0

The application should transition to this state only for accessing a Graphics Resource across different graphics engine types.

Specifically, a Graphics Resource must be in the Common state before being used on a Copy Queue (when previously used on a Direct / Compute Queue), and before being used on a Direct / Compute Queue (when previously used on Copy Queue). This restriction doesn't exist when accessing data between Direct and Compute queues.

The Common state can be used for all usages on a Copy Queue using the implicit state transitions. For more information, read about Multi-engine synchronization.

Additionally, Textures must be in the Common state for CPU access to be legal, assuming the Texture was created in a CPU-visible heap in the first place.

CopyDestination = 1024

The Graphics Resource is used as the destination in a copy operation.

Graphics Sub-Resources must be in this state when they are used as the destination of a copy operation, or a blt operation.

This is a write-only state.

CopySource = 2048

The Graphics Resource is used as the source in a copy operation.

Graphics Sub-Resources must be in this state when they are used as the source of a copy operation, or a blt operation.

This is a read-only state.

DepthRead = 32

This state should be used when the Graphics Sub-Resource is in a read-only Depth-Stencil View, or when depth write is disabled (see DepthBufferWriteEnable).

It can be combined with other read states (for example, PixelShaderResource), such that the Graphics Resource can be used for the Depth or Stencil test, and accessed by a Shader within the same draw call.

Using it when depth will be written by a draw call or clear command is invalid.

DepthWrite = 16

This state should be used for Clear(Texture, DepthStencilClearOptions, float, byte) when the flags (see DepthStencilClearOptions) indicate a given Graphics Sub-Resource should be cleared (otherwise the Graphics Sub-Resource state doesn't matter), or when using it in a writable Depth-Stencil View when the Pipeline State has depth write enabled (see DepthBufferWriteEnable).

This state is mutually exclusive with other states.

GenericRead = VertexAndConstantBuffer | IndexBuffer | AllShaderResource | IndirectArgument | CopySource

This state is the required starting state for an upload heap. It is a combination of other read-state bits.

The application should generally avoid transitioning to GenericRead when possible, since that can result in premature cache flushes, or Graphics Resource layout changes (for example, compress / decompress), causing unnecessary pipeline stalls. You should instead transition resources only to the actually-used states.

IndexBuffer = 2

A Graphics Sub-Resource must be in this state when it is accessed by the 3D pipeline as an Index Buffer.

This is a read-only state.

IndirectArgument = 512

The Graphics Resource is used as an Indirect Argument.

Graphics Sub-Resources must be in this state when they are used as the Argument Buffer passed to a indirect drawing method like DrawInstanced(Buffer, int) or DrawIndexedInstanced(Buffer, int).

This is a read-only state.

NonPixelShaderResource = 64

The Graphics Resource is used with a Shader other than the Pixel Shader.

A Graphics Sub-Resource must be in this state before being read by any stage (except for the Pixel Shader stage) via a Shader Resource View. You can still use the Graphics Resource in a Pixel Shader with this flag as long as it also has the flag PixelShaderResource set.

This is a read-only state.

PixelShaderResource = 128

The Graphics Resource is used with a Pixel Shader.

A Graphics Sub-Resource must be in this state before being read by the Pixel Shader via a Shader Resource View.

This is a read-only state.

Predication = 512

The Graphics Resource is used for Predication.

Predication is a feature that enables the GPU rather than the CPU to determine to not draw, copy, or dispatch an object.

The typical use of predication is with occlusion; if a bounding box is drawn and is occluded, there is obviously no point in drawing the object itself. In this situation, the drawing of the object can be "predicated", enabling its removal from actual rendering by the GPU.

Present = 0

Synonymous with the Common flag.

RenderTarget = 4

The Graphics Resource is used as a Render Target.

A Graphics Sub-Resource must be in this state when it is rendered to, or when it is cleared with Clear(Texture, Color4).

This is a write-only state. To read from a Render Target as a Shader Resource, the Graphics Resource must be in either NonPixelShaderResource or PixelShaderResource state.

ResolveDestination = 4096

The Graphics Resource is used as the destination in a resolve operation.

ResolveSource = 8192

The Graphics Resource is used as the source in a resolve operation.

StreamOut = 256

The Graphics Resource is used with Stream Output.

A Graphics Sub-Resource must be in this state when it is accessed by the 3D pipeline as a Stream-Out target.

This is a write-only state.

UnorderedAccess = 8

The Graphics Resource is used for Unordered Access.

A Graphics Sub-Resource must be in this state when it is accessed by the GPU via an Unordered Access View. A Graphics Sub-Resource must also be in this state when it is cleared with ClearReadWrite(Buffer, Vector4).

This is a read / write state.

VertexAndConstantBuffer = 1

A Graphics Sub-Resource must be in this state when it is accessed by the GPU as a Vertex Buffer or Constant Buffer.

This is a read-only state.