1*8975f5c5SAndroid Build Coastguard Worker# ANGLE Restricted Traces 2*8975f5c5SAndroid Build Coastguard Worker 3*8975f5c5SAndroid Build Coastguard WorkerThe files in this directory are traces of real applications. We host them 4*8975f5c5SAndroid Build Coastguard Workerinternally because they may contain third party IP which we don't want 5*8975f5c5SAndroid Build Coastguard Workerto share publicly. 6*8975f5c5SAndroid Build Coastguard Worker 7*8975f5c5SAndroid Build Coastguard Worker## Accessing the traces 8*8975f5c5SAndroid Build Coastguard Worker 9*8975f5c5SAndroid Build Coastguard WorkerIn order to compile and run with these, you must be granted access by Google, 10*8975f5c5SAndroid Build Coastguard Workerthen authenticate with [CIPD](CIPD). Googlers, use your @google account. 11*8975f5c5SAndroid Build Coastguard Worker``` 12*8975f5c5SAndroid Build Coastguard Workercipd auth-login 13*8975f5c5SAndroid Build Coastguard Worker``` 14*8975f5c5SAndroid Build Coastguard WorkerAdd the following to ANGLE's .gclient file: 15*8975f5c5SAndroid Build Coastguard Worker``` 16*8975f5c5SAndroid Build Coastguard Worker "custom_vars": { 17*8975f5c5SAndroid Build Coastguard Worker "checkout_angle_restricted_traces": True 18*8975f5c5SAndroid Build Coastguard Worker }, 19*8975f5c5SAndroid Build Coastguard Worker``` 20*8975f5c5SAndroid Build Coastguard Worker 21*8975f5c5SAndroid Build Coastguard WorkerNote: alternatively, you can checkout only a few specific traces using the following format (`angle_restricted_traces` in gn args below should be a matching list or a subset): 22*8975f5c5SAndroid Build Coastguard Worker``` 23*8975f5c5SAndroid Build Coastguard Worker "custom_vars": { 24*8975f5c5SAndroid Build Coastguard Worker "checkout_angle_restricted_trace_{trace_name_1}": True, 25*8975f5c5SAndroid Build Coastguard Worker "checkout_angle_restricted_trace_{trace_name_2}": True, 26*8975f5c5SAndroid Build Coastguard Worker ... 27*8975f5c5SAndroid Build Coastguard Worker }, 28*8975f5c5SAndroid Build Coastguard Worker``` 29*8975f5c5SAndroid Build Coastguard Worker 30*8975f5c5SAndroid Build Coastguard WorkerThen use gclient to pull down binary files from CIPD. 31*8975f5c5SAndroid Build Coastguard Worker``` 32*8975f5c5SAndroid Build Coastguard Workergclient sync -D 33*8975f5c5SAndroid Build Coastguard Worker``` 34*8975f5c5SAndroid Build Coastguard WorkerThis should result in a number of directories created in `src/tests/restricted_traces` that contain 35*8975f5c5SAndroid Build Coastguard Workerthe trace files listed in [restricted_traces.json](restricted_traces.json): 36*8975f5c5SAndroid Build Coastguard Worker``` 37*8975f5c5SAndroid Build Coastguard Worker$ ls -d src/tests/restricted_traces/*/ 38*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/aliexpress/ 39*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/angry_birds_2_1500/ 40*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/arena_of_valor/ 41*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/asphalt_8/ 42*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/brawl_stars/ 43*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/bus_simulator_indonesia/ 44*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/candy_crush_500/ 45*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/clash_of_clans/ 46*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/clash_royale/ 47*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/cod_mobile/ 48*8975f5c5SAndroid Build Coastguard Worker... 49*8975f5c5SAndroid Build Coastguard Worker``` 50*8975f5c5SAndroid Build Coastguard Worker 51*8975f5c5SAndroid Build Coastguard Worker[CIPD]: https://chromium.googlesource.com/infra/luci/luci-go/+/main/cipd/README.md 52*8975f5c5SAndroid Build Coastguard Worker 53*8975f5c5SAndroid Build Coastguard Worker## Building the trace tests 54*8975f5c5SAndroid Build Coastguard Worker 55*8975f5c5SAndroid Build Coastguard WorkerTo build for Android, follow the steps in [DevSetupAndroid.md](../../../doc/DevSetupAndroid.md) 56*8975f5c5SAndroid Build Coastguard Worker(Recommend using the [`Performance`](../../../doc/DevSetupAndroid.md#performance-config) arguments 57*8975f5c5SAndroid Build Coastguard Workerfor best performance) 58*8975f5c5SAndroid Build Coastguard Worker 59*8975f5c5SAndroid Build Coastguard WorkerTo build for Desktop, follow the steps in [DevSetup.md](../../../doc/DevSetup.md) 60*8975f5c5SAndroid Build Coastguard Worker 61*8975f5c5SAndroid Build Coastguard WorkerWhen that is working, add the following GN arg to your setup: 62*8975f5c5SAndroid Build Coastguard Worker``` 63*8975f5c5SAndroid Build Coastguard Workerbuild_angle_trace_perf_tests = true 64*8975f5c5SAndroid Build Coastguard Worker``` 65*8975f5c5SAndroid Build Coastguard Worker### Selecting which traces to build 66*8975f5c5SAndroid Build Coastguard Worker 67*8975f5c5SAndroid Build Coastguard WorkerSince the traces are numerous, you should limit compilation to a subset with the following GN arg: 68*8975f5c5SAndroid Build Coastguard Worker``` 69*8975f5c5SAndroid Build Coastguard Workerangle_restricted_traces = ["among_us 5", "street_fighter_duel 1"] 70*8975f5c5SAndroid Build Coastguard Worker``` 71*8975f5c5SAndroid Build Coastguard WorkerIf you choose not to pick any traces and build them all, you must follow different steps for Android. Skip ahead to [Building and running all traces for Android](#building-and-running-all-traces-for-android) 72*8975f5c5SAndroid Build Coastguard Worker 73*8975f5c5SAndroid Build Coastguard WorkerTo build the trace tests: 74*8975f5c5SAndroid Build Coastguard Worker``` 75*8975f5c5SAndroid Build Coastguard Workerautoninja -C out/<config> angle_trace_tests 76*8975f5c5SAndroid Build Coastguard Worker``` 77*8975f5c5SAndroid Build Coastguard Worker## Running the trace tests 78*8975f5c5SAndroid Build Coastguard WorkerThe trace tests can be run with default options like so: 79*8975f5c5SAndroid Build Coastguard Worker``` 80*8975f5c5SAndroid Build Coastguard Workerout/<config>/angle_trace_tests 81*8975f5c5SAndroid Build Coastguard Worker``` 82*8975f5c5SAndroid Build Coastguard WorkerTo select a specific trace to run, provide it with a filter: 83*8975f5c5SAndroid Build Coastguard Worker``` 84*8975f5c5SAndroid Build Coastguard Workerout/<config>/angle_trace_tests --gtest_filter=TraceTest.<trace_name> 85*8975f5c5SAndroid Build Coastguard Worker``` 86*8975f5c5SAndroid Build Coastguard WorkerThe specific options available with traces can be found in the PerfTests [`README`](../perf_tests/README.md#trace-tests) 87*8975f5c5SAndroid Build Coastguard Worker 88*8975f5c5SAndroid Build Coastguard WorkerCommon options used are: 89*8975f5c5SAndroid Build Coastguard Worker``` 90*8975f5c5SAndroid Build Coastguard Worker# Use ANGLE as the driver with the system's Vulkan driver as backend 91*8975f5c5SAndroid Build Coastguard Worker--use-angle=vulkan 92*8975f5c5SAndroid Build Coastguard Worker 93*8975f5c5SAndroid Build Coastguard Worker# Use the system's native GLES driver 94*8975f5c5SAndroid Build Coastguard Worker--use-gl=native 95*8975f5c5SAndroid Build Coastguard Worker``` 96*8975f5c5SAndroid Build Coastguard Worker 97*8975f5c5SAndroid Build Coastguard Worker### Building and running all traces for Android 98*8975f5c5SAndroid Build Coastguard WorkerOur trace library has gotten large enough that they no longer fit in a single APK. To support building and running the entire library, we can compile the libraries by themselves, outside of the APK, and push them to locations accessible by the test harness. 99*8975f5c5SAndroid Build Coastguard Worker 100*8975f5c5SAndroid Build Coastguard WorkerTo do so, remove `angle_restricted_traces` from your GN args, then compile with: 101*8975f5c5SAndroid Build Coastguard Worker``` 102*8975f5c5SAndroid Build Coastguard Workerautoninja -C out/<config> angle_trace_perf_tests 103*8975f5c5SAndroid Build Coastguard Worker``` 104*8975f5c5SAndroid Build Coastguard Workerand run with (including recommended options): 105*8975f5c5SAndroid Build Coastguard Worker``` 106*8975f5c5SAndroid Build Coastguard Workerout/<config>/angle_trace_tests --filter='*among_us*' --verbose --fixed-test-time-with-warmup 10 107*8975f5c5SAndroid Build Coastguard Worker``` 108*8975f5c5SAndroid Build Coastguard Worker 109*8975f5c5SAndroid Build Coastguard WorkerIf more than one device is connected, the target device serial should be provided as well: 110*8975f5c5SAndroid Build Coastguard Worker``` 111*8975f5c5SAndroid Build Coastguard WorkerANDROID_SERIAL=<device_serial> out/<config>/angle_trace_tests ... 112*8975f5c5SAndroid Build Coastguard Worker``` 113*8975f5c5SAndroid Build Coastguard Worker 114*8975f5c5SAndroid Build Coastguard Worker# Capturing and adding new Android traces 115*8975f5c5SAndroid Build Coastguard Worker 116*8975f5c5SAndroid Build Coastguard WorkerGenerally we want to use a Debug setup for recording new traces. That allows us to see asserts and 117*8975f5c5SAndroid Build Coastguard Workererrors if the tracer needs to be improved. 118*8975f5c5SAndroid Build Coastguard WorkerAdd the following GN arg to your Debug setup: 119*8975f5c5SAndroid Build Coastguard Worker``` 120*8975f5c5SAndroid Build Coastguard Workerangle_with_capture_by_default = true 121*8975f5c5SAndroid Build Coastguard Worker``` 122*8975f5c5SAndroid Build Coastguard Worker 123*8975f5c5SAndroid Build Coastguard WorkerAfter [building](../../../doc/DevSetupAndroid.md#building-angle-for-android) and 124*8975f5c5SAndroid Build Coastguard Worker[installing](../../../doc/DevSetupAndroid.md#install-the-angle-apk) the APK with the above arg, 125*8975f5c5SAndroid Build Coastguard Workerwe're ready to start capturing. 126*8975f5c5SAndroid Build Coastguard Worker 127*8975f5c5SAndroid Build Coastguard Worker## Determine the target app 128*8975f5c5SAndroid Build Coastguard Worker 129*8975f5c5SAndroid Build Coastguard WorkerWe first need to identify which application we want to trace. That can generally be done by 130*8975f5c5SAndroid Build Coastguard Workerlooking at the web-based Play Store entry for your app. For instance, Angry Birds 2 is listed 131*8975f5c5SAndroid Build Coastguard Workerhere: https://play.google.com/store/apps/details?id=com.rovio.baba 132*8975f5c5SAndroid Build Coastguard Worker 133*8975f5c5SAndroid Build Coastguard WorkerIf there is no Play Store entry for your app, there are a couple of ways you can determine the 134*8975f5c5SAndroid Build Coastguard Workerapp's name. 135*8975f5c5SAndroid Build Coastguard Worker 136*8975f5c5SAndroid Build Coastguard WorkerIf you have a userdebug build of Android, you can check logcat when you launch the application. 137*8975f5c5SAndroid Build Coastguard WorkerYou should see an entry like this: 138*8975f5c5SAndroid Build Coastguard Worker``` 139*8975f5c5SAndroid Build Coastguard WorkerGraphicsEnvironment: ANGLE Developer option for 'com.rovio.baba' set to: 'default' 140*8975f5c5SAndroid Build Coastguard Worker``` 141*8975f5c5SAndroid Build Coastguard WorkerIf you just have an APK, you can use the following command to find the package name: 142*8975f5c5SAndroid Build Coastguard Worker``` 143*8975f5c5SAndroid Build Coastguard Worker$ aapt dump badging angry_birds_2.apk | grep package 144*8975f5c5SAndroid Build Coastguard Workerpackage: name='com.rovio.baba' versionCode='24900001' versionName='2.49.1' platformBuildVersionName='' 145*8975f5c5SAndroid Build Coastguard Worker``` 146*8975f5c5SAndroid Build Coastguard WorkerYou can also just guess at the package name, then check your device to see if it is installed. Keep 147*8975f5c5SAndroid Build Coastguard Workertrying combinations until you find it: 148*8975f5c5SAndroid Build Coastguard Worker``` 149*8975f5c5SAndroid Build Coastguard Worker$ adb shell pm list packages | grep rovio 150*8975f5c5SAndroid Build Coastguard Workerpackage:com.rovio.baba 151*8975f5c5SAndroid Build Coastguard Worker``` 152*8975f5c5SAndroid Build Coastguard WorkerTrack the package name for use in later steps: 153*8975f5c5SAndroid Build Coastguard Worker``` 154*8975f5c5SAndroid Build Coastguard Workerexport PACKAGE_NAME=com.rovio.baba 155*8975f5c5SAndroid Build Coastguard Worker``` 156*8975f5c5SAndroid Build Coastguard Worker 157*8975f5c5SAndroid Build Coastguard Worker## Choose a trace name 158*8975f5c5SAndroid Build Coastguard Worker 159*8975f5c5SAndroid Build Coastguard WorkerNext, we need to chose a name for the trace. Choose something simple that identifies the app, then use snake 160*8975f5c5SAndroid Build Coastguard Workercase. This will be the name of the trace files, including the trace directory. Changing this value later is possible, 161*8975f5c5SAndroid Build Coastguard Workerbut not recommended. 162*8975f5c5SAndroid Build Coastguard Worker``` 163*8975f5c5SAndroid Build Coastguard Workerexport LABEL=angry_birds_2 164*8975f5c5SAndroid Build Coastguard Worker``` 165*8975f5c5SAndroid Build Coastguard Worker 166*8975f5c5SAndroid Build Coastguard Worker## Opt the application into ANGLE 167*8975f5c5SAndroid Build Coastguard Worker 168*8975f5c5SAndroid Build Coastguard WorkerNext, opt the application into using your ANGLE with capture enabled by default: 169*8975f5c5SAndroid Build Coastguard Worker``` 170*8975f5c5SAndroid Build Coastguard Workeradb shell settings put global angle_debug_package org.chromium.angle 171*8975f5c5SAndroid Build Coastguard Workeradb shell settings put global angle_gl_driver_selection_pkgs $PACKAGE_NAME 172*8975f5c5SAndroid Build Coastguard Workeradb shell settings put global angle_gl_driver_selection_values angle 173*8975f5c5SAndroid Build Coastguard Worker``` 174*8975f5c5SAndroid Build Coastguard Worker 175*8975f5c5SAndroid Build Coastguard Worker## Set up some Capture/Replay properties 176*8975f5c5SAndroid Build Coastguard Worker 177*8975f5c5SAndroid Build Coastguard WorkerWe also need to set some debug properties used by the tracer. 178*8975f5c5SAndroid Build Coastguard Worker 179*8975f5c5SAndroid Build Coastguard WorkerEnsure frame capture is enabled. This might be redundant, but ensure the property isn't set to 180*8975f5c5SAndroid Build Coastguard Workerzero, which disables frame capture. 181*8975f5c5SAndroid Build Coastguard Worker``` 182*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.capture.enabled 1 183*8975f5c5SAndroid Build Coastguard Worker``` 184*8975f5c5SAndroid Build Coastguard WorkerEmpty the start and end frames. Again, this might be redundant, but it is less confusing. 185*8975f5c5SAndroid Build Coastguard Worker``` 186*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.capture.frame_start '""' 187*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.capture.frame_end '""' 188*8975f5c5SAndroid Build Coastguard Worker``` 189*8975f5c5SAndroid Build Coastguard WorkerSet the label to be used in the trace files 190*8975f5c5SAndroid Build Coastguard Worker``` 191*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.capture.label $LABEL 192*8975f5c5SAndroid Build Coastguard Worker``` 193*8975f5c5SAndroid Build Coastguard WorkerSet a trigger value to be used by the tracer. This should be set to the *number of frames* you want 194*8975f5c5SAndroid Build Coastguard Workerto capture. We typically use 10 to get an idea of how a scene is running, but some workloads 195*8975f5c5SAndroid Build Coastguard Workerrequire more. Use your discretion here: 196*8975f5c5SAndroid Build Coastguard Worker``` 197*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.capture.trigger 10 198*8975f5c5SAndroid Build Coastguard Worker``` 199*8975f5c5SAndroid Build Coastguard Worker 200*8975f5c5SAndroid Build Coastguard Worker## Create output location 201*8975f5c5SAndroid Build Coastguard Worker 202*8975f5c5SAndroid Build Coastguard WorkerWe need to write out the trace file in a location accessible by the app. We use the app's data 203*8975f5c5SAndroid Build Coastguard Workerstorage on sdcard, but create a subfolder to isolate ANGLE's files: 204*8975f5c5SAndroid Build Coastguard Worker``` 205*8975f5c5SAndroid Build Coastguard Workeradb shell mkdir -p /sdcard/Android/data/$PACKAGE_NAME/angle_capture 206*8975f5c5SAndroid Build Coastguard Worker``` 207*8975f5c5SAndroid Build Coastguard Worker 208*8975f5c5SAndroid Build Coastguard Worker## Start the target app 209*8975f5c5SAndroid Build Coastguard Worker 210*8975f5c5SAndroid Build Coastguard WorkerFrom here, you can start the application. You should see logcat entries like the following, 211*8975f5c5SAndroid Build Coastguard Workerindicating that we've succesfully turned on capturing: 212*8975f5c5SAndroid Build Coastguard Worker``` 213*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Capture trigger detected, disabling capture start/end frame. 214*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Limiting binary format support count to zero while FrameCapture enabled 215*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Limiting image unit count to 8 while FrameCapture enabled 216*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Setting uniform buffer offset alignment to 256 while FrameCapture enabled 217*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Disabling GL_EXT_map_buffer_range and GL_OES_mapbuffer during capture, which are not supported on some native drivers 218*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Disabling GL_CHROMIUM_bind_uniform_location during capture, which is not supported on native drivers 219*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Disabling GL_NV_shader_noperspective_interpolation during capture, which is not supported on some native drivers 220*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Limiting draw buffer count to 4 while FrameCapture enabled 221*8975f5c5SAndroid Build Coastguard Worker``` 222*8975f5c5SAndroid Build Coastguard Worker## Trigger the capture 223*8975f5c5SAndroid Build Coastguard Worker 224*8975f5c5SAndroid Build Coastguard WorkerWhen you have reached the content in your application that you want to record, set the trigger 225*8975f5c5SAndroid Build Coastguard Workervalue to zero: 226*8975f5c5SAndroid Build Coastguard Worker``` 227*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.capture.trigger 0 228*8975f5c5SAndroid Build Coastguard Worker``` 229*8975f5c5SAndroid Build Coastguard WorkerIn logcat we'll see another entry corresponding to this: 230*8975f5c5SAndroid Build Coastguard Worker``` 231*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Capture triggered after frame 30440 for 10 frames 232*8975f5c5SAndroid Build Coastguard Worker``` 233*8975f5c5SAndroid Build Coastguard WorkerThe app may pause briefly when the capture is completing. You can check its progress by looking at 234*8975f5c5SAndroid Build Coastguard Workerthe file system: 235*8975f5c5SAndroid Build Coastguard Worker``` 236*8975f5c5SAndroid Build Coastguard Workeradb shell ls -la /sdcard/Android/data/$PACKAGE_NAME/angle_capture 237*8975f5c5SAndroid Build Coastguard Worker``` 238*8975f5c5SAndroid Build Coastguard WorkerAllow the app to run until the logcat entry indicating the end of the API 239*8975f5c5SAndroid Build Coastguard Workercapture. The app should continue rendering after that: 240*8975f5c5SAndroid Build Coastguard Worker``` 241*8975f5c5SAndroid Build Coastguard WorkerANGLE : INFO: Finished recording graphics API capture 242*8975f5c5SAndroid Build Coastguard Worker``` 243*8975f5c5SAndroid Build Coastguard Worker 244*8975f5c5SAndroid Build Coastguard Worker## Pull the trace files 245*8975f5c5SAndroid Build Coastguard Worker 246*8975f5c5SAndroid Build Coastguard WorkerNext, we want to pull those files over to the host and run some scripts. 247*8975f5c5SAndroid Build Coastguard Worker``` 248*8975f5c5SAndroid Build Coastguard Workercd $CHROMIUM_SRC/third_party/angle/src/tests/restricted_traces 249*8975f5c5SAndroid Build Coastguard Workermkdir -p $LABEL 250*8975f5c5SAndroid Build Coastguard Workeradb pull /sdcard/Android/data/$PACKAGE_NAME/angle_capture/. $LABEL/ 251*8975f5c5SAndroid Build Coastguard Worker``` 252*8975f5c5SAndroid Build Coastguard Worker 253*8975f5c5SAndroid Build Coastguard Worker## Add the new trace to the JSON list 254*8975f5c5SAndroid Build Coastguard Worker 255*8975f5c5SAndroid Build Coastguard WorkerThe list of traces is tracked in [restricted_traces.json](restricted_traces.json). Manually add your 256*8975f5c5SAndroid Build Coastguard Workernew trace to this list. Use version "1" for the trace version. 257*8975f5c5SAndroid Build Coastguard Worker 258*8975f5c5SAndroid Build Coastguard WorkerOn Linux, you can also use a tool called `jq` to update the list. This ensures we get them in 259*8975f5c5SAndroid Build Coastguard Workeralphabetical order with no duplicates. It can also be done by hand if you are unable to install it, 260*8975f5c5SAndroid Build Coastguard Workerfor some reason. 261*8975f5c5SAndroid Build Coastguard Worker``` 262*8975f5c5SAndroid Build Coastguard Workersudo apt-get install jq 263*8975f5c5SAndroid Build Coastguard Worker``` 264*8975f5c5SAndroid Build Coastguard WorkerThen run the following command: 265*8975f5c5SAndroid Build Coastguard Worker``` 266*8975f5c5SAndroid Build Coastguard Workerexport VERSION=1 267*8975f5c5SAndroid Build Coastguard Workerjq ".traces = (.traces + [\"$LABEL $VERSION\"] | unique)" restricted_traces.json | sponge restricted_traces.json 268*8975f5c5SAndroid Build Coastguard Worker``` 269*8975f5c5SAndroid Build Coastguard Worker 270*8975f5c5SAndroid Build Coastguard Worker## Run code auto-generation 271*8975f5c5SAndroid Build Coastguard Worker 272*8975f5c5SAndroid Build Coastguard WorkerThe [`gen_restricted_traces`](gen_restricted_traces.py) script auto-generates entries 273*8975f5c5SAndroid Build Coastguard Workerin our checkout dependencies to sync restricted trace data on checkout. To trigger 274*8975f5c5SAndroid Build Coastguard Workercode generation run the following from the angle root folder: 275*8975f5c5SAndroid Build Coastguard Worker``` 276*8975f5c5SAndroid Build Coastguard Workerpython ./scripts/run_code_generation.py 277*8975f5c5SAndroid Build Coastguard Worker``` 278*8975f5c5SAndroid Build Coastguard WorkerAfter this you should be able to `git diff` and see changes in the following files: 279*8975f5c5SAndroid Build Coastguard Worker 280*8975f5c5SAndroid Build Coastguard Worker * `DEPS` 281*8975f5c5SAndroid Build Coastguard Worker * `scripts/code_generation_hashes/restricted_traces.json` 282*8975f5c5SAndroid Build Coastguard Worker * `src/tests/restricted_traces/restricted_traces.json` (this is the file you originally modified) 283*8975f5c5SAndroid Build Coastguard Worker 284*8975f5c5SAndroid Build Coastguard WorkerNote the absence of the traces themselves listed above. They are automatically 285*8975f5c5SAndroid Build Coastguard Workerignored by [`.gitignore`](.gitignore) since they won't be checked in directly 286*8975f5c5SAndroid Build Coastguard Workerto the repo. 287*8975f5c5SAndroid Build Coastguard Worker 288*8975f5c5SAndroid Build Coastguard Worker## Upload your trace to CIPD 289*8975f5c5SAndroid Build Coastguard Worker 290*8975f5c5SAndroid Build Coastguard WorkerOnce you feel good about your trace, you can upload it to our collection of traces. This can only 291*8975f5c5SAndroid Build Coastguard Workerbe done by Googlers with write access to the trace CIPD prefix. If you need write access contact 292*8975f5c5SAndroid Build Coastguard Workersomeone listed in the `OWNERS` file. 293*8975f5c5SAndroid Build Coastguard Worker 294*8975f5c5SAndroid Build Coastguard WorkerPlease kindly go over the trace content with ANGLE code owners before running 295*8975f5c5SAndroid Build Coastguard Workerbelow commands. You can share your trace through Google Drive for content 296*8975f5c5SAndroid Build Coastguard Workeriterations. We cannot delete trace files once they are up on the CIPD. 297*8975f5c5SAndroid Build Coastguard WorkerDoing additional rounds of content check can help us save CIPD resources. 298*8975f5c5SAndroid Build Coastguard Worker 299*8975f5c5SAndroid Build Coastguard Worker``` 300*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/sync_restricted_traces_to_cipd.py 301*8975f5c5SAndroid Build Coastguard Worker``` 302*8975f5c5SAndroid Build Coastguard Worker 303*8975f5c5SAndroid Build Coastguard Worker## Upload your CL 304*8975f5c5SAndroid Build Coastguard Worker 305*8975f5c5SAndroid Build Coastguard WorkerEnsure your current working directory is up-to-date, and upload: 306*8975f5c5SAndroid Build Coastguard Worker 307*8975f5c5SAndroid Build Coastguard Worker``` 308*8975f5c5SAndroid Build Coastguard Workergit cl upload 309*8975f5c5SAndroid Build Coastguard Worker``` 310*8975f5c5SAndroid Build Coastguard Worker 311*8975f5c5SAndroid Build Coastguard WorkerYou're now ready to run your new trace on CI! 312*8975f5c5SAndroid Build Coastguard Worker 313*8975f5c5SAndroid Build Coastguard Worker# Comparing screenshots against the native driver 314*8975f5c5SAndroid Build Coastguard Worker 315*8975f5c5SAndroid Build Coastguard WorkerTo compare trace screenshots from ANGLE vs the native driver, you can 316*8975f5c5SAndroid Build Coastguard Workeruse the `compare_trace_screenshots.py` script. 317*8975f5c5SAndroid Build Coastguard Worker 318*8975f5c5SAndroid Build Coastguard WorkerThe following steps will work on Android, but are transferrable to 319*8975f5c5SAndroid Build Coastguard Workerany operating system. 320*8975f5c5SAndroid Build Coastguard Worker 321*8975f5c5SAndroid Build Coastguard WorkerFirst, make a spot for the results: 322*8975f5c5SAndroid Build Coastguard Worker``` 323*8975f5c5SAndroid Build Coastguard Workeradb shell rm -r /sdcard/angle/screenshots 324*8975f5c5SAndroid Build Coastguard Workeradb shell mkdir -p /sdcard/angle/screenshots 325*8975f5c5SAndroid Build Coastguard Worker``` 326*8975f5c5SAndroid Build Coastguard Worker 327*8975f5c5SAndroid Build Coastguard WorkerThen run the traces using ANGLE: 328*8975f5c5SAndroid Build Coastguard Worker``` 329*8975f5c5SAndroid Build Coastguard Workerout/AndroidPerformance/angle_trace_tests --verbose --run-to-key-frame --screenshot-dir /sdcard/angle/screenshots --shard-timeout 1000000 330*8975f5c5SAndroid Build Coastguard Worker``` 331*8975f5c5SAndroid Build Coastguard Worker 332*8975f5c5SAndroid Build Coastguard WorkerAnd again with the native driver: 333*8975f5c5SAndroid Build Coastguard Worker``` 334*8975f5c5SAndroid Build Coastguard Workerout/AndroidPerformance/angle_trace_tests --verbose --run-to-key-frame --screenshot-dir /sdcard/angle/screenshots --shard-timeout 1000000 --use-gl=native 335*8975f5c5SAndroid Build Coastguard Worker``` 336*8975f5c5SAndroid Build Coastguard Worker 337*8975f5c5SAndroid Build Coastguard WorkerIt may take a few tries as some drivers will crash. In that case, run the ones at the end that were stragglers, i.e.: 338*8975f5c5SAndroid Build Coastguard Worker``` 339*8975f5c5SAndroid Build Coastguard Workerout/AndroidPerformance/angle_trace_tests --verbose --run-to-key-frame --screenshot-dir /sdcard/angle/screenshots --shard-timeout 1000000 --use-gl=native --gtest_filter="*words*:*world*:*worms*:*zenonia*:*zillow*:*zombie*" 340*8975f5c5SAndroid Build Coastguard Worker``` 341*8975f5c5SAndroid Build Coastguard Worker 342*8975f5c5SAndroid Build Coastguard WorkerPull the screenshots: 343*8975f5c5SAndroid Build Coastguard Worker``` 344*8975f5c5SAndroid Build Coastguard Workeradb pull /sdcard/angle/screenshots 345*8975f5c5SAndroid Build Coastguard Workercd screenshots 346*8975f5c5SAndroid Build Coastguard Worker``` 347*8975f5c5SAndroid Build Coastguard Worker 348*8975f5c5SAndroid Build Coastguard WorkerAnd run the compare script: 349*8975f5c5SAndroid Build Coastguard Worker``` 350*8975f5c5SAndroid Build Coastguard Workerpython3 ../src/tests/restricted_traces/compare_trace_screenshots.py versus_native --trace-list-path ../src/tests/restricted_traces/ 351*8975f5c5SAndroid Build Coastguard Worker``` 352*8975f5c5SAndroid Build Coastguard Worker 353*8975f5c5SAndroid Build Coastguard WorkerThe script will print out results comparing ANGLE vs. native screenshots at different fuzz factors. 354*8975f5c5SAndroid Build Coastguard WorkerIt may also print out NA for missing screenshots: 355*8975f5c5SAndroid Build Coastguard Worker``` 356*8975f5c5SAndroid Build Coastguard Worker... 357*8975f5c5SAndroid Build Coastguard Workerarknights angle_vulkan_arknights.png MISSING_EXT.png NA NA NA NA NA NA 358*8975f5c5SAndroid Build Coastguard Workerasphalt_8 angle_vulkan_asphalt_8.png angle_native_asphalt_8.png 641849 222157 116426 1701 82 22 359*8975f5c5SAndroid Build Coastguard Workerasphalt_9 angle_vulkan_asphalt_9.png angle_native_asphalt_9.png 17919 420 305 293 232 3 360*8975f5c5SAndroid Build Coastguard Worker... 361*8975f5c5SAndroid Build Coastguard Worker``` 362*8975f5c5SAndroid Build Coastguard Worker# Upgrading existing traces 363*8975f5c5SAndroid Build Coastguard Worker 364*8975f5c5SAndroid Build Coastguard WorkerWith tracer updates sometimes we want to re-run tracing to upgrade the trace file format or to 365*8975f5c5SAndroid Build Coastguard Workertake advantage of new tracer improvements. The [`retrace_restricted_traces`](retrace_restricted_traces.py) 366*8975f5c5SAndroid Build Coastguard Workerscript allows us to re-run tracing using [SwiftShader](https://swiftshader.googlesource.com/SwiftShader) 367*8975f5c5SAndroid Build Coastguard Workeron a desktop machine. As of writing we require re-tracing on a Windows machine because of size 368*8975f5c5SAndroid Build Coastguard Workerlimitations with a Linux app window. 369*8975f5c5SAndroid Build Coastguard Worker 370*8975f5c5SAndroid Build Coastguard Worker## Part 1: Retrace it 371*8975f5c5SAndroid Build Coastguard Worker 372*8975f5c5SAndroid Build Coastguard WorkerUpgrade your trace into a new directory called `retrace-wip` 373*8975f5c5SAndroid Build Coastguard Worker 374*8975f5c5SAndroid Build Coastguard WorkerIn this instance, we'll upgrade `octopath_traveler` 375*8975f5c5SAndroid Build Coastguard Worker``` 376*8975f5c5SAndroid Build Coastguard Workerexport TRACE_GN_PATH=out/Debug 377*8975f5c5SAndroid Build Coastguard Workerexport TRACE_NAME=octopath_traveler 378*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py upgrade $TRACE_GN_PATH retrace-wip -f $TRACE_NAME 379*8975f5c5SAndroid Build Coastguard Worker``` 380*8975f5c5SAndroid Build Coastguard Worker 381*8975f5c5SAndroid Build Coastguard Worker## Part 2: Verify it 382*8975f5c5SAndroid Build Coastguard Worker 383*8975f5c5SAndroid Build Coastguard WorkerBefore we check in an upgraded trace, we want to put it through enough paces to 384*8975f5c5SAndroid Build Coastguard Workerensure behaves the same or better. 385*8975f5c5SAndroid Build Coastguard Worker 386*8975f5c5SAndroid Build Coastguard Worker### Screenshots 387*8975f5c5SAndroid Build Coastguard Worker 388*8975f5c5SAndroid Build Coastguard WorkerFor screenshots, we want to verify all frames render correctly before and after Reset. 389*8975f5c5SAndroid Build Coastguard Worker 390*8975f5c5SAndroid Build Coastguard WorkerSo make two spots to gather the screenshots, and one to gather results: 391*8975f5c5SAndroid Build Coastguard Worker``` 392*8975f5c5SAndroid Build Coastguard Workermkdir retrace-wip/${TRACE_NAME}_before 393*8975f5c5SAndroid Build Coastguard Workermkdir retrace-wip/${TRACE_NAME}_after 394*8975f5c5SAndroid Build Coastguard Workermkdir retrace-wip/${TRACE_NAME}_compare 395*8975f5c5SAndroid Build Coastguard Worker``` 396*8975f5c5SAndroid Build Coastguard Worker 397*8975f5c5SAndroid Build Coastguard WorkerWe need two loops to verify Reset, so you'll need to inspect how many frames 398*8975f5c5SAndroid Build Coastguard Workerare in the trace. In this case, `octopath_traveler` has 500 frames, so we need 399*8975f5c5SAndroid Build Coastguard Worker1000 screenshots. We use -1 as the screenshot frame so we get all images: 400*8975f5c5SAndroid Build Coastguard Worker``` 401*8975f5c5SAndroid Build Coastguard Workerout/Debug/angle_trace_tests --gtest_filter=TraceTest.${TRACE_NAME} --use-angle=swiftshader --max-steps-performed 1000 --screenshot-dir retrace-wip/${TRACE_NAME}_before --screenshot-frame -1 402*8975f5c5SAndroid Build Coastguard Worker``` 403*8975f5c5SAndroid Build Coastguard Worker 404*8975f5c5SAndroid Build Coastguard WorkerThen move the new trace in and run it again: 405*8975f5c5SAndroid Build Coastguard Worker``` 406*8975f5c5SAndroid Build Coastguard Workermv src/tests/restricted_traces/${TRACE_NAME} retrace-wip/${TRACE_NAME}_orig 407*8975f5c5SAndroid Build Coastguard Workercp -r retrace-wip/${TRACE_NAME} src/tests/restricted_traces 408*8975f5c5SAndroid Build Coastguard Workerautoninja -C out/Debug angle_trace_tests 409*8975f5c5SAndroid Build Coastguard Workerout/Debug/angle_trace_tests --gtest_filter=TraceTest.${TRACE_NAME} --use-angle=swiftshader --max-steps-performed 1000 --screenshot-dir retrace-wip/${TRACE_NAME}_after --screenshot-frame -1 410*8975f5c5SAndroid Build Coastguard Worker``` 411*8975f5c5SAndroid Build Coastguard Worker 412*8975f5c5SAndroid Build Coastguard WorkerAfter that, we have a script that will compare the before and after screenshots, 413*8975f5c5SAndroid Build Coastguard Workersaving the results: 414*8975f5c5SAndroid Build Coastguard Worker``` 415*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/compare_trace_screenshots.py versus_upgrade --before retrace-wip/${TRACE_NAME}_before --after retrace-wip/${TRACE_NAME}_after --outdir retrace-wip/${TRACE_NAME}_compare 416*8975f5c5SAndroid Build Coastguard Worker``` 417*8975f5c5SAndroid Build Coastguard Worker 418*8975f5c5SAndroid Build Coastguard WorkerIf you have any diffs, they will pop out like this, and you need to investigate: 419*8975f5c5SAndroid Build Coastguard Worker``` 420*8975f5c5SAndroid Build Coastguard Workerangle_vulkan_swiftshader_octopath_traveler_frame1.png 0 421*8975f5c5SAndroid Build Coastguard Workerangle_vulkan_swiftshader_octopath_traveler_frame10.png 0 422*8975f5c5SAndroid Build Coastguard Workerangle_vulkan_swiftshader_octopath_traveler_frame100.png 1.12185e+06 423*8975f5c5SAndroid Build Coastguard WorkerPixel diff detected! 424*8975f5c5SAndroid Build Coastguard Worker``` 425*8975f5c5SAndroid Build Coastguard Worker 426*8975f5c5SAndroid Build Coastguard Worker### Performance 427*8975f5c5SAndroid Build Coastguard Worker 428*8975f5c5SAndroid Build Coastguard WorkerWe need to ensure we're getting the same frame times and memory usage. 429*8975f5c5SAndroid Build Coastguard Worker 430*8975f5c5SAndroid Build Coastguard WorkerThe easiest way to do that is on Android, which can show us GPU and CPU memory. 431*8975f5c5SAndroid Build Coastguard Worker 432*8975f5c5SAndroid Build Coastguard WorkerFirst, restore the original trace, then build and install the most optimized build: 433*8975f5c5SAndroid Build Coastguard Worker``` 434*8975f5c5SAndroid Build Coastguard Workerrm -r src/tests/restricted_traces/${TRACE_NAME} 435*8975f5c5SAndroid Build Coastguard Workercp -r retrace-wip/${TRACE_NAME}_orig src/tests/restricted_traces/${TRACE_NAME} 436*8975f5c5SAndroid Build Coastguard Workerautoninja -C out/AndroidPerformance angle_trace_tests 437*8975f5c5SAndroid Build Coastguard Workerout/AndroidPerformance/angle_trace_tests --gtest_filter=TraceTest.${TRACE_NAME} --run-to-key-frame --no-warmup 438*8975f5c5SAndroid Build Coastguard Worker``` 439*8975f5c5SAndroid Build Coastguard Worker 440*8975f5c5SAndroid Build Coastguard WorkerThen run the `restricted_trace_perf.py` script to gather frame times and memory: 441*8975f5c5SAndroid Build Coastguard Worker``` 442*8975f5c5SAndroid Build Coastguard Workerout/AndroidPerformance/restricted_trace_perf --fixedtime 10 --sleep 10 --power --output-tag ${TRACE_NAME}.before --loop-count 5 --renderer vulkan --filter ${TRACE_NAME} 443*8975f5c5SAndroid Build Coastguard Worker``` 444*8975f5c5SAndroid Build Coastguard Worker 445*8975f5c5SAndroid Build Coastguard WorkerYou should get output like this: 446*8975f5c5SAndroid Build Coastguard Worker``` 447*8975f5c5SAndroid Build Coastguard Workertrace wall_time gpu_time cpu_time gpu_power cpu_power gpu_mem_sustained gpu_mem_peak proc_mem_median proc_mem_peak 448*8975f5c5SAndroid Build Coastguard Worker 449*8975f5c5SAndroid Build Coastguard WorkerStarting run 1 with vulkan at 2023-08-17 16:26:29 450*8975f5c5SAndroid Build Coastguard Worker 451*8975f5c5SAndroid Build Coastguard Workervulkan_octopath_traveler 2.9650 0 3.8901000000 5183 5659 186837550 206241792 586976000 591528000 452*8975f5c5SAndroid Build Coastguard Worker 453*8975f5c5SAndroid Build Coastguard WorkerStarting run 2 with vulkan at 2023-08-17 16:26:54 454*8975f5c5SAndroid Build Coastguard Worker 455*8975f5c5SAndroid Build Coastguard Workervulkan_octopath_traveler 3.0038 0 3.9452525714 5295 5128 186467084 205910016 584568000 589196000 456*8975f5c5SAndroid Build Coastguard Worker 457*8975f5c5SAndroid Build Coastguard WorkerStarting run 3 with vulkan at 2023-08-17 16:27:18 458*8975f5c5SAndroid Build Coastguard Worker 459*8975f5c5SAndroid Build Coastguard Workervulkan_octopath_traveler 3.0061 0 3.9361028571 5203 5182 187197952 205262848 586596000 590324000 460*8975f5c5SAndroid Build Coastguard Worker 461*8975f5c5SAndroid Build Coastguard WorkerStarting run 4 with vulkan at 2023-08-17 16:27:42 462*8975f5c5SAndroid Build Coastguard Worker 463*8975f5c5SAndroid Build Coastguard Workervulkan_octopath_traveler 2.9901 0 3.9330551429 5461 5165 194881803 197480448 585268000 588384000 464*8975f5c5SAndroid Build Coastguard Worker 465*8975f5c5SAndroid Build Coastguard WorkerStarting run 5 with vulkan at 2023-08-17 16:28:05 466*8975f5c5SAndroid Build Coastguard Worker 467*8975f5c5SAndroid Build Coastguard Workervulkan_octopath_traveler 3.0749 0 3.9652568571 5197 5096 193443742 203177984 583636000 586380000 468*8975f5c5SAndroid Build Coastguard Worker``` 469*8975f5c5SAndroid Build Coastguard Worker 470*8975f5c5SAndroid Build Coastguard WorkerBring in the upgraded trace, build and install the trace again: 471*8975f5c5SAndroid Build Coastguard Worker``` 472*8975f5c5SAndroid Build Coastguard Workerrm -rf src/tests/restricted_traces/${TRACE_NAME} 473*8975f5c5SAndroid Build Coastguard Workercp -r retrace-wip/${TRACE_NAME} src/tests/restricted_traces/${TRACE_NAME} 474*8975f5c5SAndroid Build Coastguard Workerautoninja -C out/AndroidPerformance angle_trace_tests 475*8975f5c5SAndroid Build Coastguard Workerout/AndroidPerformance/angle_trace_tests --gtest_filter=TraceTest.${TRACE_NAME} --run-to-key-frame --no-warmup 476*8975f5c5SAndroid Build Coastguard Worker``` 477*8975f5c5SAndroid Build Coastguard Worker 478*8975f5c5SAndroid Build Coastguard WorkerAnd collect performance data: 479*8975f5c5SAndroid Build Coastguard Worker``` 480*8975f5c5SAndroid Build Coastguard Workerout/AndroidPerformance/restricted_trace_perf --fixedtime 10 --sleep 10 --power --output-tag ${TRACE_NAME}.after --loop-count 5 --renderer vulkan --filter ${TRACE_NAME} 481*8975f5c5SAndroid Build Coastguard Worker``` 482*8975f5c5SAndroid Build Coastguard Worker 483*8975f5c5SAndroid Build Coastguard WorkerVerify using a spreadsheet that the values are relatively the same. 484*8975f5c5SAndroid Build Coastguard WorkerIf you notice a marked difference, spend some time understanding it. 485*8975f5c5SAndroid Build Coastguard WorkerFor instance, you may see memory decrease due to fixed in the upgrade. 486*8975f5c5SAndroid Build Coastguard Worker 487*8975f5c5SAndroid Build Coastguard Worker## Part 3: Test the upgraded traces under an experimental prefix 488*8975f5c5SAndroid Build Coastguard Worker 489*8975f5c5SAndroid Build Coastguard WorkerTo test the trace on all platforms, we first upload them to a temporary CIPD 490*8975f5c5SAndroid Build Coastguard Workerpath for testing. After a successful run on the CQ, we will then upload them 491*8975f5c5SAndroid Build Coastguard Workerto the main ANGLE prefix. 492*8975f5c5SAndroid Build Coastguard Worker 493*8975f5c5SAndroid Build Coastguard WorkerTo enable the experimental prefix, edit 494*8975f5c5SAndroid Build Coastguard Worker[`restricted_traces.json`](restricted_traces.json) to use a version 495*8975f5c5SAndroid Build Coastguard Workernumber beginning with 'x'. For example: 496*8975f5c5SAndroid Build Coastguard Worker 497*8975f5c5SAndroid Build Coastguard Worker``` 498*8975f5c5SAndroid Build Coastguard Worker "traces": [ 499*8975f5c5SAndroid Build Coastguard Worker ... 500*8975f5c5SAndroid Build Coastguard Worker "octopath_traveler x1", 501*8975f5c5SAndroid Build Coastguard Worker ... 502*8975f5c5SAndroid Build Coastguard Worker``` 503*8975f5c5SAndroid Build Coastguard Worker 504*8975f5c5SAndroid Build Coastguard WorkerThen run: 505*8975f5c5SAndroid Build Coastguard Worker 506*8975f5c5SAndroid Build Coastguard Worker``` 507*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/sync_restricted_traces_to_cipd.py --filter ${TRACE_NAME} 508*8975f5c5SAndroid Build Coastguard Workerscripts/run_code_generation.py 509*8975f5c5SAndroid Build Coastguard Worker``` 510*8975f5c5SAndroid Build Coastguard Worker 511*8975f5c5SAndroid Build Coastguard WorkerAfter these commands complete succesfully, create and upload a CL as normal. 512*8975f5c5SAndroid Build Coastguard Worker 513*8975f5c5SAndroid Build Coastguard WorkerBefore running tests, you need to grant the bots access to your experimental 514*8975f5c5SAndroid Build Coastguard WorkerCIPD files (substituting your account name): 515*8975f5c5SAndroid Build Coastguard Worker``` 516*8975f5c5SAndroid Build Coastguard Workercipd acl-edit experimental/google.com/$USERNAME -reader user:[email protected] 517*8975f5c5SAndroid Build Coastguard Workercipd acl-edit experimental/google.com/$USERNAME -reader user:chromium-try-gpu-builder@chops-service-accounts.iam.gserviceaccount.com 518*8975f5c5SAndroid Build Coastguard Worker``` 519*8975f5c5SAndroid Build Coastguard Worker 520*8975f5c5SAndroid Build Coastguard WorkerYou can verify it worked by running this command and seeing the bot added to readers: 521*8975f5c5SAndroid Build Coastguard Worker``` 522*8975f5c5SAndroid Build Coastguard Workercipd acl-list experimental/google.com/$USERNAME/angle/traces 523*8975f5c5SAndroid Build Coastguard Worker... 524*8975f5c5SAndroid Build Coastguard WorkerReaders: 525*8975f5c5SAndroid Build Coastguard Worker via "experimental/google.com/$USERNAME": 526*8975f5c5SAndroid Build Coastguard Worker user:[email protected] 527*8975f5c5SAndroid Build Coastguard Worker user:chromium-try-gpu-builder@chops-service-accounts.iam.gserviceaccount.com 528*8975f5c5SAndroid Build Coastguard Worker``` 529*8975f5c5SAndroid Build Coastguard Worker 530*8975f5c5SAndroid Build Coastguard WorkerRun CQ +1 Dry-Run. If you find a test regression, see the section below on 531*8975f5c5SAndroid Build Coastguard Workerdiagnosing tracer errors. Otherwise proceed with the steps below. 532*8975f5c5SAndroid Build Coastguard Worker 533*8975f5c5SAndroid Build Coastguard Worker## Part 5: Upload the verified traces to CIPD under the stable prefix 534*8975f5c5SAndroid Build Coastguard Worker 535*8975f5c5SAndroid Build Coastguard WorkerNow that you've validated the traces on the CQ, update 536*8975f5c5SAndroid Build Coastguard Worker[`restricted_traces.json`](restricted_traces.json) to remove the 'x' prefix 537*8975f5c5SAndroid Build Coastguard Workerand incrementing the version of the traces (skipping versions if you prefer) 538*8975f5c5SAndroid Build Coastguard Workerand then run: 539*8975f5c5SAndroid Build Coastguard Worker 540*8975f5c5SAndroid Build Coastguard Worker``` 541*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/sync_restricted_traces_to_cipd.py --filter ${TRACE_NAME} 542*8975f5c5SAndroid Build Coastguard Workerscripts/run_code_generation.py 543*8975f5c5SAndroid Build Coastguard Worker``` 544*8975f5c5SAndroid Build Coastguard Worker 545*8975f5c5SAndroid Build Coastguard WorkerThen create and upload a CL as normal. Congratulations, you've finished the 546*8975f5c5SAndroid Build Coastguard Workertrace upgrade! 547*8975f5c5SAndroid Build Coastguard Worker 548*8975f5c5SAndroid Build Coastguard Worker## Finding a trace's minimum requirements 549*8975f5c5SAndroid Build Coastguard Worker 550*8975f5c5SAndroid Build Coastguard Worker`retrace_restricted_traces.py` can be used to determine a trace's minimum 551*8975f5c5SAndroid Build Coastguard Workerextensions and GLES version. Run the command: 552*8975f5c5SAndroid Build Coastguard Worker 553*8975f5c5SAndroid Build Coastguard Worker``` 554*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py get_min_reqs $TRACE_GN_PATH [--traces "*"] 555*8975f5c5SAndroid Build Coastguard Worker``` 556*8975f5c5SAndroid Build Coastguard Worker 557*8975f5c5SAndroid Build Coastguard WorkerThe script will run each listed trace multiple times so it can find the minimum 558*8975f5c5SAndroid Build Coastguard Workerrequired GLES version and each required extension. Finally it records that 559*8975f5c5SAndroid Build Coastguard Workerinformation to the trace's json file. 560*8975f5c5SAndroid Build Coastguard Worker 561*8975f5c5SAndroid Build Coastguard WorkerBy default it will run with SwiftShader. To make the script use your machine's 562*8975f5c5SAndroid Build Coastguard Workernative vulkan drivers, use the `--no-swiftshader` argument before the script's 563*8975f5c5SAndroid Build Coastguard Workercommand: 564*8975f5c5SAndroid Build Coastguard Worker 565*8975f5c5SAndroid Build Coastguard Worker``` 566*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py --no-swiftshader get_min_reqs $TRACE_GN_PATH [--traces "*"] 567*8975f5c5SAndroid Build Coastguard Worker``` 568*8975f5c5SAndroid Build Coastguard Worker 569*8975f5c5SAndroid Build Coastguard WorkerIf retracing an existing trace, any associated `addExtensionPrerequisite()` calls must be removed from `TracePerfTest.cpp` and 570*8975f5c5SAndroid Build Coastguard Workerthe tracename.json file must be made writable. 571*8975f5c5SAndroid Build Coastguard Worker 572*8975f5c5SAndroid Build Coastguard WorkerTraces are run with all extensions enabled by default. It may be useful to test with only a subset of extensions. 573*8975f5c5SAndroid Build Coastguard WorkerThis can be done by adding the `--request-extensions` argument to `angle_trace_tests`. Multiple extensions must be contained by quotation 574*8975f5c5SAndroid Build Coastguard Workermarks and only a single space can be used as a separator. To run with no extensions enabled, specify a null list -- `""`: 575*8975f5c5SAndroid Build Coastguard Worker 576*8975f5c5SAndroid Build Coastguard Worker``` 577*8975f5c5SAndroid Build Coastguard Worker./out/Debug/angle_trace_tests --gtest_filter=*tracename --request-extensions "EXT_color_buffer_float GL_EXT_texture_filter_anisotropic" 578*8975f5c5SAndroid Build Coastguard Worker``` 579*8975f5c5SAndroid Build Coastguard Worker or 580*8975f5c5SAndroid Build Coastguard Worker``` 581*8975f5c5SAndroid Build Coastguard Worker./out/Debug/angle_trace_tests --gtest_filter=*tracename --request-extensions "" 582*8975f5c5SAndroid Build Coastguard Worker``` 583*8975f5c5SAndroid Build Coastguard Worker 584*8975f5c5SAndroid Build Coastguard Worker## Extended testing and full trace upgrades 585*8975f5c5SAndroid Build Coastguard Worker 586*8975f5c5SAndroid Build Coastguard WorkerIf you want to really drill down on trace differences, you might want to use the 587*8975f5c5SAndroid Build Coastguard Workerbuilt in validation support, which serailizes the internal state of ANGLE. 588*8975f5c5SAndroid Build Coastguard Worker 589*8975f5c5SAndroid Build Coastguard Worker## Prep work: Back up existing traces 590*8975f5c5SAndroid Build Coastguard Worker 591*8975f5c5SAndroid Build Coastguard WorkerThis will save the original traces in a temporary folder if you need to revert to the prior trace format: 592*8975f5c5SAndroid Build Coastguard Worker 593*8975f5c5SAndroid Build Coastguard Worker``` 594*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py backup "*" 595*8975f5c5SAndroid Build Coastguard Worker``` 596*8975f5c5SAndroid Build Coastguard Worker 597*8975f5c5SAndroid Build Coastguard Worker*Note: on Linux, remove the command `py` prefix to the Python scripts.* 598*8975f5c5SAndroid Build Coastguard Worker 599*8975f5c5SAndroid Build Coastguard WorkerThis will save the traces to `./retrace-backups`. At any time you can revert the trace files by running: 600*8975f5c5SAndroid Build Coastguard Worker 601*8975f5c5SAndroid Build Coastguard Worker``` 602*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py restore "*" 603*8975f5c5SAndroid Build Coastguard Worker``` 604*8975f5c5SAndroid Build Coastguard Worker 605*8975f5c5SAndroid Build Coastguard Worker## Part 1: Upgrading Sanity Check with T-Rex 606*8975f5c5SAndroid Build Coastguard Worker 607*8975f5c5SAndroid Build Coastguard WorkerFirst we'll retrace a single app to verify the workflow is intact. Please 608*8975f5c5SAndroid Build Coastguard Workerensure you replace the specified variables with paths that work on your 609*8975f5c5SAndroid Build Coastguard Workerconfiguration and checkout: 610*8975f5c5SAndroid Build Coastguard Worker 611*8975f5c5SAndroid Build Coastguard Worker### Step 1/3: Capture T-Rex with Validation 612*8975f5c5SAndroid Build Coastguard Worker 613*8975f5c5SAndroid Build Coastguard Worker``` 614*8975f5c5SAndroid Build Coastguard Workerexport TRACE_GN_PATH=out/Debug 615*8975f5c5SAndroid Build Coastguard Workerexport TRACE_NAME=trex_200 616*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py upgrade $TRACE_GN_PATH retrace-wip -f $TRACE_NAME --validation --limit 3 617*8975f5c5SAndroid Build Coastguard Worker``` 618*8975f5c5SAndroid Build Coastguard Worker 619*8975f5c5SAndroid Build Coastguard WorkerThe `--validation` flag will turn on additional validation checks in the 620*8975f5c5SAndroid Build Coastguard Workertrace. The `--limit 3` flag forces a maximum of 3 frames of tracing so the 621*8975f5c5SAndroid Build Coastguard Workertest will run more quickly. The trace will end up in the `retrace-wip` 622*8975f5c5SAndroid Build Coastguard Workerfolder. 623*8975f5c5SAndroid Build Coastguard Worker 624*8975f5c5SAndroid Build Coastguard Worker### Step 2/3: Validate T-Rex 625*8975f5c5SAndroid Build Coastguard Worker 626*8975f5c5SAndroid Build Coastguard WorkerThe command below will update your copy of the trace, rebuild, the run the 627*8975f5c5SAndroid Build Coastguard Workertest suite with validation enabled: 628*8975f5c5SAndroid Build Coastguard Worker 629*8975f5c5SAndroid Build Coastguard Worker``` 630*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py validate $TRACE_GN_PATH retrace-wip $TRACE_NAME 631*8975f5c5SAndroid Build Coastguard Worker``` 632*8975f5c5SAndroid Build Coastguard Worker 633*8975f5c5SAndroid Build Coastguard WorkerIf the trace failed validation, see the section below on diagnosing tracer 634*8975f5c5SAndroid Build Coastguard Workererrors. Otherwise proceed with the steps below. 635*8975f5c5SAndroid Build Coastguard Worker 636*8975f5c5SAndroid Build Coastguard Worker### Step 3/3: Restore the Canonical T-Rex Trace 637*8975f5c5SAndroid Build Coastguard Worker 638*8975f5c5SAndroid Build Coastguard Worker``` 639*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py restore $TRACE_NAME 640*8975f5c5SAndroid Build Coastguard Worker``` 641*8975f5c5SAndroid Build Coastguard Worker 642*8975f5c5SAndroid Build Coastguard Worker## Part 2: Do a limited trace upgrade with validation enabled 643*8975f5c5SAndroid Build Coastguard Worker 644*8975f5c5SAndroid Build Coastguard Worker### Step 1/3: Upgrade all traces with a limit of 3 frames 645*8975f5c5SAndroid Build Coastguard Worker 646*8975f5c5SAndroid Build Coastguard Worker``` 647*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py upgrade $TRACE_GN_PATH retrace-wip --validation --limit 3 --no-overwrite 648*8975f5c5SAndroid Build Coastguard Worker``` 649*8975f5c5SAndroid Build Coastguard Worker 650*8975f5c5SAndroid Build Coastguard WorkerIf this process gets interrupted, re-run the upgrade command. The 651*8975f5c5SAndroid Build Coastguard Worker`--no-overwrite` argument will ensure it will complete eventually. 652*8975f5c5SAndroid Build Coastguard Worker 653*8975f5c5SAndroid Build Coastguard WorkerIf any traces failed to upgrade, see the section below on diagnosing tracer 654*8975f5c5SAndroid Build Coastguard Workererrors. Otherwise proceed with the steps below. 655*8975f5c5SAndroid Build Coastguard Worker 656*8975f5c5SAndroid Build Coastguard Worker### Step 2/3: Validate all upgraded traces 657*8975f5c5SAndroid Build Coastguard Worker 658*8975f5c5SAndroid Build Coastguard Worker``` 659*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py validate $TRACE_GN_PATH retrace-wip "*" 660*8975f5c5SAndroid Build Coastguard Worker``` 661*8975f5c5SAndroid Build Coastguard Worker 662*8975f5c5SAndroid Build Coastguard WorkerIf any traces failed validation, see the section below on diagnosing tracer 663*8975f5c5SAndroid Build Coastguard Workererrors. 664*8975f5c5SAndroid Build Coastguard Worker 665*8975f5c5SAndroid Build Coastguard Worker### Step 3/3: Restore all traces 666*8975f5c5SAndroid Build Coastguard Worker 667*8975f5c5SAndroid Build Coastguard Worker``` 668*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py restore "*" 669*8975f5c5SAndroid Build Coastguard Worker``` 670*8975f5c5SAndroid Build Coastguard Worker 671*8975f5c5SAndroid Build Coastguard Worker## Part 3: Do the full trace upgrade 672*8975f5c5SAndroid Build Coastguard Worker 673*8975f5c5SAndroid Build Coastguard Worker``` 674*8975f5c5SAndroid Build Coastguard Workerrm -rf retrace-wip 675*8975f5c5SAndroid Build Coastguard Workersrc/tests/restricted_traces/retrace_restricted_traces.py upgrade $TRACE_GN_PATH retrace-wip --no-overwrite 676*8975f5c5SAndroid Build Coastguard Worker``` 677*8975f5c5SAndroid Build Coastguard Worker 678*8975f5c5SAndroid Build Coastguard WorkerIf this process gets interrupted, re-run the upgrade command. The 679*8975f5c5SAndroid Build Coastguard Worker`--no-overwrite` argument will ensure it will complete eventually. 680*8975f5c5SAndroid Build Coastguard Worker 681*8975f5c5SAndroid Build Coastguard WorkerIf any traces failed to upgrade, see the section below on diagnosing tracer 682*8975f5c5SAndroid Build Coastguard Workererrors. 683*8975f5c5SAndroid Build Coastguard Worker 684*8975f5c5SAndroid Build Coastguard WorkerOtherwise, use the steps above to [verify and upgrade your traces](#part-3-test-the-upgraded-traces-under-an-experimental-prefix). 685*8975f5c5SAndroid Build Coastguard Worker 686*8975f5c5SAndroid Build Coastguard Worker 687*8975f5c5SAndroid Build Coastguard Worker# Diagnosing and fixing tracer errors 688*8975f5c5SAndroid Build Coastguard Worker 689*8975f5c5SAndroid Build Coastguard Worker## Debugging a crash or GLES error 690*8975f5c5SAndroid Build Coastguard Worker 691*8975f5c5SAndroid Build Coastguard WorkerEnsure you're building ANGLE in Debug. Then look in the retrace script output 692*8975f5c5SAndroid Build Coastguard Workerto find the exact command line and environment variables the script uses to 693*8975f5c5SAndroid Build Coastguard Workerproduce the failure. For example: 694*8975f5c5SAndroid Build Coastguard Worker 695*8975f5c5SAndroid Build Coastguard Worker``` 696*8975f5c5SAndroid Build Coastguard WorkerINFO:root:ANGLE_CAPTURE_LABEL=trex_200 ANGLE_CAPTURE_OUT_DIR=C:\src\angle\retrace-wip\trex_200 ANGLE_CAPTURE_FRAME_START=2 ANGLE_CAPTURE_FRAME_END=4 ANGLE_CAPTURE_VALIDATION=1 ANGLE_FEATURE_OVERRIDES_ENABLED=allocateNonZeroMemory:forceInitShaderVariables out\Debug\angle_trace_tests.exe --gtest_filter=TraceTest.trex_200 --use-angle=swiftshader --max-steps-performed 3 --retrace-mode 697*8975f5c5SAndroid Build Coastguard Worker``` 698*8975f5c5SAndroid Build Coastguard Worker 699*8975f5c5SAndroid Build Coastguard WorkerOnce you can reproduce the issue you can use a debugger or other standard 700*8975f5c5SAndroid Build Coastguard Workerdebugging processes to find the root cause and a fix. 701*8975f5c5SAndroid Build Coastguard Worker 702*8975f5c5SAndroid Build Coastguard Worker## Debugging a serialization difference 703*8975f5c5SAndroid Build Coastguard Worker 704*8975f5c5SAndroid Build Coastguard WorkerIf you encouter a serialization mismatch in the retrace, you can find the 705*8975f5c5SAndroid Build Coastguard Workercomplete serialization output by looking in the retrace script output. ANGLE 706*8975f5c5SAndroid Build Coastguard Workersaves the complete serialization file contents on any mismatch. You can 707*8975f5c5SAndroid Build Coastguard Workerinspect and diff these files in a text editor to help diagnose what objects 708*8975f5c5SAndroid Build Coastguard Workerare faulty. 709*8975f5c5SAndroid Build Coastguard Worker 710*8975f5c5SAndroid Build Coastguard WorkerIf the mismatch is with a Buffer or Texture object content, you can manually 711*8975f5c5SAndroid Build Coastguard Workeredit the `frame_capture_utils.cpp` file to force some or all of the objects 712*8975f5c5SAndroid Build Coastguard Workerto serialize their entire contents. This can help show what kind of pixel or 713*8975f5c5SAndroid Build Coastguard Workerdata differences might be causing the issue. For example, change this line: 714*8975f5c5SAndroid Build Coastguard Worker 715*8975f5c5SAndroid Build Coastguard Worker``` 716*8975f5c5SAndroid Build Coastguard Workerjson->addBlob("data", dataPtr->data(), dataPtr->size()); 717*8975f5c5SAndroid Build Coastguard Worker``` 718*8975f5c5SAndroid Build Coastguard Worker 719*8975f5c5SAndroid Build Coastguard Workerto 720*8975f5c5SAndroid Build Coastguard Worker 721*8975f5c5SAndroid Build Coastguard Worker``` 722*8975f5c5SAndroid Build Coastguard Workerjson->addBlobWithMax("data", dataPtr->data(), dataPtr->size(), 1000000); 723*8975f5c5SAndroid Build Coastguard Worker``` 724*8975f5c5SAndroid Build Coastguard Worker 725*8975f5c5SAndroid Build Coastguard WorkerNote: in the future, we might make this option exposed via an envioronment 726*8975f5c5SAndroid Build Coastguard Workervariable, or even allow serialization of entire data blocks in text-encoded 727*8975f5c5SAndroid Build Coastguard Workerform that could be decoded to separate files. 728*8975f5c5SAndroid Build Coastguard Worker 729*8975f5c5SAndroid Build Coastguard WorkerIf you still can't determine what code might be causing the state difference, 730*8975f5c5SAndroid Build Coastguard Workerwe can insert finer-grained serialization checkpoints to "bisect" where the 731*8975f5c5SAndroid Build Coastguard Workercoding mismatch is happening. It is not possible to force checkpoints after 732*8975f5c5SAndroid Build Coastguard Workerevery GLES call, because serialization and validation is so prohibitively 733*8975f5c5SAndroid Build Coastguard Workerexpensive. ANGLE instead has feature in the tracer that allows us to 734*8975f5c5SAndroid Build Coastguard Workerprecisely control where the tracer inserts and validates the checkpoints, by 735*8975f5c5SAndroid Build Coastguard Workerusing a boolean expression language. 736*8975f5c5SAndroid Build Coastguard Worker 737*8975f5c5SAndroid Build Coastguard WorkerThe retrace script command `--validation-expr` allows us to specify a C-like 738*8975f5c5SAndroid Build Coastguard Workerexpression that determines when to add serialization checkpoints. For 739*8975f5c5SAndroid Build Coastguard Workerexample, we can specify this validation expression: 740*8975f5c5SAndroid Build Coastguard Worker 741*8975f5c5SAndroid Build Coastguard Worker``` 742*8975f5c5SAndroid Build Coastguard Worker((frame == 2) && (call < 1189) && (call > 1100) && ((call % 5) == 0)) 743*8975f5c5SAndroid Build Coastguard Worker``` 744*8975f5c5SAndroid Build Coastguard Worker 745*8975f5c5SAndroid Build Coastguard WorkerUsing this expression will insert a serialization checkpoint in the second 746*8975f5c5SAndroid Build Coastguard Workerframe, on every 5th captured call, and when the captured call count is 747*8975f5c5SAndroid Build Coastguard Workerbetween 1101 and 1188. Here the `call` keyword denotes the call counter, 748*8975f5c5SAndroid Build Coastguard Workerwhich resets to 1 every frame, and increments by 1 with every captured GLES 749*8975f5c5SAndroid Build Coastguard WorkerAPI call. The `frame` keyword denotes the frame counter, which starts at 1 750*8975f5c5SAndroid Build Coastguard Workerand increments by 1 every captured frame. The expression syntax supports all 751*8975f5c5SAndroid Build Coastguard Workercommon C boolean operators. 752*8975f5c5SAndroid Build Coastguard Worker 753*8975f5c5SAndroid Build Coastguard WorkerBy finding a starting and ending frame range, and narrowing this range through 754*8975f5c5SAndroid Build Coastguard Workerexperimentation, you can pinpoint the exact call that triggers the 755*8975f5c5SAndroid Build Coastguard Workerserialization mismatch, and then diagnose and fix the root cause. In some 756*8975f5c5SAndroid Build Coastguard Workercases you can use RenderDoc or other frame debugging tools to inspect 757*8975f5c5SAndroid Build Coastguard Workerresource states before/after the bad call once you have found it. 758*8975f5c5SAndroid Build Coastguard Worker 759*8975f5c5SAndroid Build Coastguard WorkerSee also: [`http://crrev.com/c/3136094`](http://crrev.com/c/3136094) 760*8975f5c5SAndroid Build Coastguard Worker 761*8975f5c5SAndroid Build Coastguard Worker## Debugging a pixel test failure without a serialization mismatch 762*8975f5c5SAndroid Build Coastguard Worker 763*8975f5c5SAndroid Build Coastguard WorkerSometimes you manage to complete validation and upload, just to find a golden 764*8975f5c5SAndroid Build Coastguard Workerimage pixel difference that manifests in some trace configurations. These 765*8975f5c5SAndroid Build Coastguard Workerproblems can be harder to root cause. For instance, some configurations may 766*8975f5c5SAndroid Build Coastguard Workerrender undefined pixels that are in practice well-defined on most GLES 767*8975f5c5SAndroid Build Coastguard Workerimplementations. 768*8975f5c5SAndroid Build Coastguard Worker 769*8975f5c5SAndroid Build Coastguard WorkerThe pixel differences can also be a product of mismatched state even if the 770*8975f5c5SAndroid Build Coastguard Workertrace validation says all states are matched. Because ANGLE's GLES state 771*8975f5c5SAndroid Build Coastguard Workerserialization is incomplete, it can help to check the state serialization 772*8975f5c5SAndroid Build Coastguard Workerlogic and add missing features as necessary. 773