Integrating RenderDoc for Unconventional Apps

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on email

RenderDoc is a fantastic tool to debug your graphics application, with broad support for many graphics APIs. Sometimes however it’s impossible for RenderDoc to figure out what you’re doing. Point in case: I was recently debugging some shader compiler issue, for which I’ve been using a small test harness which does one submission with one dispatch. That’s not how any game looks like, there is no real frame beginning nor end, and I really only care about capturing the dispatch, so how do I tell RenderDoc that’s what I’m up to?

Fortunately, this is fairly easy, thanks to the RenderDoc API. It requires only a few small code changes, no extra linking step, and does not impact anything else when RenderDoc is not used. What do we need to do? It’s fairly simple: If we’re running with RenderDoc enabled, the renderdoc.dll will be present, so we can query the API off that. We then use it to manually start/stop a capture. If you already read the API documentation then you’re probably all set, if you haven’t, please stay around 😊

It’s quite easy in practice, all you need is to get hold of the RenderDoc API pointer, and once you have it, use the API to control RenderDoc. For the API you need to include the <renderdoc_app.h> header (which is in your RenderDoc installation directory), from there on it’s smooth sailing:

RENDERDOC_API_1_0_0* GetRenderDocApi() 
    RENDERDOC_API_1_0_0* rdoc = nullptr; 
    HMODULE module = GetModuleHandleA("renderdoc.dll"); 

    if (module == NULL) 
        return nullptr; 

    pRENDERDOC_GetAPI getApi = nullptr;
    getApi = (pRENDERDOC_GetAPI)GetProcAddress(module, "RENDERDOC_GetAPI"); 

    if (getApi == nullptr) 
        return nullptr;
    if (getApi(eRENDERDOC_API_Version_1_0_0, (void**)&rdoc) != 1) 
        return nullptr;

    return rdoc; 

This can be done any time in your application. Once you have your device ready, you can then trigger the capture using:

if (rdoc)
    rdoc->StartFrameCapture(nullptr, nullptr); 

and stop it using:

if (rdoc) 
    rdoc->EndFrameCapture(nullptr, nullptr); 

Note that if your app exists super-fast, like mine did – it only ran a few milliseconds — the UI may not keep up with it. An easy fix is to wait for a keypress before exiting. This is also just the start of what you can do with the RenderDoc API. Make sure to check the documentation for more details and advanced use cases!

Other content by Matthäus Chajdas

Fast Compaction with mbcnt

With shader extensions, we provide access to a much better tool to get compaction done: GCN provides a special op-code for compaction within a wavefront.

Vulkan® Barriers Explained

Vulkan barriers are unique as they requires you to provide what resources are transitioning and also specify a source and destination pipeline stage.

Optimizing Terrain Shadows

One thing which is often forgotten is shadow map rendering. As the tessellation level of the terrain is not optimized for the shadow camera, but for the primary camera, this often results in a very strong mismatch and shadow maps end up getting extremely over-tessellated.

Matthäus Chajdas
Matthäus Chajdas is a developer technology engineer at AMD. Links to third party sites, and references to third party trademarks, are provided for convenience and illustrative purposes only. Unless explicitly stated, AMD is not responsible for the contents of such links, and no third party endorsement of AMD or any of its products is implied.

You may also like...

Some light reading to take away with you. Our presentations, ISAs, manuals, whitepapers, and many more.

Developer guides

Browse our developer guides, and find valuable advice on developing with AMD hardware, ray tracing, Vulkan, DirectX, UE4, and lots more.

Words not enough? How about pictures? How about moving pictures? We have some amazing videos to share with you!

The home of great performance and optimization advice for AMD RDNA™ 2 GPUs, AMD Ryzen™ CPUs, and so much more.

Product Blogs

Our handy product blogs will help you make good use of our tools, SDKs, and effects, as well as sharing the latest features with new releases.


Discover our published publications.