mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-09-25 08:01:45 +00:00
Some poorly coded games are able to overflow some statistics (e.g. Jimmy Neutron: Boy Genius's title screen). While funny, signed integer overflow is undefined behavior, and while in practice here it's extremely unlikely to cause issues, it's still better to avoid it.
129 lines
4.7 KiB
C++
129 lines
4.7 KiB
C++
// Copyright 2008 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <vector>
|
|
|
|
#include "VideoCommon/BPFunctions.h"
|
|
|
|
struct Statistics
|
|
{
|
|
unsigned int num_pixel_shaders_created = 0;
|
|
unsigned int num_pixel_shaders_alive = 0;
|
|
unsigned int num_vertex_shaders_created = 0;
|
|
unsigned int num_vertex_shaders_alive = 0;
|
|
|
|
unsigned int num_textures_created = 0;
|
|
unsigned int num_textures_uploaded = 0;
|
|
unsigned int num_textures_alive = 0;
|
|
|
|
unsigned int num_vertex_loaders = 0;
|
|
|
|
std::array<float, 6> proj{};
|
|
std::array<float, 16> gproj{};
|
|
std::array<float, 16> g2proj{};
|
|
|
|
// For widescreen heuristic.
|
|
float avg_persp_proj_viewport_ratio = 0;
|
|
float avg_ortho_proj_viewport_ratio = 0;
|
|
|
|
std::vector<BPFunctions::ScissorResult> scissors{};
|
|
size_t current_scissor = 0; // 0 => all, otherwise index + 1
|
|
int scissor_scale = 10;
|
|
int scissor_expected_count = 0;
|
|
bool allow_duplicate_scissors = false;
|
|
bool show_scissors = true;
|
|
bool show_raw_scissors = true;
|
|
bool show_viewports = false;
|
|
bool show_text = true;
|
|
|
|
struct ThisFrame
|
|
{
|
|
unsigned int num_bp_loads = 0;
|
|
unsigned int num_cp_loads = 0;
|
|
unsigned int num_xf_loads = 0;
|
|
|
|
unsigned int num_bp_loads_in_dl = 0;
|
|
unsigned int num_cp_loads_in_dl = 0;
|
|
unsigned int num_xf_loads_in_dl = 0;
|
|
|
|
unsigned int num_prims = 0;
|
|
unsigned int num_dl_prims = 0;
|
|
unsigned int num_shader_changes = 0;
|
|
|
|
unsigned int num_primitive_joins = 0;
|
|
unsigned int num_draw_calls = 0;
|
|
|
|
unsigned int num_dlists_called = 0;
|
|
|
|
unsigned int bytes_vertex_streamed = 0;
|
|
unsigned int bytes_index_streamed = 0;
|
|
unsigned int bytes_uniform_streamed = 0;
|
|
|
|
unsigned int num_triangles_clipped = 0;
|
|
unsigned int num_triangles_in = 0;
|
|
unsigned int num_triangles_rejected = 0;
|
|
unsigned int num_triangles_culled = 0;
|
|
unsigned int num_drawn_objects = 0;
|
|
unsigned int rasterized_pixels = 0;
|
|
unsigned int num_triangles_drawn = 0;
|
|
unsigned int num_vertices_loaded = 0;
|
|
unsigned int tev_pixels_in = 0;
|
|
unsigned int tev_pixels_out = 0;
|
|
|
|
unsigned int num_efb_peeks = 0;
|
|
unsigned int num_efb_pokes = 0;
|
|
|
|
unsigned int num_draw_done = 0;
|
|
unsigned int num_token = 0;
|
|
unsigned int num_token_int = 0;
|
|
};
|
|
ThisFrame this_frame;
|
|
void ResetFrame();
|
|
void SwapDL();
|
|
void AddScissorRect();
|
|
void Display() const;
|
|
void DisplayProj() const;
|
|
void DisplayScissor();
|
|
|
|
static void Init();
|
|
static void Shutdown();
|
|
};
|
|
|
|
extern Statistics g_stats;
|
|
|
|
#define STATISTICS
|
|
|
|
#ifdef STATISTICS
|
|
#define INCSTAT(a) \
|
|
do \
|
|
{ \
|
|
(a)++; \
|
|
} while (false)
|
|
#define ADDSTAT(a, b) \
|
|
do \
|
|
{ \
|
|
(a) += (b); \
|
|
} while (false)
|
|
#define SETSTAT(a, x) \
|
|
do \
|
|
{ \
|
|
(a) = static_cast<int>(x); \
|
|
} while (false)
|
|
#else
|
|
#define INCSTAT(a) \
|
|
do \
|
|
{ \
|
|
} while (false)
|
|
#define ADDSTAT(a, b) \
|
|
do \
|
|
{ \
|
|
} while (false)
|
|
#define SETSTAT(a, x) \
|
|
do \
|
|
{ \
|
|
} while (false)
|
|
#endif
|