OpenTTD Source 20241224-master-gf74b0cf984
|
GUI for displaying framerate/game speed information. More...
#include "framerate_type.h"
#include <chrono>
#include "gfx_func.h"
#include "newgrf_sound.h"
#include "window_gui.h"
#include "window_func.h"
#include "table/sprites.h"
#include "string_func.h"
#include "strings_func.h"
#include "console_func.h"
#include "console_type.h"
#include "company_base.h"
#include "ai/ai_info.hpp"
#include "ai/ai_instance.hpp"
#include "game/game.hpp"
#include "game/game_instance.hpp"
#include "timer/timer.h"
#include "timer/timer_window.h"
#include "widgets/framerate_widget.h"
#include <atomic>
#include <mutex>
#include "safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | anonymous_namespace{framerate_gui.cpp}::PerformanceData |
struct | FramerateWindow |
struct | FramerateWindow::CachedDecimal |
struct | FrametimeGraphWindow |
Namespaces | |
namespace | anonymous_namespace{framerate_gui.cpp} |
Private declarations for performance measurement implementation. | |
Functions | |
static TimingMeasurement | GetPerformanceTimer () |
Return a timestamp with TIMESTAMP_PRECISION ticks per second precision. | |
void | ShowFrametimeGraphWindow (PerformanceElement elem) |
Open a graph window for a performance element. | |
static const char * | GetAIName (int ai_index) |
void | ShowFramerateWindow () |
Open the general framerate window. | |
void | ConPrintFramerate () |
Print performance statistics to game console. | |
void | ProcessPendingPerformanceMeasurements () |
This drains the PFE_SOUND measurement data queue into _pf_data. | |
Variables | |
static std::mutex | _sound_perf_lock |
static std::atomic< bool > | _sound_perf_pending |
static std::vector< TimingMeasurement > | _sound_perf_measurements |
const int | anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS = 512 |
Number of data points to keep in buffer for each performance measurement. | |
const TimingMeasurement | anonymous_namespace{framerate_gui.cpp}::TIMESTAMP_PRECISION = 1000000 |
Units a second is divided into in performance measurements | |
static const double | anonymous_namespace{framerate_gui.cpp}::GL_RATE = 1000.0 / MILLISECONDS_PER_TICK |
Game loop rate, cycles per second | |
PerformanceData | anonymous_namespace{framerate_gui.cpp}::_pf_data [PFE_MAX] |
Storage for all performance element measurements. | |
static const PerformanceElement | DISPLAY_ORDER_PFE [PFE_MAX] |
static constexpr NWidgetPart | _framerate_window_widgets [] |
static WindowDesc | _framerate_display_desc (WDP_AUTO, "framerate_display", 0, 0, WC_FRAMERATE_DISPLAY, WC_NONE, 0, _framerate_window_widgets) |
static constexpr NWidgetPart | _frametime_graph_window_widgets [] |
static WindowDesc | _frametime_graph_window_desc (WDP_AUTO, "frametime_graph", 140, 90, WC_FRAMETIME_GRAPH, WC_NONE, 0, _frametime_graph_window_widgets) |
GUI for displaying framerate/game speed information.
Definition in file framerate_gui.cpp.
void ConPrintFramerate | ( | ) |
Print performance statistics to game console.
Definition at line 1037 of file framerate_gui.cpp.
References anonymous_namespace{framerate_gui.cpp}::_pf_data, CC_ERROR, IConsolePrint(), anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS, PFE_AI0, PFE_DRAWING, PFE_GAMELOOP, PFE_MAX, and PFE_VIDEO.
|
static |
Definition at line 369 of file framerate_gui.cpp.
|
static |
Return a timestamp with TIMESTAMP_PRECISION
ticks per second precision.
The basis of the timestamp is implementation defined, but the value should be steady, so differences can be taken to reliably measure intervals.
Definition at line 232 of file framerate_gui.cpp.
Referenced by PerformanceMeasurer::Paused(), PerformanceAccumulator::PerformanceAccumulator(), PerformanceMeasurer::PerformanceMeasurer(), PerformanceAccumulator::Reset(), PerformanceAccumulator::~PerformanceAccumulator(), and PerformanceMeasurer::~PerformanceMeasurer().
void ProcessPendingPerformanceMeasurements | ( | ) |
This drains the PFE_SOUND measurement data queue into _pf_data.
PFE_SOUND measurements are made by the mixer thread and so cannot be stored into _pf_data directly, because this would not be thread safe and would violate the invariants of the FPS and frame graph windows.
Definition at line 1105 of file framerate_gui.cpp.
References anonymous_namespace{framerate_gui.cpp}::_pf_data, anonymous_namespace{framerate_gui.cpp}::PerformanceData::Add(), and PFE_SOUND.
Referenced by UpdateWindows().
void ShowFramerateWindow | ( | ) |
Open the general framerate window.
Definition at line 1024 of file framerate_gui.cpp.
Referenced by MenuClickHelp().
void ShowFrametimeGraphWindow | ( | PerformanceElement | elem | ) |
Open a graph window for a performance element.
Definition at line 1030 of file framerate_gui.cpp.
References PFE_MAX.
Referenced by FramerateWindow::OnClick().
|
staticconstexpr |
Definition at line 376 of file framerate_gui.cpp.
|
staticconstexpr |
Definition at line 732 of file framerate_gui.cpp.
|
static |
Definition at line 36 of file framerate_gui.cpp.
|
static |
Definition at line 38 of file framerate_gui.cpp.
|
static |
Definition at line 37 of file framerate_gui.cpp.
|
static |
Definition at line 337 of file framerate_gui.cpp.