Hello everyone,
I’m working on optimizing my game’s performance and would like to partition the PSO cache. Instead of compiling the entire cache during the game’s startup, I want to compile only the portion of the cache that’s specific to the level being loaded.
I found here
https://dev.epicgames.com/documentation/en-us/unreal-engine/optimizing-rendering-with-pso-caches-in-unreal-engine?application_version=5.1#partitioningthecache
that it’s possible using the function
FShaderPipelineCache::SetGameUsageMaskWithComparison(GameMask)
but this function is not available in UE 5.1 with only 1 param, it requires 2.
The second param has to be a function pointer.
So I wrote this function:
static TAutoConsoleVariable<int32> CVarPSOFileCacheGameFileMaskEnabled(
TEXT("r.ShaderPipelineCache.GameFileMaskEnabled"),
(int32)0,
TEXT("Set non zero to use GameFileMask during PSO precompile - recording should always save out the usage masks to make that data availble when needed."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
bool UPsoBitmaskHelper::PreCompileMaskComparison(uint64 ReferenceGameMask, uint64 PSOMask)
{
uint64 UsageMask = (ReferenceGameMask & PSOMask);
UE_LOG(LogTemp, Warning, TEXT("PSO ReferenceGameMask: %llu"), ReferenceGameMask);
return ReferenceGameMask == PSOMask;
}
in my function library.
I’m also calling SetGameUsageMaskWithComparison() before loading any level and at the game start, before running the PSO compile (triggered with this piece of code in a black level at the start of the game, hidden by the splash screen)
FShaderPipelineCache::SetBatchMode(FShaderPipelineCache::BatchMode::Precompile);
FShaderPipelineCache::ResumeBatching();
The code is compiling and the game is running fine, but all the PSO are being compiled at the start of the game…
Any guidance, documentation references, or examples would be greatly appreciated!
Thanks in advance!