mangoconfig
FlightlessMango 7 months ago
parent 2254f3c1d1
commit 73ea9efb7b

@ -16,6 +16,7 @@
#include "hud_elements.h"
#include "overlay.h"
#include "font_default.h"
#include "faker.h"
GLFWwindow* g_window;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
@ -133,11 +134,11 @@ int init_imgui()
// Setup style
// ImGui::StyleColorsDark();
ImGuiIO& io = ImGui::GetIO();
create_fonts(nullptr, params, sw_stats.font1, sw_stats.font_text);
parse_overlay_config(&params, "MANGOHUD_CONFIG", false);
HUDElements.convert_colors(params);
sw_stats.engine = EngineTypes::VULKAN;
faker = std::make_unique<Faker>(sw_stats, params, vendorID);
resizeCanvas();
return 0;

@ -52,7 +52,7 @@ cxx_flags = [
'-s', 'USE_PTHREADS=1',
]
libs = ['-lGL']
libs = ['-lGL', '-gsource-map', '-sDISABLE_EXCEPTION_CATCHING=1', '-g']
spdlog_dep = mangohud_sp.get_variable('spdlog_dep')
executable('imgui', sources,

@ -3,7 +3,7 @@ project('MangoHud',
version : 'v0.7.0',
license : 'MIT',
meson_version: '>=0.60.0',
default_options : ['buildtype=release', 'c_std=c99', 'cpp_std=c++14', 'warning_level=2']
default_options : ['buildtype=release', 'c_std=c99', 'cpp_std=c++20', 'warning_level=2']
)
cc = meson.get_compiler('c')

@ -12,4 +12,5 @@ option('mangoapp', type: 'boolean', value : false)
option('mangohudctl', type: 'boolean', value : false)
option('mangoapp_layer', type: 'boolean', value : false)
option('tests', type: 'feature', value: 'auto', description: 'Run tests')
option('with_spdlog', type: 'feature', value: 'enabled')
option('with_spdlog', type: 'feature', value: 'enabled')
option('with_faker', type: 'feature', value: 'disabled')

@ -0,0 +1,111 @@
#include <iostream>
#include <random>
#include <cmath>
#include "overlay.h"
#include "gpu.h"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <emscripten/html5.h>
#endif
#include <random>
class SmoothNumberGenerator {
private:
std::default_random_engine generator;
std::uniform_real_distribution<float> distribution;
float previous;
float minRange, maxRange;
float delta;
public:
SmoothNumberGenerator(float min = 16.3f, float max = 17.4f, float optional_delta = 1.f)
: distribution(min, max),
minRange(min),
maxRange(max),
delta(optional_delta) {
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
generator.seed(seed);
previous = distribution(generator);
}
float next() {
float lower_bound = std::max(minRange, previous - delta);
float upper_bound = std::min(maxRange, previous + delta);
// We temporarily adjust the distribution's parameters to generate within our desired range
distribution.param(std::uniform_real_distribution<float>::param_type(lower_bound, upper_bound));
previous = distribution(generator);
return previous;
}
};
class fakeCPU {
public:
};
class fakeGPU {
private:
SmoothNumberGenerator gpuLoad;
SmoothNumberGenerator fanSpeed;
SmoothNumberGenerator temp;
SmoothNumberGenerator powerUsage;
public:
fakeGPU() : gpuLoad(90, 95),
fanSpeed(2000, 2500),
temp(85,90),
powerUsage(150,200) {}
void update() {
gpuInfo gpu;
gpu.load = gpuLoad.next();
gpu.CoreClock = 2800;
gpu.fan_speed = fanSpeed.next();
gpu.is_current_throttled = false;
gpu.is_other_throttled = false;
gpu.is_power_throttled = false;
gpu.is_temp_throttled = true;
gpu.MemClock = 1250;
gpu.memory_temp = temp.next();
gpu.memoryUsed = 3242;
gpu.powerUsage = powerUsage.next();
gpu.temp = temp.next();
gpu_info = gpu;
};
};
class Faker {
private:
swapchain_stats sw_stats;
overlay_params params;
uint32_t vendorID;
fakeGPU gpu;
public:
Faker(swapchain_stats sw_stats, overlay_params params, uint32_t vendorID)
: sw_stats(sw_stats), params(params), vendorID(vendorID) {}
void update_frametime() {
update_hud_info_with_frametime(sw_stats, params, vendorID, 16.6f);
}
void update() {
// update_frametime();
gpu.update();
}
uint64_t now() {
auto now = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch());
auto ret = duration.count();
return ret;
}
};
extern std::unique_ptr<Faker> faker;

@ -82,7 +82,8 @@ if is_unixy or cpp.get_id() == 'emscripten'
'control.cpp',
'device.cpp',
'amdgpu.cpp',
'intel.cpp'
'intel.cpp',
'faker.cpp'
)
if cpp.get_id() != 'emscripten'
@ -90,6 +91,10 @@ if is_unixy or cpp.get_id() == 'emscripten'
vklayer_files += 'notify.cpp'
endif
if get_option('with_faker').enabled()
vklayer_files += 'faker.cpp'
endif
opengl_files = files(
'gl/glad.c',
'gl/gl_renderer.cpp',

@ -26,7 +26,7 @@
#include "pci_ids.h"
#include "iostats.h"
#include "amdgpu.h"
#include "faker.h"
#ifdef __linux__
#include <libgen.h>
@ -55,6 +55,7 @@ int fan_speed;
fcatoverlay fcatstatus;
std::string drm_dev;
int current_preset;
std::unique_ptr<Faker> faker = nullptr;
void init_spdlog()
{
@ -135,6 +136,7 @@ void update_hw_info(const struct overlay_params& params, uint32_t vendorID)
if (vendorID== 0x8086)
getIntelGpuInfo();
#endif
faker->update();
}
#ifdef __linux__
@ -238,7 +240,10 @@ void stop_hw_updater()
void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID, uint64_t frametime_ns){
uint32_t f_idx = sw_stats.n_frames % ARRAY_SIZE(sw_stats.frames_stats);
uint64_t now = os_time_get_nano(); /* ns */
uint64_t now;
// now = os_time_get_nano(); /* ns */
if (faker)
now = faker->now(); /* ns */
auto elapsed = now - sw_stats.last_fps_update; /* ns */
float frametime_ms = frametime_ns / 1000000.f;
@ -256,9 +261,11 @@ void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, const stru
fps = double(1000 / frametime_ms);
if (elapsed >= params.fps_sampling_period) {
#ifndef __EMSCRIPTEN__
if (!hw_update_thread)
hw_update_thread = std::make_unique<hw_info_updater>();
hw_update_thread->update(&params, vendorID);
#endif
sw_stats.fps = 1000000000.0 * sw_stats.n_frames_since_update / elapsed;
@ -294,7 +301,7 @@ void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, const stru
}
void update_hud_info(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID){
uint64_t now = os_time_get_nano(); /* ns */
uint64_t now = faker->now(); /* ns */
uint64_t frametime_ns = now - sw_stats.last_present_time;
if (!params.no_display || logger->is_active())
update_hud_info_with_frametime(sw_stats, params, vendorID, frametime_ns);

@ -54,7 +54,7 @@
#ifdef __linux__
#include "implot.h"
#endif
#include "faker.h"
using namespace std;
float offset_x, offset_y, hudSpacing;
@ -457,6 +457,7 @@ static void snapshot_swapchain_frame(struct swapchain_data *data)
{
struct device_data *device_data = data->device;
struct instance_data *instance_data = device_data->instance;
faker = std::make_unique<Faker>(data->sw_stats, instance_data->params, device_data->properties.vendorID);
update_hud_info(data->sw_stats, instance_data->params, device_data->properties.vendorID);
check_keybinds(instance_data->params, device_data->properties.vendorID);
#ifdef __linux__

Loading…
Cancel
Save