Optimize memory alloc on Animated Model init

This commit is contained in:
Wojtek Figat
2025-06-06 22:41:29 +02:00
parent 091f76bbf2
commit d95cd2f0be
3 changed files with 13 additions and 39 deletions

View File

@@ -38,29 +38,6 @@ void SkinnedMeshDrawData::Setup(int32 bonesCount)
SAFE_DELETE_GPU_RESOURCE(PrevBoneMatrices);
}
void SkinnedMeshDrawData::SetData(const Matrix* bones, bool dropHistory)
{
if (!bones)
return;
ANIM_GRAPH_PROFILE_EVENT("SetSkinnedMeshData");
// Copy bones to the buffer
const int32 count = BonesCount;
const int32 preFetchStride = 2;
const Matrix* input = bones;
const auto output = (Matrix3x4*)Data.Get();
ASSERT(Data.Count() == count * sizeof(Matrix3x4));
for (int32 i = 0; i < count; i++)
{
Matrix3x4* bone = output + i;
Platform::Prefetch(bone + preFetchStride);
Platform::Prefetch((byte*)(bone + preFetchStride) + PLATFORM_CACHE_LINE_SIZE);
bone->SetMatrixTranspose(input[i]);
}
OnDataChanged(dropHistory);
}
void SkinnedMeshDrawData::OnDataChanged(bool dropHistory)
{
// Setup previous frame bone matrices if needed

View File

@@ -69,13 +69,6 @@ public:
/// <param name="bonesCount">The bones count.</param>
void Setup(int32 bonesCount);
/// <summary>
/// Sets the bone matrices data for the GPU buffer. Ensure to call Flush before rendering.
/// </summary>
/// <param name="bones">The bones data.</param>
/// <param name="dropHistory">True if drop previous update bones used for motion blur, otherwise will keep them and do the update.</param>
void SetData(const Matrix* bones, bool dropHistory);
/// <summary>
/// After bones Data has been modified externally. Updates the bone matrices data for the GPU buffer. Ensure to call Flush before rendering.
/// </summary>