#!/bin/bash # One paced ring-buffer run (STATUS item 4, FINDINGS 49.7.2). # # tools/bench/check.sh runs the ring pass FREE-RUNNING, which is right for what # it gates -- wrap correctness at a fixed ring size, delivery removed as a # variable by an unlimited pipe. It cannot answer the buffering question, # because a free-running decoder never lets the ring back up. # # This runs the same rig with the decoder held to the container's frame rate, # so the ring fills and FR_HEAD-FR_TAIL means "frames the decoder could still # draw with the pipe dead". Every run is verified PIXEL-EXACT: a paced decode # that drops a pixel is not a slack measurement, it is a bug. # # tools/bench/pace_run.sh [cut_at_tick] [cut_frames] # # kbps 0 = unlimited pipe. There is no default rate anywhere in this tree # (FINDINGS 50) and there is none here either. set -e cd "$(dirname "$0")/../.." RING=${1:?ring KB}; KBPS=${2:?pipe KB/s, or 0 for unlimited} CUT_AT=$3; CUT_FR=${4:-1} DLX=${DLX:-tmp/rc_fr_singe_scsi_span.dlx} TAG="r${RING}_k${KBPS}${CUT_AT:+_cut${CUT_AT}x${CUT_FR}}" tools/vasm/vasmm68k_mot -Fbin -o tmp/stream.bin src/player/stream.s > /dev/null [ -f tmp/stream_disk.bin ] || python3 tools/bench/prep_stream.py "$DLX" > tmp/prep_stream.log mkdir -p "tmp/snap_pace_$TAG"; rm -f "tmp/snap_pace_$TAG/x68000"/*.png # `env` rather than an assignment prefix: an empty ${CUT_AT:+...} in the middle # of a prefix is not an assignment token, so bash takes the next word as the # command and the run dies with "SDL_VIDEODRIVER=dummy: command not found". CUTENV=(); [ -n "$CUT_AT" ] && CUTENV=(DLX_CUT_AT="$CUT_AT" DLX_CUT_FR="$CUT_FR") ( cd tmp && env DLX_PACE=1 DLX_RING_KB=$RING DLX_STREAM_KBPS=$KBPS \ "${CUTENV[@]}" DLX_SLACK_CSV="slack_$TAG.csv" \ SDL_VIDEODRIVER=dummy stdbuf -oL timeout -k 5 900 \ mame x68000 -bios ipl10 -ramsize 2M -video soft -window -sound none \ -nothrottle -plugins -autoboot_script ../tools/bench/stream.lua \ -snapshot_directory "./snap_pace_$TAG" -snapview native -seconds_to_run 90 \ > "pace_$TAG.log" 2>&1 ) # The completion marker is not optional: a run killed mid-decode compares a # half-drawn screen and reads as a wrap bug rather than as a truncated run. grep -q "snapshot taken" "tmp/pace_$TAG.log" || { echo "FAIL($TAG): no snapshot marker -- the pass did not complete." tail -6 "tmp/pace_$TAG.log"; exit 1; } echo "=== $TAG" grep -aE "decoder (PACED|FREE)|ring: |UNDERRUNS|SEEK SLACK|RING-BOUND|RATE-BOUND|BUILD TIME|PIPE CUT|DEADLINE|REQUIRED" \ "tmp/pace_$TAG.log" | sed "s/\[STR\] / /" python3 tools/bench/verify_decode.py "$DLX" --snap "tmp/snap_pace_$TAG" | tail -2