Merge pull request #85121 from jsjtxietian/return-early-nv

Prevent crash in  `_nvapi_disable_threaded_optimization` when attached to renderdoc
This commit is contained in:
Rémi Verschelde 2023-11-21 10:44:27 +01:00
commit b5779cc5c0
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 6 additions and 2 deletions

View File

@ -104,8 +104,8 @@ static bool nvapi_err_check(const char *msg, int status) {
} }
// On windows we have to disable threaded optimization when using NVIDIA graphics cards // On windows we have to disable threaded optimization when using NVIDIA graphics cards
// to avoid stuttering, see https://github.com/microsoft/vscode-cpptools/issues/6592 // to avoid stuttering, see see https://stackoverflow.com/questions/36959508/nvidia-graphics-driver-causing-noticeable-frame-stuttering/37632948
// also see https://github.com/Ryujinx/Ryujinx/blob/master/Ryujinx.Common/GraphicsDriver/NVThreadedOptimization.cs // also see https://github.com/Ryujinx/Ryujinx/blob/master/src/Ryujinx.Common/GraphicsDriver/NVThreadedOptimization.cs
void GLManagerNative_Windows::_nvapi_disable_threaded_optimization() { void GLManagerNative_Windows::_nvapi_disable_threaded_optimization() {
HMODULE nvapi = 0; HMODULE nvapi = 0;
#ifdef _WIN64 #ifdef _WIN64
@ -149,6 +149,10 @@ void GLManagerNative_Windows::_nvapi_disable_threaded_optimization() {
NvDRSSessionHandle session_handle; NvDRSSessionHandle session_handle;
if (NvAPI_DRS_CreateSession == nullptr) {
return;
}
if (!nvapi_err_check("NVAPI: Error creating DRS session", NvAPI_DRS_CreateSession(&session_handle))) { if (!nvapi_err_check("NVAPI: Error creating DRS session", NvAPI_DRS_CreateSession(&session_handle))) {
NvAPI_Unload(); NvAPI_Unload();
return; return;