From da971ec1c62d800eda5fa9c8bcabbf1de3454d71 Mon Sep 17 00:00:00 2001 From: telans Date: Wed, 29 Jan 2020 23:23:51 +1300 Subject: [PATCH 1/6] ignore compiler warnings --- meson.build | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 88448e31..697abab8 100644 --- a/meson.build +++ b/meson.build @@ -22,8 +22,7 @@ project('mangohud', ['c', 'cpp'], version : 'v1.0.0', license : 'MIT', - meson_version : '>= 0.46', - default_options : ['buildtype=release', 'b_ndebug=if-release', 'c_std=c99', 'cpp_std=c++14'] + default_options : ['buildtype=release', 'c_std=c99', 'cpp_std=c++14'] ) cc = meson.get_compiler('c') @@ -40,6 +39,8 @@ pre_args = [ # Define DEBUG for debug builds only (debugoptimized is not included on this one) if get_option('buildtype') == 'debug' pre_args += '-DDEBUG' +else + pre_args += '-DNDEBUG' endif # TODO: this is very incomplete @@ -83,21 +84,16 @@ foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs', endif endforeach -null_dep = dependency('', required : false) - vulkan_wsi_args = [] vulkan_wsi_deps = [] with_platform_x11 = true with_platform_wayland = false -dep_x11 = dependency('x11') - if with_platform_x11 + dep_x11 = dependency('x11') vulkan_wsi_args += ['-DVK_USE_PLATFORM_XLIB_KHR'] - vulkan_wsi_deps += [ - dep_x11, - ] + vulkan_wsi_deps += dep_x11 endif if with_platform_wayland dep_wayland_client = dependency('wayland-client', version : '>=1.11') @@ -145,7 +141,7 @@ endforeach # For some reason, the test for -Wno-foo always succeeds with gcc, even if the # option is not supported. Hence, check for -Wfoo instead. -foreach a : ['non-virtual-dtor', 'missing-field-initializers', 'format-truncation'] +foreach a : ['non-virtual-dtor', 'missing-field-initializers', 'format-truncation', 'pointer-arith', 'unused-variable'] if cpp.has_argument('-W' + a) cpp_args += '-Wno-' + a endif @@ -175,6 +171,7 @@ endforeach # check for dl support if cc.has_function('dlopen') + null_dep = dependency('', required : false) dep_dl = null_dep else dep_dl = cc.find_library('dl') @@ -213,4 +210,4 @@ util_files = files( ) subdir('modules/ImGui') -subdir('src') \ No newline at end of file +subdir('src') From e82e3721b7854ba492101b77c8efb506424ec744 Mon Sep 17 00:00:00 2001 From: telans Date: Wed, 29 Jan 2020 23:24:46 +1300 Subject: [PATCH 2/6] update header location & duration_env --- src/logging.h | 4 ++-- src/overlay.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/logging.h b/src/logging.h index f243df4a..c3c0481c 100644 --- a/src/logging.h +++ b/src/logging.h @@ -22,7 +22,7 @@ struct logData{ double fps, elapsedLog; std::vector logArray; ofstream out; -const char* duration_env = std::getenv("LOG_DURATION"); +const char* log_duration_env = std::getenv("LOG_DURATION"); const char* mangohud_output_env = std::getenv("MANGOHUD_OUTPUT"); const char* log_period_env = std::getenv("LOG_PERIOD"); int duration, num; @@ -53,7 +53,7 @@ void *logging(void *){ out << fps << "," << cpuLoadLog << "," << gpuLoadLog << "," << now - log_start << endl; // logArray.push_back({fps, cpuLoadLog, gpuLoadLog, 0.0f}); - if ((elapsedLog) >= duration * 1000000 && duration_env) + if ((elapsedLog) >= duration * 1000000 && log_duration_env) loggingOn = false; this_thread::sleep_for(chrono::milliseconds(log_period)); diff --git a/src/overlay.cpp b/src/overlay.cpp index 83f242a8..ff5dcef3 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -42,7 +42,7 @@ #include "mesa/util/simple_mtx.h" #include "vk_enum_to_str.h" -#include "../include/vulkan/vk_util.h" +#include #include "cpu_gpu.h" #include "logging.h" @@ -847,8 +847,8 @@ static void snapshot_swapchain_frame(struct swapchain_data *data) if (log_period == 0) out.open("/tmp/mango", ios::out | ios::app); - if(duration_env) - duration = std::stoi(duration_env); + if(log_duration_env) + duration = std::stoi(log_duration_env); coreCounting(); if (deviceName.find("Radeon") != std::string::npos || deviceName.find("AMD") != std::string::npos) { From 678207f052ef97b4b450cfe3fe9ca980b01d5747 Mon Sep 17 00:00:00 2001 From: telans Date: Wed, 29 Jan 2020 23:25:16 +1300 Subject: [PATCH 3/6] remove unused mesa-overlay-control.py --- src/mesa-overlay-control.py | 203 ------------------------------------ src/meson.build | 7 -- 2 files changed, 210 deletions(-) delete mode 100755 src/mesa-overlay-control.py diff --git a/src/mesa-overlay-control.py b/src/mesa-overlay-control.py deleted file mode 100755 index 6947250c..00000000 --- a/src/mesa-overlay-control.py +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env python3 -import os -import socket -import sys -import select -from select import EPOLLIN, EPOLLPRI, EPOLLERR -import time -from collections import namedtuple -import argparse - -TIMEOUT = 1.0 # seconds - -VERSION_HEADER = bytearray('MesaOverlayControlVersion', 'utf-8') -DEVICE_NAME_HEADER = bytearray('DeviceName', 'utf-8') -MESA_VERSION_HEADER = bytearray('MesaVersion', 'utf-8') - -DEFAULT_SERVER_ADDRESS = "\0mesa_overlay" - -class Connection: - def __init__(self, path): - # Create a Unix Domain socket and connect - sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - try: - sock.connect(path) - except socket.error as msg: - print(msg) - sys.exit(1) - - self.sock = sock - - # initialize poll interface and register socket - epoll = select.epoll() - epoll.register(sock, EPOLLIN | EPOLLPRI | EPOLLERR) - self.epoll = epoll - - def recv(self, timeout): - ''' - timeout as float in seconds - returns: - - None on error or disconnection - - bytes() (empty) on timeout - ''' - - events = self.epoll.poll(timeout) - for ev in events: - (fd, event) = ev - if fd != self.sock.fileno(): - continue - - # check for socket error - if event & EPOLLERR: - return None - - # EPOLLIN or EPOLLPRI, just read the message - msg = self.sock.recv(4096) - - # socket disconnected - if len(msg) == 0: - return None - - return msg - - return bytes() - - def send(self, msg): - self.sock.send(msg) - -class MsgParser: - MSGBEGIN = bytes(':', 'utf-8')[0] - MSGEND = bytes(';', 'utf-8')[0] - MSGSEP = bytes('=', 'utf-8')[0] - - def __init__(self, conn): - self.cmdpos = 0 - self.parampos = 0 - self.bufferpos = 0 - self.reading_cmd = False - self.reading_param = False - self.buffer = None - self.cmd = bytearray(4096) - self.param = bytearray(4096) - - self.conn = conn - - def readCmd(self, ncmds, timeout=TIMEOUT): - ''' - returns: - - None on error or disconnection - - bytes() (empty) on timeout - ''' - - parsed = [] - - remaining = timeout - - while remaining > 0 and ncmds > 0: - now = time.monotonic() - - if self.buffer == None: - self.buffer = self.conn.recv(remaining) - self.bufferpos = 0 - - # disconnected or error - if self.buffer == None: - return None - - for i in range(self.bufferpos, len(self.buffer)): - c = self.buffer[i] - self.bufferpos += 1 - if c == self.MSGBEGIN: - self.cmdpos = 0 - self.parampos = 0 - self.reading_cmd = True - self.reading_param = False - elif c == self.MSGEND: - if not self.reading_cmd: - continue - self.reading_cmd = False - self.reading_param = False - - cmd = self.cmd[0:self.cmdpos] - param = self.param[0:self.parampos] - self.reading_cmd = False - self.reading_param = False - - parsed.append((cmd, param)) - ncmds -= 1 - if ncmds == 0: - break - elif c == self.MSGSEP: - if self.reading_cmd: - self.reading_param = True - else: - if self.reading_param: - self.param[self.parampos] = c - self.parampos += 1 - elif self.reading_cmd: - self.cmd[self.cmdpos] = c - self.cmdpos += 1 - - # if we read the entire buffer and didn't finish the command, - # throw it away - self.buffer = None - - # check if we have time for another iteration - elapsed = time.monotonic() - now - remaining = max(0, remaining - elapsed) - - # timeout - return parsed - -def control(args): - if args.socket: - address = '\0' + args.socket - else: - address = DEFAULT_SERVER_ADDRESS - - conn = Connection(address) - msgparser = MsgParser(conn) - - version = None - name = None - mesa_version = None - - msgs = msgparser.readCmd(3) - - for m in msgs: - cmd, param = m - if cmd == VERSION_HEADER: - version = int(param) - elif cmd == DEVICE_NAME_HEADER: - name = param.decode('utf-8') - elif cmd == MESA_VERSION_HEADER: - mesa_version = param.decode('utf-8') - - if version != 1 or name == None or mesa_version == None: - print('ERROR: invalid protocol') - sys.exit(1) - - - if args.info: - info = "Protocol Version: {}\n" - info += "Device Name: {}\n" - info += "Mesa Version: {}" - print(info.format(version, name, mesa_version)) - - if args.cmd == 'start-capture': - conn.send(bytearray(':capture=1;', 'utf-8')) - elif args.cmd == 'stop-capture': - conn.send(bytearray(':capture=0;', 'utf-8')) - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='MESA_overlay control client') - parser.add_argument('--info', action='store_true', help='Print info from socket') - parser.add_argument('--socket', '-s', type=str, help='Path to socket') - - commands = parser.add_subparsers(help='commands to run', dest='cmd') - commands.add_parser('start-capture') - commands.add_parser('stop-capture') - - args = parser.parse_args() - - control(args) diff --git a/src/meson.build b/src/meson.build index 43ad0f0b..3665b2b5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -69,10 +69,3 @@ install_data( files('mangohud.json'), install_dir : join_paths(get_option('datadir'), 'vulkan', 'implicit_layer.d'), ) - -configure_file( - input : files('mesa-overlay-control.py'), - output : '@PLAINNAME@', - configuration : configuration_data(), # only copy the file - install_dir: get_option('bindir'), -) From 8dc2f46548e7e0ed5d6eacc447eb1d37de547336 Mon Sep 17 00:00:00 2001 From: telans Date: Wed, 29 Jan 2020 23:35:42 +1300 Subject: [PATCH 4/6] build.sh: add package option for redistribution --- .gitignore | 2 ++ build.sh | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f2f0487a..dc63d488 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ build/ __pycache__/ +.vscode/ +MangoHud.tar.gz # Prerequisites *.d diff --git a/build.sh b/build.sh index 70c4febd..bb21231a 100755 --- a/build.sh +++ b/build.sh @@ -1,18 +1,18 @@ #!/bin/bash DATA_DIR=$HOME/.local/share/MangoHud -LAYER=build/release/share/vulkan/implicit_layer.d/mangohud.json +LAYER=build/release/usr/share/vulkan/implicit_layer.d/mangohud.json IMPLICIT_LAYER_DIR=$HOME/.local/share/vulkan/implicit_layer.d configure() { if [[ ! -d build/meson64 ]]; then - meson build/meson64 --libdir lib64 --prefix $PWD/build/release + meson build/meson64 --libdir lib64 --prefix $PWD/build/release/usr export CC="gcc -m32" export CXX="g++ -m32" export PKG_CONFIG_PATH="/usr/lib32/pkgconfig" export LLVM_CONFIG="/usr/bin/llvm-config32" - meson build/meson32 --libdir lib32 --prefix $PWD/build/release + meson build/meson32 --libdir lib32 --prefix $PWD/build/release/usr fi } @@ -25,8 +25,8 @@ install() { mkdir -p $IMPLICIT_LAYER_DIR mkdir -p $DATA_DIR - cp build/release/lib32/libMangoHud.so $DATA_DIR/libMangoHud32.so - cp build/release/lib64/libMangoHud.so $DATA_DIR/libMangoHud.so + cp build/release/usr/lib32/libMangoHud.so $DATA_DIR/libMangoHud32.so + cp build/release/usr/lib64/libMangoHud.so $DATA_DIR/libMangoHud.so cp $LAYER $IMPLICIT_LAYER_DIR/mangohud64.json cp $LAYER $IMPLICIT_LAYER_DIR/mangohud32.json @@ -35,6 +35,11 @@ install() { sed -i "s|64bit|32bit|g" $IMPLICIT_LAYER_DIR/mangohud32.json } +package() { + cd build/release + tar czf ../../MangoHud.tar.gz * +} + clean() { rm -r build } @@ -48,6 +53,7 @@ case $1 in "") configure; build;; "build") configure; build;; "install") configure; build; install;; + "package") package;; "clean") clean;; "uninstall") uninstall;; *) From ef98f2d2d88edbaba67e4c70eba8c694d2ca16ee Mon Sep 17 00:00:00 2001 From: telans Date: Wed, 29 Jan 2020 23:43:01 +1300 Subject: [PATCH 5/6] build.sh: add version to package --- .gitignore | 2 +- build.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index dc63d488..4bf7ae50 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ build/ __pycache__/ .vscode/ -MangoHud.tar.gz +MangoHud*.tar.gz # Prerequisites *.d diff --git a/build.sh b/build.sh index bb21231a..bfd98881 100755 --- a/build.sh +++ b/build.sh @@ -36,8 +36,9 @@ install() { } package() { + VERSION=$(printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)") cd build/release - tar czf ../../MangoHud.tar.gz * + tar czf ../../MangoHud-$VERSION.tar.gz * } clean() { From d2cd2c5743a477a85e5ccdfff272585ebd507626 Mon Sep 17 00:00:00 2001 From: telans Date: Thu, 30 Jan 2020 07:36:25 +1300 Subject: [PATCH 6/6] revert part of "ignore compiler warnings"; fixed on master --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 697abab8..8b41defd 100644 --- a/meson.build +++ b/meson.build @@ -141,7 +141,7 @@ endforeach # For some reason, the test for -Wno-foo always succeeds with gcc, even if the # option is not supported. Hence, check for -Wfoo instead. -foreach a : ['non-virtual-dtor', 'missing-field-initializers', 'format-truncation', 'pointer-arith', 'unused-variable'] +foreach a : ['non-virtual-dtor', 'missing-field-initializers', 'format-truncation'] if cpp.has_argument('-W' + a) cpp_args += '-Wno-' + a endif