[dxvk] Add CS thread load to the HUD

This commit is contained in:
Robin Kertels 2025-03-01 14:05:09 +01:00
parent b35e69b467
commit e5c55ca0e0
No known key found for this signature in database
GPG key ID: 3824904F14D40757
4 changed files with 36 additions and 5 deletions

View file

@ -202,11 +202,22 @@ namespace dxvk {
while (!m_stopped.load()) {
{ std::unique_lock<dxvk::mutex> lock(m_mutex);
m_condOnAdd.wait(lock, [this] {
return (!m_queueOrdered.queue.empty())
|| (!m_queueHighPrio.queue.empty())
|| (m_stopped.load());
});
auto pred = [this] { return
!m_queueOrdered.queue.empty()
|| !m_queueHighPrio.queue.empty()
|| m_stopped.load();
};
if (unlikely(!pred())) {
auto t0 = dxvk::high_resolution_clock::now();
m_condOnAdd.wait(lock, [&] {
return pred();
});
auto t1 = dxvk::high_resolution_clock::now();
m_device->addStatCtr(DxvkStatCounter::CsIdleTicks, std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count());
}
std::swap(ordered, m_queueOrdered.queue);
std::swap(highPrio, m_queueHighPrio.queue);

View file

@ -28,6 +28,7 @@ namespace dxvk {
GpuIdleTicks, ///< GPU idle time in microseconds
CsSyncCount, ///< CS thread synchronizations
CsSyncTicks, ///< Time spent waiting on CS
CsIdleTicks, ///< CS thread idle time in microseconds
CsChunkCount, ///< Submitted CS chunks
DescriptorPoolCount, ///< Descriptor pool count
DescriptorSetCount, ///< Descriptor sets allocated

View file

@ -1446,6 +1446,17 @@ namespace dxvk::hud {
? str::format(m_maxCsSyncCount, " (", (syncTicks / 10), ".", (syncTicks % 10), " ms)")
: str::format(m_maxCsSyncCount);
uint64_t currCsIdleTicks = counters.getCtr(DxvkStatCounter::CsIdleTicks);
m_diffCsIdleTicks = currCsIdleTicks - m_prevCsIdleTicks;
m_prevCsIdleTicks = currCsIdleTicks;
uint64_t busyTicks = ticks > m_diffCsIdleTicks
? uint64_t(ticks - m_diffCsIdleTicks)
: uint64_t(0);
m_csLoadString = str::format((100 * busyTicks) / ticks, "%");
m_maxCsSyncCount = 0;
m_maxCsSyncTicks = 0;
@ -1469,6 +1480,10 @@ namespace dxvk::hud {
renderer.drawText(16, position, 0xff40ff40, "CS syncs:");
renderer.drawText(16, { position.x + 132, position.y }, 0xffffffffu, m_csSyncString);
position.y += 20;
renderer.drawText(16, position, 0xff40ff40, "CS load:");
renderer.drawText(16, { position.x + 132, position.y }, 0xffffffffu, m_csLoadString);
position.y += 8;
return position;
}

View file

@ -645,14 +645,18 @@ namespace dxvk::hud {
uint64_t m_prevCsSyncCount = 0;
uint64_t m_prevCsSyncTicks = 0;
uint64_t m_prevCsChunks = 0;
uint64_t m_prevCsIdleTicks = 0;
uint64_t m_maxCsSyncCount = 0;
uint64_t m_maxCsSyncTicks = 0;
uint64_t m_diffCsIdleTicks = 0;
uint64_t m_updateCount = 0;
std::string m_csSyncString;
std::string m_csChunkString;
std::string m_csLoadString;
dxvk::high_resolution_clock::time_point m_lastUpdate
= dxvk::high_resolution_clock::now();