Skip to content

Commit

Permalink
HnRenderDelegateMemoryStats: added pending vertex/index data size
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Nov 7, 2024
1 parent f86525a commit 40dba30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Hydrogent/interface/HnRenderDelegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ struct HnRenderDelegateMemoryStats

/// The number of allcations.
Uint32 AllocationCount = 0;

/// The amount of index data pending upload, in bytes.
Uint64 PendingDataSize = 0;
};
/// Index pool usage statistics.
IndexPoolUsage IndexPool;
Expand All @@ -96,6 +99,9 @@ struct HnRenderDelegateMemoryStats

/// The number of vertices allocated from the pool.
Uint64 AllocatedVertexCount = 0;

/// The amount vertex data pending upload, in bytes.
Uint64 PendingDataSize = 0;
};
/// Vertex pool usage statistics.
VertexPoolUsage VertexPool;
Expand Down Expand Up @@ -468,6 +474,11 @@ class HnRenderDelegate final : public pxr::HdRenderDelegate
Uint32 m_MaterialResourcesVersion = ~0u;
Uint32 m_ShadowAtlasVersion = ~0u;
Uint32 m_LightResourcesVersion = ~0u;

// Amount of index data pending upload before the last call to m_GeometryPool->Commit
Uint64 m_LastPendingIndexDataSize = 0;
// Amount of vertex data pending upload before the last call to m_GeometryPool->Commit
Uint64 m_LastPendingVertexDataSize = 0;
};

} // namespace USD
Expand Down
6 changes: 6 additions & 0 deletions Hydrogent/src/HnRenderDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,11 @@ void HnRenderDelegate::CommitResources(pxr::HdChangeTracker* tracker)
m_ResourceMgr->UpdateIndexBuffer(m_pDevice, m_pContext);

m_TextureRegistry->Commit(m_pContext);

m_LastPendingIndexDataSize = m_GeometryPool->GetPendingIndexDataSize();
m_LastPendingVertexDataSize = m_GeometryPool->GetPendingVertexDataSize();
m_GeometryPool->Commit(m_pContext);

if (m_ShadowMapManager)
{
m_ShadowMapManager->Commit(m_pDevice, m_pContext);
Expand Down Expand Up @@ -825,11 +829,13 @@ HnRenderDelegateMemoryStats HnRenderDelegate::GetMemoryStats() const
MemoryStats.IndexPool.CommittedSize = IndexUsage.CommittedSize;
MemoryStats.IndexPool.UsedSize = IndexUsage.UsedSize;
MemoryStats.IndexPool.AllocationCount = IndexUsage.AllocationCount;
MemoryStats.IndexPool.PendingDataSize = m_LastPendingIndexDataSize;

MemoryStats.VertexPool.CommittedSize = VertexUsage.CommittedMemorySize;
MemoryStats.VertexPool.UsedSize = VertexUsage.UsedMemorySize;
MemoryStats.VertexPool.AllocationCount = VertexUsage.AllocationCount;
MemoryStats.VertexPool.AllocatedVertexCount = VertexUsage.AllocatedVertexCount;
MemoryStats.VertexPool.PendingDataSize = m_LastPendingVertexDataSize;

MemoryStats.Atlas.CommittedSize = AtlasUsage.CommittedSize;
MemoryStats.Atlas.AllocationCount = AtlasUsage.AllocationCount;
Expand Down

0 comments on commit 40dba30

Please sign in to comment.