mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-18 13:54:16 +01:00
[hud] Add GPU load monitor
This commit is contained in:
parent
5bb20cceb6
commit
3f4c9a3bb5
@ -12,6 +12,7 @@ namespace dxvk::hud {
|
|||||||
{ "submissions", HudElement::StatSubmissions },
|
{ "submissions", HudElement::StatSubmissions },
|
||||||
{ "pipelines", HudElement::StatPipelines },
|
{ "pipelines", HudElement::StatPipelines },
|
||||||
{ "memory", HudElement::StatMemory },
|
{ "memory", HudElement::StatMemory },
|
||||||
|
{ "gpuload", HudElement::StatGpuLoad },
|
||||||
{ "version", HudElement::DxvkVersion },
|
{ "version", HudElement::DxvkVersion },
|
||||||
{ "api", HudElement::DxvkClientApi },
|
{ "api", HudElement::DxvkClientApi },
|
||||||
{ "compiler", HudElement::CompilerActivity },
|
{ "compiler", HudElement::CompilerActivity },
|
||||||
|
@ -18,9 +18,10 @@ namespace dxvk::hud {
|
|||||||
StatSubmissions = 4,
|
StatSubmissions = 4,
|
||||||
StatPipelines = 5,
|
StatPipelines = 5,
|
||||||
StatMemory = 6,
|
StatMemory = 6,
|
||||||
DxvkVersion = 7,
|
StatGpuLoad = 7,
|
||||||
DxvkClientApi = 8,
|
DxvkVersion = 8,
|
||||||
CompilerActivity = 9,
|
DxvkClientApi = 9,
|
||||||
|
CompilerActivity = 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
using HudElements = Flags<HudElement>;
|
using HudElements = Flags<HudElement>;
|
||||||
|
@ -21,6 +21,11 @@ namespace dxvk::hud {
|
|||||||
DxvkStatCounters nextCounters = device->getStatCounters();
|
DxvkStatCounters nextCounters = device->getStatCounters();
|
||||||
m_diffCounters = nextCounters.diff(m_prevCounters);
|
m_diffCounters = nextCounters.diff(m_prevCounters);
|
||||||
m_prevCounters = nextCounters;
|
m_prevCounters = nextCounters;
|
||||||
|
|
||||||
|
// GPU load is a bit more complex than that since
|
||||||
|
// we don't want to update this every frame
|
||||||
|
if (m_elements.test(HudElement::StatGpuLoad))
|
||||||
|
this->updateGpuLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -40,6 +45,9 @@ namespace dxvk::hud {
|
|||||||
if (m_elements.test(HudElement::StatMemory))
|
if (m_elements.test(HudElement::StatMemory))
|
||||||
position = this->printMemoryStats(context, renderer, position);
|
position = this->printMemoryStats(context, renderer, position);
|
||||||
|
|
||||||
|
if (m_elements.test(HudElement::StatGpuLoad))
|
||||||
|
position = this->printGpuLoad(context, renderer, position);
|
||||||
|
|
||||||
if (m_elements.test(HudElement::CompilerActivity)) {
|
if (m_elements.test(HudElement::CompilerActivity)) {
|
||||||
this->printCompilerActivity(context, renderer,
|
this->printCompilerActivity(context, renderer,
|
||||||
{ position.x, float(renderer.surfaceSize().height) - 20.0f });
|
{ position.x, float(renderer.surfaceSize().height) - 20.0f });
|
||||||
@ -49,6 +57,25 @@ namespace dxvk::hud {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HudStats::updateGpuLoad() {
|
||||||
|
auto now = std::chrono::high_resolution_clock::now();
|
||||||
|
uint64_t ticks = std::chrono::duration_cast<std::chrono::microseconds>(now - m_gpuLoadUpdateTime).count();
|
||||||
|
|
||||||
|
if (ticks >= 500'000) {
|
||||||
|
m_gpuLoadUpdateTime = now;
|
||||||
|
|
||||||
|
m_diffGpuIdleTicks = m_prevCounters.getCtr(DxvkStatCounter::GpuIdleTicks) - m_prevGpuIdleTicks;
|
||||||
|
m_prevGpuIdleTicks = m_prevCounters.getCtr(DxvkStatCounter::GpuIdleTicks);
|
||||||
|
|
||||||
|
uint64_t busyTicks = ticks > m_diffGpuIdleTicks
|
||||||
|
? uint64_t(ticks - m_diffGpuIdleTicks)
|
||||||
|
: uint64_t(0);
|
||||||
|
|
||||||
|
m_gpuLoadString = str::format("GPU: ", (100 * busyTicks) / ticks, "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HudPos HudStats::printDrawCallStats(
|
HudPos HudStats::printDrawCallStats(
|
||||||
const Rc<DxvkContext>& context,
|
const Rc<DxvkContext>& context,
|
||||||
HudRenderer& renderer,
|
HudRenderer& renderer,
|
||||||
@ -150,6 +177,19 @@ namespace dxvk::hud {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HudPos HudStats::printGpuLoad(
|
||||||
|
const Rc<DxvkContext>& context,
|
||||||
|
HudRenderer& renderer,
|
||||||
|
HudPos position) {
|
||||||
|
renderer.drawText(context, 16.0f,
|
||||||
|
{ position.x, position.y },
|
||||||
|
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||||
|
m_gpuLoadString);
|
||||||
|
|
||||||
|
return { position.x, position.y + 24.0f };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HudPos HudStats::printCompilerActivity(
|
HudPos HudStats::printCompilerActivity(
|
||||||
const Rc<DxvkContext>& context,
|
const Rc<DxvkContext>& context,
|
||||||
HudRenderer& renderer,
|
HudRenderer& renderer,
|
||||||
@ -183,6 +223,7 @@ namespace dxvk::hud {
|
|||||||
HudElement::StatSubmissions,
|
HudElement::StatSubmissions,
|
||||||
HudElement::StatPipelines,
|
HudElement::StatPipelines,
|
||||||
HudElement::StatMemory,
|
HudElement::StatMemory,
|
||||||
|
HudElement::StatGpuLoad,
|
||||||
HudElement::CompilerActivity);
|
HudElement::CompilerActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,15 @@ namespace dxvk::hud {
|
|||||||
DxvkStatCounters m_prevCounters;
|
DxvkStatCounters m_prevCounters;
|
||||||
DxvkStatCounters m_diffCounters;
|
DxvkStatCounters m_diffCounters;
|
||||||
|
|
||||||
|
std::chrono::high_resolution_clock::time_point m_gpuLoadUpdateTime;
|
||||||
std::chrono::high_resolution_clock::time_point m_compilerShowTime;
|
std::chrono::high_resolution_clock::time_point m_compilerShowTime;
|
||||||
|
|
||||||
|
uint64_t m_prevGpuIdleTicks = 0;
|
||||||
|
uint64_t m_diffGpuIdleTicks = 0;
|
||||||
|
|
||||||
|
std::string m_gpuLoadString = "GPU: ";
|
||||||
|
|
||||||
|
void updateGpuLoad();
|
||||||
|
|
||||||
HudPos printDrawCallStats(
|
HudPos printDrawCallStats(
|
||||||
const Rc<DxvkContext>& context,
|
const Rc<DxvkContext>& context,
|
||||||
@ -60,6 +68,11 @@ namespace dxvk::hud {
|
|||||||
HudRenderer& renderer,
|
HudRenderer& renderer,
|
||||||
HudPos position);
|
HudPos position);
|
||||||
|
|
||||||
|
HudPos printGpuLoad(
|
||||||
|
const Rc<DxvkContext>& context,
|
||||||
|
HudRenderer& renderer,
|
||||||
|
HudPos position);
|
||||||
|
|
||||||
HudPos printCompilerActivity(
|
HudPos printCompilerActivity(
|
||||||
const Rc<DxvkContext>& context,
|
const Rc<DxvkContext>& context,
|
||||||
HudRenderer& renderer,
|
HudRenderer& renderer,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user