nv2a: Fix nv2a_dbg_renderdoc_init on Windows

This commit is contained in:
Matt Borgerson 2024-07-28 23:59:32 -07:00 committed by mborgerson
parent 4e75b5e3ce
commit f6d70abd04
1 changed files with 27 additions and 16 deletions

View File

@ -45,26 +45,37 @@ void nv2a_dbg_renderdoc_init(void)
#ifdef _WIN32 #ifdef _WIN32
HMODULE renderdoc = GetModuleHandleA("renderdoc.dll"); HMODULE renderdoc = GetModuleHandleA("renderdoc.dll");
if (renderdoc) { if (!renderdoc) {
pRENDERDOC_GetAPI RENDERDOC_GetAPI = fprintf(stderr, "Error: Failed to open renderdoc library: 0x%lx\n",
(pRENDERDOC_GetAPI)GetProcAddress(renderdoc, "RENDERDOC_GetAPI"); GetLastError());
#else return;
void *renderdoc = dlopen( }
pRENDERDOC_GetAPI RENDERDOC_GetAPI =
(pRENDERDOC_GetAPI)GetProcAddress(renderdoc, "RENDERDOC_GetAPI");
#else // _WIN32
#ifdef __APPLE__ #ifdef __APPLE__
"librenderdoc.dylib", void *renderdoc = dlopen("librenderdoc.dylib", RTLD_LAZY);
#else #else
"librenderdoc.so", void *renderdoc = dlopen("librenderdoc.so", RTLD_LAZY);
#endif #endif
RTLD_LAZY); if (!renderdoc) {
if (renderdoc) { fprintf(stderr, "Error: Failed to open renderdoc library: %s\n",
pRENDERDOC_GetAPI RENDERDOC_GetAPI = dlerror());
(pRENDERDOC_GetAPI)dlsym(renderdoc, "RENDERDOC_GetAPI"); return;
}
pRENDERDOC_GetAPI RENDERDOC_GetAPI =
(pRENDERDOC_GetAPI)dlsym(renderdoc, "RENDERDOC_GetAPI");
#endif // _WIN32 #endif // _WIN32
int ret =
RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_6_0, (void **)&rdoc_api); if (!RENDERDOC_GetAPI) {
assert(ret == 1 && "Failed to retrieve RenderDoc API."); fprintf(stderr, "Error: Could not get RENDERDOC_GetAPI address\n");
} else { return;
fprintf(stderr, "Error: Failed to open renderdoc library: %s\n", dlerror()); }
int ret =
RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_6_0, (void **)&rdoc_api);
if (ret != 1) {
fprintf(stderr, "Error: Failed to retrieve RenderDoc API.\n");
} }
} }