SlateSdfText.GeneratorPoolSize
SlateSdfText.GeneratorPoolSize
#Overview
name: SlateSdfText.GeneratorPoolSize
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Sets the maximum number of concurrent tasks when generating multi-channel distance fields for Slate text glyphs
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of SlateSdfText.GeneratorPoolSize is to control the maximum number of concurrent tasks when generating multi-channel distance fields for Slate text glyphs in Unreal Engine 5.
This setting variable is primarily used by the Slate rendering system, specifically for the generation of signed distance field (SDF) text. It is part of the SlateCore module, which is responsible for the core functionality of Unreal Engine’s UI framework.
The value of this variable is set through a console variable (CVar) named CVarSlateSdfTextGeneratorPoolSize. It is defined in the SlateSdfGenerator.cpp file within the SlateCore module.
The associated variable CVarSlateSdfTextGeneratorPoolSize directly interacts with SlateSdfText.GeneratorPoolSize. They share the same value and purpose.
Developers must be aware of the following when using this variable:
- The default value is set to 1, but it can be changed at runtime through the console or configuration files.
- If the value is set to 0 or a negative number, the system will use the number of worker threads available on the platform instead.
- Changing this value affects the performance and resource usage of the SDF text generation system.
Best practices when using this variable include:
- Adjusting the value based on the target hardware capabilities and the game’s text rendering requirements.
- Monitoring performance metrics to find the optimal balance between resource usage and text generation speed.
- Consider increasing the value on systems with more available cores or threads.
Regarding the associated variable CVarSlateSdfTextGeneratorPoolSize:
The purpose of CVarSlateSdfTextGeneratorPoolSize is to provide a programmatic way to access and modify the SlateSdfText.GeneratorPoolSize setting.
This variable is used within the FSlateSdfGeneratorImpl class, which is part of the SDF text generation system in the SlateCore module.
The value of CVarSlateSdfTextGeneratorPoolSize is set when the console variable is initialized, and it can be modified at runtime using console commands.
It directly interacts with the SlateSdfText.GeneratorPoolSize setting, as they represent the same value.
Developers should be aware that:
- Changes to this variable will trigger the UpdatePoolSize() function in FSlateSdfGeneratorImpl.
- The actual pool size may not decrease even if a lower value is set, as the pool can only be enlarged, not shrunk.
Best practices for using CVarSlateSdfTextGeneratorPoolSize include:
- Using it for dynamic adjustments of the generator pool size during development or debugging.
- Considering performance implications when modifying this value, especially in shipping builds.
- Documenting any custom values used in different scenarios to maintain consistency across the development team.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/SlateSdfGenerator.cpp:24
Scope: file
Source code excerpt:
#define MAX_GLYPH_SDF_SIDE 4096
static TAutoConsoleVariable<int32> CVarSlateSdfTextGeneratorPoolSize(TEXT("SlateSdfText.GeneratorPoolSize"), 1, TEXT("Sets the maximum number of concurrent tasks when generating multi-channel distance fields for Slate text glyphs"));
// Corners with an angle greater than 3 radians (~171 degrees) won't be treated as corners.
static constexpr double SDF_CORNER_ANGLE_THRESHOLD = 3.0;
// When a corner's angle tends towards zero, the size of its miter tends toward infinity. The miter limit filters extreme cases from being included in bounds.
static constexpr double SDF_BOUNDS_MITER_LIMIT = 1.0;
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/SlateSdfGenerator.cpp:521
Scope (from outer to inner):
file
class class FSlateSdfGeneratorImpl : public FSlateSdfGenerator
Source code excerpt:
FAutoConsoleVariableSink PoolSizeChangeSink;
/** Enlarges the pool size according to the new value of the SlateSdfText.GeneratorPoolSize CVar. The pool cannot be shrinked and if the new value is lower, this will have no effect and false will be returned. */
bool UpdatePoolSize();
};
FSlateSdfGeneratorImpl::FSlateSdfGeneratorImpl() :
PoolSizeChangeSink(FConsoleCommandDelegate::CreateLambda([this]()
#Associated Variable and Callsites
This variable is associated with another variable named CVarSlateSdfTextGeneratorPoolSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/SlateSdfGenerator.cpp:24
Scope: file
Source code excerpt:
#define MAX_GLYPH_SDF_SIDE 4096
static TAutoConsoleVariable<int32> CVarSlateSdfTextGeneratorPoolSize(TEXT("SlateSdfText.GeneratorPoolSize"), 1, TEXT("Sets the maximum number of concurrent tasks when generating multi-channel distance fields for Slate text glyphs"));
// Corners with an angle greater than 3 radians (~171 degrees) won't be treated as corners.
static constexpr double SDF_CORNER_ANGLE_THRESHOLD = 3.0;
// When a corner's angle tends towards zero, the size of its miter tends toward infinity. The miter limit filters extreme cases from being included in bounds.
static constexpr double SDF_BOUNDS_MITER_LIMIT = 1.0;
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/SlateSdfGenerator.cpp:549
Scope (from outer to inner):
file
function bool FSlateSdfGeneratorImpl::UpdatePoolSize
Source code excerpt:
if (IsSlateSdfTextFeatureEnabled())
{
PoolSize = CVarSlateSdfTextGeneratorPoolSize.GetValueOnGameThread();
if (PoolSize <= 0)
{
PoolSize = FGenericPlatformMisc::NumberOfWorkerThreadsToSpawn();
}
}
int32 OldPoolSize = TasksPool.Num();