1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 10:24:10 +01:00

[hud] Implement draw call stats display as a HUD item

This commit is contained in:
Philip Rebohle 2019-12-13 10:56:46 +01:00
parent 0f2610010b
commit 3de8499697
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 81 additions and 0 deletions

View File

@ -40,6 +40,7 @@ namespace dxvk::hud {
addItem<HudFpsItem>("fps"); addItem<HudFpsItem>("fps");
addItem<HudFrameTimeItem>("frametimes"); addItem<HudFrameTimeItem>("frametimes");
addItem<HudSubmissionStatsItem>("submissions", device); addItem<HudSubmissionStatsItem>("submissions", device);
addItem<HudDrawCallStatsItem>("drawcalls", device);
} }

View File

@ -293,4 +293,57 @@ namespace dxvk::hud {
return position; return position;
} }
HudDrawCallStatsItem::HudDrawCallStatsItem(const Rc<DxvkDevice>& device)
: m_device(device) {
}
HudDrawCallStatsItem::~HudDrawCallStatsItem() {
}
void HudDrawCallStatsItem::update(dxvk::high_resolution_clock::time_point time) {
DxvkStatCounters counters = m_device->getStatCounters();
m_diffCounters = counters.diff(m_prevCounters);
m_prevCounters = counters;
}
HudPos HudDrawCallStatsItem::render(
HudRenderer& renderer,
HudPos position) {
uint64_t gpCalls = m_diffCounters.getCtr(DxvkStatCounter::CmdDrawCalls);
uint64_t cpCalls = m_diffCounters.getCtr(DxvkStatCounter::CmdDispatchCalls);
uint64_t rpCalls = m_diffCounters.getCtr(DxvkStatCounter::CmdRenderPassCount);
std::string strDrawCalls = str::format("Draw calls: ", gpCalls);
std::string strDispatchCalls = str::format("Dispatch calls: ", cpCalls);
std::string strRenderPasses = str::format("Render passes: ", rpCalls);
position.y += 16.0f;
renderer.drawText(16.0f,
{ position.x, position.y },
{ 1.0f, 1.0f, 1.0f, 1.0f },
strDrawCalls);
position.y += 20.0f;
renderer.drawText(16.0f,
{ position.x, position.y },
{ 1.0f, 1.0f, 1.0f, 1.0f },
strDispatchCalls);
position.y += 20.0f;
renderer.drawText(16.0f,
{ position.x, position.y },
{ 1.0f, 1.0f, 1.0f, 1.0f },
strRenderPasses);
position.y += 8.0f;
return position;
}
} }

View File

@ -242,4 +242,31 @@ namespace dxvk::hud {
}; };
/**
* \brief HUD item to display draw call counts
*/
class HudDrawCallStatsItem : public HudItem {
public:
HudDrawCallStatsItem(const Rc<DxvkDevice>& device);
~HudDrawCallStatsItem();
void update(dxvk::high_resolution_clock::time_point time);
HudPos render(
HudRenderer& renderer,
HudPos position);
private:
Rc<DxvkDevice> m_device;
DxvkStatCounters m_prevCounters;
DxvkStatCounters m_diffCounters;
};
} }