r.D3D11.Depth24Bit
r.D3D11.Depth24Bit
#Overview
name: r.D3D11.Depth24Bit
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.D3D11.Depth24Bit is to control the depth buffer format in DirectX 11 rendering. It allows developers to choose between a 32-bit float depth buffer and a 24-bit fixed point depth buffer.
This setting variable is primarily used by the DirectX 11 RHI (Rendering Hardware Interface) subsystem in Unreal Engine 5. It is specifically utilized in the D3D11RHI module, which handles DirectX 11 rendering implementation.
The value of this variable is set through a console variable (CVarD3D11UseD24) defined in the D3D11Device.cpp file. It is initialized with a default value of 0, which means it uses a 32-bit float depth buffer by default.
The associated variable CVarD3D11UseD24 interacts directly with r.D3D11.Depth24Bit. They share the same value and purpose, with CVarD3D11UseD24 being the actual console variable implementation in the engine’s code.
Developers must be aware that this variable is marked as ECVF_ReadOnly, meaning its value cannot be changed at runtime. It should be set before the engine initializes the rendering system.
Best practices when using this variable include:
- Consider the trade-offs between precision (32-bit float) and memory usage (24-bit fixed point) when choosing the depth buffer format.
- Ensure consistency across your project by setting this variable early in the initialization process.
- Be aware that changing this setting may affect the behavior of depth-dependent rendering features and post-processing effects.
Regarding the associated variable CVarD3D11UseD24:
- Its purpose is identical to r.D3D11.Depth24Bit, serving as the actual console variable implementation.
- It is used in the D3D11RHI module to determine the depth buffer format during device initialization.
- The value is set through the console variable system and is read during the FD3D11DynamicRHI constructor.
- It directly affects the PlatformFormat and BlockBytes values for PF_DepthStencil and PF_X24_G8 pixel formats.
- Developers should be aware that this variable’s value is checked during the RHI initialization, so any changes after that point will not take effect.
- Best practices include setting this variable in engine configuration files or very early in the application’s startup process to ensure consistent behavior throughout the engine’s lifecycle.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:1223, section: [HoloLens DeviceProfile]
- INI Section:
HoloLens DeviceProfile
- Raw value:
1
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11Device.cpp:25
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarD3D11UseD24(
TEXT("r.D3D11.Depth24Bit"),
0,
TEXT("0: Use 32-bit float depth buffer\n1: Use 24-bit fixed point depth buffer(default)\n"),
ECVF_ReadOnly
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarD3D11UseD24
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/RHISurfaceDataConversion.h:825
Scope (from outer to inner):
file
function static bool ConvertRAWSurfaceDataToFLinearColor
Source code excerpt:
)
{
// see CVarD3D11UseD24/CVarD3D12UseD24
ConvertRawR24G8DataToFLinearColor(Width, Height, In, SrcPitch, Out, InFlags);
return true;
}
else if ( (Format == PF_X24_G8 || Format == PF_DepthStencil ) && GPixelFormats[Format].BlockBytes > 4 )
{
// @@ D3D 11/12 different?
#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11Device.cpp:24
Scope: file
Source code excerpt:
IMPLEMENT_MODULE(FD3D11DynamicRHIModule, D3D11RHI);
static TAutoConsoleVariable<int32> CVarD3D11UseD24(
TEXT("r.D3D11.Depth24Bit"),
0,
TEXT("0: Use 32-bit float depth buffer\n1: Use 24-bit fixed point depth buffer(default)\n"),
ECVF_ReadOnly
);
#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11Device.cpp:106
Scope (from outer to inner):
file
function FD3D11DynamicRHI::FD3D11DynamicRHI
Source code excerpt:
GPixelFormats[ PF_BC4 ].PlatformFormat = DXGI_FORMAT_BC4_UNORM;
GPixelFormats[ PF_UYVY ].PlatformFormat = DXGI_FORMAT_UNKNOWN; // TODO: Not supported in D3D11
if (CVarD3D11UseD24.GetValueOnAnyThread())
{
GPixelFormats[PF_DepthStencil].PlatformFormat = DXGI_FORMAT_R24G8_TYPELESS;
GPixelFormats[PF_DepthStencil].BlockBytes = 4;
GPixelFormats[PF_DepthStencil].bIs24BitUnormDepthStencil = true;
GPixelFormats[PF_X24_G8].PlatformFormat = DXGI_FORMAT_X24_TYPELESS_G8_UINT;
GPixelFormats[PF_X24_G8].BlockBytes = 4;