Skip to content

Commit

Permalink
Hydrogent: added render delegate memory usage stats
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Nov 20, 2023
1 parent fb218df commit 25da900
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Hydrogent/interface/HnRenderDelegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,43 @@ class HnMesh;
class HnLight;
class HnRenderParam;

/// Memory usage statistics of the render delegate.
struct HnRenderDelegateMemoryStats
{
/// Index pool usage statistics.
struct IndexPoolUsage
{
/// The total committed memory size, in bytes.
Uint64 CommittedSize = 0;

/// The total memory size used by all allocations, in bytes.
Uint64 UsedSize = 0;

/// The number of allcations.
Uint32 AllocationCount = 0;
};
/// Index pool usage statistics.
IndexPoolUsage IndexPool;

/// Vertex pool usage statistics.
struct VertexPoolUsage
{
/// The total committed memory size, in bytes.
Uint64 CommittedSize = 0;

/// The total memory size used by all allocations, in bytes.
Uint64 UsedSize = 0;

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

/// The number of vertices allocated from the pool.
Uint64 AllocatedVertexCount = 0;
};
/// Vertex pool usage statistics.
VertexPoolUsage VertexPool;
};

/// USD render delegate implementation in Hydrogent.
class HnRenderDelegate final : public pxr::HdRenderDelegate
{
Expand Down Expand Up @@ -213,6 +250,8 @@ class HnRenderDelegate final : public pxr::HdRenderDelegate

const auto& GetLights() const { return m_Lights; }

HnRenderDelegateMemoryStats GetMemoryStats() const;

private:
static const pxr::TfTokenVector SupportedRPrimTypes;
static const pxr::TfTokenVector SupportedSPrimTypes;
Expand Down
19 changes: 19 additions & 0 deletions Hydrogent/src/HnRenderDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,25 @@ const pxr::SdfPath* HnRenderDelegate::GetRPrimId(Uint32 UID) const
return it != m_RPrimUIDToSdfPath.end() ? &it->second : nullptr;
}

HnRenderDelegateMemoryStats HnRenderDelegate::GetMemoryStats() const
{
HnRenderDelegateMemoryStats MemoryStats;

const BufferSuballocatorUsageStats IndexUsage = m_ResourceMgr->GetIndexBufferUsageStats();
const VertexPoolUsageStats VertexUsage = m_ResourceMgr->GetVertexPoolUsageStats();

MemoryStats.IndexPool.CommittedSize = IndexUsage.CommittedSize;
MemoryStats.IndexPool.UsedSize = IndexUsage.UsedSize;
MemoryStats.IndexPool.AllocationCount = IndexUsage.AllocationCount;

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

return MemoryStats;
}

} // namespace USD

} // namespace Diligent

0 comments on commit 25da900

Please sign in to comment.