Optimize Global SDF cascades updates intervals (max 1 cascade per frame)

This commit is contained in:
Wojtek Figat
2022-11-01 00:37:01 +01:00
parent 5f4aa39263
commit ec62763e87
3 changed files with 108 additions and 3 deletions

View File

@@ -108,6 +108,17 @@ public:
const uint32 distanceI = *((uint32*)&distance);
return ((uint32)(-(int32)(distanceI >> 31)) | 0x80000000) ^ distanceI;
}
// Calculates the update frequency and phrase for the given cached data (eg. cascaded shadow map or global sdf cascade contents). Lower data indices are updated first and more frequent.
static void ComputeCascadeUpdateFrequency(int32 cascadeIndex, int32 cascadeCount, int32& updateFrequency, int32& updatePhrase, int32 updateMaxCountPerFrame = 1);
// Checks if cached data should be updated during the given frame.
FORCE_INLINE static bool ShouldUpdateCascade(int32 frameIndex, int32 cascadeIndex, int32 cascadeCount, int32 updateMaxCountPerFrame = 1, bool updateForce = false)
{
int32 updateFrequency, updatePhrase;
ComputeCascadeUpdateFrequency(cascadeIndex, cascadeCount, updateFrequency, updatePhrase, updateMaxCountPerFrame);
return (frameIndex % updateFrequency == updatePhrase) || updateForce;
}
};
// Calculate mip levels count for a texture 1D