mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 01:24:11 +01:00
[hud] Add cache statistics to detailed memory item
This commit is contained in:
parent
9cf72b5b19
commit
7ac9918b39
@ -652,7 +652,14 @@ namespace dxvk::hud {
|
||||
|
||||
|
||||
void HudMemoryDetailsItem::update(dxvk::high_resolution_clock::time_point time) {
|
||||
m_device->getMemoryAllocationStats(m_stats);
|
||||
uint64_t ticks = std::chrono::duration_cast<std::chrono::microseconds>(time - m_lastUpdate).count();
|
||||
|
||||
if (ticks >= UpdateInterval) {
|
||||
m_cacheStats = m_device->getMemoryAllocationStats(m_stats);
|
||||
m_displayCacheStats |= m_cacheStats.requestCount != 0u;
|
||||
|
||||
m_lastUpdate = time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -702,6 +709,9 @@ namespace dxvk::hud {
|
||||
pos.y -= 30.0f + 4.0f;
|
||||
}
|
||||
|
||||
if (m_displayCacheStats)
|
||||
pos.y -= 20.0f;
|
||||
|
||||
// Actually render the thing
|
||||
for (uint32_t i = 0; i < m_stats.memoryTypes.size(); i++) {
|
||||
const auto& type = m_stats.memoryTypes.at(i);
|
||||
@ -747,6 +757,18 @@ namespace dxvk::hud {
|
||||
pos.y += 46.0f;
|
||||
}
|
||||
|
||||
if (m_displayCacheStats) {
|
||||
uint32_t hitCount = m_cacheStats.requestCount - m_cacheStats.missCount;
|
||||
uint32_t hitRate = (100 * hitCount) / std::max(m_cacheStats.requestCount, 1u);
|
||||
|
||||
std::string cacheStr = str::format("Cache: ", m_cacheStats.size >> 10, " kB (", hitRate, "% hit)");
|
||||
|
||||
renderer.drawText(14.0f,
|
||||
{ pos.x, pos.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
cacheStr);
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ namespace dxvk::hud {
|
||||
* \brief HUD item to display detailed memory allocation info
|
||||
*/
|
||||
class HudMemoryDetailsItem : public HudItem {
|
||||
|
||||
constexpr static int64_t UpdateInterval = 500'000;
|
||||
public:
|
||||
|
||||
HudMemoryDetailsItem(const Rc<DxvkDevice>& device);
|
||||
@ -421,6 +421,11 @@ namespace dxvk::hud {
|
||||
|
||||
Rc<DxvkDevice> m_device;
|
||||
DxvkMemoryAllocationStats m_stats;
|
||||
DxvkSharedAllocationCacheStats m_cacheStats;
|
||||
|
||||
high_resolution_clock::time_point m_lastUpdate = { };
|
||||
|
||||
bool m_displayCacheStats = false;
|
||||
|
||||
Rc<DxvkShader> m_vs;
|
||||
Rc<DxvkShader> m_fsBackground;
|
||||
|
Loading…
Reference in New Issue
Block a user