1 // Copyright 2008 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4
5 #include "VideoCommon/Statistics.h"
6
7 #include <utility>
8
9 #include <imgui.h>
10
11 #include "VideoCommon/VideoCommon.h"
12 #include "VideoCommon/VideoConfig.h"
13
14 Statistics g_stats;
15
ResetFrame()16 void Statistics::ResetFrame()
17 {
18 this_frame = {};
19 }
20
SwapDL()21 void Statistics::SwapDL()
22 {
23 std::swap(this_frame.num_dl_prims, this_frame.num_prims);
24 std::swap(this_frame.num_xf_loads_in_dl, this_frame.num_xf_loads);
25 std::swap(this_frame.num_cp_loads_in_dl, this_frame.num_cp_loads);
26 std::swap(this_frame.num_bp_loads_in_dl, this_frame.num_bp_loads);
27 }
28
Display() const29 void Statistics::Display() const
30 {
31 const float scale = ImGui::GetIO().DisplayFramebufferScale.x;
32 ImGui::SetNextWindowPos(ImVec2(10.0f * scale, 10.0f * scale), ImGuiCond_FirstUseEver);
33 ImGui::SetNextWindowSizeConstraints(ImVec2(275.0f * scale, 400.0f * scale),
34 ImGui::GetIO().DisplaySize);
35 if (!ImGui::Begin("Statistics", nullptr, ImGuiWindowFlags_NoNavInputs))
36 {
37 ImGui::End();
38 return;
39 }
40
41 ImGui::Columns(2, "Statistics", true);
42
43 const auto draw_statistic = [](const char* name, const char* format, auto&&... args) {
44 ImGui::TextUnformatted(name);
45 ImGui::NextColumn();
46 ImGui::Text(format, std::forward<decltype(args)>(args)...);
47 ImGui::NextColumn();
48 };
49
50 if (g_ActiveConfig.backend_info.api_type == APIType::Nothing)
51 {
52 draw_statistic("Objects", "%d", this_frame.num_drawn_objects);
53 draw_statistic("Vertices Loaded", "%d", this_frame.num_vertices_loaded);
54 draw_statistic("Triangles Input", "%d", this_frame.num_triangles_in);
55 draw_statistic("Triangles Rejected", "%d", this_frame.num_triangles_rejected);
56 draw_statistic("Triangles Culled", "%d", this_frame.num_triangles_culled);
57 draw_statistic("Triangles Clipped", "%d", this_frame.num_triangles_clipped);
58 draw_statistic("Triangles Drawn", "%d", this_frame.num_triangles_drawn);
59 draw_statistic("Rasterized Pix", "%d", this_frame.rasterized_pixels);
60 draw_statistic("TEV Pix In", "%d", this_frame.tev_pixels_in);
61 draw_statistic("TEV Pix Out", "%d", this_frame.tev_pixels_out);
62 }
63
64 draw_statistic("Textures created", "%d", num_textures_created);
65 draw_statistic("Textures uploaded", "%d", num_textures_uploaded);
66 draw_statistic("Textures alive", "%d", num_textures_alive);
67 draw_statistic("pshaders created", "%d", num_pixel_shaders_created);
68 draw_statistic("pshaders alive", "%d", num_pixel_shaders_alive);
69 draw_statistic("vshaders created", "%d", num_vertex_shaders_created);
70 draw_statistic("vshaders alive", "%d", num_vertex_shaders_alive);
71 draw_statistic("shaders changes", "%d", this_frame.num_shader_changes);
72 draw_statistic("dlists called", "%d", this_frame.num_dlists_called);
73 draw_statistic("Primitive joins", "%d", this_frame.num_primitive_joins);
74 draw_statistic("Draw calls", "%d", this_frame.num_draw_calls);
75 draw_statistic("Primitives", "%d", this_frame.num_prims);
76 draw_statistic("Primitives (DL)", "%d", this_frame.num_dl_prims);
77 draw_statistic("XF loads", "%d", this_frame.num_xf_loads);
78 draw_statistic("XF loads (DL)", "%d", this_frame.num_xf_loads_in_dl);
79 draw_statistic("CP loads", "%d", this_frame.num_cp_loads);
80 draw_statistic("CP loads (DL)", "%d", this_frame.num_cp_loads_in_dl);
81 draw_statistic("BP loads", "%d", this_frame.num_bp_loads);
82 draw_statistic("BP loads (DL)", "%d", this_frame.num_bp_loads_in_dl);
83 draw_statistic("Vertex streamed", "%i kB", this_frame.bytes_vertex_streamed / 1024);
84 draw_statistic("Index streamed", "%i kB", this_frame.bytes_index_streamed / 1024);
85 draw_statistic("Uniform streamed", "%i kB", this_frame.bytes_uniform_streamed / 1024);
86 draw_statistic("Vertex Loaders", "%d", num_vertex_loaders);
87 draw_statistic("EFB peeks:", "%d", this_frame.num_efb_peeks);
88 draw_statistic("EFB pokes:", "%d", this_frame.num_efb_pokes);
89
90 ImGui::Columns(1);
91
92 ImGui::End();
93 }
94
95 // Is this really needed?
DisplayProj() const96 void Statistics::DisplayProj() const
97 {
98 if (!ImGui::Begin("Projection Statistics", nullptr, ImGuiWindowFlags_NoNavInputs))
99 {
100 ImGui::End();
101 return;
102 }
103
104 ImGui::TextUnformatted("Projection #: X for Raw 6=0 (X for Raw 6!=0)");
105 ImGui::NewLine();
106 ImGui::Text("Projection 0: %f (%f) Raw 0: %f", gproj[0], g2proj[0], proj[0]);
107 ImGui::Text("Projection 1: %f (%f)", gproj[1], g2proj[1]);
108 ImGui::Text("Projection 2: %f (%f) Raw 1: %f", gproj[2], g2proj[2], proj[1]);
109 ImGui::Text("Projection 3: %f (%f)", gproj[3], g2proj[3]);
110 ImGui::Text("Projection 4: %f (%f)", gproj[4], g2proj[4]);
111 ImGui::Text("Projection 5: %f (%f) Raw 2: %f", gproj[5], g2proj[5], proj[2]);
112 ImGui::Text("Projection 6: %f (%f) Raw 3: %f", gproj[6], g2proj[6], proj[3]);
113 ImGui::Text("Projection 7: %f (%f)", gproj[7], g2proj[7]);
114 ImGui::Text("Projection 8: %f (%f)", gproj[8], g2proj[8]);
115 ImGui::Text("Projection 9: %f (%f)", gproj[9], g2proj[9]);
116 ImGui::Text("Projection 10: %f (%f) Raw 4: %f", gproj[10], g2proj[10], proj[4]);
117 ImGui::Text("Projection 11: %f (%f) Raw 5: %f", gproj[11], g2proj[11], proj[5]);
118 ImGui::Text("Projection 12: %f (%f)", gproj[12], g2proj[12]);
119 ImGui::Text("Projection 13: %f (%f)", gproj[13], g2proj[13]);
120 ImGui::Text("Projection 14: %f (%f)", gproj[14], g2proj[14]);
121 ImGui::Text("Projection 15: %f (%f)", gproj[15], g2proj[15]);
122
123 ImGui::End();
124 }
125