D3D12_RESOURCE_STATES enumeration (d3d12.h)

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

Syntax

typedef enum D3D12_RESOURCE_STATES {
  D3D12_RESOURCE_STATE_COMMON = 0,
  D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER = 0x1,
  D3D12_RESOURCE_STATE_INDEX_BUFFER = 0x2,
  D3D12_RESOURCE_STATE_RENDER_TARGET = 0x4,
  D3D12_RESOURCE_STATE_UNORDERED_ACCESS = 0x8,
  D3D12_RESOURCE_STATE_DEPTH_WRITE = 0x10,
  D3D12_RESOURCE_STATE_DEPTH_READ = 0x20,
  D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE = 0x40,
  D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE = 0x80,
  D3D12_RESOURCE_STATE_STREAM_OUT = 0x100,
  D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT = 0x200,
  D3D12_RESOURCE_STATE_COPY_DEST = 0x400,
  D3D12_RESOURCE_STATE_COPY_SOURCE = 0x800,
  D3D12_RESOURCE_STATE_RESOLVE_DEST = 0x1000,
  D3D12_RESOURCE_STATE_RESOLVE_SOURCE = 0x2000,
  D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE = 0x400000,
  D3D12_RESOURCE_STATE_SHADING_RATE_SOURCE = 0x1000000,
  D3D12_RESOURCE_STATE_RESERVED_INTERNAL_8000,
  D3D12_RESOURCE_STATE_RESERVED_INTERNAL_4000,
  D3D12_RESOURCE_STATE_RESERVED_INTERNAL_100000,
  D3D12_RESOURCE_STATE_RESERVED_INTERNAL_40000000,
  D3D12_RESOURCE_STATE_RESERVED_INTERNAL_80000000,
  D3D12_RESOURCE_STATE_GENERIC_READ,
  D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE,
  D3D12_RESOURCE_STATE_PRESENT = 0,
  D3D12_RESOURCE_STATE_PREDICATION = 0x200,
  D3D12_RESOURCE_STATE_VIDEO_DECODE_READ = 0x10000,
  D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE = 0x20000,
  D3D12_RESOURCE_STATE_VIDEO_PROCESS_READ = 0x40000,
  D3D12_RESOURCE_STATE_VIDEO_PROCESS_WRITE = 0x80000,
  D3D12_RESOURCE_STATE_VIDEO_ENCODE_READ = 0x200000,
  D3D12_RESOURCE_STATE_VIDEO_ENCODE_WRITE = 0x800000
} ;

Constants

 
D3D12_RESOURCE_STATE_COMMON
Value: 0
Your application should transition to this state only for accessing a resource across different graphics engine types.

Specifically, a resource must be in the COMMON state before being used on a COPY queue (when previously used on DIRECT/COMPUTE), and before being used on DIRECT/COMPUTE (when previously used on COPY). 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 info, in Multi-engine synchronization, find "common".

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.
D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER
Value: 0x1
A subresource 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.
D3D12_RESOURCE_STATE_INDEX_BUFFER
Value: 0x2
A subresource must be in this state when it is accessed by the 3D pipeline as an index buffer. This is a read-only state.
D3D12_RESOURCE_STATE_RENDER_TARGET
Value: 0x4
The resource is used as a render target. A subresource must be in this state when it is rendered to, or when it is cleared with ID3D12GraphicsCommandList::ClearRenderTargetView.

This is a write-only state. To read from a render target as a shader resource, the resource must be in either D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE or D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE.
D3D12_RESOURCE_STATE_UNORDERED_ACCESS
Value: 0x8
The resource is used for unordered access. A subresource must be in this state when it is accessed by the GPU via an unordered access view. A subresource must also be in this state when it is cleared with ID3D12GraphicsCommandList::ClearUnorderedAccessViewInt or ID3D12GraphicsCommandList::ClearUnorderedAccessViewFloat. This is a read/write state.
D3D12_RESOURCE_STATE_DEPTH_WRITE
Value: 0x10
D3D12_RESOURCE_STATE_DEPTH_WRITE is a state that is mutually exclusive with other states. You should use it for ID3D12GraphicsCommandList::ClearDepthStencilView when the flags (see D3D12_CLEAR_FLAGS) indicate a given subresource should be cleared (otherwise the subresource state doesn't matter), or when using it in a writable depth stencil view (see D3D12_DSV_FLAGS) when the PSO has depth write enabled (see D3D12_DEPTH_STENCIL_DESC).
D3D12_RESOURCE_STATE_DEPTH_READ
Value: 0x20
DEPTH_READ is a state that can be combined with other states. It should be used when the subresource is in a read-only depth stencil view, or when depth write of D3D12_DEPTH_STENCIL_DESC is disabled. It can be combined with other read states (for example, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE), such that the 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.
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE
Value: 0x40
The resource is used with a shader other than the pixel shader. A subresource 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 resource in a pixel shader with this flag as long as it also has the flag D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE set. This is a read-only state.
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE
Value: 0x80
The resource is used with a pixel shader. A subresource must be in this state before being read by the pixel shader via a shader resource view. This is a read-only state.
D3D12_RESOURCE_STATE_STREAM_OUT
Value: 0x100
The resource is used with stream output. A subresource must be in this state when it is accessed by the 3D pipeline as a stream-out target. This is a write-only state.
D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT
Value: 0x200
The resource is used as an indirect argument.
Subresources must be in this state when they are used as the argument buffer passed to the indirect drawing method ID3D12GraphicsCommandList::ExecuteIndirect.
This is a read-only state.
D3D12_RESOURCE_STATE_COPY_DEST
Value: 0x400
The resource is used as the destination in a copy operation.
Subresources must be in this state when they are used as the destination of copy operation, or a blt operation.
This is a write-only state.
D3D12_RESOURCE_STATE_COPY_SOURCE
Value: 0x800
The resource is used as the source in a copy operation.
Subresources must be in this state when they are used as the source of copy operation, or a blt operation.
This is a read-only state.
D3D12_RESOURCE_STATE_RESOLVE_DEST
Value: 0x1000
The resource is used as the destination in a resolve operation.
D3D12_RESOURCE_STATE_RESOLVE_SOURCE
Value: 0x2000
The resource is used as the source in a resolve operation.
D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE
Value: 0x400000
When a buffer is created with this as its initial state, it indicates that the resource is a raytracing acceleration structure, for use in ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure, ID3D12GraphicsCommandList4::CopyRaytracingAccelerationStructure, or ID3D12Device::CreateShaderResourceView for the D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE dimension.

NOTE

A resource to be used for the D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE state must be created in that state, and then never transitioned out of it. Nor may a resource that was created not in that state be transitioned into it. For more info, see Acceleration structure memory restrictions in the DirectX raytracing (DXR) functional specification on GitHub.

D3D12_RESOURCE_STATE_SHADING_RATE_SOURCE
Value: 0x1000000
Starting with Windows 10, version 1903 (10.0; Build 18362), indicates that the resource is a screen-space shading-rate image for variable-rate shading (VRS). For more info, see Variable-rate shading (VRS).
D3D12_RESOURCE_STATE_GENERIC_READ
D3D12_RESOURCE_STATE_GENERIC_READ is a logically OR'd combination of other read-state bits. This is the required starting state for an upload heap. Your application should generally avoid transitioning to D3D12_RESOURCE_STATE_GENERIC_READ when possible, since that can result in premature cache flushes, or resource layout changes (for example, compress/decompress), causing unnecessary pipeline stalls. You should instead transition resources only to the actually-used states.
D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE
Equivalent to D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE.
D3D12_RESOURCE_STATE_PRESENT
Value: 0
Synonymous with D3D12_RESOURCE_STATE_COMMON.
D3D12_RESOURCE_STATE_PREDICATION
Value: 0x200
The resource is used for Predication.
D3D12_RESOURCE_STATE_VIDEO_DECODE_READ
Value: 0x10000
The resource is used as a source in a decode operation. Examples include reading the compressed bitstream and reading from decode references,
D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE
Value: 0x20000
The resource is used as a destination in the decode operation. This state is used for decode output and histograms.
D3D12_RESOURCE_STATE_VIDEO_PROCESS_READ
Value: 0x40000
The resource is used to read video data during video processing; that is, the resource is used as the source in a processing operation such as video encoding (compression).
D3D12_RESOURCE_STATE_VIDEO_PROCESS_WRITE
Value: 0x80000
The resource is used to write video data during video processing; that is, the resource is used as the destination in a processing operation such as video encoding (compression).
D3D12_RESOURCE_STATE_VIDEO_ENCODE_READ
Value: 0x200000
The resource is used as the source in an encode operation. This state is used for the input and reference of motion estimation.
D3D12_RESOURCE_STATE_VIDEO_ENCODE_WRITE
Value: 0x800000
This resource is used as the destination in an encode operation. This state is used for the destination texture of a resolve motion vector heap operation.

Remarks

This enum is used by the following methods:

Requirements

Requirement Value
Header d3d12.h

See also