| Integrating RenderDoc for Unconventional Apps

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 POSTS BY MATTHAEUS 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.

GCN Shader Extensions for Direct3D and Vulkan

One of the mandates of GPUOpen is to give developers better access to the hardware, and this post details extensions for Vulkan and Direct3D12 that expose additional GCN features to developers.

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.

Matthaeus 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...

Tutorials Library

Browse all our fantastic tutorials, including programming techniques, performance improvements, guest blogs, and how to use our tools.

Samples Library

Browse all our useful samples. Perfect for when you’re needing to get started, want to integrate one of our libraries, and much more.