IDXGIDevice Interface

DirectX Graphics Infrastructure (DXGI)

IDXGIDevice Interface

Represents a Direct3D device.

Interface Properties

The IDXGIDevice interface inherits from IDXGIObject. It provides methods to query and manage the Direct3D device and its associated adapter.

Methods

The IDXGIDevice interface defines the following methods:

Method Description
GetAdapter Gets the adapter associated with the device.
CreateSurface Creates a surface.
GetDXGISurfacePitch Gets the pitch of a Direct3D surface.
ConvertDXGIFormatToDXGIFormat Converts a DXGI format to another DXGI format.
GetGPUPreferenceTearReportingSupport Gets the GPU preference for tear reporting.

Method Details

GetAdapter

Retrieves the adapter for which the DXGI device was created.

HRESULT GetAdapter(
  [out] IDXGIAdapter **pAdapter
);
  • pAdapter: A pointer to an IDXGIAdapter interface.
Note: This method increments the reference count of the adapter. You must release it when done.

CreateSurface

Creates a new surface that can be used for various Direct3D operations.

HRESULT CreateSurface(
  [in]  const DXGI_SURFACE_DESC *pDesc,
  [in]  UINT NumSurfaces,
  [in]  DXGI_USAGE Usage,
  [in]  const DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
  [out] IDXGISurface **ppSurface
);
  • pDesc: Description of the surface.
  • NumSurfaces: Number of surfaces to create.
  • Usage: Usage flags for the surface.
  • pSwapChainDesc: Optional swap chain description.
  • ppSurface: Pointer to the created surface.

GetDXGISurfacePitch

Gets the pitch (the width of each row in bytes) of a Direct3D surface.

HRESULT GetDXGISurfacePitch(
  [in]  const DXGI_FORMAT Format,
  [out] UINT *pPitch
);
  • Format: The format of the surface.
  • pPitch: The pitch in bytes.

ConvertDXGIFormatToDXGIFormat

Converts a DXGI format to another DXGI format. This is typically used for compatibility or specific hardware features.

HRESULT ConvertDXGIFormatToDXGIFormat(
  [in]  DXGI_FORMAT SrcFormat,
  [in]  DXGI_FORMAT DestFormat,
  [in]  UINT SrcRowPitch,
  [in]  UINT DestRowPitch,
  [out] void *pConvertedData
);
  • SrcFormat: Source format.
  • DestFormat: Destination format.
  • SrcRowPitch: Pitch of the source data.
  • DestRowPitch: Pitch of the destination buffer.
  • pConvertedData: Pointer to the buffer for converted data.
Tip: Use this method cautiously, as some format conversions may involve loss of precision or data.

GetGPUPreferenceTearReportingSupport

Checks if the GPU supports tear reporting.

HRESULT GetGPUPreferenceTearReportingSupport(
  [out] DXGI_QUERY_VIDEO_MEMORY_FRAME_STATISTICS *pStats
);
  • pStats: Pointer to a structure that receives the statistics.

Inheritance Hierarchy

IUnknownIDXGIObjectIDXGIDevice

Requirements

Header Dll
dxgi.h dxgi.dll

Remarks

The IDXGIDevice interface is the primary way to interact with a Direct3D device through DXGI. It allows you to query information about the graphics adapter and create surfaces for rendering. Understanding this interface is crucial for advanced graphics programming in Windows.

Important: Always ensure that you correctly manage the reference counts of objects obtained from DXGI interfaces, especially adapters and surfaces, to prevent memory leaks.