Merge branch 'telans'

Remove unused python file
Fix includes
Add package build.sh option
pull/20/head
telans 4 years ago
commit b67a2aad16
No known key found for this signature in database
GPG Key ID: 195444EE92DBCB20

2
.gitignore vendored

@ -1,5 +1,7 @@
build/
__pycache__/
.vscode/
MangoHud*.tar.gz
# Prerequisites
*.d

@ -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,12 @@ install() {
sed -i "s|64bit|32bit|g" $IMPLICIT_LAYER_DIR/mangohud32.json
}
package() {
VERSION=$(printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)")
cd build/release
tar czf ../../MangoHud-$VERSION.tar.gz *
}
clean() {
rm -r build
}
@ -48,6 +54,7 @@ case $1 in
"") configure; build;;
"build") configure; build;;
"install") configure; build; install;;
"package") package;;
"clean") clean;;
"uninstall") uninstall;;
*)

@ -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')
@ -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')
subdir('src')

@ -22,7 +22,7 @@ struct logData{
double fps, elapsedLog;
std::vector<logData> 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));

@ -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)

@ -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'),
)

@ -42,7 +42,7 @@
#include "mesa/util/simple_mtx.h"
#include "vk_enum_to_str.h"
#include "../include/vulkan/vk_util.h"
#include <vulkan/vk_util.h>
#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) {

Loading…
Cancel
Save