2018-01-17 12:59:32 +00:00
|
|
|
// Copyright (c) 2016- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2023-02-26 14:12:46 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <sstream>
|
|
|
|
#include <cstring>
|
|
|
|
|
2020-10-04 21:24:14 +00:00
|
|
|
#include "Common/Render/DrawBuffer.h"
|
|
|
|
#include "Common/GPU/thin3d.h"
|
2023-02-26 14:12:46 +00:00
|
|
|
#include "Common/GPU/Vulkan/VulkanContext.h"
|
2020-10-04 18:48:47 +00:00
|
|
|
#include "Common/UI/Context.h"
|
|
|
|
#include "Common/UI/View.h"
|
2020-10-11 17:04:35 +00:00
|
|
|
#include "Common/System/Display.h"
|
2020-10-11 11:07:08 +00:00
|
|
|
#include "Common/System/System.h"
|
2018-01-29 22:49:55 +00:00
|
|
|
|
2023-02-26 14:12:46 +00:00
|
|
|
#include "ext/vma/vk_mem_alloc.h"
|
|
|
|
|
2018-01-17 12:59:32 +00:00
|
|
|
#include "DebugVisVulkan.h"
|
2023-05-24 12:32:38 +00:00
|
|
|
#include "Common/GPU/GPUBackendCommon.h"
|
2020-10-04 21:24:14 +00:00
|
|
|
#include "Common/GPU/Vulkan/VulkanMemory.h"
|
|
|
|
#include "Common/GPU/Vulkan/VulkanImage.h"
|
2023-02-26 14:12:46 +00:00
|
|
|
#include "Common/Data/Text/Parsers.h"
|
2018-01-17 12:59:32 +00:00
|
|
|
#include "GPU/Vulkan/GPU_Vulkan.h"
|
|
|
|
#include "GPU/Vulkan/VulkanUtil.h"
|
2020-09-13 21:34:00 +00:00
|
|
|
#include "GPU/Vulkan/TextureCacheVulkan.h"
|
2018-01-17 12:59:32 +00:00
|
|
|
|
2023-05-17 12:38:11 +00:00
|
|
|
#include "Core/Config.h"
|
|
|
|
|
2019-08-20 22:03:00 +00:00
|
|
|
#undef DrawText
|
|
|
|
|
2023-05-24 12:32:38 +00:00
|
|
|
bool comparePushBufferNames(const GPUMemoryManager *a, const GPUMemoryManager *b) {
|
2023-02-26 14:12:46 +00:00
|
|
|
return strcmp(a->Name(), b->Name()) < 0;
|
|
|
|
}
|
|
|
|
|
2023-05-19 07:20:22 +00:00
|
|
|
void DrawGPUMemoryVis(UIContext *ui, GPUInterface *gpu) {
|
2023-02-26 14:12:46 +00:00
|
|
|
// This one will simply display stats.
|
|
|
|
Draw::DrawContext *draw = ui->GetDrawContext();
|
|
|
|
|
2023-05-24 12:32:38 +00:00
|
|
|
std::stringstream str;
|
2023-02-26 14:12:46 +00:00
|
|
|
|
2023-05-24 12:32:38 +00:00
|
|
|
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;
|
2023-02-26 14:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
str << "Push buffers:" << std::endl;
|
|
|
|
|
|
|
|
// Now list the various push buffers.
|
2023-05-24 12:32:38 +00:00
|
|
|
auto managers = GetActiveGPUMemoryManagers();
|
2023-03-14 21:44:37 +00:00
|
|
|
std::sort(managers.begin(), managers.end(), comparePushBufferNames);
|
2023-02-26 14:12:46 +00:00
|
|
|
|
2023-03-14 23:54:50 +00:00
|
|
|
char buffer[512];
|
2023-03-14 21:44:37 +00:00
|
|
|
for (auto manager : managers) {
|
2023-03-14 23:54:50 +00:00
|
|
|
manager->GetDebugString(buffer, sizeof(buffer));
|
|
|
|
str << " " << buffer << std::endl;
|
2023-02-26 14:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const int padding = 10 + System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT);
|
|
|
|
const int starty = 50 + System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_TOP);
|
|
|
|
int x = padding;
|
|
|
|
int y = starty;
|
|
|
|
|
|
|
|
ui->SetFontScale(0.7f, 0.7f);
|
|
|
|
ui->DrawTextShadow(str.str().c_str(), x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
|
|
|
|
ui->SetFontScale(1.0f, 1.0f);
|
|
|
|
ui->Flush();
|
2018-01-17 12:59:32 +00:00
|
|
|
}
|
2019-08-20 22:03:00 +00:00
|
|
|
|
2020-10-11 11:07:08 +00:00
|
|
|
void DrawGPUProfilerVis(UIContext *ui, GPUInterface *gpu) {
|
2019-08-20 22:03:00 +00:00
|
|
|
using namespace Draw;
|
2020-10-11 17:04:35 +00:00
|
|
|
const int padding = 10 + System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT);
|
|
|
|
const int starty = 50 + System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_TOP);
|
2019-08-20 22:03:00 +00:00
|
|
|
int x = padding;
|
|
|
|
int y = starty;
|
|
|
|
|
|
|
|
ui->Begin();
|
|
|
|
|
2023-05-17 12:38:11 +00:00
|
|
|
float scale = 0.4f;
|
|
|
|
if (g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
|
|
|
|
// Don't have as much info, let's go bigger.
|
|
|
|
scale = 0.7f;
|
|
|
|
}
|
2019-08-20 22:03:00 +00:00
|
|
|
|
2023-08-03 14:31:20 +00:00
|
|
|
std::string text = ui->GetDrawContext()->GetGpuProfileString();
|
2019-08-20 22:03:00 +00:00
|
|
|
|
2019-08-21 16:28:20 +00:00
|
|
|
ui->SetFontScale(0.4f, 0.4f);
|
2020-10-11 17:04:35 +00:00
|
|
|
ui->DrawTextShadow(text.c_str(), x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
|
2019-08-21 21:10:41 +00:00
|
|
|
ui->SetFontScale(1.0f, 1.0f);
|
2019-08-20 22:03:00 +00:00
|
|
|
ui->Flush();
|
|
|
|
}
|