1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[hud] Implement compiler activity display as a HUD item

This commit is contained in:
Philip Rebohle 2019-12-13 11:53:24 +01:00
parent 5d8ae8f988
commit 3415376984
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 71 additions and 0 deletions

View File

@ -44,6 +44,7 @@ namespace dxvk::hud {
addItem<HudPipelineStatsItem>("pipelines", device);
addItem<HudMemoryStatsItem>("memory", device);
addItem<HudGpuLoadItem>("gpuload", device);
addItem<HudCompilerActivityItem>("compiler", device);
}

View File

@ -477,4 +477,45 @@ namespace dxvk::hud {
return position;
}
HudCompilerActivityItem::HudCompilerActivityItem(const Rc<DxvkDevice>& device)
: m_device(device) {
}
HudCompilerActivityItem::~HudCompilerActivityItem() {
}
void HudCompilerActivityItem::update(dxvk::high_resolution_clock::time_point time) {
DxvkStatCounters counters = m_device->getStatCounters();
bool doShow = counters.getCtr(DxvkStatCounter::PipeCompilerBusy);
if (!doShow) {
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(time - m_timeShown);
doShow = elapsed.count() <= MinShowDuration;
}
if (doShow && !m_show)
m_timeShown = time;
m_show = doShow;
}
HudPos HudCompilerActivityItem::render(
HudRenderer& renderer,
HudPos position) {
if (m_show) {
renderer.drawText(16.0f,
{ position.x, renderer.surfaceSize().height - 20.0f },
{ 1.0f, 1.0f, 1.0f, 1.0f },
"Compiling shaders...");
}
return position;
}
}

View File

@ -354,4 +354,33 @@ namespace dxvk::hud {
};
/**
* \brief HUD item to display pipeline compiler activity
*/
class HudCompilerActivityItem : public HudItem {
constexpr static int64_t MinShowDuration = 1500;
public:
HudCompilerActivityItem(const Rc<DxvkDevice>& device);
~HudCompilerActivityItem();
void update(dxvk::high_resolution_clock::time_point time);
HudPos render(
HudRenderer& renderer,
HudPos position);
private:
Rc<DxvkDevice> m_device;
bool m_show = false;
dxvk::high_resolution_clock::time_point m_timeShown
= dxvk::high_resolution_clock::now();
};
}