@@ -73,9 +73,7 @@ BUILD_DIR=./build
73
73
GFXR_DUMP_RESOURCES=" ${BUILD_DIR} /gfxr_dump_resources/gfxr_dump_resources"
74
74
JSON_BASENAME=dump.json
75
75
DUMP_DIR=" ${REMOTE_TEMP_DIR} /dump"
76
- # Needs to be high enough to skip over loading screens but not too high to trip the wait_for_logcat_line timeout.
77
- CAPTURE_FRAME=720
78
- GFXR_BASENAME=" ${PACKAGE} _frame_${CAPTURE_FRAME} .gfxr"
76
+ GFXR_BASENAME=" ${PACKAGE} _trim_trigger.gfxr"
79
77
GFXA_BASENAME=" ${PACKAGE} _asset_file.gfxa"
80
78
GFXR_REPLAY_APK=./install/gfxr-replay.apk
81
79
RESULTS_DIR=" ${PACKAGE} -$( date +%Y%m%d_%H%M%S) "
@@ -88,7 +86,10 @@ VALIDATION_LAYER_LIB=libVkLayer_khronos_validation.so
88
86
REMOTE_TEMP_FILEPATH=" /data/local/tmp/${VALIDATION_LAYER_LIB} "
89
87
ARCH=$( adb shell getprop ro.product.cpu.abi)
90
88
LOCAL_VALIDATION_LAYER_FILEPATH=" ${VALIDATION_LAYER_DIR} /${ARCH} /${VALIDATION_LAYER_LIB} "
91
- FRAME_DELIMITER_PROP=openxr.enable_frame_delimiter
89
+ # The old prop requires root access
90
+ OLD_FRAME_DELIMITER_PROP=openxr.enable_frame_delimiter
91
+ # The new prop works with shell user (does not require root access)
92
+ NEW_FRAME_DELIMITER_PROP=debug.openxr.enable_frame_delimiter
92
93
93
94
#
94
95
# Clear anything previously set (in case the script exited prematurely)
@@ -101,12 +102,15 @@ unset_vulkan_debug_settings
101
102
# Ask OpenXR runtime to emit frame debug marker
102
103
#
103
104
104
- # Only try if it's not set (to avoid having to root all the time)
105
- ENABLE_FRAME_DELIMITER=" $( adb shell getprop ${FRAME_DELIMITER_PROP} ) "
105
+ adb shell setprop " ${NEW_FRAME_DELIMITER_PROP} " true
106
+
107
+ # Since root/unroot disconnects the device and disrupts any host monitoring scripts (logcat, scrcpy), minimize the number of times it's called.
108
+ # It's only required to set the old prop. We can check if it's already set to avoid root/unroot.
109
+ ENABLE_FRAME_DELIMITER=" $( adb shell getprop ${OLD_FRAME_DELIMITER_PROP} ) "
106
110
if [ -z " ${ENABLE_FRAME_DELIMITER} " ]
107
111
then
108
112
adb root
109
- adb shell setprop ${FRAME_DELIMITER_PROP } true
113
+ adb shell setprop ${OLD_FRAME_DELIMITER_PROP } true
110
114
adb unroot
111
115
fi
112
116
@@ -202,17 +206,14 @@ adb shell settings put global gpu_debug_layer_app "${CAPTURE_DEBUG_LAYER_APPS}"
202
206
# See //third_party/gfxreconstruct/USAGE_android.md for more options.
203
207
adb shell mkdir -p " ${REMOTE_TEMP_DIR} "
204
208
adb shell setprop debug.gfxrecon.capture_file " ${REMOTE_TEMP_DIR} /${PACKAGE} .gfxr"
205
- # NOTE: quit_after_capture_frames doesn't work with capture_android_trigger or capture_frames :(
206
- # Prefer capture_frames over trigger since it's more friendly to scripting. It knows better when the app is ready and producing frames compared to trigger capture (where we have to guess).
207
- # adb shell setprop debug.gfxrecon.capture_trigger_frames 1
208
- # adb shell setprop debug.gfxrecon.capture_android_trigger false
209
- adb shell setprop debug.gfxrecon.capture_frames " ${CAPTURE_FRAME} "
210
- adb shell setprop debug.gfxrecon.capture_use_asset_file false # XXX asset file is known to have problems
211
- # Remove timestamp from capture filename so it's more predictable
209
+ # Use trigger trim with asset file since it's what Dive prefers
210
+ adb shell setprop debug.gfxrecon.capture_trigger_frames 1
211
+ adb shell setprop debug.gfxrecon.capture_android_trigger false
212
+ adb shell setprop debug.gfxrecon.capture_use_asset_file true
213
+ # Remove timestamp from capture filename so it's more predictable.
214
+ # Since we copy into a timestamped results folder, we don't end up overwriting pulled results.
212
215
adb shell setprop debug.gfxrecon.capture_file_timestamp false
213
- # Try to write all packets, even when we crash
214
- adb shell setprop debug.gfxrecon.capture_file_flush true
215
- # More logging
216
+ # Since we focused on "does this work?" the extra logging helps
216
217
adb shell setprop debug.gfxrecon.log_level debug
217
218
# Capture layer in PACKAGE needs permissions to read capture/asset file from storage.
218
219
adb shell appops set " ${PACKAGE} " MANAGE_EXTERNAL_STORAGE allow
@@ -221,14 +222,15 @@ adb shell appops set "${PACKAGE}" MANAGE_EXTERNAL_STORAGE allow
221
222
# 4. Capture
222
223
#
223
224
224
- # Clear logcat so that we can use it to determine when capture is done
225
+ # Clear logcat so that we can use it to determine when capture is done based on logging.
225
226
adb logcat -c
226
227
227
228
if [ ${CAPTURE_DEBUG} -eq 1 ]
228
229
then
229
230
adb shell am set-debug-app -w " ${PACKAGE} "
230
231
fi
231
232
233
+ # Start app, wait for it to start
232
234
adb shell am start -S -W -n " ${PACKAGE} /${ACTIVITY} "
233
235
234
236
# Given how long it takes to attach the debugger, etc, it is unlikely that you'll want the script to proceed.
@@ -237,8 +239,22 @@ then
237
239
exit 0
238
240
fi
239
241
242
+ # Likely redundant, but wait for the capture layer to log that it's been loaded
243
+ if ! wait_for_logcat_line gfxrecon " Initializing GFXReconstruct capture layer"
244
+ then
245
+ adb bugreport
246
+ fi
247
+
248
+ # Trigger a capture after the app has enough time to load.
249
+ # Use this over the capture_frame setting since Dive doesn't use capture_frame.
250
+ # Unfortunately "the app is loaded" is not something we can determine so we need to sleep... This is where capture_frame could really help.
251
+ # 20s is too short for some large Unity apps.
252
+ sleep 30
253
+ adb shell setprop debug.gfxrecon.capture_android_trigger true
254
+
240
255
# Wait for capture to finish. Luckily, the app logs when it's done so use that as the signal to proceed.
241
256
# This only works since we clear the logcat at the start of the test.
257
+ # We prefer this over quit_after_capture_frames since that setting seems broken.
242
258
if ! wait_for_logcat_line gfxrecon " Finished recording graphics API capture"
243
259
then
244
260
adb bugreport
@@ -247,23 +263,23 @@ adb shell am force-stop "${PACKAGE}"
247
263
248
264
# Pull the GFXR/GFXA for gfxr_dump_resources
249
265
adb pull " ${REMOTE_TEMP_DIR} /${GFXR_BASENAME} " " ${RESULTS_DIR} "
250
- # TODO asset file was disabled for testing; re-enable
251
- # adb pull "${REMOTE_TEMP_DIR}/${GFXA_BASENAME}" "${RESULTS_DIR}"
266
+ adb pull " ${REMOTE_TEMP_DIR} /${GFXA_BASENAME} " " ${RESULTS_DIR} "
252
267
253
268
#
254
269
# 5. Post-capture clean-up
255
270
#
256
271
257
272
# NOTE: Don't clean up GFXA/GFXR since we can use it for replay. Saves having to push again.
258
273
259
- # Next launch should not use GFXR
274
+ # Next launch of PACKAGE/ACTIVITY should not use GFXR
260
275
unset_gfxr_props
261
276
unset_vulkan_debug_settings
262
277
263
278
#
264
279
# 6. Replay with dump-resources
265
280
#
266
281
282
+ # --last-draw-only saves time by only dumping the final draw call. This should represent what the user sees.
267
283
" ${GFXR_DUMP_RESOURCES} " --last_draw_only " ${RESULTS_DIR} /${GFXR_BASENAME} " " ${JSON} "
268
284
adb shell mkdir -p " ${DUMP_DIR} "
269
285
adb push " ${JSON} " " ${REMOTE_TEMP_DIR} "
@@ -290,7 +306,7 @@ python "${GFXRECON}" replay \
290
306
291
307
# `gfxrecon.py replay` does not wait for the app to start so. However, if it starts logging then we can assume that it has started.
292
308
# This only works since we clear the logcat at the start of the test.
293
- if ! wait_for_logcat_line gfxrecon " Initializing GFXReconstruct capture layer "
309
+ if ! wait_for_logcat_line gfxrecon " Loading state for captured frame "
294
310
then
295
311
adb bugreport
296
312
fi
@@ -316,18 +332,23 @@ adb shell rm -rf "${REMOTE_TEMP_DIR}/${GFXR_BASENAME}"
316
332
adb shell rm -rf " ${REMOTE_TEMP_DIR} /${GFXA_BASENAME} "
317
333
adb shell rm -rf " ${REMOTE_TEMP_DIR} /${JSON_BASENAME} "
318
334
319
- # Next launch should not use GFXR
320
-
335
+ # Next launch should not use GFXR. Likely redudant but doesn't hurt.
336
+ unset_gfxr_props
337
+ unset_vulkan_debug_settings
321
338
322
339
#
323
340
# 8. Collect results
324
341
#
325
342
326
- # Show logcat for diagnostic purposes. Include DEBUG in case there was a crash.
343
+ # Show logcat to the user for diagnostic purposes. Include DEBUG in case there was a crash.
327
344
adb logcat -d -s gfxrecon,DEBUG
328
345
329
346
# Convert BMP captures into JPG for convenience.
330
347
find " ${RESULTS_DIR} " -name " *.bmp" | xargs -P0 -I {} convert {} {}.jpg
331
348
349
+ # Compress files to make them easier to share.
332
350
tar czf " ${RESULTS_DIR} .tgz" " ${RESULTS_DIR} "
333
- echo " Results written to: ${RESULTS_DIR} "
351
+
352
+ set +x
353
+ echo " ------------------------------------------"
354
+ echo " Results written to: ${RESULTS_DIR} .tgz"
0 commit comments