Debugger: Track texture usage too.

This commit is contained in:
Unknown W. Brackets
2021-02-03 20:46:41 -08:00
parent 76ae1b4d28
commit 10a77d29ab
7 changed files with 76 additions and 10 deletions
+7
View File
@@ -59,6 +59,7 @@ private:
static MemSlabMap allocMap;
static MemSlabMap suballocMap;
static MemSlabMap writeMap;
static MemSlabMap textureMap;
MemSlabMap::MemSlabMap() {
Reset();
@@ -268,6 +269,9 @@ void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_
// Maintain the previous allocation tag for debugging.
suballocMap.Mark(start, size, 0, false, "");
}
if (flags & MemBlockFlags::TEXTURE) {
textureMap.Mark(start, size, pc, true, tag);
}
if (flags & MemBlockFlags::WRITE) {
CBreakPoints::ExecMemCheck(start, true, size, pc, tag);
writeMap.Mark(start, size, pc, true, tag);
@@ -281,6 +285,7 @@ std::vector<MemBlockInfo> FindMemInfo(uint32_t start, uint32_t size) {
allocMap.Find(MemBlockFlags::ALLOC, start, size, results);
suballocMap.Find(MemBlockFlags::SUB_ALLOC, start, size, results);
writeMap.Find(MemBlockFlags::WRITE, start, size, results);
textureMap.Find(MemBlockFlags::TEXTURE, start, size, results);
return results;
}
@@ -291,6 +296,7 @@ void MemBlockInfoShutdown() {
allocMap.Reset();
suballocMap.Reset();
writeMap.Reset();
textureMap.Reset();
}
void MemBlockInfoDoState(PointerWrap &p) {
@@ -301,4 +307,5 @@ void MemBlockInfoDoState(PointerWrap &p) {
allocMap.DoState(p);
suballocMap.DoState(p);
writeMap.DoState(p);
textureMap.DoState(p);
}
+7 -6
View File
@@ -25,13 +25,14 @@
class PointerWrap;
enum class MemBlockFlags {
ALLOC = 1,
SUB_ALLOC = 2,
WRITE = 4,
ALLOC = 0x0001,
SUB_ALLOC = 0x0002,
WRITE = 0x0004,
TEXTURE = 0x0008,
// Not actually logged.
READ = 8,
FREE = 16,
SUB_FREE = 32,
READ = 0x0800,
FREE = 0x1000,
SUB_FREE = 0x2000,
};
ENUM_CLASS_BITOPS(MemBlockFlags);
+2 -2
View File
@@ -1303,13 +1303,13 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w,
shaderManager_->DirtyLastShader();
char tag[256];
snprintf(tag, sizeof(tag), "%08x_%08x_%dx%d_%s", vfb->fb_address, vfb->z_address, w, h, GeBufferFormatToString(vfb->format));
snprintf(tag, sizeof(tag), "FB_%08x_%08x_%dx%d_%s", vfb->fb_address, vfb->z_address, w, h, GeBufferFormatToString(vfb->format));
vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, tag });
if (Memory::IsVRAMAddress(vfb->fb_address) && vfb->fb_stride != 0) {
NotifyMemInfo(MemBlockFlags::ALLOC, vfb->fb_address, ColorBufferByteSize(vfb), tag);
}
if (Memory::IsVRAMAddress(vfb->z_address) && vfb->z_stride != 0) {
NotifyMemInfo(MemBlockFlags::ALLOC, vfb->z_address, vfb->fb_stride * vfb->height * sizeof(uint16_t), std::string("z_") + tag);
NotifyMemInfo(MemBlockFlags::ALLOC, vfb->z_address, vfb->fb_stride * vfb->height * sizeof(uint16_t), std::string("Z_") + tag);
}
if (old.fbo) {
INFO_LOG(FRAMEBUF, "Resizing FBO for %08x : %dx%dx%s", vfb->fb_address, w, h, GeBufferFormatToString(vfb->format));
+7
View File
@@ -21,7 +21,9 @@
#include "Common/Profiler/Profiler.h"
#include "Common/ColorConv.h"
#include "Common/MemoryUtil.h"
#include "Common/StringUtils.h"
#include "Core/Config.h"
#include "Core/Debugger/MemBlockInfo.h"
#include "Core/Reporting.h"
#include "Core/System.h"
#include "GPU/Common/FramebufferManagerCommon.h"
@@ -1110,6 +1112,8 @@ void TextureCacheCommon::LoadClut(u32 clutAddr, u32 loadBytes) {
}
}
}
NotifyMemInfo(MemBlockFlags::ALLOC, clutAddr, loadBytes, "CLUT");
}
// It's possible for a game to (successfully) access outside valid memory.
@@ -1294,6 +1298,9 @@ void TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETextureForm
int w = gstate.getTextureWidth(level);
int h = gstate.getTextureHeight(level);
const u8 *texptr = Memory::GetPointer(texaddr);
const uint32_t byteSize = (textureBitsPerPixel[format] * bufw * h) / 8;
NotifyMemInfo(MemBlockFlags::TEXTURE, texaddr, byteSize, StringFromFormat("Texture_%08x_%dx%d_%s", texaddr, w, h, GeTextureFormatToString(format, clutformat)));
switch (format) {
case GE_TFMT_CLUT4:
+48
View File
@@ -10,6 +10,16 @@ const char *GeBufferFormatToString(GEBufferFormat fmt) {
}
}
const char *GEPaletteFormatToString(GEPaletteFormat pfmt) {
switch (pfmt) {
case GE_CMODE_16BIT_BGR5650: return "565";
case GE_CMODE_16BIT_ABGR5551: return "5551";
case GE_CMODE_16BIT_ABGR4444: return "4444";
case GE_CMODE_32BIT_ABGR8888: return "8888";
default: return "N/A";
}
}
const char *GeTextureFormatToString(GETextureFormat fmt) {
switch (fmt) {
case GE_TFMT_5650: return "565";
@@ -26,3 +36,41 @@ const char *GeTextureFormatToString(GETextureFormat fmt) {
default: return "N/A";
}
}
const char *GeTextureFormatToString(GETextureFormat tfmt, GEPaletteFormat pfmt) {
switch (tfmt) {
case GE_TFMT_CLUT4:
switch (pfmt) {
case GE_CMODE_16BIT_BGR5650: return "CLUT4_565";
case GE_CMODE_16BIT_ABGR5551: return "CLUT4_5551";
case GE_CMODE_16BIT_ABGR4444: return "CLUT4_4444";
case GE_CMODE_32BIT_ABGR8888: return "CLUT4_8888";
default: return "N/A";
}
case GE_TFMT_CLUT8:
switch (pfmt) {
case GE_CMODE_16BIT_BGR5650: return "CLUT8_565";
case GE_CMODE_16BIT_ABGR5551: return "CLUT8_5551";
case GE_CMODE_16BIT_ABGR4444: return "CLUT8_4444";
case GE_CMODE_32BIT_ABGR8888: return "CLUT8_8888";
default: return "N/A";
}
case GE_TFMT_CLUT16:
switch (pfmt) {
case GE_CMODE_16BIT_BGR5650: return "CLUT16_565";
case GE_CMODE_16BIT_ABGR5551: return "CLUT16_5551";
case GE_CMODE_16BIT_ABGR4444: return "CLUT16_4444";
case GE_CMODE_32BIT_ABGR8888: return "CLUT16_8888";
default: return "N/A";
}
case GE_TFMT_CLUT32:
switch (pfmt) {
case GE_CMODE_16BIT_BGR5650: return "CLUT32_565";
case GE_CMODE_16BIT_ABGR5551: return "CLUT32_5551";
case GE_CMODE_16BIT_ABGR4444: return "CLUT32_4444";
case GE_CMODE_32BIT_ABGR8888: return "CLUT32_8888";
default: return "N/A";
}
default: return GeTextureFormatToString(tfmt);
}
}
+1 -1
View File
@@ -862,7 +862,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
}
char texName[128]{};
snprintf(texName, sizeof(texName), "texture_%08x_%s", entry->addr, GeTextureFormatToString((GETextureFormat)entry->format));
snprintf(texName, sizeof(texName), "texture_%08x_%s", entry->addr, GeTextureFormatToString((GETextureFormat)entry->format, gstate.getClutPaletteFormat()));
image->SetTag(texName);
bool allocSuccess = image->CreateDirect(cmdInit, allocator_, w * scaleFactor, h * scaleFactor, maxLevelToGenerate + 1, actualFmt, imageLayout, usage, mapping);
+4 -1
View File
@@ -419,7 +419,6 @@ enum GETextureFormat
GE_TFMT_DXT5 = 10,
};
const char *GeTextureFormatToString(GETextureFormat tfmt);
inline bool IsClutFormat(GETextureFormat tfmt) {
return tfmt == GE_TFMT_CLUT4 || tfmt == GE_TFMT_CLUT8 || tfmt == GE_TFMT_CLUT16 || tfmt == GE_TFMT_CLUT32;
}
@@ -609,3 +608,7 @@ enum GEPaletteFormat
GE_CMODE_16BIT_ABGR4444,
GE_CMODE_32BIT_ABGR8888,
};
const char *GEPaletteFormatToString(GEPaletteFormat pfmt);
const char *GeTextureFormatToString(GETextureFormat tfmt);
const char *GeTextureFormatToString(GETextureFormat tfmt, GEPaletteFormat pfmt);