Skip to content

Conversation

@spall
Copy link
Collaborator

@spall spall commented Jan 14, 2026

Add support to get a frame capture for Vulkan on Windows using the RenderDoc API.

Copy link
Collaborator

@damyanp damyanp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some code conventions things mentioned, plus I do think we should fix the error handling from GetAPI.

(pRENDERDOC_GetAPI)GetProcAddress(Mod, "RENDERDOC_GetAPI");
int Ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_4_1, (void **)&RDocAPI);
assert(Ret == 1);
llvm::outs() << "RenderDoc API initialized.\n";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really check the return code from GetAPI - so if the user has, say, an older version of renderdoc.dll then it'll happily say "RenderDoc API initialized" and then not take a capture.

Related to this, I don't think we want to handle runtime errors like this with an assert.

llvm::outs() << "RenderDoc API initialized.\n";
} else {
DWORD error = GetLastError();
llvm::outs() << "Failed to get renderdoc dll: " << error << "\n";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

llvm::mapLastWindowsError() might be interesting to look at here. Looks like it should convert to strings as well.

Kinda hard to find the right balance for polish for a feature like this.

Comment on lines +1985 to +1987
} else if(Capture)
llvm::outs() << "RenderDoc frame capture NOT started because we failed to \
initialize RenderDoc API. It is only supported on Windows.";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if(Capture)
llvm::outs() << "RenderDoc frame capture NOT started because we failed to \
initialize RenderDoc API. It is only supported on Windows.";
} else if(Capture) {
llvm::outs() << "RenderDoc frame capture NOT started because we failed to \
initialize RenderDoc API. It is only supported on Windows.";
}

I don't know why the diffs on suggestions is so broken these days - anyway suggestion is to add braces around the else if.

https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements:

Inconsistent bracing within if/else if/else chains (if one block requires braces, all must)

if (RDocAPI) {
uint32_t Ret = RDocAPI->EndFrameCapture(NULL, NULL);
if (Ret) {
llvm::outs() << "RenderDoc frame capture ended.\n";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paging the tab police!!

if (Capture) {
// Initialize RenderDoc on Windows
#if defined(_WIN32)
if (HMODULE Mod = GetModuleHandleA("renderdoc.dll")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leaks the module. I don't know if we care about that though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants