shim: retry application-ID init with d4r's project identity

NGX 617.14 rejects application-ID initialization on this path (Cyberpunk
2077: 0xBAD0000C, or SR unavailable with 0xBAD00004). Streamline's RR
plugin reads capabilities right after that first Init, so a failure
there hides RR for the session even though the game's later project-ID
Init works. When the app-ID NVSDK_NGX_CUDA_Init fails and the caller
gave no project identity, retry once with d4r's own project identity
(the diagnostics' default) so the first Init succeeds; log the retry as
D4R_NGX_IDENTITY_FALLBACK. Port of the windows-branch fix in
tools/windows/ngx_runtime_initialization.h.

Co-authored-by: omp <[email protected]>
This commit is contained in:
woutermansandomp authored and ayo committed 2026-10-19 11:29:11 -04:00
1 parent 32d84d7fd6
commit ca93d0fbf7
1 file changed
+16
+16
View File
@@ -2046,6 +2046,22 @@ static NgxResult initialize(unsigned long long applicationId, const wchar_t* dat
result = g.worker.call([&] { return g.ngx.init(id, g.dataPath.c_str(), &g.featureInfo, apiVersion); });
logf("NVSDK_NGX_CUDA_Init(app=%llu, sdk=0x%x) -> 0x%08x", id, version, result);
}
const bool hasProject = project != nullptr && !project->id.empty();
if (result != NGX_SUCCESS && !hasProject && g.ngx.initProjectId != nullptr)
{
// NGX 617.14 rejects application-ID initialization on this path (Cyberpunk 2077:
// 0xBAD0000C, or SR unavailable with 0xBAD00004). Streamline's RR plugin reads
// capabilities right after that first Init, so a failure there hides RR for the
// session even though the game's later project-ID Init works. Retry with d4r's
// own project identity (the diagnostics' default) so the first Init succeeds.
logf("D4R_NGX_IDENTITY_FALLBACK application=%llu: 0x%08x", id, result);
result = g.worker.call([&] {
return g.ngx.initProjectId("24480451-f00d-face-1304-0308dabad187", 0, "1.0", g.dataPath.c_str(),
apiVersion, &g.featureInfo);
});
logf("NVSDK_NGX_CUDA_Init_ProjectID(d4r fallback project=24480451-f00d-face-1304-0308dabad187, engine=0 1.0, sdk=0x%x) -> 0x%08x",
version, result);
}
using LoadErrorFn = const char*(WINAPI*)();
const auto loadError = reinterpret_cast<LoadErrorFn>(reinterpret_cast<void*>(GetProcAddress(g.cuda, "d4rLoadError")));
if (loadError != nullptr && loadError()[0] != '\0')