UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
D3D11Util.cpp File Reference
#include "D3D11Util.h"
#include "D3D11RHIPrivate.h"
#include "EngineModule.h"
#include "Engine/GameEngine.h"
#include "RendererInterface.h"
#include "ProfilingDebugging/ScopedDebugInfo.h"
#include "HAL/ExceptionHandling.h"

Macros

#define D3DERR(x)   case x: ErrorCodeText = TEXT(#x); break;
 
#define LOCTEXT_NAMESPACE   "Developer.MessageLog"
 

Functions

void SetD3D11ObjectName (ID3D11DeviceChild *Object, FAnsiStringView Name)
 
void SetD3D11ObjectName (ID3D11DeviceChild *Object, FStringView Name)
 
void SetD3D11ResourceName (FD3D11Texture *Texture, FStringView Name)
 
void SetD3D11ResourceName (FD3D11Buffer *Buffer, FStringView Name)
 
void SetD3D11ResourceName (FD3D11UnorderedAccessView *UAV, FStringView Name)
 
FString GetD3D11ErrorString (HRESULT ErrorCode, ID3D11Device *Device)
 
void GetAndLogMemoryStats (const FD3D11Adapter &InAdapter, uint64 &OutVRAMBudgetBytes, uint64 &OutVRAMUsageBytes)
 
void VerifyD3D11ResultNoExit (HRESULT D3DResult, const ANSICHAR *Code, const ANSICHAR *Filename, uint32 Line, ID3D11Device *Device)
 
void VerifyD3D11Result (HRESULT D3DResult, const ANSICHAR *Code, const ANSICHAR *Filename, uint32 Line, ID3D11Device *Device)
 
void VerifyD3D11ShaderResult (FRHIShader *Shader, HRESULT D3DResult, const ANSICHAR *Code, const ANSICHAR *Filename, uint32 Line, ID3D11Device *Device)
 
void VerifyD3D11CreateTextureResult (HRESULT D3DResult, int32 UEFormat, const ANSICHAR *Code, const ANSICHAR *Filename, uint32 Line, uint32 SizeX, uint32 SizeY, uint32 SizeZ, uint8 D3DFormat, uint32 NumMips, uint32 Flags, D3D11_USAGE Usage, uint32 CPUAccessFlags, uint32 MiscFlags, uint32 SampleCount, uint32 SampleQuality, const void *SubResPtr, uint32 SubResPitch, uint32 SubResSlicePitch, ID3D11Device *Device, const TCHAR *DebugName)
 
void VerifyD3D11ResizeViewportResult (HRESULT D3DResult, const ANSICHAR *Code, const ANSICHAR *Filename, uint32 Line, const FD3D11ResizeViewportState &OldState, const FD3D11ResizeViewportState &NewState, ID3D11Device *Device)
 
void VerifyD3D11CreateViewResult (HRESULT D3DResult, const ANSICHAR *Code, const ANSICHAR *Filename, uint32 Line, ID3D11Device *Device, const FString &ResourceName, const D3D11_UNORDERED_ACCESS_VIEW_DESC &Desc)
 
void VerifyD3D11CreateViewResult (HRESULT D3DResult, const ANSICHAR *Code, const ANSICHAR *Filename, uint32 Line, ID3D11Device *Device, FRHITexture *Texture, const D3D11_UNORDERED_ACCESS_VIEW_DESC &Desc)
 
void VerifyD3D11CreateViewResult (HRESULT D3DResult, const ANSICHAR *Code, const ANSICHAR *Filename, uint32 Line, ID3D11Device *Device, FRHIBuffer *Buffer, const D3D11_UNORDERED_ACCESS_VIEW_DESC &Desc)
 
void VerifyComRefCount (IUnknown *Object, int32 ExpectedRefs, const TCHAR *Code, const TCHAR *Filename, int32 Line)
 
 DEFINE_STAT (STAT_D3D11PresentTime)
 
 DEFINE_STAT (STAT_D3D11CustomPresentTime)
 
 DEFINE_STAT (STAT_D3D11TexturesAllocated)
 
 DEFINE_STAT (STAT_D3D11TexturesReleased)
 
 DEFINE_STAT (STAT_D3D11ClearShaderResourceTime)
 
 DEFINE_STAT (STAT_D3D11CreateTextureTime)
 
 DEFINE_STAT (STAT_D3D11LockTextureTime)
 
 DEFINE_STAT (STAT_D3D11UnlockTextureTime)
 
 DEFINE_STAT (STAT_D3D11CopyTextureTime)
 
 DEFINE_STAT (STAT_D3D11NewBoundShaderStateTime)
 
 DEFINE_STAT (STAT_D3D11CreateBoundShaderStateTime)
 
 DEFINE_STAT (STAT_D3D11CleanUniformBufferTime)
 
 DEFINE_STAT (STAT_D3D11UpdateUniformBufferTime)
 
 DEFINE_STAT (STAT_D3D11TexturePoolMemory)
 
 DEFINE_STAT (STAT_D3D11FreeUniformBufferMemory)
 
 DEFINE_STAT (STAT_D3D11NumFreeUniformBuffers)
 
 DEFINE_STAT (STAT_D3D11NumImmutableUniformBuffers)
 
 DEFINE_STAT (STAT_D3D11NumBoundShaderState)
 
 DEFINE_STAT (STAT_D3D11RenderTargetCommits)
 
 DEFINE_STAT (STAT_D3D11RenderTargetCommitsUAV)
 

Variables

CORE_API bool GIsGPUCrashed
 

Macro Definition Documentation

◆ D3DERR

#define D3DERR (   x)    case x: ErrorCodeText = TEXT(#x); break;

◆ LOCTEXT_NAMESPACE

#define LOCTEXT_NAMESPACE   "Developer.MessageLog"

Function Documentation

◆ DEFINE_STAT() [1/20]

◆ DEFINE_STAT() [2/20]

◆ DEFINE_STAT() [3/20]

DEFINE_STAT ( STAT_D3D11CopyTextureTime  )

◆ DEFINE_STAT() [4/20]

◆ DEFINE_STAT() [5/20]

DEFINE_STAT ( STAT_D3D11CreateTextureTime  )

◆ DEFINE_STAT() [6/20]

DEFINE_STAT ( STAT_D3D11CustomPresentTime  )

◆ DEFINE_STAT() [7/20]

◆ DEFINE_STAT() [8/20]

DEFINE_STAT ( STAT_D3D11LockTextureTime  )

◆ DEFINE_STAT() [9/20]

◆ DEFINE_STAT() [10/20]

DEFINE_STAT ( STAT_D3D11NumBoundShaderState  )

◆ DEFINE_STAT() [11/20]

◆ DEFINE_STAT() [12/20]

◆ DEFINE_STAT() [13/20]

DEFINE_STAT ( STAT_D3D11PresentTime  )

◆ DEFINE_STAT() [14/20]

DEFINE_STAT ( STAT_D3D11RenderTargetCommits  )

◆ DEFINE_STAT() [15/20]

◆ DEFINE_STAT() [16/20]

DEFINE_STAT ( STAT_D3D11TexturePoolMemory  )

◆ DEFINE_STAT() [17/20]

DEFINE_STAT ( STAT_D3D11TexturesAllocated  )

◆ DEFINE_STAT() [18/20]

DEFINE_STAT ( STAT_D3D11TexturesReleased  )

◆ DEFINE_STAT() [19/20]

DEFINE_STAT ( STAT_D3D11UnlockTextureTime  )

◆ DEFINE_STAT() [20/20]

◆ GetAndLogMemoryStats()

void GetAndLogMemoryStats ( const FD3D11Adapter InAdapter,
uint64 OutVRAMBudgetBytes,
uint64 OutVRAMUsageBytes 
)

◆ GetD3D11ErrorString()

FString GetD3D11ErrorString ( HRESULT  ErrorCode,
ID3D11Device Device 
)

Returns a string for the provided error code, can include device removed information if the device is provided.

◆ SetD3D11ObjectName() [1/2]

void SetD3D11ObjectName ( ID3D11DeviceChild Object,
FAnsiStringView  Name 
)

◆ SetD3D11ObjectName() [2/2]

void SetD3D11ObjectName ( ID3D11DeviceChild Object,
FStringView  Name 
)

◆ SetD3D11ResourceName() [1/3]

void SetD3D11ResourceName ( FD3D11Buffer Buffer,
FStringView  Name 
)

◆ SetD3D11ResourceName() [2/3]

void SetD3D11ResourceName ( FD3D11Texture Texture,
FStringView  Name 
)

◆ SetD3D11ResourceName() [3/3]

void SetD3D11ResourceName ( FD3D11UnorderedAccessView UAV,
FStringView  Name 
)

◆ VerifyComRefCount()

void VerifyComRefCount ( IUnknown Object,
int32  ExpectedRefs,
const TCHAR Code,
const TCHAR Filename,
int32  Line 
)

Checks that a COM object has the expected number of references.

◆ VerifyD3D11CreateTextureResult()

void VerifyD3D11CreateTextureResult ( HRESULT  D3DResult,
int32  UEFormat,
const ANSICHAR Code,
const ANSICHAR Filename,
uint32  Line,
uint32  SizeX,
uint32  SizeY,
uint32  SizeZ,
uint8  D3DFormat,
uint32  NumMips,
uint32  Flags,
D3D11_USAGE  Usage,
uint32  CPUAccessFlags,
uint32  MiscFlags,
uint32  SampleCount,
uint32  SampleQuality,
const void SubResPtr,
uint32  SubResPitch,
uint32  SubResSlicePitch,
ID3D11Device Device,
const TCHAR DebugName 
)

Checks that the given result isn't a failure. If it is, the application exits with an appropriate error message.

Parameters
Result- The result code to check
Code- The code which yielded the result.
Filename- The filename of the source file containing Code.
Line- The line number of Code within Filename.

◆ VerifyD3D11CreateViewResult() [1/3]

void VerifyD3D11CreateViewResult ( HRESULT  D3DResult,
const ANSICHAR Code,
const ANSICHAR Filename,
uint32  Line,
ID3D11Device Device,
const FString &  ResourceName,
const D3D11_UNORDERED_ACCESS_VIEW_DESC Desc 
)

◆ VerifyD3D11CreateViewResult() [2/3]

void VerifyD3D11CreateViewResult ( HRESULT  D3DResult,
const ANSICHAR Code,
const ANSICHAR Filename,
uint32  Line,
ID3D11Device Device,
FRHIBuffer Buffer,
const D3D11_UNORDERED_ACCESS_VIEW_DESC Desc 
)

◆ VerifyD3D11CreateViewResult() [3/3]

void VerifyD3D11CreateViewResult ( HRESULT  D3DResult,
const ANSICHAR Code,
const ANSICHAR Filename,
uint32  Line,
ID3D11Device Device,
FRHITexture Texture,
const D3D11_UNORDERED_ACCESS_VIEW_DESC Desc 
)

◆ VerifyD3D11ResizeViewportResult()

void VerifyD3D11ResizeViewportResult ( HRESULT  D3DResult,
const ANSICHAR Code,
const ANSICHAR Filename,
uint32  Line,
const FD3D11ResizeViewportState OldState,
const FD3D11ResizeViewportState NewState,
ID3D11Device Device 
)

◆ VerifyD3D11Result()

void VerifyD3D11Result ( HRESULT  Result,
const ANSICHAR Code,
const ANSICHAR Filename,
uint32  Line,
ID3D11Device Device 
)

Checks that the given result isn't a failure. If it is, the application exits with an appropriate error message.

Parameters
Result- The result code to check.
Code- The code which yielded the result.
Filename- The filename of the source file containing Code.
Line- The line number of Code within Filename.

◆ VerifyD3D11ResultNoExit()

void VerifyD3D11ResultNoExit ( HRESULT  Result,
const ANSICHAR Code,
const ANSICHAR Filename,
uint32  Line,
ID3D11Device Device 
)

Checks that the given result isn't a failure. If it is, the application does not exit and only logs an appropriate error message.

Parameters
Result- The result code to check.
Code- The code which yielded the result.
Filename- The filename of the source file containing Code.
Line- The line number of Code within Filename.

◆ VerifyD3D11ShaderResult()

void VerifyD3D11ShaderResult ( class FRHIShader Shader,
HRESULT  Result,
const ANSICHAR Code,
const ANSICHAR Filename,
uint32  Line,
ID3D11Device Device 
)

Checks that the given result isn't a failure. If it is, the application exits with an appropriate error message.

Parameters
Shader- The shader we are trying to create.
Result- The result code to check.
Code- The code which yielded the result.
Filename- The filename of the source file containing Code.
Line- The line number of Code within Filename.
Device- The D3D device used to create the shader.

Variable Documentation

◆ GIsGPUCrashed

CORE_API bool GIsGPUCrashed
extern