mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-29 01:03:41 +01:00
Allow other backends than Vulkan to have GPU memory stats. Implement for GL.
This commit is contained in:
1 parent
62b41c6640
commit
dfb446f89d
15 files changed
+116
-79
No files matched your search
@@ -30,6 +30,7 @@
|
||||
#include "ext/vma/vk_mem_alloc.h"
|
||||
|
||||
#include "DebugVisVulkan.h"
|
||||
#include "Common/GPU/GPUBackendCommon.h"
|
||||
#include "Common/GPU/Vulkan/VulkanMemory.h"
|
||||
#include "Common/GPU/Vulkan/VulkanImage.h"
|
||||
#include "Common/Data/Text/Parsers.h"
|
||||
@@ -41,7 +42,7 @@
|
||||
|
||||
#undef DrawText
|
||||
|
||||
bool comparePushBufferNames(const VulkanMemoryManager *a, const VulkanMemoryManager *b) {
|
||||
bool comparePushBufferNames(const GPUMemoryManager *a, const GPUMemoryManager *b) {
|
||||
return strcmp(a->Name(), b->Name()) < 0;
|
||||
}
|
||||
|
||||
@@ -49,35 +50,34 @@ void DrawGPUMemoryVis(UIContext *ui, GPUInterface *gpu) {
|
||||
// This one will simply display stats.
|
||||
Draw::DrawContext *draw = ui->GetDrawContext();
|
||||
|
||||
VulkanContext *vulkan = (VulkanContext *)draw->GetNativeObject(Draw::NativeObject::CONTEXT);
|
||||
if (!vulkan) {
|
||||
return;
|
||||
}
|
||||
|
||||
VmaTotalStatistics vmaStats;
|
||||
vmaCalculateStatistics(vulkan->Allocator(), &vmaStats);
|
||||
|
||||
std::vector<VmaBudget> budgets;
|
||||
budgets.resize(vulkan->GetMemoryProperties().memoryHeapCount);
|
||||
vmaGetHeapBudgets(vulkan->Allocator(), &budgets[0]);
|
||||
|
||||
size_t totalBudget = 0;
|
||||
size_t totalUsedBytes = 0;
|
||||
for (auto &budget : budgets) {
|
||||
totalBudget += budget.budget;
|
||||
totalUsedBytes += budget.usage;
|
||||
}
|
||||
|
||||
std::stringstream str;
|
||||
str << vulkan->GetPhysicalDeviceProperties().properties.deviceName << std::endl;
|
||||
str << "Allocated " << NiceSizeFormat(vmaStats.total.statistics.allocationBytes) << " in " << vmaStats.total.statistics.allocationCount << " allocs" << std::endl;
|
||||
// Note: The overall number includes stuff like descriptor sets pools and other things that are not directly visible as allocations.
|
||||
str << "Overall " << NiceSizeFormat(totalUsedBytes) << " used out of " << NiceSizeFormat(totalBudget) << " available" << std::endl;
|
||||
|
||||
VulkanContext *vulkan = (VulkanContext *)draw->GetNativeObject(Draw::NativeObject::CONTEXT);
|
||||
if (vulkan) {
|
||||
VmaTotalStatistics vmaStats;
|
||||
vmaCalculateStatistics(vulkan->Allocator(), &vmaStats);
|
||||
|
||||
std::vector<VmaBudget> budgets;
|
||||
budgets.resize(vulkan->GetMemoryProperties().memoryHeapCount);
|
||||
vmaGetHeapBudgets(vulkan->Allocator(), &budgets[0]);
|
||||
|
||||
size_t totalBudget = 0;
|
||||
size_t totalUsedBytes = 0;
|
||||
for (auto &budget : budgets) {
|
||||
totalBudget += budget.budget;
|
||||
totalUsedBytes += budget.usage;
|
||||
}
|
||||
|
||||
str << vulkan->GetPhysicalDeviceProperties().properties.deviceName << std::endl;
|
||||
str << "Allocated " << NiceSizeFormat(vmaStats.total.statistics.allocationBytes) << " in " << vmaStats.total.statistics.allocationCount << " allocs" << std::endl;
|
||||
// Note: The overall number includes stuff like descriptor sets pools and other things that are not directly visible as allocations.
|
||||
str << "Overall " << NiceSizeFormat(totalUsedBytes) << " used out of " << NiceSizeFormat(totalBudget) << " available" << std::endl;
|
||||
}
|
||||
|
||||
str << "Push buffers:" << std::endl;
|
||||
|
||||
// Now list the various push buffers.
|
||||
auto managers = GetActiveVulkanMemoryManagers();
|
||||
auto managers = GetActiveGPUMemoryManagers();
|
||||
std::sort(managers.begin(), managers.end(), comparePushBufferNames);
|
||||
|
||||
char buffer[512];
|
||||
|
||||
Reference in new issue
Block a user