Add `spdlog` wrap and logging

libinput_only
jackun 3 years ago
parent 537b527af4
commit 2f807a4c0d
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

1
.gitignore vendored

@ -40,6 +40,7 @@ lib32-mangohud*.tar.*
subprojects/packagecache/
subprojects/Vulkan-Headers-*/
subprojects/imgui-*/
subprojects/spdlog-*/
#GNU Global Metadata
**/GPATH

@ -242,6 +242,16 @@ dearimgui_sp = subproject('imgui', default_options: [
])
dearimgui_dep = dearimgui_sp.get_variable('imgui_dep')
spdlog_dep = cpp.find_library('spdlog', required: get_option('use_system_spdlog'))
if not spdlog_dep.found()
spdlog_sp = subproject('spdlog', default_options: [
'default_library=static',
])
spdlog_dep = spdlog_sp.get_variable('spdlog_dep')
else
spdlog_dep = dependency('spdlog', required: true)
endif
if ['windows', 'mingw'].contains(host_machine.system())
subdir('modules/minhook')
inc_common += ( include_directories('modules/minhook/include'))

@ -1,5 +1,6 @@
option('glibcxx_asserts', type : 'boolean', value : false)
option('use_system_vulkan', type : 'feature', value : 'disabled', description: 'Use system vulkan headers instead of the provided ones')
option('use_system_spdlog', type : 'feature', value : 'disabled', description: 'Use system spdlog library')
option('vulkan_datadir', type : 'string', value : '', description: 'Path to the system vulkan headers data directory if different from MangoHud\'s datadir')
option('append_libdir_mangohud', type : 'boolean', value : true, description: 'Append "mangohud" to libdir path or not.')
option('ld_libdir_prefix', type : 'boolean', value : false, description: 'Set ld libdir to "$prefix/lib/mangohud/\$LIB"')

@ -1,6 +1,7 @@
#include <stdio.h>
#include "battery.h"
#include <filesystem.h>
#include <spdlog/spdlog.h>
namespace fs = ghc::filesystem;
@ -26,7 +27,7 @@ void BatteryStats::update() {
if (!batt_check) {
numBattery();
if (batt_count == 0) {
std::cerr<<"MANGOHUD: No battery found\n";
spdlog::error("No battery found");
}
}

@ -5,6 +5,7 @@
#include <thread>
#include <unordered_map>
#include <string>
#include <spdlog/spdlog.h>
#include "config.h"
#include "file_utils.h"
#include "string_utils.h"
@ -110,17 +111,16 @@ void parseConfigFile(overlay_params& params) {
std::ifstream stream(*p);
if (!stream.good()) {
// printing just so user has an idea of possible configs
std::cerr << "skipping config: " << *p << " [ not found ]" << std::endl;
spdlog::info("skipping config: '{}' [ not found ]", *p);
continue;
}
stream.imbue(std::locale::classic());
std::cerr << "parsing config: " << *p;
spdlog::info("parsing config: '{}'", *p);
while (std::getline(stream, line))
{
parseConfigLine(line, params.options);
}
std::cerr << " [ ok ]" << std::endl;
params.config_file_path = *p;
return;
}

@ -9,6 +9,7 @@
#include <algorithm>
#include <regex>
#include <inttypes.h>
#include <spdlog/spdlog.h>
#include "string_utils.h"
#ifndef PROCDIR
@ -116,13 +117,13 @@ bool CPUStats::Init()
m_cpuData.clear();
if (!file.is_open()) {
std::cerr << "Failed to opening " << PROCSTATFILE << std::endl;
spdlog::error("Failed to opening " PROCSTATFILE);
return false;
}
do {
if (!std::getline(file, line)) {
std::cerr << "Failed to read all of " << PROCSTATFILE << std::endl;
spdlog::debug("Failed to read all of " PROCSTATFILE);
return false;
} else if (starts_with(line, "cpu")) {
if (first) {
@ -175,7 +176,7 @@ bool CPUStats::UpdateCPUData()
bool ret = false;
if (!file.is_open()) {
std::cerr << "Failed to opening " << PROCSTATFILE << std::endl;
spdlog::error("Failed to opening " PROCSTATFILE);
return false;
}
@ -189,21 +190,20 @@ bool CPUStats::UpdateCPUData()
} else if (sscanf(line.c_str(), "cpu%4d %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu",
&cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice) == 11) {
//std::cerr << "Parsing 'cpu" << cpuid << "' line:" << line << std::endl;
//spdlog::debug("Parsing 'cpu{}' line:{}", cpuid, line);
if (!ret) {
//std::cerr << "Failed to parse 'cpu' line" << std::endl;
std::cerr << "Failed to parse 'cpu' line:" << line << std::endl;
spdlog::debug("Failed to parse 'cpu' line:{}", line);
return false;
}
if (cpuid < 0 /* can it? */) {
std::cerr << "Cpu id '" << cpuid << "' is out of bounds" << std::endl;
spdlog::debug("Cpu id '{}' is out of bounds", cpuid);
return false;
}
if ((size_t)cpuid >= m_cpuData.size()) {
std::cerr << "Cpu id '" << cpuid << "' is out of bounds, reiniting" << std::endl;
spdlog::debug("Cpu id '{}' is out of bounds, reiniting", cpuid);
return Reinit();
}
@ -399,9 +399,7 @@ static bool find_fallback_temp_input(const std::string path, std::string& input)
if (!ends_with(file, "_input"))
continue;
input = path + "/" + file;
#ifndef NDEBUG
std::cerr << "fallback cpu temp input: " << input << "\n";
#endif
spdlog::debug("fallback cpu temp input: {}", input);
return true;
}
return false;
@ -418,9 +416,8 @@ bool CPUStats::GetCpuFile() {
for (auto& dir : dirs) {
path = hwmon + dir;
name = read_line(path + "/name");
#ifndef NDEBUG
std::cerr << "hwmon: sensor name: " << name << std::endl;
#endif
spdlog::debug("hwmon: sensor name: {}", name);
if (name == "coretemp") {
find_temp_input(path, input, "Package id 0");
break;
@ -437,12 +434,11 @@ bool CPUStats::GetCpuFile() {
}
if (path.empty() || (!file_exists(input) && !find_fallback_temp_input(path, input))) {
std::cerr << "MANGOHUD: Could not find cpu temp sensor location" << std::endl;
spdlog::error("Could not find cpu temp sensor location");
return false;
} else {
#ifndef NDEBUG
std::cerr << "hwmon: using input: " << input << std::endl;
#endif
spdlog::debug("hwmon: using input: {}", input);
m_cpuTempFile = fopen(input.c_str(), "r");
}
return true;
@ -480,12 +476,10 @@ CPUPowerData_k10temp* init_cpu_power_data_k10temp(const std::string path) {
if(!find_input(path, "in", socVoltageInput, "Vsoc")) return nullptr;
if(!find_input(path, "curr", socCurrentInput, "Isoc")) return nullptr;
#ifndef NDEBUG
std::cerr << "hwmon: using input: " << coreVoltageInput << std::endl;
std::cerr << "hwmon: using input: " << coreCurrentInput << std::endl;
std::cerr << "hwmon: using input: " << socVoltageInput << std::endl;
std::cerr << "hwmon: using input: " << socCurrentInput << std::endl;
#endif
spdlog::debug("hwmon: using input: {}", coreVoltageInput);
spdlog::debug("hwmon: using input: {}", coreCurrentInput);
spdlog::debug("hwmon: using input: {}", socVoltageInput);
spdlog::debug("hwmon: using input: {}", socCurrentInput);
powerData->coreVoltageFile = fopen(coreVoltageInput.c_str(), "r");
powerData->coreCurrentFile = fopen(coreCurrentInput.c_str(), "r");
@ -503,10 +497,8 @@ CPUPowerData_zenpower* init_cpu_power_data_zenpower(const std::string path) {
if(!find_input(path, "power", corePowerInput, "SVI2_P_Core")) return nullptr;
if(!find_input(path, "power", socPowerInput, "SVI2_P_SoC")) return nullptr;
#ifndef NDEBUG
std::cerr << "hwmon: using input: " << corePowerInput << std::endl;
std::cerr << "hwmon: using input: " << socPowerInput << std::endl;
#endif
spdlog::debug("hwmon: using input: {}", corePowerInput);
spdlog::debug("hwmon: using input: {}", socPowerInput);
powerData->corePowerFile = fopen(corePowerInput.c_str(), "r");
powerData->socPowerFile = fopen(socPowerInput.c_str(), "r");
@ -538,9 +530,8 @@ bool CPUStats::InitCpuPowerData() {
for (auto& dir : dirs) {
path = hwmon + dir;
name = read_line(path + "/name");
#ifndef NDEBUG
std::cerr << "hwmon: sensor name: " << name << std::endl;
#endif
spdlog::debug("hwmon: sensor name: {}", name);
if (name == "k10temp") {
cpuPowerData = (CPUPowerData*)init_cpu_power_data_k10temp(path);
break;
@ -556,9 +547,7 @@ bool CPUStats::InitCpuPowerData() {
for (auto& dir : powercap_dirs) {
path = powercap + dir;
name = read_line(path + "/name");
#ifndef NDEBUG
std::cerr << "powercap: name: " << name << std::endl;
#endif
spdlog::debug("powercap: name: {}", name);
if (name == "package-0") {
cpuPowerData = (CPUPowerData*)init_cpu_power_data_rapl(path);
break;
@ -567,7 +556,7 @@ bool CPUStats::InitCpuPowerData() {
}
if(cpuPowerData == nullptr) {
std::cerr << "MANGOHUD: Failed to initialize CPU power data" << std::endl;
spdlog::error("Failed to initialize CPU power data");
return false;
}

@ -163,7 +163,7 @@ bool dbus_manager::init(const std::string& requested_player) {
}
if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("libdbus-1.so.3")) {
std::cerr << "MANGOHUD: Could not load libdbus-1.so.3\n";
spdlog::error("Could not load libdbus-1.so.3");
return false;
}
@ -173,14 +173,13 @@ bool dbus_manager::init(const std::string& requested_player) {
if (nullptr ==
(m_dbus_conn = m_dbus_ldr.bus_get(DBUS_BUS_SESSION, &m_error))) {
std::cerr << "MANGOHUD: " << m_error.message << std::endl;
spdlog::error("{}", m_error.message);
m_dbus_ldr.error_free(&m_error);
return false;
}
std::cout << "MANGOHUD: Connected to D-Bus as \""
<< m_dbus_ldr.bus_get_unique_name(m_dbus_conn) << "\"."
<< std::endl;
spdlog::debug("Connected to D-Bus as \"{}\"",
m_dbus_ldr.bus_get_unique_name(m_dbus_conn));
dbus_list_name_to_owner();
connect_to_signals();
@ -198,10 +197,7 @@ bool dbus_manager::select_active_player() {
// If the requested player is available, use it
if (m_name_owners.count(m_requested_player) > 0) {
m_active_player = m_requested_player;
#ifndef NDEBUG
std::cerr << "Selecting requested player: " << m_requested_player
<< "\n";
#endif
spdlog::debug("Selecting requested player: {}", m_requested_player);
get_media_player_metadata(meta, m_active_player);
}
} else {
@ -221,9 +217,7 @@ bool dbus_manager::select_active_player() {
if(it != m_name_owners.end()){
m_active_player = it->first;
#ifndef NDEBUG
std::cerr << "Selecting fallback player: " << m_active_player << "\n";
#endif
spdlog::debug("Selecting fallback player: {}", m_active_player);
}
}
}
@ -232,9 +226,7 @@ bool dbus_manager::select_active_player() {
onNewPlayer(meta);
return true;
} else {
#ifndef NDEBUG
std::cerr << "No active players\n";
#endif
spdlog::debug("No active players");
if (!old_active_player.empty()) {
onNoPlayer();
}
@ -333,8 +325,7 @@ void dbus_manager::connect_to_signals() {
auto signal = format_signal(kv);
m_dbus_ldr.bus_add_match(m_dbus_conn, signal.c_str(), &m_error);
if (m_dbus_ldr.error_is_set(&m_error)) {
::perror(m_error.name);
::perror(m_error.message);
spdlog::error("{}: {}", m_error.name, m_error.message);
m_dbus_ldr.error_free(&m_error);
// return;
}
@ -352,8 +343,7 @@ void dbus_manager::disconnect_from_signals() {
auto signal = format_signal(kv);
m_dbus_ldr.bus_remove_match(m_dbus_conn, signal.c_str(), &m_error);
if (m_dbus_ldr.error_is_set(&m_error)) {
::perror(m_error.name);
::perror(m_error.message);
spdlog::error("{}: {}", m_error.name, m_error.message);
m_dbus_ldr.error_free(&m_error);
}
}

@ -3,6 +3,7 @@
#define MANGOHUD_DBUS_HELPERS
#include <vector>
#include <spdlog/spdlog.h>
#include "loaders/loader_dbus.h"
@ -136,8 +137,8 @@ template <class T>
auto DBusMessageIter_wrap::get_primitive() -> T {
auto requested_type = detail::dbus_type_identifier<T>;
if (requested_type != type()) {
std::cerr << "Type mismatch: '" << ((char)requested_type) << "' vs '"
<< (char)type() << "'\n";
spdlog::error("Type mismatch: '{}' vs '{}'",
((char)requested_type), (char)type());
#ifndef NDEBUG
exit(-1);
#else
@ -190,13 +191,13 @@ auto DBusMessageIter_wrap::get_stringified() -> std::string {
if (is_unsigned()) return std::to_string(get_unsigned());
if (is_signed()) return std::to_string(get_signed());
if (is_double()) return std::to_string(get_primitive<double>());
std::cerr << "stringify failed\n";
spdlog::error("stringify failed");
return std::string();
}
auto DBusMessageIter_wrap::get_array_iter() -> DBusMessageIter_wrap {
if (!is_array()) {
std::cerr << "Not an array; " << (char)type() << "\n";
spdlog::error("Not an array; {}", (char)type());
return DBusMessageIter_wrap(DBusMessageIter{}, m_DBus);
}
@ -207,7 +208,7 @@ auto DBusMessageIter_wrap::get_array_iter() -> DBusMessageIter_wrap {
auto DBusMessageIter_wrap::get_dict_entry_iter() -> DBusMessageIter_wrap {
if (type() != DBUS_TYPE_DICT_ENTRY) {
std::cerr << "Not a dict entry" << (char)type() << "\n";
spdlog::error("Not a dict entry {}", (char)type());
return DBusMessageIter_wrap(DBusMessageIter{}, m_DBus);
}
@ -334,7 +335,7 @@ DBusMessage_wrap DBusMessage_wrap::send_with_reply_and_block(
auto reply = m_DBus->connection_send_with_reply_and_block(conn, m_msg,
timeout, &err);
if (reply == nullptr) {
std::cerr << "MangoHud[" << __func__ << "]: " << err.message << "\n";
spdlog::error("[{}]: {}", __func__, err.message);
free_if_owning();
m_DBus->error_free(&err);
}

@ -8,6 +8,7 @@
#include <fstream>
#include <cstring>
#include <string>
#include <spdlog/spdlog.h>
std::string read_line(const std::string& filename)
{
@ -22,8 +23,7 @@ bool find_folder(const char* root, const char* prefix, std::string& dest)
struct dirent* dp;
DIR* dirp = opendir(root);
if (!dirp) {
std::cerr << "Error opening directory '" << root << "': ";
perror("");
spdlog::error("Error opening directory '{}': {}", root, strerror(errno));
return false;
}
@ -52,8 +52,7 @@ std::vector<std::string> ls(const char* root, const char* prefix, LS_FLAGS flags
DIR* dirp = opendir(root);
if (!dirp) {
std::cerr << "Error opening directory '" << root << "': ";
perror("");
spdlog::error("Error opening directory '{}': {}", root, strerror(errno));
return list;
}

@ -168,10 +168,6 @@ void imgui_create(void *ctx)
void imgui_shutdown()
{
#ifndef NDEBUG
std::cerr << __func__ << std::endl;
#endif
if (state.imgui_ctx) {
ImGui::SetCurrentContext(state.imgui_ctx);
ImGui_ImplOpenGL3_Shutdown();
@ -185,10 +181,6 @@ void imgui_set_context(void *ctx)
{
if (!ctx)
return;
#ifndef NDEBUG
std::cerr << __func__ << ": " << ctx << std::endl;
#endif
imgui_create(ctx);
}

@ -70,6 +70,7 @@
#include <stdint.h> // intptr_t
#include <sstream>
#include <spdlog/spdlog.h>
#include <glad/glad.h>
#include "overlay.h"
@ -138,13 +139,13 @@ static bool CheckShader(GLuint handle, const char* desc)
glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
if ((GLboolean)status == GL_FALSE)
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
spdlog::error("ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile {}!", desc);
if (log_length > 1)
{
ImVector<char> buf;
buf.resize((int)(log_length + 1));
glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
fprintf(stderr, "%s\n", buf.begin());
spdlog::error("{}", buf.begin());
}
return (GLboolean)status == GL_TRUE;
}
@ -156,13 +157,13 @@ static bool CheckProgram(GLuint handle, const char* desc)
glGetProgramiv(handle, GL_LINK_STATUS, &status);
glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
if ((GLboolean)status == GL_FALSE)
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
spdlog::error("ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link {}! (with GLSL '{}')", desc, g_GlslVersionString);
if (log_length > 1)
{
ImVector<char> buf;
buf.resize((int)(log_length + 1));
glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
fprintf(stderr, "%s\n", buf.begin());
spdlog::error("{}", buf.begin());
}
return (GLboolean)status == GL_TRUE;
}
@ -478,16 +479,12 @@ void ImGui_ImplOpenGL3_NewFrame()
if (!g_ShaderHandle)
ImGui_ImplOpenGL3_CreateDeviceObjects();
else if (!glIsProgram(g_ShaderHandle)) { // TODO Got created in a now dead context?
#ifndef NDEBUG
fprintf(stderr, "MANGOHUD: recreating lost objects\n");
#endif
spdlog::debug("Recreating lost objects");
ImGui_ImplOpenGL3_CreateDeviceObjects();
}
if (!glIsTexture(g_FontTexture)) {
#ifndef NDEBUG
fprintf(stderr, "MANGOHUD: GL Texture lost? Regenerating.\n");
#endif
spdlog::debug("GL Texture lost? Regenerating.");
g_FontTexture = 0;
ImGui_ImplOpenGL3_CreateFontsTexture();
}

@ -2,14 +2,13 @@
#include <array>
#include <cstring>
#include <dlfcn.h>
#include <chrono>
#include <iomanip>
#include <spdlog/spdlog.h>
#include "real_dlsym.h"
#include "mesa/util/macros.h"
#include "mesa/util/os_time.h"
#include "blacklist.h"
#include <chrono>
#include <iomanip>
#include "imgui_hud.h"
using namespace MangoHud::GL;
@ -23,7 +22,7 @@ void* get_egl_proc_address(const char* name) {
if (!pfn_eglGetProcAddress) {
void *handle = real_dlopen("libEGL.so.1", RTLD_LAZY|RTLD_LOCAL);
if (!handle) {
std::cerr << "MANGOHUD: Failed to open " << "" MANGOHUD_ARCH << " libEGL.so.1: " << dlerror() << std::endl;
spdlog::error("Failed to open " MANGOHUD_ARCH " libEGL.so.1: {}", dlerror());
} else {
pfn_eglGetProcAddress = reinterpret_cast<decltype(pfn_eglGetProcAddress)>(real_dlsym(handle, "eglGetProcAddress"));
}
@ -36,7 +35,7 @@ void* get_egl_proc_address(const char* name) {
func = get_proc_address( name );
if (!func) {
std::cerr << "MANGOHUD: Failed to get function '" << name << "'" << std::endl;
spdlog::debug("Failed to get function '{}'", name);
}
return func;
@ -44,10 +43,7 @@ void* get_egl_proc_address(const char* name) {
//EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
EXPORT_C_(int) eglMakeCurrent_OFF(void *dpy, void *draw, void *read,void *ctx) {
#ifndef NDEBUG
std::cerr << __func__ << ": " << draw << ", " << ctx << std::endl;
#endif
spdlog::trace("{}: draw: {}, ctx: {}", __func__, draw, ctx);
int ret = 0;
return ret;
}
@ -63,9 +59,6 @@ EXPORT_C_(unsigned int) eglSwapBuffers( void* dpy, void* surf)
if (!pfn_eglQuerySurface)
pfn_eglQuerySurface = reinterpret_cast<decltype(pfn_eglQuerySurface)>(get_egl_proc_address("eglQuerySurface"));
//std::cerr << __func__ << "\n";
imgui_create(surf);
int width=0, height=0;
@ -73,7 +66,6 @@ EXPORT_C_(unsigned int) eglSwapBuffers( void* dpy, void* surf)
pfn_eglQuerySurface(dpy, surf, 0x3057, &width))
imgui_render(width, height);
//std::cerr << "\t" << width << " x " << height << "\n";
using namespace std::chrono_literals;
if (fps_limit_stats.targetFrameTime > 0s){
fps_limit_stats.frameStart = Clock::now();
@ -111,10 +103,9 @@ EXPORT_C_(void *) mangohud_find_egl_ptr(const char *name)
}
EXPORT_C_(void *) eglGetProcAddress(const char* procName) {
//std::cerr << __func__ << ": " << procName << std::endl;
void* real_func = get_egl_proc_address(procName);
void* func = mangohud_find_egl_ptr(procName);
spdlog::trace("{}: proc: {}, real: {}, fun: {}", __func__, procName, real_func, func);
if (func && real_func)
return func;

@ -6,6 +6,7 @@
#include <algorithm>
#include <atomic>
#include <cstring>
#include <spdlog/spdlog.h>
#include "real_dlsym.h"
#include "loaders/loader_glx.h"
#include "loaders/loader_x11.h"
@ -47,7 +48,7 @@ void* get_glx_proc_address(const char* name) {
func = get_proc_address( name );
if (!func) {
std::cerr << "MANGOHUD: Failed to get function '" << name << "'" << std::endl;
spdlog::error("Failed to get function '{}'", name);
}
return func;
@ -59,9 +60,7 @@ EXPORT_C_(void *) glXCreateContext(void *dpy, void *vis, void *shareList, int di
void *ctx = glx.CreateContext(dpy, vis, shareList, direct);
if (ctx)
refcnt++;
#ifndef NDEBUG
std::cerr << __func__ << ":" << ctx << std::endl;
#endif
spdlog::debug("{}: {}", __func__, ctx);
return ctx;
}
@ -71,9 +70,7 @@ EXPORT_C_(void *) glXCreateContextAttribs(void *dpy, void *config,void *share_co
void *ctx = glx.CreateContextAttribs(dpy, config, share_context, direct, attrib_list);
if (ctx)
refcnt++;
#ifndef NDEBUG
std::cerr << __func__ << ":" << ctx << std::endl;
#endif
spdlog::debug("{}: {}", __func__, ctx);
return ctx;
}
@ -83,9 +80,7 @@ EXPORT_C_(void *) glXCreateContextAttribsARB(void *dpy, void *config,void *share
void *ctx = glx.CreateContextAttribsARB(dpy, config, share_context, direct, attrib_list);
if (ctx)
refcnt++;
#ifndef NDEBUG
std::cerr << __func__ << ":" << ctx << std::endl;
#endif
spdlog::debug("{}: {}", __func__, ctx);
return ctx;
}
@ -96,25 +91,18 @@ EXPORT_C_(void) glXDestroyContext(void *dpy, void *ctx)
refcnt--;
if (refcnt <= 0)
imgui_shutdown();
#ifndef NDEBUG
std::cerr << __func__ << ":" << ctx << std::endl;
#endif
spdlog::debug("{}: {}", __func__, ctx);
}
EXPORT_C_(int) glXMakeCurrent(void* dpy, void* drawable, void* ctx) {
glx.Load();
#ifndef NDEBUG
std::cerr << __func__ << ": " << drawable << ", " << ctx << std::endl;
#endif
spdlog::debug("{}: {}, {}", __func__, drawable, ctx);
int ret = glx.MakeCurrent(dpy, drawable, ctx);
if (!is_blacklisted()) {
if (ret) {
imgui_set_context(ctx);
#ifndef NDEBUG
std::cerr << "MANGOHUD: GL ref count: " << refcnt << "\n";
#endif
spdlog::debug("GL ref count: {}", refcnt);
}
// Afaik -1 only works with EXT version if it has GLX_EXT_swap_control_tear, maybe EGL_MESA_swap_control_tear someday
@ -159,6 +147,7 @@ static void do_imgui_swap(void *dpy, void *drawable)
break;
}
spdlog::trace("swap buffers: {}x{}", width, height);
imgui_render(width, height);
}
}
@ -196,9 +185,7 @@ EXPORT_C_(int64_t) glXSwapBuffersMscOML(void* dpy, void* drawable, int64_t targe
}
EXPORT_C_(void) glXSwapIntervalEXT(void *dpy, void *draw, int interval) {
#ifndef NDEBUG
std::cerr << __func__ << ": " << interval << std::endl;
#endif
spdlog::debug("{}: {}", __func__, interval);
glx.Load();
if (!glx.SwapIntervalEXT)
return;
@ -210,9 +197,7 @@ EXPORT_C_(void) glXSwapIntervalEXT(void *dpy, void *draw, int interval) {
}
EXPORT_C_(int) glXSwapIntervalSGI(int interval) {
#ifndef NDEBUG
std::cerr << __func__ << ": " << interval << std::endl;
#endif
spdlog::debug("{}: {}", __func__, interval);
glx.Load();
if (!glx.SwapIntervalSGI)
return -1;
@ -224,9 +209,7 @@ EXPORT_C_(int) glXSwapIntervalSGI(int interval) {
}
EXPORT_C_(int) glXSwapIntervalMESA(unsigned int interval) {
#ifndef NDEBUG
std::cerr << __func__ << ": " << interval << std::endl;
#endif
spdlog::debug("{}: {}", __func__, interval);
glx.Load();
if (!glx.SwapIntervalMESA)
return -1;
@ -256,9 +239,7 @@ EXPORT_C_(int) glXGetSwapIntervalMESA() {
}
}
#ifndef NDEBUG
std::cerr << __func__ << ": " << interval << std::endl;
#endif
spdlog::debug("{}: {}", __func__, interval);
return interval;
}
@ -300,10 +281,10 @@ EXPORT_C_(void *) mangohud_find_glx_ptr(const char *name)
}
EXPORT_C_(void *) glXGetProcAddress(const unsigned char* procName) {
//std::cerr << __func__ << ":" << procName << std::endl;
void *real_func = get_glx_proc_address((const char*)procName);
void *func = mangohud_find_glx_ptr( (const char*)procName );
spdlog::trace("{}: '{}', real: {}, fun: {}", __func__, procName, real_func, func);
if (func && real_func)
return func;
@ -311,10 +292,9 @@ EXPORT_C_(void *) glXGetProcAddress(const unsigned char* procName) {
}
EXPORT_C_(void *) glXGetProcAddressARB(const unsigned char* procName) {
//std::cerr << __func__ << ":" << procName << std::endl;
void *real_func = get_glx_proc_address((const char*)procName);
void *func = mangohud_find_glx_ptr( (const char*)procName );
spdlog::trace("{}: '{}', real: {}, fun: {}", __func__, procName, real_func, func);
if (func && real_func)
return func;

@ -4,6 +4,7 @@
#include <functional>
#include <thread>
#include <cstring>
#include <spdlog/spdlog.h>
#include "nvctrl.h"
#include "timing.hpp"
#ifdef HAVE_NVML
@ -229,20 +230,20 @@ bool amdgpu_open(const char *path) {
int fd = open(path, O_RDWR | O_CLOEXEC);
if (fd < 0) {
perror("MANGOHUD: Failed to open DRM device: "); // Gives sensible perror message?
spdlog::error("Failed to open DRM device: {}", strerror(errno));
return false;
}
drmVersionPtr ver = libdrm_ptr->drmGetVersion(fd);
if (!ver) {
perror("MANGOHUD: Failed to query driver version: ");
spdlog::error("Failed to query driver version: {}", strerror(errno));
close(fd);
return false;
}
if (strcmp(ver->name, "amdgpu") || !DRM_ATLEAST_VERSION(ver, 3, 11)) {
fprintf(stderr, "MANGOHUD: Unsupported driver/version: %s %d.%d.%d\n", ver->name, ver->version_major, ver->version_minor, ver->version_patchlevel);
spdlog::error("Unsupported driver/version: {} {}.{}.{}", ver->name, ver->version_major, ver->version_minor, ver->version_patchlevel);
close(fd);
libdrm_ptr->drmFreeVersion(ver);
return false;
@ -259,7 +260,7 @@ bool amdgpu_open(const char *path) {
uint32_t drm_major, drm_minor;
amdgpu_device_handle dev;
if (libdrm_ptr->amdgpu_device_initialize(fd, &drm_major, &drm_minor, &dev)){
perror("MANGOHUD: Failed to initialize amdgpu device");
spdlog::error("Failed to initialize amdgpu device: {}", strerror(errno));
close(fd);
return false;
}

@ -1,6 +1,7 @@
#include "loaders/loader_dbus.h"
#include <iostream>
#include <spdlog/spdlog.h>
// Put these sanity checks here so that they fire at most once
// (to avoid cluttering the build output).
@ -26,7 +27,7 @@ bool libdbus_loader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_DBUS_H_DLOPEN)
library_ = dlopen(library_name.c_str(), RTLD_LAZY);
if (!library_) {
std::cerr << "MANGOHUD: Failed to open " << "" MANGOHUD_ARCH << " " << library_name << ": " << dlerror() << std::endl;
spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror());
return false;
}

@ -1,4 +1,5 @@
#include <iostream>
#include <spdlog/spdlog.h>
#include "real_dlsym.h"
#include "loaders/loader_glx.h"
@ -24,7 +25,7 @@ bool glx_loader::Load() {
if (!handle)
handle = real_dlopen("libGL.so.1", RTLD_LAZY);
if (!handle) {
std::cerr << "MANGOHUD: Failed to open " << "" MANGOHUD_ARCH << " libGL.so.1: " << dlerror() << std::endl;
spdlog::error("Failed to open " MANGOHUD_ARCH " libGL.so.1: {}", dlerror());
return false;
}

@ -1,6 +1,7 @@
#include "loaders/loader_libdrm.h"
#include <iostream>
#include <spdlog/spdlog.h>
// Put these sanity checks here so that they fire at most once
// (to avoid cluttering the build output).
@ -27,13 +28,13 @@ bool libdrm_loader::Load() {
#if defined(LIBRARY_LOADER_LIBDRM_H_DLOPEN)
library_drm = dlopen("libdrm.so.2", RTLD_LAZY);
if (!library_drm) {
std::cerr << "MANGOHUD: Failed to open " << "" MANGOHUD_ARCH << " libdrm.so.2: " << dlerror() << std::endl;
spdlog::error("Failed to open " MANGOHUD_ARCH " libdrm.so.2: {}", dlerror());
return false;
}
library_amdgpu = dlopen("libdrm_amdgpu.so.1", RTLD_LAZY);
if (!library_amdgpu) {
std::cerr << "MANGOHUD: Failed to open " << "" MANGOHUD_ARCH << " libdrm_amdgpu.so.1: " << dlerror() << std::endl;
spdlog::error("Failed to open " MANGOHUD_ARCH " libdrm_amdgpu.so.1: {}", dlerror());
CleanUp(true);
return false;
}

@ -1,6 +1,7 @@
#include "loader_nvctrl.h"
#include <iostream>
#include <memory>
#include <spdlog/spdlog.h>
// Put these sanity checks here so that they fire at most once
// (to avoid cluttering the build output).
@ -35,7 +36,7 @@ bool libnvctrl_loader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_NVCTRL_H_DLOPEN)
library_ = dlopen(library_name.c_str(), RTLD_LAZY);
if (!library_) {
std::cerr << "MANGOHUD: Failed to open " << "" MANGOHUD_ARCH << " " << library_name << ": " << dlerror() << std::endl;
spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror());
return false;
}

@ -4,6 +4,7 @@
#include "loader_nvml.h"
#include <iostream>
#include <memory>
#include <spdlog/spdlog.h>
// Put these sanity checks here so that they fire at most once
// (to avoid cluttering the build output).
@ -38,7 +39,7 @@ bool libnvml_loader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_NVML_H_DLOPEN)
library_ = dlopen(library_name.c_str(), RTLD_LAZY);
if (!library_) {
std::cerr << "MANGOHUD: Failed to open " << "" MANGOHUD_ARCH << " " << library_name << ": " << dlerror() << std::endl;
spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror());
return false;
}
#endif

@ -1,5 +1,6 @@
#include "loader_x11.h"
#include <iostream>
#include <spdlog/spdlog.h>
libx11_loader::libx11_loader() : loaded_(false) {
}
@ -15,7 +16,7 @@ bool libx11_loader::Load(const std::string& library_name) {
library_ = dlopen(library_name.c_str(), RTLD_LAZY);
if (!library_) {
std::cerr << "MANGOHUD: Failed to open " << "" MANGOHUD_ARCH << " " << library_name << ": " << dlerror() << std::endl;
spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror());
return false;
}

@ -1,5 +1,6 @@
#include <sstream>
#include <iomanip>
#include <spdlog/spdlog.h>
#include "logging.h"
#include "overlay.h"
#include "config.h"
@ -58,9 +59,7 @@ void upload_files(const std::vector<std::string>& logFiles){
void writeFile(string filename){
auto& logArray = logger->get_log_data();
#ifndef NDEBUG
std::cerr << "Writing log file [" << filename << "], " << logArray.size() << " entries\n";
#endif
spdlog::debug("Writing log file [{}], {} entries", filename, logArray.size());
std::ofstream out(filename, ios::out | ios::app);
if (out){
out << "os," << "cpu," << "gpu," << "ram," << "kernel," << "driver," << "cpuscheduler" << endl;
@ -110,9 +109,7 @@ Logger::Logger(overlay_params* in_params)
m_values_valid(false),
m_params(in_params)
{
#ifndef NDEBUG
std::cerr << "Logger constructed!\n";
#endif
spdlog::debug("Logger constructed!");
}
void Logger::start_logging() {

@ -186,6 +186,7 @@ vklayer_mesa_overlay = shared_library(
dependencies : [
vulkan_wsi_deps,
dearimgui_dep,
spdlog_dep,
dep_libdrm,
#dep_libdrm_amdgpu,
dbus_dep,

@ -3,6 +3,7 @@
#include <fcntl.h>
#include <sys/types.h>
#include <sys/inotify.h>
#include <spdlog/spdlog.h>
#include "config.h"
#include "notify.h"
@ -27,9 +28,7 @@ static void fileChanged(void *params_void) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
parse_overlay_config(&local_params, getenv("MANGOHUD_CONFIG"));
if ((event->mask & IN_DELETE_SELF) || (nt->params->config_file_path != local_params.config_file_path)) {
#ifndef NDEBUG
fprintf(stderr, "MANGOHUD: watching config file: %s\n", local_params.config_file_path.c_str());
#endif
spdlog::debug("Watching config file: {}", local_params.config_file_path.c_str());
inotify_rm_watch(nt->fd, nt->wd);
nt->wd = inotify_add_watch(nt->fd, local_params.config_file_path.c_str(), IN_MODIFY | IN_DELETE_SELF);
}
@ -46,7 +45,7 @@ bool start_notifier(notify_thread& nt)
{
nt.fd = inotify_init1(IN_NONBLOCK);
if (nt.fd < 0) {
perror("MANGOHUD: inotify_init1");
spdlog::error("inotify_init1 failed: {}", strerror(errno));
return false;
}

@ -4,6 +4,7 @@
#include <unordered_map>
#include <memory>
#include <functional>
#include <spdlog/spdlog.h>
#include "nvctrl.h"
#include "loaders/loader_nvctrl.h"
#include "loaders/loader_x11.h"
@ -25,7 +26,7 @@ static bool find_nv_x11(libnvctrl_loader& nvctrl, Display*& dpy)
if (d) {
if (nvctrl.XNVCTRLIsNvScreen(d, 0)) {
dpy = d;
std::cerr << "MANGOHUD: XNVCtrl is using display " << buf << std::endl;
spdlog::debug("XNVCtrl is using display {}", buf);
return true;
}
g_x11->XCloseDisplay(d);
@ -36,14 +37,12 @@ static bool find_nv_x11(libnvctrl_loader& nvctrl, Display*& dpy)
bool checkXNVCtrl()
{
if (!g_x11->IsLoaded()) {
std::cerr << "MANGOHUD: XNVCtrl: X11 loader failed to load\n";
if (!g_x11->IsLoaded())
return false;
}
auto& nvctrl = get_libnvctrl_loader();
if (!nvctrl.IsLoaded()) {
std::cerr << "MANGOHUD: XNVCtrl loader failed to load\n";
spdlog::error("XNVCtrl loader failed to load");
return false;
}
@ -51,7 +50,7 @@ bool checkXNVCtrl()
nvctrlSuccess = find_nv_x11(nvctrl, dpy);
if (!nvctrlSuccess) {
std::cerr << "MANGOHUD: XNVCtrl didn't find the correct display" << std::endl;
spdlog::error("XNVCtrl didn't find the correct display");
return false;
}
@ -86,7 +85,6 @@ static void parse_token(std::string token, string_map& options) {
param = token.substr(0, equal);
trim(param);
trim(value);
//std::cerr << __func__ << ": " << param << "=" << value << std::endl;
if (!param.empty())
options[param] = value;
}
@ -94,7 +92,7 @@ static void parse_token(std::string token, string_map& options) {
char* get_attr_target_string(libnvctrl_loader& nvctrl, int attr, int target_type, int target_id) {
char* c = nullptr;
if (!nvctrl.XNVCTRLQueryTargetStringAttribute(display.get(), target_type, target_id, 0, attr, &c)) {
std::cerr << "Failed to query attribute '" << attr << "'.\n";
spdlog::error("Failed to query attribute '{}'", attr);
}
return c;
}

@ -1,3 +1,4 @@
#include <spdlog/spdlog.h>
#include "loaders/loader_nvml.h"
#include "nvidia_info.h"
#include <iostream>
@ -16,30 +17,30 @@ bool checkNVML(const char* pciBusId){
if (nvml.IsLoaded()){
result = nvml.nvmlInit();
if (NVML_SUCCESS != result) {
std::cerr << "MANGOHUD: Nvidia module not loaded\n";
spdlog::error("Nvidia module not loaded");
} else {
nvmlReturn_t ret = NVML_ERROR_UNKNOWN;
if (pciBusId && ((ret = nvml.nvmlDeviceGetHandleByPciBusId(pciBusId, &nvidiaDevice)) != NVML_SUCCESS)) {
std::cerr << "MANGOHUD: Getting device handle by PCI bus ID failed: " << nvml.nvmlErrorString(ret) << "\n";
std::cerr << " Using index 0.\n";
spdlog::error("Getting device handle by PCI bus ID failed: {}", nvml.nvmlErrorString(ret));
spdlog::error("Using index 0.");
}
if (ret != NVML_SUCCESS)
ret = nvml.nvmlDeviceGetHandleByIndex(0, &nvidiaDevice);
if (ret != NVML_SUCCESS)
std::cerr << "MANGOHUD: Getting device handle failed: " << nvml.nvmlErrorString(ret) << "\n";
spdlog::error("Getting device handle failed: {}", nvml.nvmlErrorString(ret));
nvmlSuccess = (ret == NVML_SUCCESS);
if (ret == NVML_SUCCESS)
nvml.nvmlDeviceGetPciInfo_v3(nvidiaDevice, &nvidiaPciInfo);
return nvmlSuccess;
}
} else {
std::cerr << "MANGOHUD: Failed to load NVML\n";
spdlog::error("Failed to load NVML");
}
return false;
}

@ -1,6 +1,7 @@
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <spdlog/spdlog.h>
#include "overlay.h"
#include "logging.h"
#include "cpu.h"
@ -517,12 +518,10 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
<< std::setw(1) << pci.func;
params.pci_dev = ss.str();
pci_dev = params.pci_dev.c_str();
#ifndef NDEBUG
std::cerr << "MANGOHUD: PCI device ID: '" << pci_dev << "'\n";
#endif
spdlog::debug("PCI device ID: '{}'", pci_dev);
} else {
std::cerr << "MANGOHUD: Failed to parse PCI device ID: '" << pci_dev << "'\n";
std::cerr << "MANGOHUD: Specify it as 'domain:bus:slot.func'\n";
spdlog::error("Failed to parse PCI device ID: '{}'", pci_dev);
spdlog::error("Specify it as 'domain:bus:slot.func'");
}
}
@ -549,9 +548,8 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
for (auto& dir : dirs) {
path = drm + dir;
#ifndef NDEBUG
std::cerr << "amdgpu path check: " << path << "/device/vendor" << std::endl;
#endif
spdlog::debug("amdgpu path check: {}/device/vendor", path);
string device = read_line(path + "/device/device");
deviceID = strtol(device.c_str(), NULL, 16);
string line = read_line(path + "/device/vendor");
@ -561,18 +559,14 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
if (pci_bus_parsed && pci_dev) {
string pci_device = read_symlink((path + "/device").c_str());
#ifndef NDEBUG
std::cerr << "PCI device symlink: " << pci_device << "\n";
#endif
spdlog::debug("PCI device symlink: '{}'", pci_device);
if (!ends_with(pci_device, pci_dev)) {
std::cerr << "MANGOHUD: skipping GPU, no PCI ID match\n";
spdlog::debug("skipping GPU, no PCI ID match");
continue;
}
}
#ifndef NDEBUG
std::cerr << "using amdgpu path: " << path << std::endl;
#endif
spdlog::debug("using amdgpu path: {}", path);
#ifdef HAVE_LIBDRM_AMDGPU
int idx = -1;
@ -585,12 +579,12 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
using_libdrm = true;
getAmdGpuInfo_actual = getAmdGpuInfo_libdrm;
amdgpu_set_sampling_period(params.fps_sampling_period);
#ifndef NDEBUG
std::cerr << "MANGOHUD: using libdrm\n";
#endif
spdlog::debug("Using libdrm");
// fall through and open sysfs handles for fallback or check DRM version beforehand
} else if (!params.enabled[OVERLAY_PARAM_ENABLED_force_amdgpu_hwmon]) {
std::cerr << "MANGOHUD: Failed to open device '/dev/dri/card" << idx << "' with libdrm, falling back to using hwmon sysfs.\n";
spdlog::error("Failed to open device '/dev/dri/card{}' with libdrm, falling back to using hwmon sysfs.", idx);
}
#endif
@ -626,7 +620,7 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
}
#endif
if (!params.permit_upload)
printf("MANGOHUD: Uploading is disabled (permit_upload = 0)\n");
spdlog::info("Uploading is disabled (permit_upload = 0)");
}
void init_system_info(){
@ -719,15 +713,14 @@ void init_system_info(){
if (ld_preload)
setenv("LD_PRELOAD", ld_preload, 1);
#ifndef NDEBUG
std::cout << "Ram:" << ram << "\n"
<< "Cpu:" << cpu << "\n"
<< "Kernel:" << kernel << "\n"
<< "Os:" << os << "\n"
<< "Gpu:" << gpu << "\n"
<< "Driver:" << driver << "\n"
<< "CPU Scheduler:" << cpusched << std::endl;
#endif
spdlog::debug("Ram:{}", ram);
spdlog::debug("Cpu:{}", cpu);
spdlog::debug("Kernel:{}", kernel);
spdlog::debug("Os:{}", os);
spdlog::debug("Gpu:{}", gpu);
spdlog::debug("Driver:{}", driver);
spdlog::debug("CPU Scheduler:{}", cpusched);
#endif
}

@ -16,6 +16,9 @@
#include <cctype>
#include <array>
#include <functional>
#include <spdlog/spdlog.h>
#include <spdlog/cfg/env.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include "overlay_params.h"
#include "overlay.h"
@ -92,8 +95,8 @@ parse_control(const char *str)
{
int ret = os_socket_listen_abstract(str, 1);
if (ret < 0) {
fprintf(stderr, "ERROR: Couldn't create socket pipe at '%s'\n", str);
fprintf(stderr, "ERROR: '%s'\n", strerror(errno));
spdlog::error("Couldn't create socket pipe at '{}'\n", str);
spdlog::error("ERROR: '{}'", strerror(errno));
return ret;
}
@ -126,7 +129,7 @@ parse_string_to_keysym_vec(const char *str)
if (xk)
keys.push_back(xk);
else
std::cerr << "MANGOHUD: Unrecognized key: '" << ks << "'\n";
spdlog::error("Unrecognized key: '{}'", ks);
}
}
return keys;
@ -167,7 +170,7 @@ parse_fps_limit(const char *str)
try {
as_int = static_cast<uint32_t>(std::stoul(value));
} catch (const std::invalid_argument&) {
std::cerr << "MANGOHUD: invalid fps_limit value: '" << value << "'\n";
spdlog::error("invalid fps_limit value: '{}'", value);
continue;
}
@ -317,17 +320,17 @@ parse_benchmark_percentiles(const char *str)
try {
as_float = parse_float(value, &float_len);
} catch (const std::invalid_argument&) {
std::cerr << "MANGOHUD: invalid benchmark percentile: '" << value << "'\n";
spdlog::error("invalid benchmark percentile: '{}'", value);
continue;
}
if (float_len != value.length()) {
std::cerr << "MANGOHUD: invalid benchmark percentile: '" << value << "'\n";
spdlog::error("invalid benchmark percentile: '{}'", value);
continue;
}
if (as_float > 100 || as_float < 0) {
std::cerr << "MANGOHUD: benchmark percentile is not between 0 and 100 (" << value << ")\n";
spdlog::error("benchmark percentile is not between 0 and 100 ({})", value);
continue;
}
@ -495,9 +498,8 @@ parse_string(const char *s, char *out_param, char *out_value)
}
if (*s && !i) {
fprintf(stderr, "MANGOHUD: syntax error: unexpected '%c' (%i) while "
"parsing a string\n", *s, *s);
fflush(stderr);
spdlog::error("syntax error: unexpected '{0:c}' ({0:d}) while "
"parsing a string", *s);
}
return i;
@ -547,7 +549,7 @@ parse_overlay_env(struct overlay_params *params,
OVERLAY_PARAMS
#undef OVERLAY_PARAM_BOOL
#undef OVERLAY_PARAM_CUSTOM
fprintf(stderr, "Unknown option '%s'\n", key);
spdlog::error("Unknown option '{}'", key);
}
}
@ -555,6 +557,9 @@ void
parse_overlay_config(struct overlay_params *params,
const char *env)
{
if (!spdlog::get("MANGOHUD"))
spdlog::set_default_logger(spdlog::stderr_color_mt("MANGOHUD")); // Just to get the name in log
spdlog::cfg::load_env_levels();
*params = {};
@ -684,7 +689,7 @@ parse_overlay_config(struct overlay_params *params,
OVERLAY_PARAMS
#undef OVERLAY_PARAM_BOOL
#undef OVERLAY_PARAM_CUSTOM
fprintf(stderr, "Unknown option '%s'\n", it.first.c_str());
spdlog::error("Unknown option '{}'", it.first.c_str());
}
}

@ -1,9 +1,10 @@
#include "shared_x11.h"
#include "loaders/loader_x11.h"
#include <cstdlib>
#include <iostream>
#include <memory>
#include <functional>
#include <spdlog/spdlog.h>
#include "shared_x11.h"
#include "loaders/loader_x11.h"
static std::unique_ptr<Display, std::function<void(Display*)>> display;
@ -16,7 +17,7 @@ bool init_x11() {
return true;
if (!g_x11->IsLoaded()) {
std::cerr << "MANGOHUD: X11 loader failed to load\n";
spdlog::error("X11 loader failed to load");
failed = true;
return false;
}
@ -34,7 +35,7 @@ bool init_x11() {
failed = !display;
if (failed)
std::cerr << "MANGOHUD: XOpenDisplay failed to open display '" << displayid << "'\n";
spdlog::error("XOpenDisplay failed to open display '{}'", displayid);
return !!display;
}

@ -34,6 +34,7 @@
#include <list>
#include <array>
#include <iomanip>
#include <spdlog/spdlog.h>
#include <vulkan/vulkan.h>
#include <vulkan/vk_layer.h>
@ -207,7 +208,7 @@ static void unmap_object(uint64_t obj)
do { \
VkResult __result = (expr); \
if (__result != VK_SUCCESS) { \
fprintf(stderr, "'%s' line %i failed with %s\n", \
spdlog::error("'{}' line {} failed with {}", \
#expr, __LINE__, vk_Result_to_str(__result)); \
} \
} while (0)
@ -708,7 +709,7 @@ static void check_fonts(struct swapchain_data* data)
if (params.font_params_hash != data->sw_stats.font_params_hash)
{
std::cerr << "MANGOHUD: recreating font image\n";
spdlog::debug("Recreating font image");
VkDescriptorSet desc_set = (VkDescriptorSet)io.Fonts->TexID;
create_fonts(instance_data->params, data->sw_stats.font1, data->sw_stats.font_text);
unsigned char* pixels;
@ -725,14 +726,9 @@ static void check_fonts(struct swapchain_data* data)
desc_set = create_image_with_desc(data, width, height, VK_FORMAT_R8_UNORM, data->font_image, data->font_mem, data->font_image_view);
io.Fonts->SetTexID((ImTextureID)desc_set);
data->font_uploaded = false;
data->sw_stats.font_params_hash = params.font_params_hash;
#ifndef NDEBUG
std::cerr << "MANGOHUD: Default font tex size: " << width << "x" << height << "px (" << (width*height*1) << " bytes)" << "\n";
#endif
spdlog::debug("Default font tex size: {}x{}px", width, height);
}
}

@ -0,0 +1,12 @@
[wrap-file]
directory = spdlog-1.8.5
source_url = https://github.com/gabime/spdlog/archive/v1.8.5.tar.gz
source_filename = v1.8.5.tar.gz
source_hash = 944d0bd7c763ac721398dca2bb0f3b5ed16f67cef36810ede5061f35a543b4b8
patch_url = https://wrapdb.mesonbuild.com/v1/projects/spdlog/1.8.5/1/get_zip
patch_filename = spdlog-1.8.5-1-wrap.zip
patch_hash = 3c38f275d5792b1286391102594329e98b17737924b344f98312ab09929b74be
[provide]
spdlog = spdlog_dep
Loading…
Cancel
Save