Skip to content

Commit 456d244

Browse files
USD Viewer: added task execution time to render stats
1 parent 1901869 commit 456d244

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Samples/USDViewer/src/USDViewer.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#include "AdvancedMath.hpp"
3737
#include "PBR_Renderer.hpp"
3838
#include "FileSystem.hpp"
39+
#include "Timer.hpp"
40+
3941
#include "Tasks/HnReadRprimIdTask.hpp"
4042
#include "Tasks/HnRenderAxesTask.hpp"
4143
#include "HnTokens.hpp"
@@ -330,6 +332,8 @@ void USDViewer::Render()
330332
if (!m_Stage)
331333
return;
332334

335+
Timer Stowatch;
336+
333337
m_Stage.Camera->SetViewMatrix(m_CameraView);
334338
m_Stage.Camera->SetProjectionMatrix(m_CameraProj);
335339

@@ -358,6 +362,8 @@ void USDViewer::Render()
358362
m_Stats.NumTriangles = CtxStats.GetTotalTriangleCount();
359363
m_Stats.NumLines = CtxStats.GetTotalLineCount();
360364
m_Stats.NumPoints = CtxStats.GetTotalPointCount();
365+
366+
m_Stats.TaskRunTime = static_cast<float>(Stowatch.GetElapsedTime()) * 0.05f + m_Stats.TaskRunTime * 0.95f;
361367
}
362368

363369
void USDViewer::PopulateSceneTree(const pxr::UsdPrim& Prim)
@@ -687,7 +693,8 @@ void USDViewer::UpdateUI()
687693
if (ImGui::BeginTabItem("Stats"))
688694
{
689695
const auto MemoryStats = m_Stage.RenderDelegate->GetMemoryStats();
690-
ImGui::TextDisabled("Num draws\n"
696+
ImGui::TextDisabled("Task time\n"
697+
"Num draws\n"
691698
"Tris\n"
692699
"Lines\n"
693700
"Points\n"
@@ -708,7 +715,8 @@ void USDViewer::UpdateUI()
708715
const std::string IndPoolCommittedSizeStr = GetMemorySizeString(MemoryStats.IndexPool.CommittedSize).c_str();
709716
const std::string IndPoolUsedSizeStr = GetMemorySizeString(MemoryStats.IndexPool.UsedSize).c_str();
710717
const std::string AtlasCommittedSizeStr = GetMemorySizeString(MemoryStats.Atlas.CommittedSize).c_str();
711-
ImGui::TextDisabled("%d\n"
718+
ImGui::TextDisabled("%.1f ms\n"
719+
"%d\n"
712720
"%d\n"
713721
"%d\n"
714722
"%d\n"
@@ -722,6 +730,7 @@ void USDViewer::UpdateUI()
722730
"%s / %s (%d allocs, %dK verts)\n"
723731
"%s / %s (%d allocs)\n"
724732
"%s (%.1lf%%, %d allocs)",
733+
m_Stats.TaskRunTime * 1000.f,
725734
m_Stats.NumDrawCommands,
726735
m_Stats.NumTriangles,
727736
m_Stats.NumLines,

Samples/USDViewer/src/USDViewer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ class USDViewer final : public SampleBase
152152
Uint32 NumTriangles = 0;
153153
Uint32 NumLines = 0;
154154
Uint32 NumPoints = 0;
155+
156+
float TaskRunTime = 0;
155157
};
156158
RenderStats m_Stats;
157159

0 commit comments

Comments
 (0)