Use strings instead of arbitrary buffers for video statistics
This commit is contained in:
parent
010ca048df
commit
1583ce9363
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <string>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
|
||||||
#include "Common/Timer.h"
|
#include "Common/Timer.h"
|
||||||
|
@ -872,9 +873,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char msg [255];
|
std::string msg = StringFromFormat("Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
|
||||||
sprintf_s(msg,255, "Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
|
|
||||||
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), s_recordWidth, s_recordHeight);
|
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), s_recordWidth, s_recordHeight);
|
||||||
|
|
||||||
OSD::AddMessage(msg, 2000);
|
OSD::AddMessage(msg, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -912,37 +913,29 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
|
||||||
// Finish up the current frame, print some stats
|
// Finish up the current frame, print some stats
|
||||||
if (g_ActiveConfig.bShowFPS)
|
if (g_ActiveConfig.bShowFPS)
|
||||||
{
|
{
|
||||||
char fps[20];
|
std::string fps = StringFromFormat("FPS: %d\n", s_fps);
|
||||||
StringCchPrintfA(fps, 20, "FPS: %d\n", s_fps);
|
|
||||||
D3D::font.DrawTextScaled(0, 0, 20, 0.0f, 0xFF00FFFF, fps);
|
D3D::font.DrawTextScaled(0, 0, 20, 0.0f, 0xFF00FFFF, fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SConfig::GetInstance().m_ShowLag)
|
if (SConfig::GetInstance().m_ShowLag)
|
||||||
{
|
{
|
||||||
char lag[10];
|
std::string lag = StringFromFormat("Lag: %" PRIu64 "\n", Movie::g_currentLagCount);
|
||||||
StringCchPrintfA(lag, 10, "Lag: %" PRIu64 "\n", Movie::g_currentLagCount);
|
|
||||||
D3D::font.DrawTextScaled(0, 18, 20, 0.0f, 0xFF00FFFF, lag);
|
D3D::font.DrawTextScaled(0, 18, 20, 0.0f, 0xFF00FFFF, lag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ActiveConfig.bShowInputDisplay)
|
if (g_ActiveConfig.bShowInputDisplay)
|
||||||
{
|
{
|
||||||
char inputDisplay[1000];
|
D3D::font.DrawTextScaled(0, 36, 20, 0.0f, 0xFF00FFFF, Movie::GetInputDisplay());
|
||||||
StringCchPrintfA(inputDisplay, 1000, Movie::GetInputDisplay().c_str());
|
|
||||||
D3D::font.DrawTextScaled(0, 36, 20, 0.0f, 0xFF00FFFF, inputDisplay);
|
|
||||||
}
|
}
|
||||||
Renderer::DrawDebugText();
|
Renderer::DrawDebugText();
|
||||||
|
|
||||||
if (g_ActiveConfig.bOverlayStats)
|
if (g_ActiveConfig.bOverlayStats)
|
||||||
{
|
{
|
||||||
char buf[32768];
|
D3D::font.DrawTextScaled(0, 36, 20, 0.0f, 0xFF00FFFF, Statistics::ToString());
|
||||||
Statistics::ToString(buf);
|
|
||||||
D3D::font.DrawTextScaled(0, 36, 20, 0.0f, 0xFF00FFFF, buf);
|
|
||||||
}
|
}
|
||||||
else if (g_ActiveConfig.bOverlayProjStats)
|
else if (g_ActiveConfig.bOverlayProjStats)
|
||||||
{
|
{
|
||||||
char buf[32768];
|
D3D::font.DrawTextScaled(0, 36, 20, 0.0f, 0xFF00FFFF, Statistics::ToStringProj());
|
||||||
Statistics::ToStringProj(buf);
|
|
||||||
D3D::font.DrawTextScaled(0, 36, 20, 0.0f, 0xFF00FFFF, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OSD::DrawMessages();
|
OSD::DrawMessages();
|
||||||
|
|
|
@ -680,19 +680,18 @@ void Renderer::DrawDebugInfo()
|
||||||
{
|
{
|
||||||
// Reset viewport for drawing text
|
// Reset viewport for drawing text
|
||||||
glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight());
|
glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight());
|
||||||
|
|
||||||
// Draw various messages on the screen, like FPS, statistics, etc.
|
// Draw various messages on the screen, like FPS, statistics, etc.
|
||||||
char debugtext_buffer[8192];
|
std::string debug_info;
|
||||||
char *p = debugtext_buffer;
|
|
||||||
p[0] = 0;
|
|
||||||
|
|
||||||
if (g_ActiveConfig.bShowFPS)
|
if (g_ActiveConfig.bShowFPS)
|
||||||
p+=sprintf(p, "FPS: %d\n", s_fps);
|
debug_info += StringFromFormat("FPS: %d\n", s_fps);
|
||||||
|
|
||||||
if (SConfig::GetInstance().m_ShowLag)
|
if (SConfig::GetInstance().m_ShowLag)
|
||||||
p+=sprintf(p, "Lag: %" PRIu64 "\n", Movie::g_currentLagCount);
|
debug_info += StringFromFormat("Lag: %" PRIu64 "\n", Movie::g_currentLagCount);
|
||||||
|
|
||||||
if (g_ActiveConfig.bShowInputDisplay)
|
if (g_ActiveConfig.bShowInputDisplay)
|
||||||
p+=sprintf(p, "%s", Movie::GetInputDisplay().c_str());
|
debug_info += Movie::GetInputDisplay();
|
||||||
|
|
||||||
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL && g_ActiveConfig.bShowEFBCopyRegions)
|
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL && g_ActiveConfig.bShowEFBCopyRegions)
|
||||||
{
|
{
|
||||||
|
@ -815,16 +814,16 @@ void Renderer::DrawDebugInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ActiveConfig.bOverlayStats)
|
if (g_ActiveConfig.bOverlayStats)
|
||||||
p = Statistics::ToString(p);
|
debug_info += Statistics::ToString();
|
||||||
|
|
||||||
if (g_ActiveConfig.bOverlayProjStats)
|
if (g_ActiveConfig.bOverlayProjStats)
|
||||||
p = Statistics::ToStringProj(p);
|
debug_info += Statistics::ToStringProj();
|
||||||
|
|
||||||
// Render a shadow, and then the text.
|
if (!debug_info.empty())
|
||||||
if (p != debugtext_buffer)
|
|
||||||
{
|
{
|
||||||
Renderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
|
// Render a shadow, and then the text.
|
||||||
Renderer::RenderText(debugtext_buffer, 20, 20, 0xFF00FFFF);
|
Renderer::RenderText(debug_info, 21, 21, 0xDD000000);
|
||||||
|
Renderer::RenderText(debug_info, 20, 20, 0xFF00FFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <string.h>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
#include "VideoCommon/Statistics.h"
|
#include "VideoCommon/Statistics.h"
|
||||||
#include "VideoCommon/VertexLoaderManager.h"
|
#include "VideoCommon/VertexLoaderManager.h"
|
||||||
|
|
||||||
|
@ -23,70 +24,72 @@ void Statistics::SwapDL()
|
||||||
std::swap(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
std::swap(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Statistics::ToString(char *ptr)
|
std::string Statistics::ToString()
|
||||||
{
|
{
|
||||||
char *p = ptr;
|
std::string str;
|
||||||
ptr+=sprintf(ptr,"Textures created: %i\n",stats.numTexturesCreated);
|
str += StringFromFormat("Textures created: %i\n",stats.numTexturesCreated);
|
||||||
ptr+=sprintf(ptr,"Textures alive: %i\n",stats.numTexturesAlive);
|
str += StringFromFormat("Textures alive: %i\n", stats.numTexturesAlive);
|
||||||
ptr+=sprintf(ptr,"pshaders created: %i\n",stats.numPixelShadersCreated);
|
str += StringFromFormat("pshaders created: %i\n", stats.numPixelShadersCreated);
|
||||||
ptr+=sprintf(ptr,"pshaders alive: %i\n",stats.numPixelShadersAlive);
|
str += StringFromFormat("pshaders alive: %i\n",stats.numPixelShadersAlive);
|
||||||
ptr+=sprintf(ptr,"pshaders (unique, delete cache first): %i\n",stats.numUniquePixelShaders);
|
str += StringFromFormat("pshaders (unique, delete cache first): %i\n",stats.numUniquePixelShaders);
|
||||||
ptr+=sprintf(ptr,"vshaders created: %i\n",stats.numVertexShadersCreated);
|
str += StringFromFormat("vshaders created: %i\n",stats.numVertexShadersCreated);
|
||||||
ptr+=sprintf(ptr,"vshaders alive: %i\n",stats.numVertexShadersAlive);
|
str += StringFromFormat("vshaders alive: %i\n",stats.numVertexShadersAlive);
|
||||||
ptr+=sprintf(ptr,"dlists called: %i\n",stats.numDListsCalled);
|
str += StringFromFormat("dlists called: %i\n",stats.numDListsCalled);
|
||||||
ptr+=sprintf(ptr,"dlists called(f): %i\n",stats.thisFrame.numDListsCalled);
|
str += StringFromFormat("dlists called(f): %i\n",stats.thisFrame.numDListsCalled);
|
||||||
ptr+=sprintf(ptr,"dlists alive: %i\n",stats.numDListsAlive);
|
str += StringFromFormat("dlists alive: %i\n",stats.numDListsAlive);
|
||||||
ptr+=sprintf(ptr,"Primitive joins: %i\n",stats.thisFrame.numPrimitiveJoins);
|
str += StringFromFormat("Primitive joins: %i\n",stats.thisFrame.numPrimitiveJoins);
|
||||||
ptr+=sprintf(ptr,"Draw calls: %i\n",stats.thisFrame.numDrawCalls);
|
str += StringFromFormat("Draw calls: %i\n",stats.thisFrame.numDrawCalls);
|
||||||
ptr+=sprintf(ptr,"Indexed draw calls: %i\n",stats.thisFrame.numIndexedDrawCalls);
|
str += StringFromFormat("Indexed draw calls: %i\n",stats.thisFrame.numIndexedDrawCalls);
|
||||||
ptr+=sprintf(ptr,"Buffer splits: %i\n",stats.thisFrame.numBufferSplits);
|
str += StringFromFormat("Buffer splits: %i\n",stats.thisFrame.numBufferSplits);
|
||||||
ptr+=sprintf(ptr,"Primitives: %i\n",stats.thisFrame.numPrims);
|
str += StringFromFormat("Primitives: %i\n",stats.thisFrame.numPrims);
|
||||||
ptr+=sprintf(ptr,"Primitives (DL): %i\n",stats.thisFrame.numDLPrims);
|
str += StringFromFormat("Primitives (DL): %i\n",stats.thisFrame.numDLPrims);
|
||||||
ptr+=sprintf(ptr,"XF loads: %i\n",stats.thisFrame.numXFLoads);
|
str += StringFromFormat("XF loads: %i\n",stats.thisFrame.numXFLoads);
|
||||||
ptr+=sprintf(ptr,"XF loads (DL): %i\n",stats.thisFrame.numXFLoadsInDL);
|
str += StringFromFormat("XF loads (DL): %i\n",stats.thisFrame.numXFLoadsInDL);
|
||||||
ptr+=sprintf(ptr,"CP loads: %i\n",stats.thisFrame.numCPLoads);
|
str += StringFromFormat("CP loads: %i\n",stats.thisFrame.numCPLoads);
|
||||||
ptr+=sprintf(ptr,"CP loads (DL): %i\n",stats.thisFrame.numCPLoadsInDL);
|
str += StringFromFormat("CP loads (DL): %i\n",stats.thisFrame.numCPLoadsInDL);
|
||||||
ptr+=sprintf(ptr,"BP loads: %i\n",stats.thisFrame.numBPLoads);
|
str += StringFromFormat("BP loads: %i\n",stats.thisFrame.numBPLoads);
|
||||||
ptr+=sprintf(ptr,"BP loads (DL): %i\n",stats.thisFrame.numBPLoadsInDL);
|
str += StringFromFormat("BP loads (DL): %i\n",stats.thisFrame.numBPLoadsInDL);
|
||||||
ptr+=sprintf(ptr,"Vertex streamed: %i kB\n",stats.thisFrame.bytesVertexStreamed/1024);
|
str += StringFromFormat("Vertex streamed: %i kB\n",stats.thisFrame.bytesVertexStreamed/1024);
|
||||||
ptr+=sprintf(ptr,"Index streamed: %i kB\n",stats.thisFrame.bytesIndexStreamed/1024);
|
str += StringFromFormat("Index streamed: %i kB\n",stats.thisFrame.bytesIndexStreamed/1024);
|
||||||
ptr+=sprintf(ptr,"Uniform streamed: %i kB\n",stats.thisFrame.bytesUniformStreamed/1024);
|
str += StringFromFormat("Uniform streamed: %i kB\n",stats.thisFrame.bytesUniformStreamed/1024);
|
||||||
ptr+=sprintf(ptr,"Vertex Loaders: %i\n",stats.numVertexLoaders);
|
str += StringFromFormat("Vertex Loaders: %i\n",stats.numVertexLoaders);
|
||||||
|
|
||||||
std::string text1;
|
std::string vertex_list;
|
||||||
VertexLoaderManager::AppendListToString(&text1);
|
VertexLoaderManager::AppendListToString(&vertex_list);
|
||||||
|
|
||||||
// TODO : at some point text1 just becomes too huge and overflows, we can't even read the added stuff
|
// TODO : at some point text1 just becomes too huge and overflows, we can't even read the added stuff
|
||||||
// since it gets added at the far bottom of the screen anyway (actually outside the rendering window)
|
// since it gets added at the far bottom of the screen anyway (actually outside the rendering window)
|
||||||
// we should really reset the list instead of using substr
|
// we should really reset the list instead of using substr
|
||||||
if (text1.size() + ptr - p > 8170)
|
if (vertex_list.size() + str.size() > 8170)
|
||||||
text1 = text1.substr(0, 8170 - (ptr - p));
|
vertex_list = vertex_list.substr(0, 8170 - str.size());
|
||||||
|
|
||||||
ptr+=sprintf(ptr,"%s",text1.c_str());
|
str += vertex_list;
|
||||||
|
|
||||||
return ptr;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this really needed?
|
// Is this really needed?
|
||||||
char *Statistics::ToStringProj(char *ptr)
|
std::string Statistics::ToStringProj()
|
||||||
{
|
{
|
||||||
char *p = ptr;
|
std::string projections;
|
||||||
p+=sprintf(p,"Projection #: X for Raw 6=0 (X for Raw 6!=0)\n\n");
|
|
||||||
p+=sprintf(p,"Projection 0: %f (%f) Raw 0: %f\n", stats.gproj_0, stats.g2proj_0, stats.proj_0);
|
projections += "Projection #: X for Raw 6=0 (X for Raw 6!=0)\n\n";
|
||||||
p+=sprintf(p,"Projection 1: %f (%f)\n", stats.gproj_1, stats.g2proj_1);
|
projections += StringFromFormat("Projection 0: %f (%f) Raw 0: %f\n", stats.gproj_0, stats.g2proj_0, stats.proj_0);
|
||||||
p+=sprintf(p,"Projection 2: %f (%f) Raw 1: %f\n", stats.gproj_2, stats.g2proj_2, stats.proj_1);
|
projections += StringFromFormat("Projection 1: %f (%f)\n", stats.gproj_1, stats.g2proj_1);
|
||||||
p+=sprintf(p,"Projection 3: %f (%f)\n\n", stats.gproj_3, stats.g2proj_3);
|
projections += StringFromFormat("Projection 2: %f (%f) Raw 1: %f\n", stats.gproj_2, stats.g2proj_2, stats.proj_1);
|
||||||
p+=sprintf(p,"Projection 4: %f (%f)\n", stats.gproj_4, stats.g2proj_4);
|
projections += StringFromFormat("Projection 3: %f (%f)\n\n", stats.gproj_3, stats.g2proj_3);
|
||||||
p+=sprintf(p,"Projection 5: %f (%f) Raw 2: %f\n", stats.gproj_5, stats.g2proj_5, stats.proj_2);
|
projections += StringFromFormat("Projection 4: %f (%f)\n", stats.gproj_4, stats.g2proj_4);
|
||||||
p+=sprintf(p,"Projection 6: %f (%f) Raw 3: %f\n", stats.gproj_6, stats.g2proj_6, stats.proj_3);
|
projections += StringFromFormat("Projection 5: %f (%f) Raw 2: %f\n", stats.gproj_5, stats.g2proj_5, stats.proj_2);
|
||||||
p+=sprintf(p,"Projection 7: %f (%f)\n\n", stats.gproj_7, stats.g2proj_7);
|
projections += StringFromFormat("Projection 6: %f (%f) Raw 3: %f\n", stats.gproj_6, stats.g2proj_6, stats.proj_3);
|
||||||
p+=sprintf(p,"Projection 8: %f (%f)\n", stats.gproj_8, stats.g2proj_8);
|
projections += StringFromFormat("Projection 7: %f (%f)\n\n", stats.gproj_7, stats.g2proj_7);
|
||||||
p+=sprintf(p,"Projection 9: %f (%f)\n", stats.gproj_9, stats.g2proj_9);
|
projections += StringFromFormat("Projection 8: %f (%f)\n", stats.gproj_8, stats.g2proj_8);
|
||||||
p+=sprintf(p,"Projection 10: %f (%f) Raw 4: %f\n\n", stats.gproj_10, stats.g2proj_10, stats.proj_4);
|
projections += StringFromFormat("Projection 9: %f (%f)\n", stats.gproj_9, stats.g2proj_9);
|
||||||
p+=sprintf(p,"Projection 11: %f (%f) Raw 5: %f\n\n", stats.gproj_11, stats.g2proj_11, stats.proj_5);
|
projections += StringFromFormat("Projection 10: %f (%f) Raw 4: %f\n\n", stats.gproj_10, stats.g2proj_10, stats.proj_4);
|
||||||
p+=sprintf(p,"Projection 12: %f (%f)\n", stats.gproj_12, stats.g2proj_12);
|
projections += StringFromFormat("Projection 11: %f (%f) Raw 5: %f\n\n", stats.gproj_11, stats.g2proj_11, stats.proj_5);
|
||||||
p+=sprintf(p,"Projection 13: %f (%f)\n", stats.gproj_13, stats.g2proj_13);
|
projections += StringFromFormat("Projection 12: %f (%f)\n", stats.gproj_12, stats.g2proj_12);
|
||||||
p+=sprintf(p,"Projection 14: %f (%f)\n", stats.gproj_14, stats.g2proj_14);
|
projections += StringFromFormat("Projection 13: %f (%f)\n", stats.gproj_13, stats.g2proj_13);
|
||||||
p+=sprintf(p,"Projection 15: %f (%f)\n", stats.gproj_15, stats.g2proj_15);
|
projections += StringFromFormat("Projection 14: %f (%f)\n", stats.gproj_14, stats.g2proj_14);
|
||||||
return p;
|
projections += StringFromFormat("Projection 15: %f (%f)\n", stats.gproj_15, stats.g2proj_15);
|
||||||
|
|
||||||
|
return projections;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
@ -69,10 +70,8 @@ struct Statistics
|
||||||
void ResetFrame();
|
void ResetFrame();
|
||||||
static void SwapDL();
|
static void SwapDL();
|
||||||
|
|
||||||
// Yeah, this is unsafe, but we really don't wanna faff around allocating
|
static std::string ToString();
|
||||||
// buffers here.
|
static std::string ToStringProj();
|
||||||
static char *ToString(char *ptr);
|
|
||||||
static char *ToStringProj(char *ptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Statistics stats;
|
extern Statistics stats;
|
||||||
|
|
Loading…
Reference in New Issue