[docs, tools] Add 3rd party links, debug and testing guidelines; add extra tools for maintaining strings, rewrite lanczos generator in perl (#2749)

RenderDoc checklist inspired by writeup of Charles G. of LunarG
Signed-off-by: lizzie <lizzie@eden-emu.dev>

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2749
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-10-20 14:25:03 +02:00 committed by crueter
parent 0eeeee515e
commit 226160f639
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
14 changed files with 308 additions and 101 deletions

View file

@ -11,15 +11,16 @@ Tools for Eden and other subprojects.
- `find-unused-strings.pl`: Find unused strings (for Android XML files).
- `shellcheck.sh`: Ensure POSIX compliance (and syntax sanity) for all tools in this directory and subdirectories.
- `llvmpipe-run.sh`: Sets environment variables needed to run any command (or Eden) with llvmpipe.
- `optimize-assets.sh`: Optimize PNG assets with OptiPng.
- `optimize-assets.sh`: Optimizes PNG assets with OptiPng.
- `update-cpm.sh`: Updates CPM.cmake to the latest version.
- `update-icons.sh`: Rebuild all icons (macOS, Windows, bitmaps) based on the master SVG file (`dist/dev.eden_emu.eden.svg`)
* Also optimizes the master SVG
* Requires: `png2icns` (libicns), ImageMagick, [`svgo`](https://github.com/svg/svgo)
- `dtrace-tool.sh`
- `lanczos_gen.c`
- `lanczos-gen.pl`: Generates constants for the Lanczos filter.
- `clang-format.sh`: Runs `clang-format` on the entire codebase.
* Requires: clang
- `find-unused-strings.sh`: Find any unused strings in the Android app (XML -> Kotlin).
## Android
It's recommended to run these scritps after almost any Android change, as they are relatively fast and important both for APK bloat and CI.
@ -29,4 +30,4 @@ It's recommended to run these scritps after almost any Android change, as they a
## Translations
- [Translation Scripts](./translations)
- [Translation Scripts](./translations)

131
tools/dtrace-tool.pl Executable file
View file

@ -0,0 +1,131 @@
#!/usr/bin/perl
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
# Basic script to run dtrace sampling over the program (requires Flamegraph)
# Usage is either running as: ./dtrace-tool.sh pid (then input the pid of the process)
# Or just run directly with: ./dtrace-tool.sh <command>
use strict;
use warnings;
use POSIX qw(strftime);
my $input;
my $sampling_hz = '4000';
my $sampling_time = '5';
my $sampling_pid = `pgrep eden`;
my $sampling_program = 'eden';
my $sampling_type = 0;
sub dtrace_ask_params {
my $is_ok = 'Y';
do {
print "Sampling HZ [" . $sampling_hz . "]: ";
chomp($input = <STDIN>);
$sampling_hz = $input || $sampling_hz;
print "Sampling time [" . $sampling_time . "]: ";
chomp($input = <STDIN>);
$sampling_time = $input || $sampling_time;
print "Sampling pid [" . $sampling_pid . "]: ";
chomp($input = <STDIN>);
$sampling_pid = $input || $sampling_pid;
print "Are these settings correct?: [" . $is_ok . "]\n";
print "HZ = " . $sampling_hz . "\nTime = " . $sampling_time . "\nPID = " . $sampling_pid . "\n";
chomp($input = <STDIN>);
$is_ok = $input || $is_ok;
} while ($is_ok eq 'n');
}
sub dtrace_probe_profiling {
if ($sampling_type eq 0) {
return "
profile-".$sampling_hz." /pid == ".$sampling_pid." && arg0/ {
@[stack(100)] = count();
}
profile-".$sampling_hz." /pid == ".$sampling_pid." && arg1/ {
@[ustack(100)] = count();
}
tick-".$sampling_time."s {
exit(0);
}";
} elsif ($sampling_type eq 1) {
return "
syscall:::entry /pid == ".$sampling_pid."/ {
\@traces[ustack(100)] = count();
}
tick-".$sampling_time."s {
exit(0);
}";
} elsif ($sampling_type eq 2) {
return "
profile-".$sampling_hz." /pid == ".$sampling_pid." && arg0/ {
@[stringof(curthread->td_name), stack(100)] = count();
}
profile-".$sampling_hz." /pid == ".$sampling_pid." && arg1/ {
@[stringof(curthread->td_name), ustack(100)] = count();
}
tick-".$sampling_time."s {
exit(0);
}";
} elsif ($sampling_type eq 3) {
return "
io::start /pid == ".$sampling_pid."/ {
@[ustack(100)] = count();
}
tick-".$sampling_time."s {
exit(0);
}";
} else {
die "idk";
}
}
sub dtrace_generate {
my @date = (localtime(time))[5, 4, 3, 2, 1, 0];
$date[0] += 1900;
$date[1]++;
my $fmt_date = sprintf "%4d-%02d-%02d_%02d-%02d-%02d", @date;
my $trace_dir = "dtrace-out";
my $trace_file = $trace_dir . "/" . $fmt_date . ".user_stacks";
my $trace_fold = $trace_dir . "/" . $fmt_date . ".fold";
my $trace_svg = $trace_dir . "/" . $fmt_date . ".svg";
my $trace_probe = dtrace_probe_profiling;
print $trace_probe . "\n";
system "sudo", "dtrace", "-Z", "-n", $trace_probe, "-o", $trace_file;
die "$!" if $?;
open (my $trace_fold_handle, ">", $trace_fold) or die "$!";
#run ["perl", "../FlameGraph/stackcollapse.pl", $trace_file], ">", \my $fold_output;
my $fold_output = `perl ../FlameGraph/stackcollapse.pl $trace_file`;
print $trace_fold_handle $fold_output;
open (my $trace_svg_handle, ">", $trace_svg) or die "$!";
#run ["perl", "../FlameGraph/flamegraph.pl", $trace_fold], ">", \my $svg_output;
my $svg_output = `perl ../FlameGraph/flamegraph.pl $trace_fold`;
print $trace_svg_handle $svg_output;
system "sudo", "chmod", "0666", $trace_file;
}
foreach my $i (0 .. $#ARGV) {
if ($ARGV[$i] eq '-h') {
print "Usage: $0\n";
printf "%-20s%s\n", "-p", "Prompt for parameters";
printf "%-20s%s\n", "-g", "Generate dtrace output";
printf "%-20s%s\n", "-s", "Continously generate output until Ctrl^C";
printf "%-20s%s\n", "-<n>", "Select dtrace type";
} elsif ($ARGV[$i] eq '-g') {
dtrace_generate;
} elsif ($ARGV[$i] eq '-s') {
while (1) {
dtrace_generate;
}
} elsif ($ARGV[$i] eq '-p') {
dtrace_ask_params;
} else {
$sampling_type = substr $ARGV[$i], 1;
print "Select: ".$sampling_type."\n";
}
}

View file

@ -0,0 +1,7 @@
#!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
cat src/android/app/src/main/res/values/strings.xml \
| grep 'string name="' | awk -F'"' '$0=$2' \
| xargs -I {} sh -c 'grep -qirnw R.string.'{}' src/android/app/src || echo '{}

40
tools/lanczos-gen.pl Normal file
View file

@ -0,0 +1,40 @@
#!/usr/bin/perl
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
use strict;
use warnings;
sub generate_lanczos {
my $pi = 3.14159265358979;
sub sinc {
if ($_[0] eq 0.0) {
return 1.0;
} else {
return sin($pi * $_[0]) / ($pi * $_[0]);
}
}
sub lanczos {
my $d = sqrt($_[0] * $_[0] + $_[1] * $_[1]);
return sinc($d) / sinc($d / $_[2]);
}
my $r = 3.0; #radius (1 = 3 steps)
my $k_size = ($r * 2.0 + 1.0) * ($r * 2.0 + 1.0);
my $w_sum = \0.0;
my $factor = 1.0 / ($r + 1.0);
#kernel size = (r * 2 + 1) ^ 2
printf("const float w_kernel[%i] = float[] (\n ", $k_size);
for (my $x = -$r; $x <= $r; $x++) {
for (my $y = -$r; $y <= $r; $y++) {
my $w = lanczos($x, $y, $r);
printf("%f, ", $w);
$w_sum += $w;
}
}
printf("\n);\nconst vec2 w_pos[%i] = vec[](\n ", $k_size);
for (my $x = -$r; $x <= $r; $x++) {
for (my $y = -$r; $y <= $r; $y++) {
printf("vec2(%f, %f), ", $x * $factor, $y * $factor);
}
}
printf("\n);\nconst float w_sum = %f;\n", $w_sum);
}
generate_lanczos;

View file

@ -1,48 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// clang -lm tools/lanczos_gen.c -o tools/lanczos_gen && ./tools/lanczos_gen
#include <stdio.h>
#include <math.h>
double sinc(double x) {
return x == 0.0f ? 1.0f : sin(M_PI * x) / (M_PI * x);
}
typedef struct vec2 {
double x;
double y;
} vec2;
double lanczos(vec2 v, float a) {
double d = sqrt(v.x * v.x + v.y * v.y);
return sinc(d) / sinc(d / a);
}
int main(int argc, char* argv[]) {
const int r = 3; //radius (1 = 3 steps)
const int k_size = (r * 2 + 1) * (r * 2 + 1);
double w_sum = 0.0f;
// kernel size = (r * 2 + 1) ^ 2
printf("const float w_kernel[%i] = float[] (\n ", k_size);
double factor = 1.0f / ((double)r + 1.0f);
for (int x = -r; x <= r; x++)
for (int y = -r; y <= r; y++) {
double w = lanczos((vec2){ .x = x, .y = y }, (double)r);
printf("%lff, ", w);
w_sum += w;
}
printf("\n);\n");
printf("const vec2 w_pos[%i] = vec2[] (\n ", k_size);
for (int x = -r; x <= r; x++)
for (int y = -r; y <= r; y++) {
vec2 kp = (vec2){
.x = x * factor,
.y = y * factor
};
printf("vec2(%lff, %lff), ", kp.x, kp.y);
}
printf("\n);\n");
printf("const float w_sum = %lff;\n", w_sum);
return 0;
}

View file

@ -1,9 +1,5 @@
#!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
# Optimizes assets of Eden (requires OptiPng)
which optipng || exit
find . -type f -name "*.png" -exec optipng -o7 {} \;
find . -type f -iname '*.png' -print0 | xargs -0 -P 16 -I {} optipng -o7 {}