DXGI_USAGE Enumeration

Namespace: Microsoft.Directx.DXGI

Header file: dxgi.h

The DXGI_USAGE enumeration specifies how a resource will be accessed by the CPU and GPU.

Syntax

enum DXGI_USAGE {
  DXGI_USAGE_SHADER_INPUT = 0x00000001,
  DXGI_USAGE_RENDER_TARGET_OUTPUT = 0x00000002,
  DXGI_USAGE_BACK_BUFFER = 0x00000004,
  DXGI_USAGE_SHARED = 0x00000008,
  DXGI_USAGE_READ_ONLY = 0x00000010,
  DXGI_USAGE_DISCARD_WRITE = 0x00000020
};

Members

DXGI_USAGE_SHADER_INPUT

The resource will be used as a shader input (e.g., a texture).

DXGI_USAGE_RENDER_TARGET_OUTPUT

The resource will be used as a render target output.

DXGI_USAGE_BACK_BUFFER

The resource will be used as a back buffer.

DXGI_USAGE_SHARED

The resource will be shared between multiple processes.

DXGI_USAGE_READ_ONLY

The resource will be accessed in a read-only manner.

DXGI_USAGE_DISCARD_WRITE

The resource will be written to and then discarded. This can allow for optimizations.

Remarks

The DXGI_USAGE flags are used when creating resources to inform the system about how the resource will be accessed. This information can be used by the graphics driver for performance optimizations.

Multiple flags can be combined using the bitwise OR operator (|) to specify that a resource will be used in multiple ways.

Example Usage

Here's how you might use DXGI_USAGE when creating a swap chain:

// Assume pSwapChainDesc is initialized
pSwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
// ... rest of swap chain description

And when creating a texture that will be used as a shader resource:

// Assume pDesc is initialized for a texture resource
pDesc.Usage = D3D11_USAGE_DEFAULT; // Example using D3D11 usage
pDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
pDesc.CPUAccessFlags = 0;
// DXGI_USAGE is implicitly handled by D3D11_BIND_SHADER_RESOURCE

Requirements

Header dxgi.h
Library dxgi.lib
Minimum supported client Windows 7
Minimum supported server Windows Server 2008 R2