From c67481b904379c8e6ceca810c17411fff06ee152 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 23 Jun 2022 00:41:53 +0200 Subject: [PATCH] [hud] Add HUD item for descriptor stats --- README.md | 1 + src/dxvk/hud/dxvk_hud.cpp | 1 + src/dxvk/hud/dxvk_hud_item.cpp | 49 ++++++++++++++++++++++++++++++++++ src/dxvk/hud/dxvk_hud_item.h | 27 +++++++++++++++++++ 4 files changed, 78 insertions(+) diff --git a/README.md b/README.md index 8c02992a..4db6c29a 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ The `DXVK_HUD` environment variable controls a HUD which can display the framera - `submissions`: Shows the number of command buffers submitted per frame. - `drawcalls`: Shows the number of draw calls and render passes per frame. - `pipelines`: Shows the total number of graphics and compute pipelines. +- `descriptors`: Shows the number of descriptor pools and descriptor sets. - `memory`: Shows the amount of device memory allocated and used. - `gpuload`: Shows estimated GPU load. May be inaccurate. - `version`: Shows DXVK version. diff --git a/src/dxvk/hud/dxvk_hud.cpp b/src/dxvk/hud/dxvk_hud.cpp index 003c1915..f5e72504 100644 --- a/src/dxvk/hud/dxvk_hud.cpp +++ b/src/dxvk/hud/dxvk_hud.cpp @@ -42,6 +42,7 @@ namespace dxvk::hud { addItem("submissions", -1, device); addItem("drawcalls", -1, device); addItem("pipelines", -1, device); + addItem("descriptors", -1, device); addItem("memory", -1, device); addItem("cs", -1, device); addItem("gpuload", -1, device); diff --git a/src/dxvk/hud/dxvk_hud_item.cpp b/src/dxvk/hud/dxvk_hud_item.cpp index d236287a..59ca3ffe 100644 --- a/src/dxvk/hud/dxvk_hud_item.cpp +++ b/src/dxvk/hud/dxvk_hud_item.cpp @@ -500,6 +500,55 @@ namespace dxvk::hud { } + HudDescriptorStatsItem::HudDescriptorStatsItem(const Rc& device) + : m_device(device) { + + } + + + HudDescriptorStatsItem::~HudDescriptorStatsItem() { + + } + + + void HudDescriptorStatsItem::update(dxvk::high_resolution_clock::time_point time) { + DxvkStatCounters counters = m_device->getStatCounters(); + + m_descriptorPoolCount = counters.getCtr(DxvkStatCounter::DescriptorPoolCount); + m_descriptorSetCount = counters.getCtr(DxvkStatCounter::DescriptorSetCount); + } + + + HudPos HudDescriptorStatsItem::render( + HudRenderer& renderer, + HudPos position) { + position.y += 16.0f; + renderer.drawText(16.0f, + { position.x, position.y }, + { 1.0f, 0.25f, 0.5f, 1.0f }, + "Descriptor pools:"); + + renderer.drawText(16.0f, + { position.x + 216.0f, position.y }, + { 1.0f, 1.0f, 1.0f, 1.0f }, + str::format(m_descriptorPoolCount)); + + position.y += 20.0f; + renderer.drawText(16.0f, + { position.x, position.y }, + { 1.0f, 0.25f, 0.5f, 1.0f }, + "Descriptor sets:"); + + renderer.drawText(16.0f, + { position.x + 216.0f, position.y }, + { 1.0f, 1.0f, 1.0f, 1.0f }, + str::format(m_descriptorSetCount)); + + position.y += 8.0f; + return position; + } + + HudMemoryStatsItem::HudMemoryStatsItem(const Rc& device) : m_device(device), m_memory(device->adapter()->memoryProperties()) { diff --git a/src/dxvk/hud/dxvk_hud_item.h b/src/dxvk/hud/dxvk_hud_item.h index 275461c6..a868c929 100644 --- a/src/dxvk/hud/dxvk_hud_item.h +++ b/src/dxvk/hud/dxvk_hud_item.h @@ -336,6 +336,33 @@ namespace dxvk::hud { }; + /** + * \brief HUD item to display descriptor stats + */ + class HudDescriptorStatsItem : public HudItem { + + public: + + HudDescriptorStatsItem(const Rc& device); + + ~HudDescriptorStatsItem(); + + void update(dxvk::high_resolution_clock::time_point time); + + HudPos render( + HudRenderer& renderer, + HudPos position); + + private: + + Rc m_device; + + uint64_t m_descriptorPoolCount = 0; + uint64_t m_descriptorSetCount = 0; + + }; + + /** * \brief HUD item to display memory usage */