-
Notifications
You must be signed in to change notification settings - Fork 28
Add support for RenderDoc API to offload test suite to capture for Vulkan on Windows #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,11 @@ | |||||||||||||||
| #include "Support/Pipeline.h" | ||||||||||||||||
| #include "llvm/ADT/DenseSet.h" | ||||||||||||||||
| #include "llvm/Support/Error.h" | ||||||||||||||||
| #include "renderdoc_app.h" | ||||||||||||||||
|
|
||||||||||||||||
| #ifdef _WIN32 | ||||||||||||||||
| #include <windows.h> | ||||||||||||||||
| #endif | ||||||||||||||||
|
|
||||||||||||||||
| #include <memory> | ||||||||||||||||
| #include <numeric> | ||||||||||||||||
|
|
@@ -1951,10 +1956,36 @@ class VKDevice : public offloadtest::Device { | |||||||||||||||
| return llvm::Error::success(); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| llvm::Error executeProgram(Pipeline &P) override { | ||||||||||||||||
| llvm::Error executeProgram(Pipeline &P, bool Capture = false) override { | ||||||||||||||||
| RENDERDOC_API_1_4_1 *RDocAPI = NULL; | ||||||||||||||||
| if (Capture) { | ||||||||||||||||
| // Initialize RenderDoc on Windows | ||||||||||||||||
| #if defined(_WIN32) | ||||||||||||||||
| if (HMODULE Mod = GetModuleHandleA("renderdoc.dll")) { | ||||||||||||||||
| pRENDERDOC_GetAPI RENDERDOC_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"; | ||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||||||||||||
| } else { | ||||||||||||||||
| DWORD error = GetLastError(); | ||||||||||||||||
| llvm::outs() << "Failed to get renderdoc dll: " << error << "\n"; | ||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Kinda hard to find the right balance for polish for a feature like this. |
||||||||||||||||
| } | ||||||||||||||||
| #endif | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| InvocationState State; | ||||||||||||||||
| if (auto Err = createDevice(State)) | ||||||||||||||||
| return Err; | ||||||||||||||||
|
|
||||||||||||||||
| // Start capture | ||||||||||||||||
| if (RDocAPI) { | ||||||||||||||||
| RDocAPI->StartFrameCapture(NULL, NULL); | ||||||||||||||||
| llvm::outs() << "RenderDoc frame capture started.\n"; | ||||||||||||||||
| } else if(Capture) | ||||||||||||||||
| llvm::outs() << "RenderDoc frame capture NOT started because we failed to \ | ||||||||||||||||
| initialize RenderDoc API. It is only supported on Windows."; | ||||||||||||||||
|
Comment on lines
+1985
to
+1987
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I don't know why the diffs on suggestions is so broken these days - anyway suggestion is to add braces around the else if.
|
||||||||||||||||
|
|
||||||||||||||||
| llvm::outs() << "Physical device created.\n"; | ||||||||||||||||
| if (auto Err = createShaderModules(P, State)) | ||||||||||||||||
| return Err; | ||||||||||||||||
|
|
@@ -1998,6 +2029,25 @@ class VKDevice : public offloadtest::Device { | |||||||||||||||
| return Err; | ||||||||||||||||
| llvm::outs() << "Compute pipeline created.\n"; | ||||||||||||||||
|
|
||||||||||||||||
| // Stop frame capture | ||||||||||||||||
| if (RDocAPI) { | ||||||||||||||||
| uint32_t Ret = RDocAPI->EndFrameCapture(NULL, NULL); | ||||||||||||||||
| if (Ret) { | ||||||||||||||||
| llvm::outs() << "RenderDoc frame capture ended.\n"; | ||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. paging the tab police!! |
||||||||||||||||
| uint32_t CaptureID = RDocAPI->GetNumCaptures() - 1; | ||||||||||||||||
| uint32_t PathLength; | ||||||||||||||||
| // get PathLength | ||||||||||||||||
| if (RDocAPI->GetCapture(CaptureID, NULL, &PathLength, NULL)) { | ||||||||||||||||
| std::string CapturePath(PathLength, ' '); | ||||||||||||||||
| // populate the path | ||||||||||||||||
| RDocAPI->GetCapture(CaptureID, CapturePath.data(), NULL, NULL); | ||||||||||||||||
| llvm::outs() << "The RenderDoc frame capture has been saved to " << CapturePath << "\n"; | ||||||||||||||||
| } else | ||||||||||||||||
| llvm::outs() << "No capture generated.\n"; | ||||||||||||||||
| } else | ||||||||||||||||
| llvm::outs() << "Capture failed.\n"; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| if (auto Err = cleanup(State)) | ||||||||||||||||
| return Err; | ||||||||||||||||
| llvm::outs() << "Cleanup complete.\n"; | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
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.