r.UniformBufferPooling
r.UniformBufferPooling
#Overview
name: r.UniformBufferPooling
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If we pool object in RHICreateUniformBuffer to have less real API calls to create buffers\n 0: off (for debugging)\n 1: on (optimization)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.UniformBufferPooling is to control the optimization of uniform buffer creation in the rendering system of Unreal Engine 5. It determines whether the engine should pool objects in the RHICreateUniformBuffer process to reduce the number of actual API calls for buffer creation.
This setting variable is primarily used by the rendering subsystem, specifically in the OpenGL and Direct3D 11 (D3D11) rendering modules. It’s referenced in the OpenGLDrv and D3D11RHI modules, which are responsible for interfacing with these graphics APIs.
The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable with a default value of 1 (enabled), but can be changed at runtime through console commands or configuration files.
The r.UniformBufferPooling variable interacts with the uniform buffer creation process. When enabled, it allows the engine to reuse previously allocated uniform buffers instead of creating new ones for each request, potentially improving performance.
Developers should be aware that this variable is intended for optimization purposes. Disabling it (setting to 0) might be useful for debugging, but could impact rendering performance in normal gameplay scenarios.
Best practices when using this variable include:
- Leaving it enabled (default value of 1) for production builds to benefit from the optimization.
- Only disabling it temporarily when debugging specific uniform buffer-related issues.
- Being cautious about changing its value during runtime, as it could affect rendering performance and behavior.
- Considering the impact on different platforms, as the implementation may vary between OpenGL and D3D11.
When modifying this variable, developers should test thoroughly across different scenarios and platforms to ensure consistent behavior and performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3450
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarUniformBufferPooling(
TEXT("r.UniformBufferPooling"),
1,
TEXT("If we pool object in RHICreateUniformBuffer to have less real API calls to create buffers\n"
" 0: off (for debugging)\n"
" 1: on (optimization)"),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLUniformBuffer.cpp:334
Scope (from outer to inner):
file
function static bool IsPoolingEnabled
Source code excerpt:
static bool IsPoolingEnabled()
{
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.UniformBufferPooling"));
int32 CVarValue = IsInParallelRenderingThread() ? CVar->GetValueOnRenderThread() : CVar->GetValueOnGameThread();
return CVarValue != 0;
};
struct TUBOPoolBuffer
{
#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11UniformBuffer.cpp:105
Scope (from outer to inner):
file
function static bool IsPoolingEnabled
Source code excerpt:
static bool IsPoolingEnabled()
{
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.UniformBufferPooling"));
int32 CVarValue = CVar->GetValueOnAnyThread();
return CVarValue != 0;
};
static TRefCountPtr<ID3D11Buffer> CreateAndUpdatePooledUniformBuffer(
FD3D11Device* Device,