Microsoft Docs

IDXGIDebug Interface

The IDXGIDebug interface is used to debug Direct3D 10, Direct3D 11, and Direct3D 12 objects.

Methods

This interface supports the following methods:

Method Description
EnableDebugLayer Enables the Direct3D debug layer.
ReportLiveObjects Reports live objects.

Remarks

The IDXGIDebug interface is an extension to the core DXGI interfaces and is primarily used for diagnostic purposes during application development. It allows developers to gain insights into the lifetime and state of DXGI objects, helping to identify potential memory leaks or incorrect usage.

To obtain an instance of the IDXGIDebug interface, you typically use functions like DXGIGetDebugInterface.

Note: The debug layer should only be enabled in debug builds of your application. It can incur a performance overhead.

EnableDebugLayer Method

Syntax

HRESULT EnableDebugLayer();

Parameters

This method has no parameters.

Return Value

Returns one of the following DXGI or HRESULT error codes:

  • DXGI_OK if the debug layer was successfully enabled.
  • E_FAIL if the debug layer could not be enabled.

Remarks

Call this method to enable the Direct3D debug layer. This allows for more detailed error reporting and object tracking.

ReportLiveObjects Method

Syntax

HRESULT ReportLiveObjects(
  REFIID    Interface,
  UINT      Flags
);

Parameters

Interface [in]
A GUID that specifies the interface to query for live objects. For example, __uuidof(IDXGISwapChain).
Flags [in]
A value that specifies how to report live objects. Currently, only 0 is supported.

Return Value

Returns one of the following DXGI or HRESULT error codes:

  • DXGI_OK if the report was generated successfully.
  • E_FAIL if there was an error generating the report.

Remarks

This method enumerates all live objects of a specified interface type and prints their information to the debug output. This is invaluable for tracking down object leaks.

Tip: You can use this method periodically during your application's execution to check for any unintended object leaks.

Example


#include <dxgi1_2.h> // Or appropriate DXGI header

// Assume pDXGIDebug is a valid IDXGIDebug interface pointer

HRESULT hr = pDXGIDebug->ReportLiveObjects(
    __uuidof(IDXGISwapChain),
    0
);

if (FAILED(hr)) {
    // Handle error
}
                

See Also