style: adjust clang-format rules (#2186)
Co-authored-by: Vithorio Polten <reach@vithor.io>
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
* @file src/platform/windows/nvprefs/driver_settings.cpp
|
||||
* @brief Definitions for nvidia driver settings.
|
||||
*/
|
||||
// local includes
|
||||
// this include
|
||||
#include "driver_settings.h"
|
||||
|
||||
// local includes
|
||||
#include "nvprefs_common.h"
|
||||
|
||||
namespace {
|
||||
@@ -11,15 +13,13 @@ namespace {
|
||||
const auto sunshine_application_profile_name = L"SunshineStream";
|
||||
const auto sunshine_application_path = L"sunshine.exe";
|
||||
|
||||
void
|
||||
nvapi_error_message(NvAPI_Status status) {
|
||||
void nvapi_error_message(NvAPI_Status status) {
|
||||
NvAPI_ShortString message = {};
|
||||
NvAPI_GetErrorMessage(status, message);
|
||||
nvprefs::error_message(std::string("NvAPI error: ") + message);
|
||||
}
|
||||
|
||||
void
|
||||
fill_nvapi_string(NvAPI_UnicodeString &dest, const wchar_t *src) {
|
||||
void fill_nvapi_string(NvAPI_UnicodeString &dest, const wchar_t *src) {
|
||||
static_assert(sizeof(NvU16) == sizeof(wchar_t));
|
||||
memcpy_s(dest, NVAPI_UNICODE_STRING_MAX * sizeof(NvU16), src, (wcslen(src) + 1) * sizeof(wchar_t));
|
||||
}
|
||||
@@ -34,9 +34,10 @@ namespace nvprefs {
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
driver_settings_t::init() {
|
||||
if (session_handle) return true;
|
||||
bool driver_settings_t::init() {
|
||||
if (session_handle) {
|
||||
return true;
|
||||
}
|
||||
|
||||
NvAPI_Status status;
|
||||
|
||||
@@ -56,8 +57,7 @@ namespace nvprefs {
|
||||
return load_settings();
|
||||
}
|
||||
|
||||
void
|
||||
driver_settings_t::destroy() {
|
||||
void driver_settings_t::destroy() {
|
||||
if (session_handle) {
|
||||
NvAPI_DRS_DestroySession(session_handle);
|
||||
session_handle = 0;
|
||||
@@ -65,9 +65,10 @@ namespace nvprefs {
|
||||
NvAPI_Unload();
|
||||
}
|
||||
|
||||
bool
|
||||
driver_settings_t::load_settings() {
|
||||
if (!session_handle) return false;
|
||||
bool driver_settings_t::load_settings() {
|
||||
if (!session_handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NvAPI_Status status = NvAPI_DRS_LoadSettings(session_handle);
|
||||
if (status != NVAPI_OK) {
|
||||
@@ -80,9 +81,10 @@ namespace nvprefs {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
driver_settings_t::save_settings() {
|
||||
if (!session_handle) return false;
|
||||
bool driver_settings_t::save_settings() {
|
||||
if (!session_handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NvAPI_Status status = NvAPI_DRS_SaveSettings(session_handle);
|
||||
if (status != NVAPI_OK) {
|
||||
@@ -94,9 +96,10 @@ namespace nvprefs {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
driver_settings_t::restore_global_profile_to_undo(const undo_data_t &undo_data) {
|
||||
if (!session_handle) return false;
|
||||
bool driver_settings_t::restore_global_profile_to_undo(const undo_data_t &undo_data) {
|
||||
if (!session_handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto &swapchain_data = undo_data.get_opengl_swapchain();
|
||||
if (swapchain_data) {
|
||||
@@ -130,8 +133,7 @@ namespace nvprefs {
|
||||
error_message("NvAPI_DRS_SetSetting() OGL_CPL_PREFER_DXPRESENT failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
status = NvAPI_DRS_DeleteProfileSetting(session_handle, profile_handle, OGL_CPL_PREFER_DXPRESENT_ID);
|
||||
|
||||
if (status != NVAPI_OK && status != NVAPI_SETTING_NOT_FOUND) {
|
||||
@@ -142,11 +144,9 @@ namespace nvprefs {
|
||||
}
|
||||
|
||||
info_message("Restored OGL_CPL_PREFER_DXPRESENT for base profile");
|
||||
}
|
||||
else if (status == NVAPI_OK || status == NVAPI_SETTING_NOT_FOUND) {
|
||||
} else if (status == NVAPI_OK || status == NVAPI_SETTING_NOT_FOUND) {
|
||||
info_message("OGL_CPL_PREFER_DXPRESENT has been changed from our value in base profile, not restoring");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
error_message("NvAPI_DRS_GetSetting() OGL_CPL_PREFER_DXPRESENT failed");
|
||||
return false;
|
||||
}
|
||||
@@ -155,9 +155,10 @@ namespace nvprefs {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
driver_settings_t::check_and_modify_global_profile(std::optional<undo_data_t> &undo_data) {
|
||||
if (!session_handle) return false;
|
||||
bool driver_settings_t::check_and_modify_global_profile(std::optional<undo_data_t> &undo_data) {
|
||||
if (!session_handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
undo_data.reset();
|
||||
NvAPI_Status status;
|
||||
@@ -184,8 +185,7 @@ namespace nvprefs {
|
||||
undo_data = undo_data_t();
|
||||
if (status == NVAPI_OK) {
|
||||
undo_data->set_opengl_swapchain(OGL_CPL_PREFER_DXPRESENT_PREFER_ENABLED, setting.u32CurrentValue);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
undo_data->set_opengl_swapchain(OGL_CPL_PREFER_DXPRESENT_PREFER_ENABLED, std::nullopt);
|
||||
}
|
||||
|
||||
@@ -204,8 +204,7 @@ namespace nvprefs {
|
||||
}
|
||||
|
||||
info_message("Changed OGL_CPL_PREFER_DXPRESENT to OGL_CPL_PREFER_DXPRESENT_PREFER_ENABLED for base profile");
|
||||
}
|
||||
else if (status != NVAPI_OK) {
|
||||
} else if (status != NVAPI_OK) {
|
||||
nvapi_error_message(status);
|
||||
error_message("NvAPI_DRS_GetSetting() OGL_CPL_PREFER_DXPRESENT failed");
|
||||
return false;
|
||||
@@ -214,9 +213,10 @@ namespace nvprefs {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
driver_settings_t::check_and_modify_application_profile(bool &modified) {
|
||||
if (!session_handle) return false;
|
||||
bool driver_settings_t::check_and_modify_application_profile(bool &modified) {
|
||||
if (!session_handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
modified = false;
|
||||
NvAPI_Status status;
|
||||
@@ -285,10 +285,9 @@ namespace nvprefs {
|
||||
|
||||
info_message(std::wstring(L"Removed PREFERRED_PSTATE for ") + sunshine_application_path);
|
||||
}
|
||||
}
|
||||
else if (status != NVAPI_OK ||
|
||||
setting.settingLocation != NVDRS_CURRENT_PROFILE_LOCATION ||
|
||||
setting.u32CurrentValue != PREFERRED_PSTATE_PREFER_MAX) {
|
||||
} else if (status != NVAPI_OK ||
|
||||
setting.settingLocation != NVDRS_CURRENT_PROFILE_LOCATION ||
|
||||
setting.u32CurrentValue != PREFERRED_PSTATE_PREFER_MAX) {
|
||||
// Set power setting if needed
|
||||
setting = {};
|
||||
setting.version = NVDRS_SETTING_VER1;
|
||||
|
||||
Reference in New Issue
Block a user