34 lines
1.5 KiB
Shell
34 lines
1.5 KiB
Shell
|
|
#!/data/data/com.termux/files/usr/bin/bash
|
||
|
|
# Times a fullscreen background shader's per-pixel cost. Same Xvfb + Mesa
|
||
|
|
# softpipe rig as screenshot.sh (see the long note there about llvmpipe
|
||
|
|
# crashing with SIGILL in this environment), because a fragment shader can
|
||
|
|
# only be timed if something actually rasterizes it - --headless renders
|
||
|
|
# nothing at all.
|
||
|
|
#
|
||
|
|
# Softpipe is a CPU rasterizer, so treat the numbers as RELATIVE only:
|
||
|
|
# comparing two versions of the same shader is meaningful, comparing against
|
||
|
|
# a phone's frame budget is not.
|
||
|
|
#
|
||
|
|
# Usage: bash tests/profile_shader.sh <shader_res_path> [timed_frames] [warmup] [WxH]
|
||
|
|
# Example: bash tests/profile_shader.sh res://lunar_surface.gdshader 30 10 720x1280
|
||
|
|
|
||
|
|
set -e
|
||
|
|
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||
|
|
GODOT_BIN="/root/Godot_v4.7.1-stable_linux.arm64"
|
||
|
|
|
||
|
|
SHADER_PATH="${1:?usage: profile_shader.sh <shader_res_path> [timed_frames] [warmup] [WxH]}"
|
||
|
|
TIMED_FRAMES="${2:-30}"
|
||
|
|
WARMUP_FRAMES="${3:-10}"
|
||
|
|
RESOLUTION="${4:-720x1280}"
|
||
|
|
|
||
|
|
proot-distro login ubuntu -- bash -c "
|
||
|
|
pkill -x Xvfb >/dev/null 2>&1 || true
|
||
|
|
rm -f /tmp/.X99-lock /tmp/.X11-unix/X99
|
||
|
|
Xvfb :99 -screen 0 ${RESOLUTION}x24 &
|
||
|
|
XVFB_PID=\$!
|
||
|
|
trap 'kill \$XVFB_PID >/dev/null 2>&1 || true' EXIT
|
||
|
|
sleep 2
|
||
|
|
mkdir -p /tmp/xdgrt && chmod 700 /tmp/xdgrt
|
||
|
|
cd '$PROJECT_DIR'
|
||
|
|
DISPLAY=:99 XDG_RUNTIME_DIR=/tmp/xdgrt GALLIUM_DRIVER=softpipe '$GODOT_BIN' --audio-driver Dummy --rendering-driver opengl3 --rendering-method gl_compatibility --resolution '$RESOLUTION' -s res://tests/_profile_surface_shader.gd -- '$SHADER_PATH' '$TIMED_FRAMES' '$WARMUP_FRAMES'
|
||
|
|
"
|