Skip to content

Caching the AnimToTexture Data Asset to double vertex anim processor performance #24

@Voyager0001

Description

@Voyager0001

not calling LoadSynchronous() for every entity every frame and instead calling it once every chunk increases performance from 20 to 35 fps for 20k entities for me

So something like

UAnimToTextureDataAsset* CachedAsset = nullptr;
TSoftObjectPtr<UAnimToTextureDataAsset> CachedSoftAsset;
TMap<int32, FAnimToTextureAutoPlayData> PlayDataCache;

for (int EntityIdx = 0; EntityIdx < NumEntities; EntityIdx++)


if (VertexAnimInfoFragment.AnimToTextureData != CachedSoftAsset)
{
				CachedSoftAsset = VertexAnimInfoFragment.AnimToTextureData;
				CachedAsset = CachedSoftAsset.LoadSynchronous();
				PlayDataCache.Reset();
}

if (CachedAsset)
{
				FAnimToTextureAutoPlayData* PlayDataPtr = PlayDataCache.Find(AnimIndex);
				if (!PlayDataPtr)
				{
								FAnimToTextureAutoPlayData NewPlayData;
								if (UAnimToTextureInstancePlaybackLibrary::GetAutoPlayDataFromDataAsset(CachedAsset, AnimIndex, NewPlayData))
								{
									PlayDataPtr = &PlayDataCache.Add(VertexAnimInfoFragment.AnimationStateIndex, NewPlayData);
								}
				}

				if (PlayDataPtr)
				{
								ISMInfo.AddBatchedCustomData<FAnimToTextureAutoPlayData>(*PlayDataPtr, RepresentationLODFragment.LODSignificance, RepresentationFragment.PrevLODSignificance, 0);
				}```


Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions