Slate.DumpFontCacheStats
Slate.DumpFontCacheStats
#Overview
name: Slate.DumpFontCacheStats
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Dump statistics about font cache usage.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.DumpFontCacheStats is to enable dumping of statistics about font cache usage in the Unreal Engine’s Slate UI framework.
This setting variable is primarily used in the Slate subsystem, specifically within the font cache management component. It is part of the SlateCore module, which is responsible for core functionality of the Slate UI framework.
The value of this variable is set through the Unreal Engine’s console variable system. It’s defined as an FAutoConsoleVariableRef, which allows it to be changed at runtime through console commands or configuration files.
The Slate.DumpFontCacheStats console variable is directly associated with the boolean variable bDumpFontCacheStats. They share the same value, and bDumpFontCacheStats is used in the actual code logic to determine whether to dump the font cache statistics.
Developers should be aware that this variable is only available in non-shipping builds (#if !UE_BUILD_SHIPPING). It’s primarily used for debugging and performance analysis purposes, not for gameplay or release builds.
When using this variable, best practices include:
- Only enable it when necessary for debugging or performance analysis, as dumping stats may have a performance impact.
- Remember to disable it after use, as the code sets it back to false after dumping the stats.
- Use in conjunction with other font cache-related variables like Slate.FlushFontCache for comprehensive font cache management during development.
Regarding the associated variable bDumpFontCacheStats:
The purpose of bDumpFontCacheStats is to act as an internal flag that controls whether font cache statistics should be dumped.
It’s used within the FSlateFontCache class, specifically in the ConditionalDumpFontCacheStats method. When this flag is true, the method will collect and output detailed statistics about the font cache, including glyph count, pixels used in atlas, and breakdowns by font family and size.
The value of bDumpFontCacheStats is set by the Slate.DumpFontCacheStats console variable, allowing for runtime control.
Developers should be aware that this variable is reset to false after the statistics are dumped, meaning it’s a one-shot operation each time it’s set to true.
Best practices for using bDumpFontCacheStats include:
- Use it in conjunction with profiling tools to understand font cache performance.
- Be aware that frequent dumping of stats may impact performance, so use judiciously.
- Remember that changes to this variable through the console will be reflected in the behavior of the ConditionalDumpFontCacheStats method.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:60
Scope: file
Source code excerpt:
static bool bDumpFontCacheStats = false;
FAutoConsoleVariableRef CVarDumpFontCacheStats(
TEXT("Slate.DumpFontCacheStats"),
bDumpFontCacheStats,
TEXT("Dump statistics about font cache usage."));
static bool bFlushFontCache = false;
FAutoConsoleVariableRef CVarFlushFontCache(
TEXT("Slate.FlushFontCache"),
#Associated Variable and Callsites
This variable is associated with another variable named bDumpFontCacheStats
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:58
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
static bool bDumpFontCacheStats = false;
FAutoConsoleVariableRef CVarDumpFontCacheStats(
TEXT("Slate.DumpFontCacheStats"),
bDumpFontCacheStats,
TEXT("Dump statistics about font cache usage."));
static bool bFlushFontCache = false;
FAutoConsoleVariableRef CVarFlushFontCache(
TEXT("Slate.FlushFontCache"),
bFlushFontCache,
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:1599
Scope (from outer to inner):
file
function void FSlateFontCache::ConditionalDumpFontCacheStats
Source code excerpt:
void FSlateFontCache::ConditionalDumpFontCacheStats() const
{
if (bDumpFontCacheStats)
{
TMap<FFontCacheStatsKey, int> Stats;
// Prepare statistics.
int GlyphCount = 0;
int PixelsUsedInAtlasCount = 0;
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:1675
Scope (from outer to inner):
file
function void FSlateFontCache::ConditionalDumpFontCacheStats
Source code excerpt:
}
bDumpFontCacheStats = false;
}
}
#endif
bool FSlateFontCache::ConditionalFlushCache()
{