mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-20 06:00:58 +00:00
Better debug vis for push pools
This commit is contained in:
parent
9fcd6d6612
commit
c8b25e50b0
@ -27,6 +27,7 @@
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/Math/math_util.h"
|
||||
#include "Common/GPU/Vulkan/VulkanMemory.h"
|
||||
#include "Common/Data/Text/Parsers.h"
|
||||
|
||||
using namespace PPSSPP_VK;
|
||||
|
||||
@ -150,8 +151,13 @@ size_t VulkanPushBuffer::GetTotalSize() const {
|
||||
return sum;
|
||||
}
|
||||
|
||||
size_t VulkanPushBuffer::GetTotalCapacity() const {
|
||||
return size_ * buffers_.size();
|
||||
void VulkanPushBuffer::GetDebugString(char *buffer, size_t bufSize) const {
|
||||
size_t sum = 0;
|
||||
if (buffers_.size() > 1)
|
||||
sum += size_ * (buffers_.size() - 1);
|
||||
sum += offset_;
|
||||
size_t capacity = size_ * buffers_.size();
|
||||
snprintf(buffer, bufSize, "Push %s: %s/%s", name_, NiceSizeFormat(capacity).c_str(), NiceSizeFormat(sum).c_str());
|
||||
}
|
||||
|
||||
void VulkanPushBuffer::Map() {
|
||||
@ -367,18 +373,13 @@ void VulkanPushPool::NextBlock(VkDeviceSize allocationSize) {
|
||||
// curBlockIndex_ is already set correctly here.
|
||||
}
|
||||
|
||||
size_t VulkanPushPool::GetTotalSize() const {
|
||||
size_t sz = 0;
|
||||
void VulkanPushPool::GetDebugString(char *buffer, size_t bufSize) const {
|
||||
size_t used = 0;
|
||||
size_t capacity = 0;
|
||||
for (auto &block : blocks_) {
|
||||
sz += block.used;
|
||||
used += block.used;
|
||||
capacity += block.size;
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
size_t VulkanPushPool::GetTotalCapacity() const {
|
||||
size_t sz = 0;
|
||||
for (auto &block : blocks_) {
|
||||
sz += block.size;
|
||||
}
|
||||
return sz;
|
||||
snprintf(buffer, bufSize, "Pool %s: %s / %s (%d extra blocks)", name_, NiceSizeFormat(used).c_str(), NiceSizeFormat(capacity).c_str(), (int)blocks_.size() - 3);
|
||||
}
|
||||
|
@ -24,9 +24,8 @@ class VulkanMemoryManager {
|
||||
public:
|
||||
virtual ~VulkanMemoryManager() {}
|
||||
|
||||
virtual size_t GetTotalSize() const = 0;
|
||||
virtual size_t GetTotalCapacity() const = 0;
|
||||
virtual const char *Name() const = 0;
|
||||
virtual void GetDebugString(char *buffer, size_t bufSize) const = 0;
|
||||
virtual const char *Name() const = 0; // for sorting
|
||||
};
|
||||
|
||||
// VulkanPushBuffer
|
||||
@ -53,6 +52,11 @@ public:
|
||||
|
||||
void Reset() { offset_ = 0; }
|
||||
|
||||
void GetDebugString(char *buffer, size_t bufSize) const override;
|
||||
const char *Name() const override {
|
||||
return name_;
|
||||
}
|
||||
|
||||
// Needs context in case of defragment.
|
||||
void Begin(VulkanContext *vulkan) {
|
||||
buf_ = 0;
|
||||
@ -112,10 +116,6 @@ public:
|
||||
return offset_;
|
||||
}
|
||||
|
||||
const char *Name() const override {
|
||||
return name_;
|
||||
}
|
||||
|
||||
// "Zero-copy" variant - you can write the data directly as you compute it.
|
||||
// Recommended.
|
||||
void *Push(size_t size, uint32_t *bindOffset, VkBuffer *vkbuf) {
|
||||
@ -141,8 +141,7 @@ public:
|
||||
info->range = sizeof(T);
|
||||
}
|
||||
|
||||
size_t GetTotalSize() const override; // Used size
|
||||
size_t GetTotalCapacity() const override;
|
||||
size_t GetTotalSize() const;
|
||||
|
||||
private:
|
||||
bool AddBuffer();
|
||||
@ -171,8 +170,10 @@ public:
|
||||
void Destroy();
|
||||
void BeginFrame();
|
||||
|
||||
size_t GetTotalSize() const override; // Used size
|
||||
size_t GetTotalCapacity() const override;
|
||||
const char *Name() const override {
|
||||
return name_;
|
||||
}
|
||||
void GetDebugString(char *buffer, size_t bufSize) const override;
|
||||
|
||||
// When using the returned memory, make sure to bind the returned vkbuf.
|
||||
uint8_t *Allocate(VkDeviceSize numBytes, VkDeviceSize alignment, VkBuffer *vkbuf, uint32_t *bindOffset) {
|
||||
@ -202,10 +203,6 @@ public:
|
||||
return bindOffset;
|
||||
}
|
||||
|
||||
const char *Name() const override {
|
||||
return name_;
|
||||
}
|
||||
|
||||
private:
|
||||
void NextBlock(VkDeviceSize allocationSize);
|
||||
|
||||
|
@ -78,10 +78,10 @@ void DrawAllocatorVis(UIContext *ui, GPUInterface *gpu) {
|
||||
auto managers = GetActiveVulkanMemoryManagers();
|
||||
std::sort(managers.begin(), managers.end(), comparePushBufferNames);
|
||||
|
||||
char buffer[512];
|
||||
for (auto manager : managers) {
|
||||
str << " " << manager->Name() << " "
|
||||
<< NiceSizeFormat(manager->GetTotalCapacity()) << ", used: "
|
||||
<< NiceSizeFormat(manager->GetTotalSize()) << std::endl;
|
||||
manager->GetDebugString(buffer, sizeof(buffer));
|
||||
str << " " << buffer << std::endl;
|
||||
}
|
||||
|
||||
const int padding = 10 + System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user