From 232e961b6f703b2c8b83b04841acecec105f0819 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 15 Feb 2009 12:38:25 +0000 Subject: [PATCH] Sort vertex loader debug statistics by number of verts loaded - now easy to identify the heaviest vertex loader in games. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2252 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Core/VideoCommon/Src/NativeVertexWriter.h | 2 -- Source/Core/VideoCommon/Src/VertexLoader.cpp | 4 +-- Source/Core/VideoCommon/Src/VertexLoader.h | 3 +- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 2 +- .../Src/VertexLoaderManager.cpp | 28 +++++++++++++++++-- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Source/Core/VideoCommon/Src/NativeVertexWriter.h b/Source/Core/VideoCommon/Src/NativeVertexWriter.h index 6af9105ee9..3d6b8c5c44 100644 --- a/Source/Core/VideoCommon/Src/NativeVertexWriter.h +++ b/Source/Core/VideoCommon/Src/NativeVertexWriter.h @@ -24,8 +24,6 @@ namespace VertexManager void AddVertices(int primitive, int numvertices); void Flush(); // flushes the current buffer - -// This doesn't really belong here and are not relevant for D3D - TODO, find better place to put them. int GetRemainingSize(); // remaining space in the current buffer. // TODO: move, rename. diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp index 65be39a539..084eba7ed1 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp @@ -84,7 +84,7 @@ void LOADERDECL PosMtx_Write() void LOADERDECL TexMtx_ReadDirect_UByte() { - s_curtexmtx[s_texmtxread] = DataReadU8()&0x3f; + s_curtexmtx[s_texmtxread] = DataReadU8() & 0x3f; PRIM_LOG("texmtx%d: %d, ", s_texmtxread, s_curtexmtx[s_texmtxread]); s_texmtxread++; } @@ -700,7 +700,7 @@ void VertexLoader::SetVAT(u32 _group0, u32 _group1, u32 _group2) m_VtxAttr.texCoord[7].Frac = vat.g2.Tex7Frac; }; -void VertexLoader::AppendToString(std::string *dest) +void VertexLoader::AppendToString(std::string *dest) const { dest->reserve(250); static const char *posMode[4] = { diff --git a/Source/Core/VideoCommon/Src/VertexLoader.h b/Source/Core/VideoCommon/Src/VertexLoader.h index 0e91fa7c67..6138fcabe4 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader.h +++ b/Source/Core/VideoCommon/Src/VertexLoader.h @@ -63,7 +63,8 @@ public: void RunVertices(int vtx_attr_group, int primitive, int count); // For debugging / profiling - void AppendToString(std::string *dest); + void AppendToString(std::string *dest) const; + int GetNumLoadedVerts() const { return m_numLoadedVertices; } private: enum diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index fbb90f3456..454737e732 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -912,7 +912,7 @@ void Renderer::SwapBuffers() } if (g_Config.bOverlayStats) { - char st[2048]; + char st[8192]; char *p = st; if (g_Config.bShowFPS) p+=sprintf(p, "FPS: %d\n", s_fps); // So it shows up before the stats and doesn't make anyting ugly diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoaderManager.cpp index 88b1ec18b7..b77821bc40 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoaderManager.cpp @@ -16,6 +16,8 @@ // http://code.google.com/p/dolphin-emu/ #include +#include +#include #include "VideoCommon.h" #include "Statistics.h" @@ -51,11 +53,33 @@ void Shutdown() g_VertexLoaderMap.clear(); } +namespace { +struct entry { + std::string text; + u64 num_verts; + bool operator < (const entry &other) const { + return num_verts > other.num_verts; + } +}; +} + void AppendListToString(std::string *dest) { - for (VertexLoaderMap::iterator iter = g_VertexLoaderMap.begin(); iter != g_VertexLoaderMap.end(); ++iter) + std::vector entries; + + size_t total_size = 0; + for (VertexLoaderMap::const_iterator iter = g_VertexLoaderMap.begin(); iter != g_VertexLoaderMap.end(); ++iter) { - iter->second->AppendToString(dest); + entry e; + iter->second->AppendToString(&e.text); + e.num_verts = iter->second->GetNumLoadedVerts(); + entries.push_back(e); + total_size += e.text.size() + 1; + } + sort(entries.begin(), entries.end()); + dest->reserve(dest->size() + total_size); + for (std::vector::const_iterator iter = entries.begin(); iter != entries.end(); ++iter) { + dest->append(iter->text); } }