Skip to content

Commit

Permalink
[hud] Add HUD item for descriptor stats
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Jun 28, 2022
1 parent d4a3b82 commit c67481b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/dxvk/hud/dxvk_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace dxvk::hud {
addItem<HudSubmissionStatsItem>("submissions", -1, device);
addItem<HudDrawCallStatsItem>("drawcalls", -1, device);
addItem<HudPipelineStatsItem>("pipelines", -1, device);
addItem<HudDescriptorStatsItem>("descriptors", -1, device);
addItem<HudMemoryStatsItem>("memory", -1, device);
addItem<HudCsThreadItem>("cs", -1, device);
addItem<HudGpuLoadItem>("gpuload", -1, device);
Expand Down
49 changes: 49 additions & 0 deletions src/dxvk/hud/dxvk_hud_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,55 @@ namespace dxvk::hud {
}


HudDescriptorStatsItem::HudDescriptorStatsItem(const Rc<DxvkDevice>& 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<DxvkDevice>& device)
: m_device(device), m_memory(device->adapter()->memoryProperties()) {

Expand Down
27 changes: 27 additions & 0 deletions src/dxvk/hud/dxvk_hud_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,33 @@ namespace dxvk::hud {
};


/**
* \brief HUD item to display descriptor stats
*/
class HudDescriptorStatsItem : public HudItem {

public:

HudDescriptorStatsItem(const Rc<DxvkDevice>& device);

~HudDescriptorStatsItem();

void update(dxvk::high_resolution_clock::time_point time);

HudPos render(
HudRenderer& renderer,
HudPos position);

private:

Rc<DxvkDevice> m_device;

uint64_t m_descriptorPoolCount = 0;
uint64_t m_descriptorSetCount = 0;

};


/**
* \brief HUD item to display memory usage
*/
Expand Down

0 comments on commit c67481b

Please sign in to comment.