OpenTTD Source 20250503-master-gf4f05dea33
|
GUI for displaying framerate/game speed information. More...
#include "stdafx.h"
#include "framerate_type.h"
#include <chrono>
#include "gfx_func.h"
#include "newgrf_sound.h"
#include "window_gui.h"
#include "window_func.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 "zoom_func.h"
#include "widgets/framerate_widget.h"
#include <atomic>
#include <mutex>
#include "table/strings.h"
#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 std::string_view | 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, {}, _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, {}, _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 999 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 373 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 236 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 1067 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 986 of file framerate_gui.cpp.
Referenced by MenuClickHelp().
void ShowFrametimeGraphWindow | ( | PerformanceElement | elem | ) |
Open a graph window for a performance element.
Definition at line 992 of file framerate_gui.cpp.
References PFE_MAX.
Referenced by FramerateWindow::OnClick().
|
staticconstexpr |
Definition at line 380 of file framerate_gui.cpp.
|
staticconstexpr |
Definition at line 698 of file framerate_gui.cpp.
|
static |
Definition at line 40 of file framerate_gui.cpp.
|
static |
Definition at line 42 of file framerate_gui.cpp.
|
static |
Definition at line 41 of file framerate_gui.cpp.
|
static |
Definition at line 341 of file framerate_gui.cpp.