diff --git a/Source/Core/VideoBackends/Software/DebugUtil.cpp b/Source/Core/VideoBackends/Software/DebugUtil.cpp index 4577987a42..b930969daa 100644 --- a/Source/Core/VideoBackends/Software/DebugUtil.cpp +++ b/Source/Core/VideoBackends/Software/DebugUtil.cpp @@ -21,29 +21,37 @@ namespace DebugUtil { -u32 skipFrames = 0; -bool drawingHwTriangles = false; +static u32 skipFrames = 0; +static bool drawingHwTriangles = false; enum { NumObjectBuffers = 40}; -u32 ObjectBuffer[NumObjectBuffers][EFB_WIDTH*EFB_HEIGHT]; -u32 TempBuffer[NumObjectBuffers]; +static u32 *ObjectBuffer[NumObjectBuffers]; +static u32 TempBuffer[NumObjectBuffers]; -bool DrawnToBuffer[NumObjectBuffers]; -const char* ObjectBufferName[NumObjectBuffers]; -int BufferBase[NumObjectBuffers]; +static bool DrawnToBuffer[NumObjectBuffers]; +static const char* ObjectBufferName[NumObjectBuffers]; +static int BufferBase[NumObjectBuffers]; void Init() { for (int i = 0; i < NumObjectBuffers; i++) { - memset(ObjectBuffer[i], 0, sizeof(ObjectBuffer[i])); + ObjectBuffer[i] = new u32[EFB_WIDTH*EFB_HEIGHT](); DrawnToBuffer[i] = false; ObjectBufferName[i] = nullptr; BufferBase[i] = 0; } } +void Shutdown() +{ + for (int i = 0; i < NumObjectBuffers; i++) + { + delete[] ObjectBuffer[i]; + } +} + void SaveTexture(const std::string& filename, u32 texmap, s32 mip) { FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1]; @@ -245,7 +253,7 @@ void OnObjectEnd() swstats.thisFrame.numDrawnObjects, ObjectBufferName[i], i - BufferBase[i]); (void)TextureToPng((u8*)ObjectBuffer[i], EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true); - memset(ObjectBuffer[i], 0, sizeof(ObjectBuffer[i])); + memset(ObjectBuffer[i], 0, EFB_WIDTH * EFB_HEIGHT * sizeof(u32)); } } diff --git a/Source/Core/VideoBackends/Software/DebugUtil.h b/Source/Core/VideoBackends/Software/DebugUtil.h index ba2d7dd1c9..e975b2afc8 100644 --- a/Source/Core/VideoBackends/Software/DebugUtil.h +++ b/Source/Core/VideoBackends/Software/DebugUtil.h @@ -7,6 +7,7 @@ namespace DebugUtil { void Init(); + void Shutdown(); void GetTextureRGBA(u8 *dst, u32 texmap, s32 mip, u32 width, u32 height); diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index c42cc136f2..f41aba3a28 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -167,6 +167,7 @@ void VideoSoftware::Shutdown() // TODO: should be in Video_Cleanup HwRasterizer::Shutdown(); SWRenderer::Shutdown(); + DebugUtil::Shutdown(); // Do our OSD callbacks OSD::DoCallbacks(OSD::OSD_SHUTDOWN);