Hello everyone!
I thought I’d share what I’ve been working on for the last couple of weeks.
One thing I learned from my tag buffer adventure was that debugging certain parts of UE4 can really be a pain, and one notable area is the rendering pipeline and shaders.
All tools I tried either I could not get to work (RenderDoc) or they just crashed (nSight & VS GPU debugging tools). As a pleasant surprise though, the main developer of
RenderDoc, BaldurK (baldurk (Baldur Karlsson) · GitHub BIG PROPS to this guy!!) contacted me, curious of why I couldn’t get it to work. With his help, I managed to sort out what was wrong and made a wiki entry to explain how others could get it to work
using the same techniques. I’m a big fan of renderdoc, especially since it went open source, and as it was kind of awkward setting it up with UE4, plus there were some things that didn’t mesh
that well with the editor, I decided to try to make it easy for everyone by making a set of plugins that integrates renderdoc with UE4 in a more user friendly manner.
I say a set of plugins since it is actually two of them. The first one is simply a loader that injects the proper DLL as early as possible to be able to catch device creation etc.
This would not have been needed if the same plugin could get callbacks for all different load stages, but this is currently, as far as I know, not supported.
The plugin has a few features:
-
It detects your current installation of renderdoc, so you are not bound to the version I use, and can update at will as long as the API is compatible.
If you don’t have an installation, and have just downloaded a zip, built it yourself etc. It will prompt for a path. Or you could set the path yourself in your project game.ini under [RenderDoc] BinaryPath=PATHGOESHERE -
It adds capture buttons to all viewports of the editor. This means you no longer have to cycle swap chains to get to the element you want. When you press the capture button (or its hotkey) it will capture the window the viewport
is attached to, and then launch renderdoc with that capture as argument. It also opens a connection to renderdoc so you can perform subsequent captures etc.
- I’ve added a small options menu button next to the capture button. This small window lets you set several properties that control how the plugin operates:
The settings are:
Capture callstacks
Save the call stack for every draw event in addition to the event itself. This is useful when you need additional information to solve your particular problem.
Capture all resources:
Capture all resources, including those that are not referenced by the current frame.
Save all initial states
Save the initial status of all resources, even if we think that they will be overwritten in this frame.
In addition, when UE4 compiles it’s shaders, it strips them of all of their symbols and other meta-data, presumably to make them more compact.
This makes them very hard to debug though as you can no longer see the variable names, attributes etc.
I’m working on a pull request that adds support to optionally not strip the data by sending a flag to the compiler. I don’t want to make this the default behavior though as that might break some peoples project (deploy) that is why it will default to off, but I highly recommend using this when debugging.
I am not currently done with this feature, but you can follow my progress on the AutoCompileShaders branch of the repository.
After a capture is complete, the plugin simply launches the RenderDoc UI. After this point, it is just like any other RenderDoc debugging session. If you are new to RenderDoc, I would suggest checking out these video tutorials:
RenderDoc - An overview - YouTube
To install the plugin, simply clone this git-repo to your project/plugins/ folder:
GitHub - Temaran/UE4RenderDocPlugin: A plugin that adds easy access to Renderdoc inside UE4</title
You can also add the plugin as an engine plugin by adding it to your engine plugin folder, although I recommend using the project plugin route as I feel it is cleaner.
The plugin also requires recent code from RenderDoc’s github (GitHub - baldurk/renderdoc: RenderDoc is a stand-alone graphics debugging tool.) which isn’t in the latest stable release.
You can find a beta release here: http://renderdoc.org/builds or build it yourself from source if you prefer.