Skip to content

Commit

Permalink
Display how many instanced objects are drawn (#5994)
Browse files Browse the repository at this point in the history
* Display how many instanced objects are drawn
  • Loading branch information
fluffyfreak authored Jan 7, 2025
1 parent e0f5244 commit cae2dfe
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/graphics/Stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace Graphics {

m_counterRefs = {
GetOrCreateCounter("DrawMesh Calls"),
GetOrCreateCounter("DrawMesh Instance Calls"),
GetOrCreateCounter("DrawMesh Instanced Calls"),
GetOrCreateCounter("Num Points Drawn"),
GetOrCreateCounter("Num Lines Drawn"),
GetOrCreateCounter("Num Tris Drawn"),
Expand Down
2 changes: 2 additions & 0 deletions src/graphics/Stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace Graphics {
enum StatType {
// renderer entries
STAT_DRAWCALL = 0,
STAT_DRAWCALLINSTANCES,
STAT_DRAWCALLSINSTANCED,
STAT_NUM_POINTS,
STAT_NUM_LINES,
STAT_NUM_TRIS,
Expand Down
3 changes: 2 additions & 1 deletion src/graphics/opengl/RendererGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,8 @@ namespace Graphics {

inst->Release();
CheckRenderErrors(__FUNCTION__, __LINE__);
m_stats.AddToStatCount(Stats::STAT_DRAWCALL, 1);
m_stats.AddToStatCount(Stats::STAT_DRAWCALLINSTANCES, 1);
m_stats.AddToStatCount(Stats::STAT_DRAWCALLSINSTANCED, inst->GetInstanceCount());
stat_primitives(m_stats, type, numElems);
return true;
}
Expand Down
6 changes: 4 additions & 2 deletions src/pigui/PerfInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ void PerfInfo::DrawRendererStats()
{
const Graphics::Stats::TFrameData &stats = Pi::renderer->GetStats().FrameStatsPrevious();
const Uint32 numDrawCalls = stats.m_stats[Graphics::Stats::STAT_DRAWCALL];
const Uint32 numDrawCallInstances = stats.m_stats[Graphics::Stats::STAT_DRAWCALLINSTANCES];
const Uint32 numDrawCallsInstanced = stats.m_stats[Graphics::Stats::STAT_DRAWCALLSINSTANCED];
const Uint32 numTris = stats.m_stats[Graphics::Stats::STAT_NUM_TRIS];
const Uint32 numLines = stats.m_stats[Graphics::Stats::STAT_NUM_LINES];
const Uint32 numPoints = stats.m_stats[Graphics::Stats::STAT_NUM_POINTS];
Expand Down Expand Up @@ -433,8 +435,8 @@ void PerfInfo::DrawRendererStats()
const Uint32 cachedTextureMemUsage = tex2dMemUsage + texCubeMemUsage + texArray2dMemUsage;

ImGui::SeparatorText("Renderer");
ImGui::Text("%u Draw calls, %u CommandList flushes",
numDrawCalls, numCmdListFlushes);
ImGui::Text("%u Draw calls, %u Instances (%u Draw calls), %u CommandList flushes",
numDrawCalls, numDrawCallsInstanced, numDrawCallInstances, numCmdListFlushes);

ImGui::Indent();
ImGui::Text("%u points", numPoints);
Expand Down

0 comments on commit cae2dfe

Please sign in to comment.