Merge pull request #8195 from lioncash/macro

VideoCommon/Statistics: Remove preprocessor macro
This commit is contained in:
Léo Lam 2019-06-20 13:29:27 +02:00 committed by GitHub
commit baf02194c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 52 deletions

View file

@ -2,22 +2,19 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <cstring> #include "VideoCommon/Statistics.h"
#include <string>
#include <utility> #include <utility>
#include "imgui.h" #include <imgui.h>
#include "Common/StringUtil.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
Statistics stats; Statistics stats;
void Statistics::ResetFrame() void Statistics::ResetFrame()
{ {
memset(&thisFrame, 0, sizeof(ThisFrame)); thisFrame = {};
} }
void Statistics::SwapDL() void Statistics::SwapDL()
@ -42,53 +39,52 @@ void Statistics::Display()
ImGui::Columns(2, "Statistics", true); ImGui::Columns(2, "Statistics", true);
#define DRAW_STAT(name, format, ...) \ const auto draw_statistic = [](const char* name, const char* format, auto&&... args) {
ImGui::Text(name); \ ImGui::TextUnformatted(name);
ImGui::NextColumn(); \
ImGui::Text(format, __VA_ARGS__); \
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text(format, std::forward<decltype(args)>(args)...);
ImGui::NextColumn();
};
if (g_ActiveConfig.backend_info.api_type == APIType::Nothing) if (g_ActiveConfig.backend_info.api_type == APIType::Nothing)
{ {
DRAW_STAT("Objects", "%d", stats.thisFrame.numDrawnObjects); draw_statistic("Objects", "%d", stats.thisFrame.numDrawnObjects);
DRAW_STAT("Vertices Loaded", "%d", stats.thisFrame.numVerticesLoaded); draw_statistic("Vertices Loaded", "%d", stats.thisFrame.numVerticesLoaded);
DRAW_STAT("Triangles Input", "%d", stats.thisFrame.numTrianglesIn); draw_statistic("Triangles Input", "%d", stats.thisFrame.numTrianglesIn);
DRAW_STAT("Triangles Rejected", "%d", stats.thisFrame.numTrianglesRejected); draw_statistic("Triangles Rejected", "%d", stats.thisFrame.numTrianglesRejected);
DRAW_STAT("Triangles Culled", "%d", stats.thisFrame.numTrianglesCulled); draw_statistic("Triangles Culled", "%d", stats.thisFrame.numTrianglesCulled);
DRAW_STAT("Triangles Clipped", "%d", stats.thisFrame.numTrianglesClipped); draw_statistic("Triangles Clipped", "%d", stats.thisFrame.numTrianglesClipped);
DRAW_STAT("Triangles Drawn", "%d", stats.thisFrame.numTrianglesDrawn); draw_statistic("Triangles Drawn", "%d", stats.thisFrame.numTrianglesDrawn);
DRAW_STAT("Rasterized Pix", "%d", stats.thisFrame.rasterizedPixels); draw_statistic("Rasterized Pix", "%d", stats.thisFrame.rasterizedPixels);
DRAW_STAT("TEV Pix In", "%d", stats.thisFrame.tevPixelsIn); draw_statistic("TEV Pix In", "%d", stats.thisFrame.tevPixelsIn);
DRAW_STAT("TEV Pix Out", "%d", stats.thisFrame.tevPixelsOut); draw_statistic("TEV Pix Out", "%d", stats.thisFrame.tevPixelsOut);
} }
DRAW_STAT("Textures created", "%d", stats.numTexturesCreated); draw_statistic("Textures created", "%d", stats.numTexturesCreated);
DRAW_STAT("Textures uploaded", "%d", stats.numTexturesUploaded); draw_statistic("Textures uploaded", "%d", stats.numTexturesUploaded);
DRAW_STAT("Textures alive", "%d", stats.numTexturesAlive); draw_statistic("Textures alive", "%d", stats.numTexturesAlive);
DRAW_STAT("pshaders created", "%d", stats.numPixelShadersCreated); draw_statistic("pshaders created", "%d", stats.numPixelShadersCreated);
DRAW_STAT("pshaders alive", "%d", stats.numPixelShadersAlive); draw_statistic("pshaders alive", "%d", stats.numPixelShadersAlive);
DRAW_STAT("vshaders created", "%d", stats.numVertexShadersCreated); draw_statistic("vshaders created", "%d", stats.numVertexShadersCreated);
DRAW_STAT("vshaders alive", "%d", stats.numVertexShadersAlive); draw_statistic("vshaders alive", "%d", stats.numVertexShadersAlive);
DRAW_STAT("shaders changes", "%d", stats.thisFrame.numShaderChanges); draw_statistic("shaders changes", "%d", stats.thisFrame.numShaderChanges);
DRAW_STAT("dlists called", "%d", stats.thisFrame.numDListsCalled); draw_statistic("dlists called", "%d", stats.thisFrame.numDListsCalled);
DRAW_STAT("Primitive joins", "%d", stats.thisFrame.numPrimitiveJoins); draw_statistic("Primitive joins", "%d", stats.thisFrame.numPrimitiveJoins);
DRAW_STAT("Draw calls", "%d", stats.thisFrame.numDrawCalls); draw_statistic("Draw calls", "%d", stats.thisFrame.numDrawCalls);
DRAW_STAT("Primitives", "%d", stats.thisFrame.numPrims); draw_statistic("Primitives", "%d", stats.thisFrame.numPrims);
DRAW_STAT("Primitives (DL)", "%d", stats.thisFrame.numDLPrims); draw_statistic("Primitives (DL)", "%d", stats.thisFrame.numDLPrims);
DRAW_STAT("XF loads", "%d", stats.thisFrame.numXFLoads); draw_statistic("XF loads", "%d", stats.thisFrame.numXFLoads);
DRAW_STAT("XF loads (DL)", "%d", stats.thisFrame.numXFLoadsInDL); draw_statistic("XF loads (DL)", "%d", stats.thisFrame.numXFLoadsInDL);
DRAW_STAT("CP loads", "%d", stats.thisFrame.numCPLoads); draw_statistic("CP loads", "%d", stats.thisFrame.numCPLoads);
DRAW_STAT("CP loads (DL)", "%d", stats.thisFrame.numCPLoadsInDL); draw_statistic("CP loads (DL)", "%d", stats.thisFrame.numCPLoadsInDL);
DRAW_STAT("BP loads", "%d", stats.thisFrame.numBPLoads); draw_statistic("BP loads", "%d", stats.thisFrame.numBPLoads);
DRAW_STAT("BP loads (DL)", "%d", stats.thisFrame.numBPLoadsInDL); draw_statistic("BP loads (DL)", "%d", stats.thisFrame.numBPLoadsInDL);
DRAW_STAT("Vertex streamed", "%i kB", stats.thisFrame.bytesVertexStreamed / 1024); draw_statistic("Vertex streamed", "%i kB", stats.thisFrame.bytesVertexStreamed / 1024);
DRAW_STAT("Index streamed", "%i kB", stats.thisFrame.bytesIndexStreamed / 1024); draw_statistic("Index streamed", "%i kB", stats.thisFrame.bytesIndexStreamed / 1024);
DRAW_STAT("Uniform streamed", "%i kB", stats.thisFrame.bytesUniformStreamed / 1024); draw_statistic("Uniform streamed", "%i kB", stats.thisFrame.bytesUniformStreamed / 1024);
DRAW_STAT("Vertex Loaders", "%d", stats.numVertexLoaders); draw_statistic("Vertex Loaders", "%d", stats.numVertexLoaders);
DRAW_STAT("EFB peeks:", "%d", stats.thisFrame.numEFBPeeks); draw_statistic("EFB peeks:", "%d", stats.thisFrame.numEFBPeeks);
DRAW_STAT("EFB pokes:", "%d", stats.thisFrame.numEFBPokes); draw_statistic("EFB pokes:", "%d", stats.thisFrame.numEFBPokes);
#undef DRAW_STAT
ImGui::Columns(1); ImGui::Columns(1);
@ -104,7 +100,7 @@ void Statistics::DisplayProj()
return; return;
} }
ImGui::Text("Projection #: X for Raw 6=0 (X for Raw 6!=0)"); ImGui::TextUnformatted("Projection #: X for Raw 6=0 (X for Raw 6!=0)");
ImGui::NewLine(); ImGui::NewLine();
ImGui::Text("Projection 0: %f (%f) Raw 0: %f", stats.gproj_0, stats.g2proj_0, stats.proj_0); ImGui::Text("Projection 0: %f (%f) Raw 0: %f", stats.gproj_0, stats.g2proj_0, stats.proj_0);
ImGui::Text("Projection 1: %f (%f)", stats.gproj_1, stats.g2proj_1); ImGui::Text("Projection 1: %f (%f)", stats.gproj_1, stats.g2proj_1);

View file

@ -4,8 +4,6 @@
#pragma once #pragma once
#include <string>
struct Statistics struct Statistics
{ {
int numPixelShadersCreated; int numPixelShadersCreated;