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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
|
#!/bin/bash
# This script is to be run on the KVM host, inside the container
set -ex
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export PYTHONPATH=/usr/local/lib/python3.7/site-packages
benchmark_loops=0
perfetto_loops=10
wait_after_frame=
debug=no
trace=
command=""
prep_snapshot=
vtest=no
minigbm=true
while [ -n "$1" ] ; do
case "$1" in
--trace|-t)
trace="$2"
shift
;;
--benchmark|-b)
command="$command benchmark=$2"
benchmark_loops=$2
shift
;;
--perfetto|-p)
command="$command perfetto=$2"
perfetto_loops=$2
shift
;;
--wait-after-frame|-w)
command="$command wait-after-frame=1"
wait_after_frame="--wait-after-frame"
;;
--snapshot|-s)
command="$command record-frame=1"
prep_snapshot=yes
;;
--debug)
debug=yes
;;
--vtest)
vtest=yes
minigbm=false
;;
*)
echo "Unknown option '$1' given, run with option --help to see supported options"
exit
;;
esac
shift
done
if [ "x$trace" = "x" ]; then
echo "No trace given in run script, you must pass is as free parameter to the docker call"
exit 1
fi
pushd /mesa
mkdir -p build
if [ ! -f build/build.ninja ]; then
meson setup build/ \
-Dprefix=/usr/local \
-Dgallium-drivers=softpipe,virgl,radeonsi,iris \
-Dbuildtype=debugoptimized \
-Dllvm=enabled \
-Dglx=dri \
-Degl=enabled \
-Dgbm=disabled \
-Dgallium-vdpau=disabled \
-Dgallium-va=disabled \
-Dvulkan-drivers=[] \
-Dvalgrind=disabled \
-Dperfetto=true \
-Dlibdir=lib
else
pushd build
meson configure \
-Dprefix=/usr/local \
-Dgallium-drivers=swrast,virgl,radeonsi,iris \
-Dbuildtype=debugoptimized \
-Dllvm=enabled \
-Dglx=dri \
-Degl=enabled \
-Dgbm=disabled \
-Dgallium-vdpau=disabled \
-Dgallium-va=disabled \
-Dvulkan-drivers=[] \
-Dvalgrind=disabled \
-Dperfetto=true \
-Dlibdir=lib
popd
fi
ninja -C build/ install
popd
pushd /virglrenderer
mkdir -p build
if [ ! -f build/build.ninja ]; then
meson setup build/ \
-Dprefix=/usr/local \
-Dlibdir=lib \
-Dplatforms=egl \
-Dminigbm_allocation=$minigbm \
-Dtracing=perfetto \
-Dbuildtype=debugoptimized
else
pushd build
meson configure \
-Dprefix=/usr/local \
-Dlibdir=lib \
-Dplatforms=egl \
-Dminigbm_allocation=$minigbm \
-Dtracing=perfetto \
-Dbuildtype=debugoptimized
popd
fi
ninja -C build/ install
popd
# Crosvm needs to link with minigbm, due to incompatible ABI
if [ "x$minigbm" == "xtrue" ] ; then
export LD_PRELOAD=/usr/lib/libminigbm.so.1.0.0
fi
export PATH="/apitrace/build:$PATH"
export PATH="/waffle/build/bin:$PATH"
export LD_LIBRARY_PATH="/waffle/build/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/usr/local/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH"
trace_no_ext=${trace%.*}
datadir="/traces-db/${trace_no_ext}-out"
echo "Host:"
wflinfo --platform surfaceless_egl --api gles2
export EGL_PLATFORM="surfaceless"
export WAFFLE_PLATFORM="surfaceless_egl"
export DISPLAY=
if [ "x$benchmark_loops" != "x0" ]; then
echo "Measuring rendering times:"
eglretrace --benchmark --loop=$benchmark_loops --headless "/traces-db/${trace}"
fi
# To keep Perfetto happy
echo 0 > /sys/kernel/debug/tracing/tracing_on
echo nop > /sys/kernel/debug/tracing/current_tracer
if [ "x$perfetto_loops" != "x" ] ; then
echo "perfetto_loops parameter not given"
fi
if [ "x$perfetto_loops" != "x0" ]; then
/perfetto/out/dist/traced &
/perfetto/out/dist/traced_probes &
sleep 1
/gfx-pps/build/src/gpu/producer-gpu &
sleep 1
/perfetto/out/dist/perfetto --txt -c /usr/local/perfetto-host.cfg -o /tmp/perfetto-host.trace --detach=mykey
sleep 1
echo "Replaying for Perfetto:"
eglretrace --benchmark --singlethread --loop=$perfetto_loops $wait_after_frame --headless "/traces-db/${trace}"
fi
if [ "x$vtest" != "xyes" ]; then
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
fi
# store name of trace to be replayed so the guest can obtain the name
echo $trace_no_ext > /traces-db/current_trace
echo $command > /traces-db/command
trace_base=$(basename $trace_no_ext)
guest_perf="$datadir/${trace_base}-guest.perfetto"
host_perf="$datadir/${trace_base}-host.perfetto"
vtest_perf="$datadir/${trace_base}-vtest.perfetto"
summary_perf="$datadir/${trace_base}-summary.perfetto"
mkdir -p $datadir
# work around Crosvm crashing because of errors in context
# handling, could be a problem with the kernel and/or with virglrenderer
export MESA_EXTENSION_OVERRIDE="-GL_ARB_buffer_storage -GL_EXT_buffer_storage"
if [ "x$debug" = "xyes" ]; then
export EGL_DEBUG=debug
fi
if [ "x$vtest" == "xyes" ]; then
/usr/local/bin/virgl_test_server --use-egl-surfaceless &
sleep 1
export LIBGL_ALWAYS_SOFTWARE=1
export GALLIUM_DRIVER="virpipe"
/perfetto/out/dist/perfetto --attach=mykey --stop
sleep 1
/perfetto/out/dist/perfetto --txt -c /usr/local/perfetto-vtest.cfg -o /tmp/perfetto-vtest.trace --detach=mykey
sleep 1
echo "Replaying for Perfetto:"
eglretrace --benchmark --singlethread --loop=$perfetto_loops $wait_after_frame --headless "/traces-db/${trace}"
unset LIBGL_ALWAYS_SOFTWARE
unset GALLIUM_DRIVER
killall virgl_test_server
elif [ -e /wd/crosvm-debug.cmd ]; then
gdb -x /wd/crosvm-debug.cmd
else
crosvm run \
--gpu gles=false\
-m 4096 \
-c 4 \
-i /rootfs.cpio.gz \
--shared-dir "/usr/local:local:type=fs" \
--shared-dir "/waffle:waffle-tag:type=fs" \
--shared-dir "/apitrace:apitrace-tag:type=fs" \
--shared-dir "/traces-db:traces-db-tag:type=fs" \
--shared-dir "/perfetto:perfetto-tag:type=fs" \
--host_ip 192.168.200.1 --netmask 255.255.255.0 --mac AA:BB:CC:00:00:12 \
-p "root=/dev/ram0 rdinit=/init.sh ip=192.168.200.2::192.168.200.1:255.255.255.0:crosvm:eth0 nohz=off clocksource=kvm-clock" \
/vmlinux
fi
rm -f /traces-db/current_trace
rm -f /traces-db/command
if [ "x$perfetto_loops" != "x0" ]; then
/perfetto/out/dist/perfetto --attach=mykey --stop
mv /tmp/perfetto-host.trace "$host_perf"
chmod a+rw "$host_perf"
# sometimes one of these processes seems to crash or exit before, so
# check whether it is still
kill `pidof producer-gpu` || echo "producer-gpu was not running (anymore)"
kill `pidof traced_probes` || echo "traced_probes was not running (anymore)"
kill `pidof traced` || echo "traced was not running (anymore="
if [ "x$vtest" == "xyes" ]; then
mv /tmp/perfetto-vtest.trace "$vtest_perf"
chmod a+rw "$vtest_perf"
else
/usr/local/merge_traces.py "$host_perf" "$guest_perf" "$summary_perf"
fi
fi
sleep 1
|