summaryrefslogtreecommitdiffstats
path: root/tools/lg/frame_sequence.sh
blob: 958a34afc9a56f34c3a057e3e5767b678d012f08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# frame_sequence.sh - capture an animated GPU-rendered frame sequence end to
# end: run the guest's CUDA frame producer into the kvmfr ivshmem BAR and
# save every published frame on the host as PPM/PNG (the proven
# CUDA -> ivshmem -> host path; see docs/05-operations/06).
#
# Usage: tools/lg/frame_sequence.sh [frames] [width] [height] [fps] [outdir]
set -u
HERE="$(cd "$(dirname "$0")" && pwd)"
REPO="$(cd "$HERE/../.." && pwd)"
FRAMES="${1:-40}"
W="${2:-800}"
H="${3:-600}"
FPS="${4:-10}"
OUT="${5:-/tmp/opencode/frames-seq}"

mkdir -p "$OUT"
rm -f "$OUT"/frame-*.ppm "$OUT"/frame-*.png

# Start the host reader first so no published frame is missed.
python3 "$REPO/tools/lg/frame_reader.py" --frames "$FRAMES" --out "$OUT" \
    --timeout 240 > "$OUT/reader.log" 2>&1 &
READER=$!

sleep 1
"$REPO/scripts/ssh_guest.sh" \
    "sudo /tmp/frame_producer $FRAMES $W $H $FPS" 2>&1 | grep -v "Permanently added" \
    | tail -5

wait "$READER"
echo "reader rc=$?"
ls -1 "$OUT"/frame-*.ppm 2>/dev/null | wc -l