2020-06-29 14:15:50 +00:00
|
|
|
#pragma once
|
2020-07-06 17:31:40 +00:00
|
|
|
#ifndef MANGOHUD_OVERLAY_H
|
|
|
|
#define MANGOHUD_OVERLAY_H
|
2020-06-29 14:15:50 +00:00
|
|
|
|
2020-03-10 05:19:18 +00:00
|
|
|
#include <string>
|
|
|
|
#include <stdint.h>
|
2020-05-16 11:35:50 +00:00
|
|
|
#include <vector>
|
2021-12-18 15:20:54 +00:00
|
|
|
#include <deque>
|
2021-08-07 12:55:04 +00:00
|
|
|
#include <imgui.h>
|
2023-05-27 06:30:07 +00:00
|
|
|
#include "imgui_internal.h"
|
2020-03-10 05:19:18 +00:00
|
|
|
#include "overlay_params.h"
|
2020-11-03 14:35:10 +00:00
|
|
|
#include "hud_elements.h"
|
2022-04-07 08:28:48 +00:00
|
|
|
#include "engine_types.h"
|
2022-01-14 21:41:38 +00:00
|
|
|
|
2020-11-03 14:35:10 +00:00
|
|
|
#include "dbus_info.h"
|
2022-03-14 18:49:20 +00:00
|
|
|
#include "logging.h"
|
|
|
|
|
2020-03-10 05:19:18 +00:00
|
|
|
struct frame_stat {
|
2020-03-24 19:38:08 +00:00
|
|
|
uint64_t stats[OVERLAY_PLOTS_MAX];
|
2020-03-10 05:19:18 +00:00
|
|
|
};
|
|
|
|
|
2021-12-18 15:20:54 +00:00
|
|
|
static const int kMaxGraphEntries = 50;
|
|
|
|
|
2020-03-10 05:19:18 +00:00
|
|
|
struct swapchain_stats {
|
|
|
|
uint64_t n_frames;
|
2020-03-24 19:38:08 +00:00
|
|
|
enum overlay_plots stat_selector;
|
2020-03-10 05:19:18 +00:00
|
|
|
double time_dividor;
|
|
|
|
struct frame_stat stats_min, stats_max;
|
|
|
|
struct frame_stat frames_stats[200];
|
|
|
|
|
|
|
|
ImFont* font1 = nullptr;
|
2020-06-29 14:15:50 +00:00
|
|
|
ImFont* font_text = nullptr;
|
2020-11-16 13:51:37 +00:00
|
|
|
size_t font_params_hash = 0;
|
2020-03-10 05:19:18 +00:00
|
|
|
std::string time;
|
|
|
|
double fps;
|
|
|
|
uint64_t last_present_time;
|
|
|
|
unsigned n_frames_since_update;
|
|
|
|
uint64_t last_fps_update;
|
2020-05-16 11:35:50 +00:00
|
|
|
ImVec2 main_window_pos;
|
|
|
|
|
2020-03-16 22:24:04 +00:00
|
|
|
struct {
|
|
|
|
int32_t major;
|
|
|
|
int32_t minor;
|
2020-04-12 13:16:13 +00:00
|
|
|
bool is_gles;
|
2020-03-16 22:24:04 +00:00
|
|
|
} version_gl;
|
|
|
|
struct {
|
|
|
|
int32_t major;
|
|
|
|
int32_t minor;
|
|
|
|
int32_t patch;
|
|
|
|
} version_vk;
|
2020-03-23 14:35:21 +00:00
|
|
|
std::string engineName;
|
|
|
|
std::string engineVersion;
|
2020-04-28 15:05:25 +00:00
|
|
|
std::string deviceName;
|
2020-05-09 23:43:08 +00:00
|
|
|
std::string gpuName;
|
2020-05-10 00:22:44 +00:00
|
|
|
std::string driverName;
|
2021-06-27 13:30:23 +00:00
|
|
|
enum EngineTypes engine;
|
2020-03-10 05:19:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct fps_limit {
|
2020-06-24 18:14:24 +00:00
|
|
|
Clock::time_point frameStart;
|
|
|
|
Clock::time_point frameEnd;
|
|
|
|
Clock::duration targetFrameTime;
|
|
|
|
Clock::duration frameOverhead;
|
|
|
|
Clock::duration sleepTime;
|
2023-03-16 01:57:10 +00:00
|
|
|
enum fps_limit_method method;
|
2020-03-10 05:19:18 +00:00
|
|
|
};
|
|
|
|
|
2020-05-16 11:35:50 +00:00
|
|
|
struct benchmark_stats {
|
|
|
|
float total;
|
|
|
|
std::vector<float> fps_data;
|
2020-06-18 22:42:25 +00:00
|
|
|
std::vector<std::pair<std::string, float>> percentile_data;
|
2020-05-16 11:35:50 +00:00
|
|
|
};
|
|
|
|
|
2020-10-22 05:17:14 +00:00
|
|
|
struct LOAD_DATA {
|
|
|
|
ImVec4 color_low;
|
2020-11-26 01:39:02 +00:00
|
|
|
ImVec4 color_med;
|
|
|
|
ImVec4 color_high;
|
2020-10-22 05:17:14 +00:00
|
|
|
unsigned med_load;
|
2020-11-26 01:39:02 +00:00
|
|
|
unsigned high_load;
|
2020-10-22 05:17:14 +00:00
|
|
|
};
|
2021-11-04 01:08:26 +00:00
|
|
|
|
2020-03-15 16:09:03 +00:00
|
|
|
extern struct fps_limit fps_limit_stats;
|
2022-03-15 17:48:36 +00:00
|
|
|
extern uint32_t deviceID;
|
2020-03-15 16:09:03 +00:00
|
|
|
|
2020-05-16 11:35:50 +00:00
|
|
|
extern struct benchmark_stats benchmark;
|
2020-09-23 10:23:29 +00:00
|
|
|
extern ImVec2 real_font_size;
|
2020-11-03 14:35:10 +00:00
|
|
|
extern std::string wineVersion;
|
2021-12-18 15:20:54 +00:00
|
|
|
extern std::deque<logData> graph_data;
|
2021-11-04 01:07:38 +00:00
|
|
|
extern overlay_params *_params;
|
2022-01-25 11:37:58 +00:00
|
|
|
extern double min_frametime, max_frametime;
|
2022-02-15 18:16:45 +00:00
|
|
|
extern bool steam_focused;
|
2022-04-04 05:07:31 +00:00
|
|
|
extern int fan_speed;
|
2023-07-07 04:23:12 +00:00
|
|
|
extern int current_preset;
|
2023-09-21 20:19:42 +00:00
|
|
|
extern std::vector<float> frametime_data;
|
2020-05-16 11:35:50 +00:00
|
|
|
|
2022-03-24 09:01:32 +00:00
|
|
|
void init_spdlog();
|
2022-05-14 22:11:46 +00:00
|
|
|
void overlay_new_frame(const struct overlay_params& params);
|
|
|
|
void overlay_end_frame();
|
2022-03-13 11:17:38 +00:00
|
|
|
void position_layer(struct swapchain_stats& data, const struct overlay_params& params, const ImVec2& window_size);
|
2020-03-17 13:00:20 +00:00
|
|
|
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan);
|
2022-03-13 11:17:38 +00:00
|
|
|
void update_hud_info(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID);
|
|
|
|
void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID, uint64_t frametime_ns);
|
|
|
|
void update_hw_info(const struct overlay_params& params, uint32_t vendorID);
|
2022-01-02 11:04:22 +00:00
|
|
|
void init_gpu_stats(uint32_t& vendorID, uint32_t reported_deviceID, overlay_params& params);
|
2020-03-14 21:04:02 +00:00
|
|
|
void init_cpu_stats(overlay_params& params);
|
2022-02-18 14:44:10 +00:00
|
|
|
void check_keybinds(overlay_params& params, uint32_t vendorID);
|
2020-03-10 05:19:18 +00:00
|
|
|
void init_system_info(void);
|
|
|
|
void FpsLimiter(struct fps_limit& stats);
|
2022-07-28 20:05:58 +00:00
|
|
|
void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont*& small_font, ImFont*& text_font);
|
2020-11-03 14:35:10 +00:00
|
|
|
void right_aligned_text(ImVec4& col, float off_x, const char *fmt, ...);
|
2021-08-07 12:55:04 +00:00
|
|
|
void center_text(const std::string& text);
|
2020-11-17 18:25:20 +00:00
|
|
|
ImVec4 change_on_load_temp(LOAD_DATA& data, unsigned current);
|
2020-11-03 14:35:10 +00:00
|
|
|
float get_time_stat(void *_data, int _idx);
|
2021-10-02 13:42:37 +00:00
|
|
|
void stop_hw_updater();
|
2022-04-07 08:28:48 +00:00
|
|
|
extern void control_client_check(int control, int& control_client, const std::string& deviceName);
|
|
|
|
extern void process_control_socket(int& control_client, overlay_params ¶ms);
|
2022-07-28 00:48:35 +00:00
|
|
|
extern void control_send(int control_client, const char *cmd, unsigned cmdlen, const char *param, unsigned paramlen);
|
|
|
|
extern int global_control_client;
|
2022-03-13 11:17:38 +00:00
|
|
|
#ifdef HAVE_DBUS
|
|
|
|
void render_mpris_metadata(const overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing);
|
2020-11-03 20:58:40 +00:00
|
|
|
#endif
|
2022-04-04 05:07:31 +00:00
|
|
|
void update_fan();
|
2022-12-12 15:23:47 +00:00
|
|
|
void next_hud_position(struct overlay_params& params);
|
2023-03-11 17:27:55 +00:00
|
|
|
void horizontal_separator(struct overlay_params& params);
|
2023-05-27 06:30:07 +00:00
|
|
|
void RenderOutlinedText(const char* text, ImU32 textColor);
|
2022-02-18 14:44:10 +00:00
|
|
|
#endif //MANGOHUD_OVERLAY_H
|