mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 19:54:19 +01:00
[d3d9] Add HUD item for unmappable memory
This commit is contained in:
parent
c3dbb6429f
commit
d598fd3156
@ -33,4 +33,63 @@ namespace dxvk::hud {
|
||||
return position;
|
||||
}
|
||||
|
||||
HudTextureMemory::HudTextureMemory(D3D9DeviceEx* device)
|
||||
: m_device (device)
|
||||
, m_allocatedString ("")
|
||||
, m_mappedString ("") {}
|
||||
|
||||
|
||||
void HudTextureMemory::update(dxvk::high_resolution_clock::time_point time) {
|
||||
D3D9MemoryAllocator* allocator = m_device->GetAllocator();
|
||||
|
||||
m_maxAllocated = std::max(m_maxAllocated, allocator->AllocatedMemory());
|
||||
m_maxUsed = std::max(m_maxUsed, allocator->UsedMemory());
|
||||
m_maxMapped = std::max(m_maxMapped, allocator->MappedMemory());
|
||||
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(time - m_lastUpdate);
|
||||
|
||||
if (elapsed.count() < UpdateInterval)
|
||||
return;
|
||||
|
||||
m_allocatedString = str::format(m_maxAllocated >> 20, " MB (Used: ", m_maxUsed >> 20, " MB)");
|
||||
m_mappedString = str::format(m_maxMapped >> 20, " MB");
|
||||
m_maxAllocated = 0;
|
||||
m_maxUsed = 0;
|
||||
m_maxMapped = 0;
|
||||
m_lastUpdate = time;
|
||||
}
|
||||
|
||||
|
||||
HudPos HudTextureMemory::render(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
position.y += 16.0f;
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 0.0f, 1.0f, 0.75f, 1.0f },
|
||||
"Mappable:");
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x + 120.0f, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
m_allocatedString);
|
||||
|
||||
position.y += 24.0f;
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 0.0f, 1.0f, 0.75f, 1.0f },
|
||||
"Mapped:");
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x + 120.0f, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
m_mappedString);
|
||||
|
||||
position.y += 8.0f;
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
namespace dxvk::hud {
|
||||
|
||||
/**
|
||||
* \brief HUD item to display DXVK version
|
||||
* \brief HUD item to display sampler count
|
||||
*/
|
||||
class HudSamplerCount : public HudItem {
|
||||
|
||||
@ -28,4 +28,36 @@ namespace dxvk::hud {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief HUD item to display unmappable memory
|
||||
*/
|
||||
class HudTextureMemory : public HudItem {
|
||||
constexpr static int64_t UpdateInterval = 500'000;
|
||||
|
||||
public:
|
||||
|
||||
HudTextureMemory(D3D9DeviceEx* device);
|
||||
|
||||
void update(dxvk::high_resolution_clock::time_point time);
|
||||
|
||||
HudPos render(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
private:
|
||||
|
||||
D3D9DeviceEx* m_device;
|
||||
|
||||
uint32_t m_maxAllocated = 0;
|
||||
uint32_t m_maxUsed = 0;
|
||||
uint32_t m_maxMapped = 0;
|
||||
|
||||
dxvk::high_resolution_clock::time_point m_lastUpdate
|
||||
= dxvk::high_resolution_clock::now();
|
||||
|
||||
std::string m_allocatedString;
|
||||
std::string m_mappedString;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -1081,6 +1081,10 @@ namespace dxvk {
|
||||
if (m_hud != nullptr) {
|
||||
m_hud->addItem<hud::HudClientApiItem>("api", 1, GetApiName());
|
||||
m_hud->addItem<hud::HudSamplerCount>("samplers", -1, m_parent);
|
||||
|
||||
#ifdef D3D9_ALLOW_UNMAPPING
|
||||
m_hud->addItem<hud::HudTextureMemory>("memory", -1, m_parent);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user