xref: /aosp_15_r20/external/angle/doc/DebuggingTips.md (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# Debugging Tips
2*8975f5c5SAndroid Build Coastguard Worker
3*8975f5c5SAndroid Build Coastguard WorkerThere are many ways to debug ANGLE using generic or platform-dependent tools. Here is a list of tips
4*8975f5c5SAndroid Build Coastguard Workeron how to use them.
5*8975f5c5SAndroid Build Coastguard Worker
6*8975f5c5SAndroid Build Coastguard Worker## Running ANGLE under apitrace on Linux
7*8975f5c5SAndroid Build Coastguard Worker
8*8975f5c5SAndroid Build Coastguard Worker[Apitrace](http://apitrace.github.io/) captures traces of OpenGL commands for later analysis,
9*8975f5c5SAndroid Build Coastguard Workerallowing us to see how ANGLE translates OpenGL ES commands. In order to capture the trace, it
10*8975f5c5SAndroid Build Coastguard Workerinserts a driver shim using `LD_PRELOAD` that records the command and then forwards it to the OpenGL
11*8975f5c5SAndroid Build Coastguard Workerdriver.
12*8975f5c5SAndroid Build Coastguard Worker
13*8975f5c5SAndroid Build Coastguard WorkerThe problem with ANGLE is that it exposes the same symbols as the OpenGL driver so apitrace captures
14*8975f5c5SAndroid Build Coastguard Workerthe entry point calls intended for ANGLE and reroutes them to the OpenGL driver. In order to avoid
15*8975f5c5SAndroid Build Coastguard Workerthis problem, use the following:
16*8975f5c5SAndroid Build Coastguard Worker
17*8975f5c5SAndroid Build Coastguard Worker1. Link your application against the static ANGLE libraries (libGLESv2_static and libEGL_static) so
18*8975f5c5SAndroid Build Coastguard Worker   they don't get shadowed by apitrace's shim.
19*8975f5c5SAndroid Build Coastguard Worker2. Ask apitrace to explicitly load the driver instead of using a dlsym on the current module.
20*8975f5c5SAndroid Build Coastguard Worker   Otherwise apitrace will use ANGLE's symbols as the OpenGL driver entrypoint (causing infinite
21*8975f5c5SAndroid Build Coastguard Worker   recursion). To do this you must point an environment variable to your GL driver.  For example:
22*8975f5c5SAndroid Build Coastguard Worker   `export TRACE_LIBGL=/usr/lib/libGL.so.1`. You can find your libGL with
23*8975f5c5SAndroid Build Coastguard Worker   `ldconfig -p | grep libGL`.
24*8975f5c5SAndroid Build Coastguard Worker3. Link ANGLE against libGL instead of dlsyming the symbols at runtime; otherwise ANGLE won't use
25*8975f5c5SAndroid Build Coastguard Worker   the replaced driver entry points. This is done with the gn arg `angle_link_glx = true`.
26*8975f5c5SAndroid Build Coastguard Worker
27*8975f5c5SAndroid Build Coastguard WorkerIf you follow these steps, apitrace will work correctly aside from a few minor bugs like not being
28*8975f5c5SAndroid Build Coastguard Workerable to figure out what the default framebuffer size is if there is no glViewport command.
29*8975f5c5SAndroid Build Coastguard Worker
30*8975f5c5SAndroid Build Coastguard WorkerFor example, to trace a run of `hello_triangle`, assuming the apitrace executables are in `$PATH`:
31*8975f5c5SAndroid Build Coastguard Worker
32*8975f5c5SAndroid Build Coastguard Worker```
33*8975f5c5SAndroid Build Coastguard Workergn args out/Debug # add "angle_link_glx = true"
34*8975f5c5SAndroid Build Coastguard Worker# edit samples/BUILD.gn and append "_static" to "angle_util", "libEGL", "libGLESv2"
35*8975f5c5SAndroid Build Coastguard Workerninja -C out/Debug
36*8975f5c5SAndroid Build Coastguard Workerexport TRACE_LIBGL="/usr/lib/libGL.so.1" # may require a different path
37*8975f5c5SAndroid Build Coastguard Workerapitrace trace -o mytrace ./out/Debug/hello_triangle
38*8975f5c5SAndroid Build Coastguard Workerqapitrace mytrace
39*8975f5c5SAndroid Build Coastguard Worker```
40*8975f5c5SAndroid Build Coastguard Worker
41*8975f5c5SAndroid Build Coastguard Worker## Enabling General Logging
42*8975f5c5SAndroid Build Coastguard Worker
43*8975f5c5SAndroid Build Coastguard WorkerNormally, ANGLE only logs errors and warnings (e.g. to Android logcat).  General logging, or
44*8975f5c5SAndroid Build Coastguard Workeradditional levels of "trace" messages will be logged when the following GN arg is set:
45*8975f5c5SAndroid Build Coastguard Worker```
46*8975f5c5SAndroid Build Coastguard Workerangle_enable_trace = true
47*8975f5c5SAndroid Build Coastguard Worker```
48*8975f5c5SAndroid Build Coastguard Worker
49*8975f5c5SAndroid Build Coastguard WorkerTo log all GLES and EGL commands submitted by an application, including the following flag:
50*8975f5c5SAndroid Build Coastguard Worker```
51*8975f5c5SAndroid Build Coastguard Workerangle_enable_trace_events = true
52*8975f5c5SAndroid Build Coastguard Worker```
53*8975f5c5SAndroid Build Coastguard Worker
54*8975f5c5SAndroid Build Coastguard WorkerIf you want to enable `INFO`-level logs (and up) without incuring the log spam
55*8975f5c5SAndroid Build Coastguard Workerof `angle_enable_trace`, you can instead use the following flag:
56*8975f5c5SAndroid Build Coastguard Worker```
57*8975f5c5SAndroid Build Coastguard Workerangle_always_log_info = true
58*8975f5c5SAndroid Build Coastguard Worker```
59*8975f5c5SAndroid Build Coastguard Worker
60*8975f5c5SAndroid Build Coastguard Worker## Debug Angle on Android
61*8975f5c5SAndroid Build Coastguard Worker
62*8975f5c5SAndroid Build Coastguard WorkerAndroid is built as an Android APK, which makes it more difficult to debug an APK that is using ANGLE.  The following information can allow you to debug ANGLE with LLDB.
63*8975f5c5SAndroid Build Coastguard Worker* You need to build ANGLE with debug symbols enabled. Assume your build variant is called Debug. Make sure you have these lines in out/Debug/args.gn
64*8975f5c5SAndroid Build Coastguard Worker```
65*8975f5c5SAndroid Build Coastguard Workeris_component_build = false
66*8975f5c5SAndroid Build Coastguard Workeris_debug = true
67*8975f5c5SAndroid Build Coastguard Workeris_official_build = false
68*8975f5c5SAndroid Build Coastguard Workersymbol_level = 2
69*8975f5c5SAndroid Build Coastguard Workerstrip_debug_info = false
70*8975f5c5SAndroid Build Coastguard Workerignore_elf32_limitations = true
71*8975f5c5SAndroid Build Coastguard Workerangle_extract_native_libs = true
72*8975f5c5SAndroid Build Coastguard Worker```
73*8975f5c5SAndroid Build Coastguard WorkerThe following local patch may also be necessary:
74*8975f5c5SAndroid Build Coastguard Worker```
75*8975f5c5SAndroid Build Coastguard Workerdiff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni
76*8975f5c5SAndroid Build Coastguard Workerindex 96a18d91a3f6..ca7971fdfd48 100644
77*8975f5c5SAndroid Build Coastguard Worker--- a/build/config/compiler/compiler.gni
78*8975f5c5SAndroid Build Coastguard Worker+++ b/build/config/compiler/compiler.gni
79*8975f5c5SAndroid Build Coastguard Worker@@ -86,7 +86,8 @@ declare_args() {
80*8975f5c5SAndroid Build Coastguard Worker   # Whether an error should be raised on attempts to make debug builds with
81*8975f5c5SAndroid Build Coastguard Worker   # is_component_build=false. Very large debug symbols can have unwanted side
82*8975f5c5SAndroid Build Coastguard Worker   # effects so this is enforced by default for chromium.
83*8975f5c5SAndroid Build Coastguard Worker-  forbid_non_component_debug_builds = build_with_chromium
84*8975f5c5SAndroid Build Coastguard Worker+  forbid_non_component_debug_builds = false
85*8975f5c5SAndroid Build Coastguard Worker```
86*8975f5c5SAndroid Build Coastguard Worker
87*8975f5c5SAndroid Build Coastguard WorkerBuild/install/enable ANGLE apk for your application following other instructions.
88*8975f5c5SAndroid Build Coastguard Worker* Modify gdbclient.py script to let it find the ANGLE symbols.
89*8975f5c5SAndroid Build Coastguard Worker```
90*8975f5c5SAndroid Build Coastguard Workerdiff --git a/scripts/gdbclient.py b/scripts/gdbclient.py
91*8975f5c5SAndroid Build Coastguard Workerindex 61fac4000..1f43f4f64 100755
92*8975f5c5SAndroid Build Coastguard Worker--- a/scripts/gdbclient.py
93*8975f5c5SAndroid Build Coastguard Worker+++ b/scripts/gdbclient.py
94*8975f5c5SAndroid Build Coastguard Worker@@ -395,6 +395,8 @@ def generate_setup_script(debugger_path, sysroot, linker_search_dir, binary_file
95*8975f5c5SAndroid Build Coastguard Worker     vendor_paths = ["", "hw", "egl"]
96*8975f5c5SAndroid Build Coastguard Worker     solib_search_path += [os.path.join(symbols_dir, x) for x in symbols_paths]
97*8975f5c5SAndroid Build Coastguard Worker     solib_search_path += [os.path.join(vendor_dir, x) for x in vendor_paths]
98*8975f5c5SAndroid Build Coastguard Worker+    solib_search_path += ["/your_path_to_chromium_src/out/Debug/lib.unstripped/"]
99*8975f5c5SAndroid Build Coastguard Worker     if linker_search_dir is not None:
100*8975f5c5SAndroid Build Coastguard Worker         solib_search_path += [linker_search_dir]
101*8975f5c5SAndroid Build Coastguard Worker```
102*8975f5c5SAndroid Build Coastguard Worker* Start your lldbclient.py from `/your_path_to_chromium_src/out/Debug` folder. This adds the ANGLE source-file paths to what is visible to LLDB, which allows LLDB to show ANGLE's source files. Refer to https://source.android.com/devices/tech/debug/gdb for how to attach the app for debugging.
103*8975f5c5SAndroid Build Coastguard Worker* If you are debugging angle_perftests, you can use `--shard-timeout 100000000` to disable the timeout so that the test won't get killed while you are debugging. If the test runs too fast that you don't have time to attach, use `--delay-test-start=60` to give you extra time to attach.
104*8975f5c5SAndroid Build Coastguard Worker
105*8975f5c5SAndroid Build Coastguard Worker## Forcing GL vendor and renderer strings
106*8975f5c5SAndroid Build Coastguard Worker
107*8975f5c5SAndroid Build Coastguard WorkerSome applications don't recognize ANGLE and lower their settings, refuse to start or even crash.
108*8975f5c5SAndroid Build Coastguard WorkerIn those scenarios, you can force them to be values matching other devices.
109*8975f5c5SAndroid Build Coastguard Worker
110*8975f5c5SAndroid Build Coastguard WorkerOn desktop:
111*8975f5c5SAndroid Build Coastguard Worker```
112*8975f5c5SAndroid Build Coastguard WorkerANGLE_GL_VENDOR="foo"
113*8975f5c5SAndroid Build Coastguard WorkerANGLE_GL_RENDERER="bar"
114*8975f5c5SAndroid Build Coastguard Worker```
115*8975f5c5SAndroid Build Coastguard Worker
116*8975f5c5SAndroid Build Coastguard WorkerOn Android:
117*8975f5c5SAndroid Build Coastguard Worker```
118*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.gl_vendor "foo"
119*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.gl_renderer "bar"
120*8975f5c5SAndroid Build Coastguard Worker```
121*8975f5c5SAndroid Build Coastguard Worker
122*8975f5c5SAndroid Build Coastguard Worker## Enabling Debug-Utils Markers
123*8975f5c5SAndroid Build Coastguard Worker
124*8975f5c5SAndroid Build Coastguard WorkerANGLE can emit debug-utils markers for every GLES API command that are visible to both Android GPU
125*8975f5c5SAndroid Build Coastguard WorkerInspector (AGI) and RenderDoc.  This support requires
126*8975f5c5SAndroid Build Coastguard Worker[enabling general logging](#enabling-general-logging) as well as setting the following additional
127*8975f5c5SAndroid Build Coastguard WorkerGN arg:
128*8975f5c5SAndroid Build Coastguard Worker```
129*8975f5c5SAndroid Build Coastguard Workerangle_enable_annotator_run_time_checks = true
130*8975f5c5SAndroid Build Coastguard Worker```
131*8975f5c5SAndroid Build Coastguard WorkerIn addition, if the following GN arg is set, the API calls will output to Android's logcat:
132*8975f5c5SAndroid Build Coastguard Worker```
133*8975f5c5SAndroid Build Coastguard Workerangle_enable_trace_android_logcat = true
134*8975f5c5SAndroid Build Coastguard Worker```
135*8975f5c5SAndroid Build Coastguard WorkerOnce compiled, the markers need to be turned on.
136*8975f5c5SAndroid Build Coastguard Worker
137*8975f5c5SAndroid Build Coastguard Worker### Turning on Debug Markers on Android
138*8975f5c5SAndroid Build Coastguard Worker
139*8975f5c5SAndroid Build Coastguard WorkerOn Android, debug markers are turned on and off with an Android debug property that is
140*8975f5c5SAndroid Build Coastguard Workerautomatically deleted at the next reboot:
141*8975f5c5SAndroid Build Coastguard Worker
142*8975f5c5SAndroid Build Coastguard Worker```
143*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.markers 1
144*8975f5c5SAndroid Build Coastguard Worker```
145*8975f5c5SAndroid Build Coastguard Worker
146*8975f5c5SAndroid Build Coastguard Worker* 0: Turned off/disabled (default)
147*8975f5c5SAndroid Build Coastguard Worker* 1: Turned on/enabled
148*8975f5c5SAndroid Build Coastguard Worker
149*8975f5c5SAndroid Build Coastguard Worker### Turning on Debug Markers on Desktop
150*8975f5c5SAndroid Build Coastguard Worker
151*8975f5c5SAndroid Build Coastguard WorkerOn desktop, debug markers are turned on and off with the ANGLE_ENABLE_DEBUG_MARKERS environment
152*8975f5c5SAndroid Build Coastguard Workervariable (set in OS-specific manner):
153*8975f5c5SAndroid Build Coastguard Worker
154*8975f5c5SAndroid Build Coastguard Worker* 0: Turned off/disabled (default)
155*8975f5c5SAndroid Build Coastguard Worker* 1: Turned on/enabled
156*8975f5c5SAndroid Build Coastguard Worker
157*8975f5c5SAndroid Build Coastguard Worker## Enable Vulkan Call Logging
158*8975f5c5SAndroid Build Coastguard Worker
159*8975f5c5SAndroid Build Coastguard WorkerANGLE can output Vulkan API call information including detailed parameter info and state. Vulkan
160*8975f5c5SAndroid Build Coastguard Workercall logging is available for ANGLE debug builds, builds with asserts enabled, or can be made
161*8975f5c5SAndroid Build Coastguard Workeravailable on any build by setting the following GN arg:
162*8975f5c5SAndroid Build Coastguard Worker```
163*8975f5c5SAndroid Build Coastguard Workerangle_enable_vulkan_api_dump_layer = true
164*8975f5c5SAndroid Build Coastguard Worker```
165*8975f5c5SAndroid Build Coastguard Worker
166*8975f5c5SAndroid Build Coastguard WorkerBy default Vulkan call logging goes to stdout, or logcat on Android. Vulkan call logging can be
167*8975f5c5SAndroid Build Coastguard Workerused with trace event and debug marker output as shown in [enabling general logging](#enabling-general-logging)
168*8975f5c5SAndroid Build Coastguard Worker and [enabling Debug-Utils markers](#enabling-debug-utils-markers)
169*8975f5c5SAndroid Build Coastguard Worker
170*8975f5c5SAndroid Build Coastguard Worker### Vulkan Call Logging on Desktop
171*8975f5c5SAndroid Build Coastguard Worker
172*8975f5c5SAndroid Build Coastguard WorkerTo log Vulkan calls on desktop set the environment variable `ANGLE_ENABLE_VULKAN_API_DUMP_LAYER` to 1.
173*8975f5c5SAndroid Build Coastguard Worker
174*8975f5c5SAndroid Build Coastguard WorkerFor Vulkan call logging output to a file, set
175*8975f5c5SAndroid Build Coastguard Workerthe environment variable `VK_APIDUMP_LOG_FILENAME` to the correct location.
176*8975f5c5SAndroid Build Coastguard Worker
177*8975f5c5SAndroid Build Coastguard WorkerTo show only Vulkan api calls without verbose parameter details set the environment variable
178*8975f5c5SAndroid Build Coastguard Worker`VK_APIDUMP_DETAILED` to `false`
179*8975f5c5SAndroid Build Coastguard Worker
180*8975f5c5SAndroid Build Coastguard Worker### Vulkan Call Logging on Android
181*8975f5c5SAndroid Build Coastguard Worker
182*8975f5c5SAndroid Build Coastguard WorkerActivate Vulkan call logging on Android by setting this Android debug property  that is
183*8975f5c5SAndroid Build Coastguard Workerautomatically deleted at the next reboot:
184*8975f5c5SAndroid Build Coastguard Worker```
185*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.angle.enable_vulkan_api_dump_layer 1
186*8975f5c5SAndroid Build Coastguard Worker```
187*8975f5c5SAndroid Build Coastguard Worker
188*8975f5c5SAndroid Build Coastguard WorkerFor Vulkan call logging to a file on Android, specify the filename with an Android debug property that is
189*8975f5c5SAndroid Build Coastguard Workerautomatically deleted at the next reboot:
190*8975f5c5SAndroid Build Coastguard Worker```
191*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.apidump.log_filename /data/data/[PACKAGE_NAME, i.e., com.android.angle.test for angle_trace_tests]/api_dump.txt
192*8975f5c5SAndroid Build Coastguard Worker```
193*8975f5c5SAndroid Build Coastguard Worker
194*8975f5c5SAndroid Build Coastguard WorkerSimilarly, detailed parameter output can be controlled by the following Android debug properties:
195*8975f5c5SAndroid Build Coastguard Worker```
196*8975f5c5SAndroid Build Coastguard Workeradb shell setprop debug.apidump.detailed false
197*8975f5c5SAndroid Build Coastguard Worker```
198*8975f5c5SAndroid Build Coastguard Worker
199*8975f5c5SAndroid Build Coastguard Worker## Running ANGLE under GAPID on Linux
200*8975f5c5SAndroid Build Coastguard Worker
201*8975f5c5SAndroid Build Coastguard Worker[GAPID](https://github.com/google/gapid) can be used to capture trace of Vulkan commands on Linux.
202*8975f5c5SAndroid Build Coastguard WorkerWhen capturing traces of gtest based tests built inside Chromium checkout, make sure to run the
203*8975f5c5SAndroid Build Coastguard Workertests with `--single-process-tests` argument.
204*8975f5c5SAndroid Build Coastguard Worker
205*8975f5c5SAndroid Build Coastguard Worker## Running ANGLE under GAPID on Android
206*8975f5c5SAndroid Build Coastguard Worker
207*8975f5c5SAndroid Build Coastguard Worker[GAPID](https://github.com/google/gapid) can be used to capture a trace of the Vulkan or OpenGL ES
208*8975f5c5SAndroid Build Coastguard Workercommand stream on Android.  For it to work, ANGLE's libraries must have different names from the
209*8975f5c5SAndroid Build Coastguard Workersystem OpenGL libraries.  This is done with the gn arg:
210*8975f5c5SAndroid Build Coastguard Worker
211*8975f5c5SAndroid Build Coastguard Worker```
212*8975f5c5SAndroid Build Coastguard Workerangle_libs_suffix = "_ANGLE_DEV"
213*8975f5c5SAndroid Build Coastguard Worker```
214*8975f5c5SAndroid Build Coastguard Worker
215*8975f5c5SAndroid Build Coastguard WorkerAll
216*8975f5c5SAndroid Build Coastguard Worker[AngleNativeTest](https://chromium.googlesource.com/chromium/src/+/main/third_party/angle/src/tests/test_utils/runner/android/java/src/com/android/angle/test/AngleNativeTest.java)
217*8975f5c5SAndroid Build Coastguard Workerbased tests share the same activity name, `com.android.angle.test.AngleUnitTestActivity`.
218*8975f5c5SAndroid Build Coastguard WorkerThus, prior to capturing your test trace, the specific test APK must be installed on the device.
219*8975f5c5SAndroid Build Coastguard WorkerWhen you build the test, a test launcher is generated, for example,
220*8975f5c5SAndroid Build Coastguard Worker`./out/Release/bin/run_angle_end2end_tests`. The best way to install the APK is to run this test
221*8975f5c5SAndroid Build Coastguard Workerlauncher once.
222*8975f5c5SAndroid Build Coastguard Worker
223*8975f5c5SAndroid Build Coastguard WorkerIn GAPID's "Capture Trace" dialog, "Package / Action:" should be:
224*8975f5c5SAndroid Build Coastguard Worker
225*8975f5c5SAndroid Build Coastguard Worker```
226*8975f5c5SAndroid Build Coastguard Workerandroid.intent.action.MAIN:com.android.angle.test/com.android.angle.test.AngleUnitTestActivity
227*8975f5c5SAndroid Build Coastguard Worker```
228*8975f5c5SAndroid Build Coastguard Worker
229*8975f5c5SAndroid Build Coastguard WorkerThe mandatory [extra intent
230*8975f5c5SAndroid Build Coastguard Workerargument](https://developer.android.com/studio/command-line/adb.html#IntentSpec) for starting the
231*8975f5c5SAndroid Build Coastguard Workeractivity is `org.chromium.native_test.NativeTest.StdoutFile`. Without it the test APK crashes. Test
232*8975f5c5SAndroid Build Coastguard Workerfilters can be specified via either the `org.chromium.native_test.NativeTest.CommandLineFlags` or
233*8975f5c5SAndroid Build Coastguard Workerthe `org.chromium.native_test.NativeTest.GtestFilter` argument.  Example "Intent Arguments:" values in
234*8975f5c5SAndroid Build Coastguard WorkerGAPID's "Capture Trace" dialog:
235*8975f5c5SAndroid Build Coastguard Worker
236*8975f5c5SAndroid Build Coastguard Worker```
237*8975f5c5SAndroid Build Coastguard Worker-e org.chromium.native_test.NativeTest.StdoutFile /sdcard/chromium_tests_root/out.txt -e org.chromium.native_test.NativeTest.CommandLineFlags "--gtest_filter=*ES2_VULKAN"
238*8975f5c5SAndroid Build Coastguard Worker```
239*8975f5c5SAndroid Build Coastguard Worker
240*8975f5c5SAndroid Build Coastguard Workeror
241*8975f5c5SAndroid Build Coastguard Worker
242*8975f5c5SAndroid Build Coastguard Worker```
243*8975f5c5SAndroid Build Coastguard Worker-e org.chromium.native_test.NativeTest.StdoutFile /sdcard/chromium_tests_root/out.txt --e org.chromium.native_test.NativeTest.GtestFilter RendererTest.SimpleOperation/ES2_VULKAN:SimpleOperationTest.DrawWithTexture/ES2_VULKAN
244*8975f5c5SAndroid Build Coastguard Worker```
245*8975f5c5SAndroid Build Coastguard Worker
246*8975f5c5SAndroid Build Coastguard Worker## Running ANGLE under RenderDoc
247*8975f5c5SAndroid Build Coastguard Worker
248*8975f5c5SAndroid Build Coastguard WorkerAn application running through ANGLE can confuse [RenderDoc](https://github.com/baldurk/renderdoc),
249*8975f5c5SAndroid Build Coastguard Workeras RenderDoc [hooks to EGL](https://github.com/baldurk/renderdoc/issues/1045) and ends up tracing
250*8975f5c5SAndroid Build Coastguard Workerthe calls the application makes, instead of the calls ANGLE makes to its backend.  As ANGLE is a
251*8975f5c5SAndroid Build Coastguard Workerspecial case, there's little support for it by RenderDoc, though there are workarounds.
252*8975f5c5SAndroid Build Coastguard Worker
253*8975f5c5SAndroid Build Coastguard Worker### Windows
254*8975f5c5SAndroid Build Coastguard Worker
255*8975f5c5SAndroid Build Coastguard WorkerOn Windows, RenderDoc supports setting the environment variable `RENDERDOC_HOOK_EGL` to 0 to avoid
256*8975f5c5SAndroid Build Coastguard Workerthis issue.
257*8975f5c5SAndroid Build Coastguard Worker
258*8975f5c5SAndroid Build Coastguard Worker### Linux
259*8975f5c5SAndroid Build Coastguard Worker
260*8975f5c5SAndroid Build Coastguard WorkerOn Linux, there is no supported workaround by RenderDoc.  See [this
261*8975f5c5SAndroid Build Coastguard Workerissue](https://github.com/baldurk/renderdoc/issues/1045#issuecomment-463999869).  To capture Vulkan
262*8975f5c5SAndroid Build Coastguard Workertraces, the workaround is to build RenderDoc without GL(ES) support.
263*8975f5c5SAndroid Build Coastguard Worker
264*8975f5c5SAndroid Build Coastguard WorkerBuilding RenderDoc is straightforward.  However, here are a few instructions to keep in mind.
265*8975f5c5SAndroid Build Coastguard Worker
266*8975f5c5SAndroid Build Coastguard Worker```
267*8975f5c5SAndroid Build Coastguard Worker# Install dependencies based on RenderDoc document.  Here are some packages that are unlikely to be already installed:
268*8975f5c5SAndroid Build Coastguard Worker$ sudo apt install libxcb-keysyms1-dev python3-dev qt5-qmake libqt5svg5-dev libqt5x11extras5-dev
269*8975f5c5SAndroid Build Coastguard Worker
270*8975f5c5SAndroid Build Coastguard Worker# Inside the RenderDoc directory:
271*8975f5c5SAndroid Build Coastguard Worker$ cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -H. -DENABLE_GLES=OFF -DENABLE_GL=OFF
272*8975f5c5SAndroid Build Coastguard Worker
273*8975f5c5SAndroid Build Coastguard Worker# QT_SELECT=5 is necessary if your distribution doesn't default to Qt5
274*8975f5c5SAndroid Build Coastguard Worker$ QT_SELECT=5 make -j -C build
275*8975f5c5SAndroid Build Coastguard Worker
276*8975f5c5SAndroid Build Coastguard Worker# Run RenderDoc from the build directory:
277*8975f5c5SAndroid Build Coastguard Worker$ ./build/bin/qrenderdoc
278*8975f5c5SAndroid Build Coastguard Worker```
279*8975f5c5SAndroid Build Coastguard Worker
280*8975f5c5SAndroid Build Coastguard WorkerIf your distribution does not provide a recent Vulkan SDK package, you would need to manually
281*8975f5c5SAndroid Build Coastguard Workerinstall that.  This script tries to perform this installation as safely as possible.  It would
282*8975f5c5SAndroid Build Coastguard Workeroverwrite the system package's files, so follow at your own risk.  Place this script just above the
283*8975f5c5SAndroid Build Coastguard Workerextracted SDK directory.
284*8975f5c5SAndroid Build Coastguard Worker
285*8975f5c5SAndroid Build Coastguard Worker```
286*8975f5c5SAndroid Build Coastguard Worker#! /bin/bash
287*8975f5c5SAndroid Build Coastguard Worker
288*8975f5c5SAndroid Build Coastguard Workerif [ $# -lt 1 ]; then
289*8975f5c5SAndroid Build Coastguard Worker  echo "Usage: $0 <version>"
290*8975f5c5SAndroid Build Coastguard Worker  exit 1
291*8975f5c5SAndroid Build Coastguard Workerfi
292*8975f5c5SAndroid Build Coastguard Worker
293*8975f5c5SAndroid Build Coastguard Workerver=$1
294*8975f5c5SAndroid Build Coastguard Worker
295*8975f5c5SAndroid Build Coastguard Workerif [ ! -d "$ver" ]; then
296*8975f5c5SAndroid Build Coastguard Worker  echo "$ver is not a directory"
297*8975f5c5SAndroid Build Coastguard Workerfi
298*8975f5c5SAndroid Build Coastguard Worker
299*8975f5c5SAndroid Build Coastguard Worker# Verify everything first
300*8975f5c5SAndroid Build Coastguard Workerecho "Verifying files..."
301*8975f5c5SAndroid Build Coastguard Workerecho "$ver"/x86_64/bin/vulkaninfo
302*8975f5c5SAndroid Build Coastguard Workertest -f "$ver"/x86_64/bin/vulkaninfo || exit 1
303*8975f5c5SAndroid Build Coastguard Workerecho "$ver"/x86_64/etc/explicit_layer.d/
304*8975f5c5SAndroid Build Coastguard Workertest -d "$ver"/x86_64/etc/explicit_layer.d || exit 1
305*8975f5c5SAndroid Build Coastguard Workerecho "$ver"/x86_64/lib/
306*8975f5c5SAndroid Build Coastguard Workertest -d "$ver"/x86_64/lib || exit 1
307*8975f5c5SAndroid Build Coastguard Worker
308*8975f5c5SAndroid Build Coastguard Workerecho "Verified. Performing copy..."
309*8975f5c5SAndroid Build Coastguard Worker
310*8975f5c5SAndroid Build Coastguard Workerecho sudo cp "$ver"/x86_64/bin/vulkaninfo /usr/bin/vulkaninfo
311*8975f5c5SAndroid Build Coastguard Workersudo cp "$ver"/x86_64/bin/vulkaninfo /usr/bin/vulkaninfo
312*8975f5c5SAndroid Build Coastguard Workerecho sudo cp "$ver"/x86_64/etc/explicit_layer.d/* /etc/explicit_layer.d/
313*8975f5c5SAndroid Build Coastguard Workersudo cp "$ver"/x86_64/etc/explicit_layer.d/* /etc/explicit_layer.d/
314*8975f5c5SAndroid Build Coastguard Workerecho sudo rm /usr/lib/x86_64-linux-gnu/libvulkan.so*
315*8975f5c5SAndroid Build Coastguard Workersudo rm /usr/lib/x86_64-linux-gnu/libvulkan.so*
316*8975f5c5SAndroid Build Coastguard Workerecho sudo cp -P "$ver"/x86_64/lib/lib* /usr/lib/x86_64-linux-gnu/
317*8975f5c5SAndroid Build Coastguard Workersudo cp -P "$ver"/x86_64/lib/lib* /usr/lib/x86_64-linux-gnu/
318*8975f5c5SAndroid Build Coastguard Worker
319*8975f5c5SAndroid Build Coastguard Workerecho "Done."
320*8975f5c5SAndroid Build Coastguard Worker```
321*8975f5c5SAndroid Build Coastguard Worker
322*8975f5c5SAndroid Build Coastguard Worker### Android
323*8975f5c5SAndroid Build Coastguard Worker#### Using Linux as a Local Machine
324*8975f5c5SAndroid Build Coastguard Worker
325*8975f5c5SAndroid Build Coastguard WorkerIf you are on Linux, make sure not to use the build done in the previous section.  The GL renderer
326*8975f5c5SAndroid Build Coastguard Workerdisabled in the previous section is actually needed in this section.
327*8975f5c5SAndroid Build Coastguard Worker
328*8975f5c5SAndroid Build Coastguard Worker```
329*8975f5c5SAndroid Build Coastguard Worker# Inside the RenderDoc directory:
330*8975f5c5SAndroid Build Coastguard Worker# First delete the Cmake Cache in build/ directory
331*8975f5c5SAndroid Build Coastguard Workerrm build/CMakeCache.txt
332*8975f5c5SAndroid Build Coastguard Worker
333*8975f5c5SAndroid Build Coastguard Worker# Then build RenderDoc with cmake:
334*8975f5c5SAndroid Build Coastguard Workercmake -DCMAKE_BUILD_TYPE=Release -Bbuild -H.
335*8975f5c5SAndroid Build Coastguard WorkerQT_SELECT=5 make -j -C build
336*8975f5c5SAndroid Build Coastguard Worker```
337*8975f5c5SAndroid Build Coastguard Worker
338*8975f5c5SAndroid Build Coastguard WorkerFollow
339*8975f5c5SAndroid Build Coastguard Worker[Android Dependencies on Linux](https://github.com/baldurk/renderdoc/blob/v1.x/docs/CONTRIBUTING/Dependencies.md#android-dependencies-on-linux)
340*8975f5c5SAndroid Build Coastguard Workerto download dependency files.
341*8975f5c5SAndroid Build Coastguard Worker
342*8975f5c5SAndroid Build Coastguard WorkerDefine the following environment variables, for example in `.bashrc` (values are examples):
343*8975f5c5SAndroid Build Coastguard Worker
344*8975f5c5SAndroid Build Coastguard Worker```
345*8975f5c5SAndroid Build Coastguard Workerexport JAVA_HOME=<path_to_jdk_root>
346*8975f5c5SAndroid Build Coastguard Workerexport ANDROID_SDK=<path_to_sdk_root>
347*8975f5c5SAndroid Build Coastguard Workerexport ANDROID_NDK=<path_to_ndk_root>
348*8975f5c5SAndroid Build Coastguard Workerexport ANDROID_NDK_HOME=<path_to_ndk_root>
349*8975f5c5SAndroid Build Coastguard Worker```
350*8975f5c5SAndroid Build Coastguard Worker
351*8975f5c5SAndroid Build Coastguard WorkerIn the renderdoc directory, create Android builds of RenderDoc:
352*8975f5c5SAndroid Build Coastguard Worker
353*8975f5c5SAndroid Build Coastguard Worker```
354*8975f5c5SAndroid Build Coastguard Workermkdir build-android-arm32
355*8975f5c5SAndroid Build Coastguard Workercd build-android-arm32/
356*8975f5c5SAndroid Build Coastguard Workercmake -DBUILD_ANDROID=On -DANDROID_ABI=armeabi-v7a ..
357*8975f5c5SAndroid Build Coastguard Workermake -j
358*8975f5c5SAndroid Build Coastguard Workercd ../
359*8975f5c5SAndroid Build Coastguard Worker
360*8975f5c5SAndroid Build Coastguard Workermkdir build-android-arm64
361*8975f5c5SAndroid Build Coastguard Workercd build-android-arm64/
362*8975f5c5SAndroid Build Coastguard Workercmake -DBUILD_ANDROID=On -DANDROID_ABI=arm64-v8a ..
363*8975f5c5SAndroid Build Coastguard Workermake -j
364*8975f5c5SAndroid Build Coastguard Workercd ../
365*8975f5c5SAndroid Build Coastguard Worker```
366*8975f5c5SAndroid Build Coastguard Worker
367*8975f5c5SAndroid Build Coastguard WorkerNote that you need both arm32 and arm64 builds even if working with an arm64 device.  See
368*8975f5c5SAndroid Build Coastguard Worker[RenderDoc's documentation](https://github.com/baldurk/renderdoc/blob/v1.x/docs/CONTRIBUTING/Compiling.md#android)
369*8975f5c5SAndroid Build Coastguard Workerfor more information.
370*8975f5c5SAndroid Build Coastguard Worker
371*8975f5c5SAndroid Build Coastguard WorkerWhen you run RenderDoc, choose the "Replay Context" from the bottom-left part of the UI (defaults to
372*8975f5c5SAndroid Build Coastguard WorkerLocal).  When selecting the device, you should see the RenderDoc application running.
373*8975f5c5SAndroid Build Coastguard Worker
374*8975f5c5SAndroid Build Coastguard WorkerIn ANGLE itself, make sure you add a suffix for its names to be different from the system's.  Add
375*8975f5c5SAndroid Build Coastguard Workerthis to gn args:
376*8975f5c5SAndroid Build Coastguard Worker
377*8975f5c5SAndroid Build Coastguard Worker```
378*8975f5c5SAndroid Build Coastguard Workerangle_libs_suffix = "_ANGLE_DEV"
379*8975f5c5SAndroid Build Coastguard Worker```
380*8975f5c5SAndroid Build Coastguard Worker
381*8975f5c5SAndroid Build Coastguard WorkerNext, you need to install an ANGLE test APK.  When you build the test, a test launcher is generated,
382*8975f5c5SAndroid Build Coastguard Workerfor example, `./out/Release/bin/run_angle_end2end_tests`. The best way to install the APK is to run
383*8975f5c5SAndroid Build Coastguard Workerthis test launcher once.
384*8975f5c5SAndroid Build Coastguard Worker
385*8975f5c5SAndroid Build Coastguard WorkerIn RenderDoc, use `com.android.angle.test/com.android.angle.test.AngleUnitTestActivity` as the
386*8975f5c5SAndroid Build Coastguard WorkerExecutable Path, and provide the following arguments:
387*8975f5c5SAndroid Build Coastguard Worker
388*8975f5c5SAndroid Build Coastguard Worker```
389*8975f5c5SAndroid Build Coastguard Worker-e org.chromium.native_test.NativeTest.StdoutFile /sdcard/chromium_tests_root/out.txt -e org.chromium.native_test.NativeTest.CommandLineFlags "--gtest_filter=*ES2_VULKAN"
390*8975f5c5SAndroid Build Coastguard Worker```
391*8975f5c5SAndroid Build Coastguard Worker
392*8975f5c5SAndroid Build Coastguard WorkerNote that in the above, only a single command line argument is supported with RenderDoc.  If testing
393*8975f5c5SAndroid Build Coastguard WorkerdEQP on a non-default platform, the easiest way would be to modify `GetDefaultAPIName()` in
394*8975f5c5SAndroid Build Coastguard Worker`src/tests/deqp_support/angle_deqp_gtest.cpp` (and avoid `--use-angle=X`).
395*8975f5c5SAndroid Build Coastguard Worker
396*8975f5c5SAndroid Build Coastguard Worker
397*8975f5c5SAndroid Build Coastguard Worker#### Using Windows as a Local Machine
398*8975f5c5SAndroid Build Coastguard WorkerYou should be able to download the latest [RenderDoc on Windows](https://renderdoc.org/builds) and follow the
399*8975f5c5SAndroid Build Coastguard Worker[RenderDoc Official Documentation](https://renderdoc.org/docs/how/how_android_capture.html) for instructions on how to
400*8975f5c5SAndroid Build Coastguard Workeruse RenderDoc on Android. If you would like to build RenderDoc for Android on Windows yourself, you can follow the
401*8975f5c5SAndroid Build Coastguard Worker[RenderDoc Officual Documentation](https://github.com/baldurk/renderdoc/blob/v1.x/docs/CONTRIBUTING/Compiling.md#android).
402*8975f5c5SAndroid Build Coastguard WorkerWe listed more detailed instructions below on how to set up the build on Windows.
403*8975f5c5SAndroid Build Coastguard Worker
404*8975f5c5SAndroid Build Coastguard Worker##### Install Android Dependencies
405*8975f5c5SAndroid Build Coastguard Worker
406*8975f5c5SAndroid Build Coastguard WorkerOn windows, we need to install dependencies to build android, as described in
407*8975f5c5SAndroid Build Coastguard Worker[RenderDoc Official Documentation](https://github.com/baldurk/renderdoc/blob/v1.x/docs/CONTRIBUTING/Dependencies.md#android)
408*8975f5c5SAndroid Build Coastguard Worker1. Install [Android SDK](https://developer.android.com/about/versions/12/setup-sdk#install-sdk).
409*8975f5c5SAndroid Build Coastguard Worker
410*8975f5c5SAndroid Build Coastguard Worker   Add a new system variable:
411*8975f5c5SAndroid Build Coastguard Worker
412*8975f5c5SAndroid Build Coastguard Worker   Variable: ANDROID_SDK
413*8975f5c5SAndroid Build Coastguard Worker
414*8975f5c5SAndroid Build Coastguard Worker   Value: path_to_sdk_directory (e.g. C:\Users\test\Appdata\Local\Android\Sdk)
415*8975f5c5SAndroid Build Coastguard Worker2. Install [Android NDK](https://developer.android.com/studio/projects/install-ndk).
416*8975f5c5SAndroid Build Coastguard Worker
417*8975f5c5SAndroid Build Coastguard Worker   Add a new system variable:
418*8975f5c5SAndroid Build Coastguard Worker
419*8975f5c5SAndroid Build Coastguard Worker   Variable: ANDROID_NDK
420*8975f5c5SAndroid Build Coastguard Worker
421*8975f5c5SAndroid Build Coastguard Worker   Value: path_to_ndk_directory (e.g. C:\Users\test\Appdata\Local\Android\Sdk\ndk\23.1.7779620)
422*8975f5c5SAndroid Build Coastguard Worker
423*8975f5c5SAndroid Build Coastguard Worker3. Install [Java 8](https://www.oracle.com/java/technologies/downloads/#java8).
424*8975f5c5SAndroid Build Coastguard Worker
425*8975f5c5SAndroid Build Coastguard Worker   Add a new system variable:
426*8975f5c5SAndroid Build Coastguard Worker
427*8975f5c5SAndroid Build Coastguard Worker   Variable: JAVA_HOME
428*8975f5c5SAndroid Build Coastguard Worker
429*8975f5c5SAndroid Build Coastguard Worker   Value: path_to_jdk1.8_directory (e.g. C:\Program Files\Java\jdk1.8.0_311)
430*8975f5c5SAndroid Build Coastguard Worker
431*8975f5c5SAndroid Build Coastguard Worker5. Install [Android Debug Bridge](https://developer.android.com/studio/releases/platform-tools).
432*8975f5c5SAndroid Build Coastguard Worker
433*8975f5c5SAndroid Build Coastguard Worker   Append android_sdk_platform-tools_directory to the Path system variable.
434*8975f5c5SAndroid Build Coastguard Worker
435*8975f5c5SAndroid Build Coastguard Worker   e.g. C:\Users\Test\AppData\Local\Android\Sdk\platform-tools
436*8975f5c5SAndroid Build Coastguard Worker
437*8975f5c5SAndroid Build Coastguard Worker
438*8975f5c5SAndroid Build Coastguard Worker##### Install Build Tools
439*8975f5c5SAndroid Build Coastguard Worker
440*8975f5c5SAndroid Build Coastguard Worker1. Install a bash shell. Git Bash comes with Git installation on Windows should work.
441*8975f5c5SAndroid Build Coastguard Worker2. Install [make](http://gnuwin32.sourceforge.net/packages/make.htm).
442*8975f5c5SAndroid Build Coastguard Worker   Add the path to bin folder of GnuWin32 to the Path system variable.
443*8975f5c5SAndroid Build Coastguard Worker
444*8975f5c5SAndroid Build Coastguard Worker
445*8975f5c5SAndroid Build Coastguard Worker##### Build RenderDoc Android APK on Windows
446*8975f5c5SAndroid Build Coastguard Worker
447*8975f5c5SAndroid Build Coastguard WorkerIf you are using the Git Bash that comes with MinGW generator, you can run below commands to build Android APK
448*8975f5c5SAndroid Build Coastguard Worker```
449*8975f5c5SAndroid Build Coastguard Workermkdir build-android-arm32
450*8975f5c5SAndroid Build Coastguard Workercd build-android-arm32/
451*8975f5c5SAndroid Build Coastguard Workercmake -DBUILD_ANDROID=On -DANDROID_ABI=armeabi-v7a -G "MinGW Makefiles" ..
452*8975f5c5SAndroid Build Coastguard Workermake -j
453*8975f5c5SAndroid Build Coastguard Workercd ../
454*8975f5c5SAndroid Build Coastguard Worker
455*8975f5c5SAndroid Build Coastguard Workermkdir build-android-arm64
456*8975f5c5SAndroid Build Coastguard Workercd build-android-arm64/
457*8975f5c5SAndroid Build Coastguard Workercmake -DBUILD_ANDROID=On -DANDROID_ABI=arm64-v8a -G "MinGW Makefiles" ..
458*8975f5c5SAndroid Build Coastguard Workermake -j
459*8975f5c5SAndroid Build Coastguard Workercd ../
460*8975f5c5SAndroid Build Coastguard Worker```
461*8975f5c5SAndroid Build Coastguard WorkerIf the generator type of the bash shell you are using is different from MinGW, replace the "MinGW" in the above cmake
462*8975f5c5SAndroid Build Coastguard Workercommand with the generator
463*8975f5c5SAndroid Build Coastguard Workertype you are using, as described in
464*8975f5c5SAndroid Build Coastguard Worker[RenderDoc Official Documentation](https://github.com/baldurk/renderdoc/blob/v1.x/docs/CONTRIBUTING/Compiling.md#android).
465*8975f5c5SAndroid Build Coastguard Worker
466*8975f5c5SAndroid Build Coastguard Worker
467*8975f5c5SAndroid Build Coastguard Worker##### Build Errors And Resolutions
468*8975f5c5SAndroid Build Coastguard Worker
469*8975f5c5SAndroid Build Coastguard Worker* **cmake command errors**
470*8975f5c5SAndroid Build Coastguard Worker
471*8975f5c5SAndroid Build Coastguard Worker```
472*8975f5c5SAndroid Build Coastguard WorkerError: Failed to run MSBuild command:
473*8975f5c5SAndroid Build Coastguard WorkerC:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/MSBuild.exe to get the value of
474*8975f5c5SAndroid Build Coastguard WorkerVCTargetsPath:
475*8975f5c5SAndroid Build Coastguard Workererror : The BaseOutputPath/OutputPath property is not set for project 'VCTargetsPath.vcxproj'.
476*8975f5c5SAndroid Build Coastguard WorkerPlease check to make sure that you have specified a valid combination of Configuration and Platform for this project.
477*8975f5c5SAndroid Build Coastguard WorkerConfiguration='Debug'  Platform='x64'.
478*8975f5c5SAndroid Build Coastguard Worker```
479*8975f5c5SAndroid Build Coastguard Worker
480*8975f5c5SAndroid Build Coastguard WorkerThis is due to the cmake command is using Visual Studio as the generator type. Run the cmake command with the
481*8975f5c5SAndroid Build Coastguard Workergenerator type "MinGW Makefiles" or "MSYS Makefiles".
482*8975f5c5SAndroid Build Coastguard Worker
483*8975f5c5SAndroid Build Coastguard Worker```Error: Does not match the generator used previously```
484*8975f5c5SAndroid Build Coastguard Worker
485*8975f5c5SAndroid Build Coastguard Worker
486*8975f5c5SAndroid Build Coastguard Worker
487*8975f5c5SAndroid Build Coastguard WorkerDelete the CMakeCache file in build directories build-android-arm64/ or build-android-arm32/.
488*8975f5c5SAndroid Build Coastguard Worker
489*8975f5c5SAndroid Build Coastguard Worker
490*8975f5c5SAndroid Build Coastguard Worker* **make command errors**
491*8975f5c5SAndroid Build Coastguard Worker
492*8975f5c5SAndroid Build Coastguard Worker```
493*8975f5c5SAndroid Build Coastguard Worker-Djava.ext.dirs is not supported.
494*8975f5c5SAndroid Build Coastguard WorkerError: Could not create the Java Virtual Machine.
495*8975f5c5SAndroid Build Coastguard WorkerError: A fatal exception has occurred. Program will exit.
496*8975f5c5SAndroid Build Coastguard Worker
497*8975f5c5SAndroid Build Coastguard Worker```
498*8975f5c5SAndroid Build Coastguard Worker
499*8975f5c5SAndroid Build Coastguard WorkerDowngrade Java JDK version to [Java 8](https://www.oracle.com/java/technologies/downloads/#java8).
500*8975f5c5SAndroid Build Coastguard Worker
501*8975f5c5SAndroid Build Coastguard Worker
502*8975f5c5SAndroid Build Coastguard Worker##### Steps to use the RenderDoc you just built
503*8975f5c5SAndroid Build Coastguard Worker1. Build arm32 and arm64 android packages. See [instructions](#build-renderdoc-android-apk-on-windows) in the above
504*8975f5c5SAndroid Build Coastguard Workersection.
505*8975f5c5SAndroid Build Coastguard Worker
506*8975f5c5SAndroid Build Coastguard Worker2. Uninstall the renderdoc package.
507*8975f5c5SAndroid Build Coastguard Worker
508*8975f5c5SAndroid Build Coastguard WorkerThis step is required if you have installed / used RenderDoc on the same Android device before. RenderDoc only pushes
509*8975f5c5SAndroid Build Coastguard Workerthe renderdoccmd APK to the Android device if it finds the version of the existing APK on the device is different from
510*8975f5c5SAndroid Build Coastguard Workerthe version of the APK we are going to install, and the version is dictated by the git hash it was built from. Therefore
511*8975f5c5SAndroid Build Coastguard Workerany local modifications in the RenderDoc codebase would not get picked up if we don't uninstall the old APK first.
512*8975f5c5SAndroid Build Coastguard Worker
513*8975f5c5SAndroid Build Coastguard Worker```
514*8975f5c5SAndroid Build Coastguard Workeradb uninstall org.renderdoc.renderdoccmd.arm64
515*8975f5c5SAndroid Build Coastguard Workeradb uninstall org.renderdoc.renderdoccmd.arm32
516*8975f5c5SAndroid Build Coastguard Worker```
517*8975f5c5SAndroid Build Coastguard Worker3. Build renderdoc on windows desktop by clicking "build solution" in visual studio.
518*8975f5c5SAndroid Build Coastguard Worker4. Launch renderdoc from visual studio, and push the android packages to android device by selecting the connected
519*8975f5c5SAndroid Build Coastguard Workerdevice at the bottom left corner.
520*8975f5c5SAndroid Build Coastguard Worker
521*8975f5c5SAndroid Build Coastguard Worker### Add SPIRV-to-GLSL Shader View Option
522*8975f5c5SAndroid Build Coastguard WorkerRenderDoc allows us to add and configure customized shader processing tools:
523*8975f5c5SAndroid Build Coastguard Workerhttps://renderdoc.org/docs/window/settings_window.html#shader-processing-tools-config.
524*8975f5c5SAndroid Build Coastguard Worker
525*8975f5c5SAndroid Build Coastguard WorkerTo configure RenderDoc to display shader source code in GLSL, instead of spirv,
526*8975f5c5SAndroid Build Coastguard Workerfollow the below steps:
527*8975f5c5SAndroid Build Coastguard Worker
528*8975f5c5SAndroid Build Coastguard Worker
529*8975f5c5SAndroid Build Coastguard Worker1. Get the SPIRV-Cross tool:
530*8975f5c5SAndroid Build Coastguard Worker
531*8975f5c5SAndroid Build Coastguard WorkerClone the SPIRV-Cross git repo: https://github.com/KhronosGroup/SPIRV-Cross:
532*8975f5c5SAndroid Build Coastguard Worker```
533*8975f5c5SAndroid Build Coastguard Workergit clone https://github.com/KhronosGroup/SPIRV-Cross.git
534*8975f5c5SAndroid Build Coastguard Worker```
535*8975f5c5SAndroid Build Coastguard WorkerCompile the SPIRV-Cross:
536*8975f5c5SAndroid Build Coastguard Worker```
537*8975f5c5SAndroid Build Coastguard Worker# inside SPIRV-Cross directory
538*8975f5c5SAndroid Build Coastguard Workermake
539*8975f5c5SAndroid Build Coastguard Worker```
540*8975f5c5SAndroid Build Coastguard Worker2. Open Shader Viewer Settings window: RenderDoc -> Tools -> Settings, and select
541*8975f5c5SAndroid Build Coastguard Worker   Shader Viewer on the left.
542*8975f5c5SAndroid Build Coastguard Worker3. Click Add on the bottom to add a new tool, and fill the new tool details:
543*8975f5c5SAndroid Build Coastguard Worker
544*8975f5c5SAndroid Build Coastguard Worker| Item       | Value                               |
545*8975f5c5SAndroid Build Coastguard Worker|------------|-------------------------------------|
546*8975f5c5SAndroid Build Coastguard Worker| Name       | SPIRV-CROSS                         |
547*8975f5c5SAndroid Build Coastguard Worker| Tool Type  | SPIRV-Cross                         |
548*8975f5c5SAndroid Build Coastguard Worker| Executable | <spirv-cross-repo-root>/spirv-cross |
549*8975f5c5SAndroid Build Coastguard Worker
550*8975f5c5SAndroid Build Coastguard Worker5. Restart RenderDoc.
551*8975f5c5SAndroid Build Coastguard Worker
552*8975f5c5SAndroid Build Coastguard Worker## Testing with Chrome Canary
553*8975f5c5SAndroid Build Coastguard Worker
554*8975f5c5SAndroid Build Coastguard WorkerMany of ANGLE's OpenGL ES entry points are exposed in Chromium as WebGL 1.0 and WebGL 2.0 APIs that
555*8975f5c5SAndroid Build Coastguard Workerare available via JavaScript. For testing purposes, custom ANGLE builds may be injected in Chrome
556*8975f5c5SAndroid Build Coastguard WorkerCanary.
557*8975f5c5SAndroid Build Coastguard Worker
558*8975f5c5SAndroid Build Coastguard Worker### Setup
559*8975f5c5SAndroid Build Coastguard Worker
560*8975f5c5SAndroid Build Coastguard Worker#### Windows
561*8975f5c5SAndroid Build Coastguard Worker
562*8975f5c5SAndroid Build Coastguard Worker1. Download and install [Google Chrome Canary](https://www.google.com/chrome/canary/).
563*8975f5c5SAndroid Build Coastguard Worker2. Build ANGLE x64, Release.
564*8975f5c5SAndroid Build Coastguard Worker3. Run `python scripts\update_chrome_angle.py` to replace Canary's ANGLE with your custom ANGLE
565*8975f5c5SAndroid Build Coastguard Worker   (note: Canary must be closed).
566*8975f5c5SAndroid Build Coastguard Worker
567*8975f5c5SAndroid Build Coastguard Worker#### Linux
568*8975f5c5SAndroid Build Coastguard Worker
569*8975f5c5SAndroid Build Coastguard Worker1. Install Google Chrome Dev (via apt, or otherwise).  Expected installation directory is
570*8975f5c5SAndroid Build Coastguard Worker   `/opt/google/chrome-unstable`.
571*8975f5c5SAndroid Build Coastguard Worker2. Build ANGLE for the running platform.  `is_component_build = false` is suggested in the GN args.
572*8975f5c5SAndroid Build Coastguard Worker3. Run `python scripts/update_chrome_angle.py` to replace Dev's ANGLE with your custom ANGLE
573*8975f5c5SAndroid Build Coastguard Worker4. Add ANGLE's build path to the `LD_LIBRARY_PATH` environment variable.
574*8975f5c5SAndroid Build Coastguard Worker
575*8975f5c5SAndroid Build Coastguard Worker#### macOS
576*8975f5c5SAndroid Build Coastguard Worker
577*8975f5c5SAndroid Build Coastguard Worker1. Download and install [Google Chrome Canary](https://www.google.com/chrome/canary/).
578*8975f5c5SAndroid Build Coastguard Worker2. Build ANGLE for the running platform; GN args should contain `is_debug = false`.
579*8975f5c5SAndroid Build Coastguard Worker3. Run `./scripts/update_chrome_angle.py` to replace Canary's ANGLE with your custom ANGLE.
580*8975f5c5SAndroid Build Coastguard Worker
581*8975f5c5SAndroid Build Coastguard Worker### Usage
582*8975f5c5SAndroid Build Coastguard Worker
583*8975f5c5SAndroid Build Coastguard WorkerRun Chrome:
584*8975f5c5SAndroid Build Coastguard Worker
585*8975f5c5SAndroid Build Coastguard Worker- On Windows: `%LOCALAPPDATA%\Google\Chrome SxS\chrome.exe`
586*8975f5c5SAndroid Build Coastguard Worker- On Linux: `/opt/google/chrome-unstable/google-chrome-unstable`
587*8975f5c5SAndroid Build Coastguard Worker- On macOS: `./Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary`
588*8975f5c5SAndroid Build Coastguard Worker
589*8975f5c5SAndroid Build Coastguard WorkerWith the following command-line options:
590*8975f5c5SAndroid Build Coastguard Worker
591*8975f5c5SAndroid Build Coastguard Worker* `--use-cmd-decoder=passthrough --use-gl=angle` and one of
592*8975f5c5SAndroid Build Coastguard Worker  * `--use-angle=d3d9` (Direct3D 9 renderer, Windows only)
593*8975f5c5SAndroid Build Coastguard Worker  * `--use-angle=d3d11` (Direct3D 11 renderer, Windows only)
594*8975f5c5SAndroid Build Coastguard Worker  * `--use-angle=d3d11on12` (Direct3D 11on12 renderer, Windows only)
595*8975f5c5SAndroid Build Coastguard Worker  * `--use-angle=gl` (OpenGL renderer)
596*8975f5c5SAndroid Build Coastguard Worker  * `--use-angle=gles` (OpenGL ES renderer)
597*8975f5c5SAndroid Build Coastguard Worker  * `--use-angle=vulkan` (Vulkan renderer)
598*8975f5c5SAndroid Build Coastguard Worker  * `--use-angle=swiftshader` (SwiftShader renderer)
599*8975f5c5SAndroid Build Coastguard Worker  * `--use-angle=metal` (Metal renderer, macOS only)
600*8975f5c5SAndroid Build Coastguard Worker
601*8975f5c5SAndroid Build Coastguard WorkerAdditional useful options:
602*8975f5c5SAndroid Build Coastguard Worker
603*8975f5c5SAndroid Build Coastguard Worker* `--enable-logging`: To see logs
604*8975f5c5SAndroid Build Coastguard Worker* `--disable-gpu-watchdog`: To disable Chromium's watchdog, killing the GPU process when slow (due
605*8975f5c5SAndroid Build Coastguard Worker  to a debug build for example)
606*8975f5c5SAndroid Build Coastguard Worker* `--disable-gpu-sandbox`: To disable Chromium's sandboxing features, if it's getting in the way of
607*8975f5c5SAndroid Build Coastguard Worker  testing.
608*8975f5c5SAndroid Build Coastguard Worker* `--disable-gpu-compositing`: To make sure only the WebGL test being debugged is run through ANGLE,
609*8975f5c5SAndroid Build Coastguard Worker  not the entirety of Chromium.
610