DXGI API Reference

Microsoft DirectX Graphics Infrastructure (DXGI)

DXGI provides the following interfaces, enumerations, structures, and functions to manage graphics adapters, presentations, and other low-level graphics operations. #include <dxgi.h>

Interfaces

DXGI interfaces are the primary way to interact with graphics hardware and manage the graphics pipeline.

IDXGIFactory

Represents a DXGI factory, which is used to enumerate adapters and create DXGI objects.

HRESULT CreateDXGIFactory(REFIID riid, void** ppvFactory);

Remarks

Use this function to create a DXGI factory. You can then use the factory to enumerate adapters and perform other factory-level operations.

IDXGIAdapter

Represents a graphics adapter (GPU).

HRESULT EnumAdapters(UINT Adapter, IDXGIAdapter** ppAdapter);

Remarks

Enumerate available graphics adapters. Each adapter represents a physical GPU.

IDXGISwapChain

Represents a swap chain, which is used to present rendered frames to the screen.

HRESULT Present(UINT SyncInterval, UINT Flags);

Remarks

Presents the contents of the next buffer in the swap chain to the user.

Enumerations

DXGI enumerations define various flags and options for graphics operations.

DXGI_FORMAT

Specifies the format of pixel data.

typedef enum DXGI_FORMAT { DXGI_FORMAT_UNKNOWN = 0, DXGI_FORMAT_R8G8B8A8_UNORM = 28, DXGI_FORMAT_B8G8R8A8_UNORM = 87, DXGI_FORMAT_R32_FLOAT = 41, DXGI_FORMAT_D32_FLOAT = 43 // ... other formats } DXGI_FORMAT;

DXGI_USAGE

Specifies the intended usage of a resource.

typedef enum DXGI_USAGE { DXGI_USAGE_SHADER_RESOURCE = 0x00000001, DXGI_USAGE_RENDER_TARGET = 0x00000002, DXGI_USAGE_UNORDERED_ACCESS = 0x00000004, DXGI_USAGE_BACK_BUFFER = 0x00000008, DXGI_USAGE_SHARED = 0x00000010 } DXGI_USAGE;

Structures

DXGI structures provide data for configuring graphics operations.

DXGI_SWAP_CHAIN_DESC

Describes a swap chain.

typedef struct DXGI_SWAP_CHAIN_DESC { DXGI_BUFFER_DESC BufferDesc; DXGI_SAMPLE_DESC SampleDesc; DXGI_USAGE BufferUsage; UINT BufferCount; HWND OutputWindow; BOOL Windowed; DXGI_SWAP_EFFECT SwapEffect; UINT Flags; } DXGI_SWAP_CHAIN_DESC;

Members

  • BufferDesc: Describes the back buffer.
  • SampleDesc: Describes multi-sampling parameters.
  • BufferUsage: Specifies how the back buffer will be used.
  • BufferCount: Number of buffers in the swap chain.
  • OutputWindow: Handle to the output window.
  • Windowed: Whether the swap chain is in windowed mode.
  • SwapEffect: Specifies swap effects.
  • Flags: Flags that modify swap chain behavior.

Functions

DXGI provides several functions for creating and managing graphics resources.

CreateDXGIFactory1

Creates a DXGI factory that can be used to enumerate adapters.

HRESULT CreateDXGIFactory1(REFIID riid, void** ppvFactory);

Remarks

This is a more modern version of CreateDXGIFactory, providing access to additional features.

DXGisimpleGetVersion

Retrieves the DXGI version number.

HRESULT DXGisimpleGetVersion(UINT* pVersion);

Remarks

A simple utility function to check the DXGI runtime version.