mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +00:00
Merge branch 'main' into feat/performance-fixes-2
This commit is contained in:
commit
42aff89ffd
11 files changed
+827
-10
No files matched your search
@@ -224,9 +224,13 @@ while read -r package_sha256 package_url; do
|
||||
zstd -dc "${package_archive}" | tar -xf - -C "${mango_pkgs}"
|
||||
done < <(grep -v '^#' "${repo_root}/tools/mangoapp/packages.txt")
|
||||
install -m644 "${mango_pkgs}/usr/bin/mangoapp" "${mango_dir}/mangoapp"
|
||||
for library in libfmt.so.10 libspdlog.so.1.13 libglfw.so.3 libtraceevent.so.1 libtracefs.so.1; do
|
||||
for library in libfmt.so.10 libspdlog.so.1.13 libglfw.so.3 libtraceevent.so.1; do
|
||||
cp -L "${mango_pkgs}/usr/lib/${library}" "${mango_dir}/${library}"
|
||||
done
|
||||
# Ours, not the package's: GPU memory without tracefs (tools/mangoapp/libtracefs-shim.c).
|
||||
docker run --rm --platform linux/amd64 --user "$(id -u):$(id -g)" -v "${repo_root}:/src" -w /src "${image_name}" \
|
||||
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wl,-soname,libtracefs.so.1 \
|
||||
-o app/src/main/assets/linuxfs/usr/local/lib/mangoapp/libtracefs.so.1 tools/mangoapp/libtracefs-shim.c
|
||||
mkdir -p "${linuxfs_dir}/usr/local/bin"
|
||||
install -m644 "${repo_root}/tools/mangoapp/mangoapp" "${linuxfs_dir}/usr/local/bin/mangoapp"
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
// libtracefs.so.1 for mangoapp: the GPU memory Valve's overlay reads, without the kernel's tracing.
|
||||
//
|
||||
// Valve's mangoapp (msm.cpp, ftrace_gpumem.c) takes the GPU's memory in use - the VRAM and PVRAM
|
||||
// lines - from the gpu_mem_total tracepoint (pid 0, the device's total) through libtracefs. An
|
||||
// Android app may not use tracefs at all: the instance could not be made, and both lines read 0.
|
||||
// This stands in for the libtracefs calls mangoapp makes, and hands its record walker one
|
||||
// gpu_mem_total record carrying what the app writes to /run/droiddeck-hud/gpu-mem (bytes; the
|
||||
// session's GpuMemComponent, from KGSL's own accounting). Only mangoapp loads this copy.
|
||||
//
|
||||
// The walker reads libtraceevent's structures directly, so the ones below are libtraceevent
|
||||
// 1.8.2's (event-parse.h), the version tools/mangoapp/packages.txt pins; tep_find_event_by_record
|
||||
// and tep_read_number are answered here too, ahead of the real libtraceevent in mangoapp's lookup.
|
||||
|
||||
#include <sched.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define EXPORT __attribute__((visibility("default")))
|
||||
|
||||
struct tep_handle;
|
||||
struct tep_event;
|
||||
struct tep_print_arg;
|
||||
struct tep_print_parse;
|
||||
|
||||
struct tep_format_field {
|
||||
struct tep_format_field *next;
|
||||
struct tep_event *event;
|
||||
char *type;
|
||||
char *name;
|
||||
char *alias;
|
||||
int offset;
|
||||
int size;
|
||||
unsigned int arraylen;
|
||||
unsigned int elementsize;
|
||||
unsigned long flags;
|
||||
};
|
||||
|
||||
struct tep_format {
|
||||
int nr_common;
|
||||
int nr_fields;
|
||||
struct tep_format_field *common_fields;
|
||||
struct tep_format_field *fields;
|
||||
};
|
||||
|
||||
struct tep_print_fmt {
|
||||
char *format;
|
||||
struct tep_print_arg *args;
|
||||
struct tep_print_parse *print_cache;
|
||||
};
|
||||
|
||||
struct tep_event {
|
||||
struct tep_handle *tep;
|
||||
char *name;
|
||||
int id;
|
||||
int flags;
|
||||
struct tep_format format;
|
||||
struct tep_print_fmt print_fmt;
|
||||
char *system;
|
||||
void *handler;
|
||||
void *context;
|
||||
};
|
||||
|
||||
struct tep_record {
|
||||
unsigned long long ts;
|
||||
unsigned long long offset;
|
||||
long long missed_events;
|
||||
int record_size;
|
||||
int size;
|
||||
void *data;
|
||||
int cpu;
|
||||
int ref_count;
|
||||
int locked;
|
||||
void *priv;
|
||||
};
|
||||
|
||||
// gpu_mem_total's record: gpu_id, pid, size - as the kernel lays it out after the common fields.
|
||||
struct gpu_mem_total {
|
||||
unsigned int gpu_id;
|
||||
unsigned int pid;
|
||||
unsigned long long size;
|
||||
};
|
||||
|
||||
static struct tep_format_field size_field = {
|
||||
.name = "size", .offset = offsetof(struct gpu_mem_total, size), .size = 8};
|
||||
static struct tep_format_field pid_field = {
|
||||
.next = &size_field, .name = "pid", .offset = offsetof(struct gpu_mem_total, pid), .size = 4};
|
||||
static struct tep_event gpu_mem_event = {
|
||||
.name = "gpu_mem_total", .system = "gpu_mem", .format = {.nr_fields = 2, .fields = &pid_field}};
|
||||
|
||||
// Never dereferenced by mangoapp: they only have to be non-null.
|
||||
static char handle;
|
||||
static char instance;
|
||||
|
||||
static unsigned long long gpu_mem_bytes(void) {
|
||||
unsigned long long bytes = 0;
|
||||
FILE *f = fopen("/run/droiddeck-hud/gpu-mem", "r");
|
||||
if (f) {
|
||||
if (fscanf(f, "%llu", &bytes) != 1) bytes = 0;
|
||||
fclose(f);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
EXPORT void *tracefs_instance_create(const char *name) { (void)name; return &instance; }
|
||||
EXPORT char *tracefs_instance_get_dir(void *inst) { (void)inst; return strdup("/run/droiddeck-hud"); }
|
||||
EXPORT void tracefs_put_tracing_file(char *name) { free(name); }
|
||||
EXPORT struct tep_handle *tracefs_local_events(const char *dir) { (void)dir; return (struct tep_handle *)&handle; }
|
||||
EXPORT int tracefs_event_enable(void *inst, const char *system, const char *event) { (void)inst; (void)system; (void)event; return 0; }
|
||||
EXPORT int tracefs_event_disable(void *inst, const char *system, const char *event) { (void)inst; (void)system; (void)event; return 0; }
|
||||
EXPORT bool tracefs_instance_is_new(void *inst) { (void)inst; return false; }
|
||||
EXPORT int tracefs_instance_destroy(void *inst) { (void)inst; return 0; }
|
||||
EXPORT void tracefs_instance_free(void *inst) { (void)inst; }
|
||||
|
||||
EXPORT int tracefs_iterate_raw_events(struct tep_handle *tep, void *inst, cpu_set_t *cpus, int cpu_size,
|
||||
int (*callback)(struct tep_event *, struct tep_record *, int, void *),
|
||||
void *context) {
|
||||
(void)tep; (void)inst; (void)cpus; (void)cpu_size;
|
||||
if (!callback) return -1;
|
||||
struct gpu_mem_total data = {.gpu_id = 0, .pid = 0, .size = gpu_mem_bytes()};
|
||||
struct tep_record record = {.size = sizeof(data), .record_size = sizeof(data), .data = &data};
|
||||
callback(&gpu_mem_event, &record, 0, context);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT struct tep_event *tep_find_event_by_record(struct tep_handle *tep, struct tep_record *record) {
|
||||
(void)tep; (void)record;
|
||||
return &gpu_mem_event;
|
||||
}
|
||||
|
||||
EXPORT unsigned long long tep_read_number(struct tep_handle *tep, const void *ptr, int size) {
|
||||
(void)tep;
|
||||
switch (size) {
|
||||
case 1: return *(const unsigned char *)ptr;
|
||||
case 2: return *(const unsigned short *)ptr;
|
||||
case 4: return *(const unsigned int *)ptr;
|
||||
case 8: return *(const unsigned long long *)ptr;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT void tep_free(struct tep_handle *tep) { (void)tep; }
|
||||
@@ -1,4 +1,4 @@
|
||||
# Valve's aarch64 mangoapp (the Deck performance overlay) and the five libraries it needs that the
|
||||
# Valve's aarch64 mangoapp (the Deck performance overlay) and the libraries it needs that the
|
||||
# runtime does not have, at the versions it was built against (its .BUILDINFO: fmt 10.2.0,
|
||||
# spdlog 1.13.0). CI fetches each, checks the sha256 and stages the files named below into the apk
|
||||
# under usr/local/lib/mangoapp; SessionFiles copies them into the runtime at every launch.
|
||||
@@ -7,5 +7,6 @@
|
||||
ef7411229ea4e9b3ab4e36ac356a85b5072f362ee1de68b28d09c43f0b0ecc44 https://steamdeck-packages.steamos.cloud/archlinux-deckard/archlinux/mash-20240705.2/extra/os/aarch64/fmt-10.2.0-1-aarch64.pkg.tar.zst
|
||||
c9bfd2c3f15071329d381b9c2061d07503c4787ceb7001b9dfbf72a23c85cb04 https://steamdeck-packages.steamos.cloud/archlinux-deckard/archlinux/mash-20240705.2/extra/os/aarch64/spdlog-1.13.0-1-aarch64.pkg.tar.zst
|
||||
f9fae6c84a0382188f1cb20761424051593fd09b1456191cc250bd16e0a1d7a5 https://steamdeck-packages.steamos.cloud/archlinux-deckard/archlinux/mash-20240705.2/extra/os/aarch64/glfw-3.4-2-aarch64.pkg.tar.zst
|
||||
# libtracefs is ours (libtracefs-shim.c), and reads libtraceevent's structures as 1.8.2 lays them
|
||||
# out: moving libtraceevent off 1.8.2 means checking event-parse.h against the shim.
|
||||
0cccdc9c92cb3cae1e37ebeb0ed20b93bb3b5000c8f955b63d0e07bd878c7018 https://steamdeck-packages.steamos.cloud/archlinux-deckard/archlinux/mash-20240705.2/extra/os/aarch64/libtraceevent-1%3A1.8.2-2-aarch64.pkg.tar.zst
|
||||
47ffd6a953959d6a0df44539bef30a67d0b8c95cce0053273908d9d70ef7abc4 https://steamdeck-packages.steamos.cloud/archlinux-deckard/archlinux/mash-20240705.2/extra/os/aarch64/libtracefs-1.8.0-1-aarch64.pkg.tar.zst
|
||||
Reference in new issue
Block a user