How to capture WebGL with Renderdoc
This setup only works on Windows with Chrome (might work with Chromium, Edge etc. as well).
- Enable process injection in RenderDoc by going to “Tools -> Settings” and checking “Enable process injection” option.
- Restart RenderDoc.
- Close all instances of Chrome running on your system.
- Launch cmd.exe and run Chrome like this:
cmd /C "set RENDERDOC_HOOK_EGL=0 && "C:\Program Files\Google\Chrome\Application\chrome.exe" --gpu-startup-dialog --disable_direct_composition=1 --disable-gpu-sandbox"
or like this in Git Bash and other Bash-like terminals:
RENDERDOC_HOOK_EGL=0 "C:\Program Files\Google\Chrome\Application\chrome.exe" --gpu-startup-dialog --disable_direct_composition=1 --disable-gpu-sandbox
The location of Chrome might differ on your system (sometimes it can be in “Program Files (x86)”. Use “Open File Location” on the Chrome’s shortcut to find where it is.
The Chrome will complain about --disable-gpu-sandbox
flag - you should just ignore it. Without this flag, it’s not possible to do RenderDoc captures.
-
A blank (white) window with a “Google Chrome GPU” popup will appear - don’t press “OK” yet.
-
In RenderDoc, go to “File -> Inject into Process”
-
Double-click on the process which has “Google Chrome Gpu” window title (you can filter by “chrome” to find it more easily).
- Alt+Tab to the popup and press “OK” (you can also note that PIDs reported by popup and in RenderDoc match).
-
You should see the RenderDoc text in top-left of your Chrome window. Navigate to the page you want to capture. You can now press F12 to capture the frame.
-
Note that ANGLE will probably use D3D11 as WebGL backend by default on Windows. I tried switching to OpenGL in
chrome:flags
but the capture then fails, unfortunately. -
Here are some screenshots of my game captured with RenderDoc.
Unfortunately, the debug capabilities of this are not as powerful as for the desktop apps - you can’t inspect and change the shaders, D3D11 calls don’t match to WebGL calls one-to-one, ANGLE renames your uniforms, buffers and textures etc. - but it’s better than nothing!