MangoHud/src/overlay.h

132 lines
3.3 KiB
C
Raw Normal View History

#pragma once
#ifndef MANGOHUD_OVERLAY_H
#define MANGOHUD_OVERLAY_H
2020-03-10 05:19:18 +00:00
#include <string>
#include <stdint.h>
#include <vector>
#include <imgui.h>
2020-03-10 05:19:18 +00:00
#include "overlay_params.h"
#include "iostats.h"
2020-06-24 18:14:24 +00:00
#include "timing.hpp"
#include "hud_elements.h"
#include "version.h"
#include "gpu.h"
2020-11-06 23:01:23 +00:00
#include "logging.h"
#ifdef HAVE_DBUS
#include "dbus_info.h"
extern float g_overflow;
#endif
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-06-27 13:30:23 +00:00
enum EngineTypes
{
UNKNOWN,
OPENGL,
VULKAN,
DXVK,
VKD3D,
DAMAVAND,
ZINK,
WINED3D,
FERAL3D,
2021-03-13 16:09:17 +00:00
TOGL,
2021-06-27 13:30:23 +00:00
};
extern const char* engines[];
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;
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;
struct iostats io;
uint64_t last_present_time;
unsigned n_frames_since_update;
uint64_t last_fps_update;
ImVec2 main_window_pos;
struct {
int32_t major;
int32_t minor;
bool is_gles;
} 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;
std::string deviceName;
std::string gpuName;
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;
2020-03-10 05:19:18 +00:00
};
struct benchmark_stats {
float total;
std::vector<float> fps_data;
std::vector<std::pair<std::string, float>> percentile_data;
};
2020-10-22 05:17:14 +00:00
struct LOAD_DATA {
ImVec4 color_low;
ImVec4 color_med;
ImVec4 color_high;
2020-10-22 05:17:14 +00:00
unsigned med_load;
unsigned high_load;
2020-10-22 05:17:14 +00:00
};
extern struct fps_limit fps_limit_stats;
2020-05-09 23:36:09 +00:00
extern int32_t deviceID;
extern struct benchmark_stats benchmark;
2020-09-23 10:23:29 +00:00
extern ImVec2 real_font_size;
extern std::string wineVersion;
2020-11-06 23:01:23 +00:00
extern std::vector<logData> graph_data;
2021-09-18 15:21:20 +00:00
extern overlay_params _params;
void position_layer(struct swapchain_stats& data, struct overlay_params& params, ImVec2 window_size);
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan);
2020-03-10 05:19:18 +00:00
void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID);
void update_hw_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID);
2020-03-10 05:19:18 +00:00
void init_gpu_stats(uint32_t& vendorID, overlay_params& params);
void init_cpu_stats(overlay_params& params);
2020-06-21 11:44:12 +00:00
void check_keybinds(struct swapchain_stats& sw_stats, struct 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);
2020-05-10 12:11:56 +00:00
void get_device_name(int32_t vendorID, int32_t deviceID, struct swapchain_stats& sw_stats);
2021-09-18 15:21:20 +00:00
void calculate_benchmark_data();
void create_fonts(const overlay_params& params, ImFont*& small_font, ImFont*& text_font);
void right_aligned_text(ImVec4& col, float off_x, const char *fmt, ...);
void center_text(const std::string& text);
ImVec4 change_on_load_temp(LOAD_DATA& data, unsigned current);
float get_time_stat(void *_data, int _idx);
2020-11-03 20:58:40 +00:00
#ifdef HAVE_DBUS
void render_mpris_metadata(overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing);
2020-11-03 20:58:40 +00:00
#endif
2020-07-18 19:18:27 +00:00
#endif //MANGOHUD_OVERLAY_H