mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-02-21 18:39:59 +00:00
Add nvprefs user override options
This commit is contained in:
parent
270716b862
commit
66150872b0
@ -329,6 +329,8 @@ namespace config {
|
||||
|
||||
{}, // nv
|
||||
true, // nv_realtime_hags
|
||||
true, // nv_opengl_vulkan_on_dxgi
|
||||
true, // nv_sunshine_high_power_mode
|
||||
{}, // nv_legacy
|
||||
|
||||
{
|
||||
@ -940,6 +942,8 @@ namespace config {
|
||||
generic_f(vars, "nvenc_twopass", video.nv.two_pass, nv::twopass_from_view);
|
||||
bool_f(vars, "nvenc_h264_cavlc", video.nv.h264_cavlc);
|
||||
bool_f(vars, "nvenc_realtime_hags", video.nv_realtime_hags);
|
||||
bool_f(vars, "nvenc_opengl_vulkan_on_dxgi", video.nv_opengl_vulkan_on_dxgi);
|
||||
bool_f(vars, "nvenc_latency_over_power", video.nv_sunshine_high_power_mode);
|
||||
|
||||
#ifndef __APPLE__
|
||||
video.nv_legacy.preset = video.nv.quality_preset + 11;
|
||||
|
@ -30,6 +30,8 @@ namespace config {
|
||||
|
||||
nvenc::nvenc_config nv;
|
||||
bool nv_realtime_hags;
|
||||
bool nv_opengl_vulkan_on_dxgi;
|
||||
bool nv_sunshine_high_power_mode;
|
||||
|
||||
struct {
|
||||
int preset;
|
||||
|
@ -158,6 +158,11 @@ namespace nvprefs {
|
||||
undo_data.reset();
|
||||
NvAPI_Status status;
|
||||
|
||||
if (!get_nvprefs_options().opengl_vulkan_on_dxgi) {
|
||||
// User requested to leave OpenGL/Vulkan DXGI swapchain setting alone
|
||||
return true;
|
||||
}
|
||||
|
||||
NvDRSProfileHandle profile_handle = 0;
|
||||
status = NvAPI_DRS_GetBaseProfile(session_handle, &profile_handle);
|
||||
if (status != NVAPI_OK) {
|
||||
@ -260,9 +265,26 @@ namespace nvprefs {
|
||||
setting.version = NVDRS_SETTING_VER1;
|
||||
status = NvAPI_DRS_GetSetting(session_handle, profile_handle, PREFERRED_PSTATE_ID, &setting);
|
||||
|
||||
if (status != NVAPI_OK ||
|
||||
setting.settingLocation != NVDRS_CURRENT_PROFILE_LOCATION ||
|
||||
setting.u32CurrentValue != PREFERRED_PSTATE_PREFER_MAX) {
|
||||
if (!get_nvprefs_options().sunshine_high_power_mode) {
|
||||
if (status == NVAPI_OK &&
|
||||
setting.settingLocation == NVDRS_CURRENT_PROFILE_LOCATION) {
|
||||
// User requested to not use high power mode for sunshine.exe,
|
||||
// remove the setting from application profile if it's been set previously
|
||||
|
||||
status = NvAPI_DRS_DeleteProfileSetting(session_handle, profile_handle, PREFERRED_PSTATE_ID);
|
||||
if (status != NVAPI_OK && status != NVAPI_SETTING_NOT_FOUND) {
|
||||
nvapi_error_message(status);
|
||||
error_message("NvAPI_DRS_DeleteProfileSetting() PREFERRED_PSTATE failed");
|
||||
return false;
|
||||
}
|
||||
modified = true;
|
||||
|
||||
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) {
|
||||
// Set power setting if needed
|
||||
setting = {};
|
||||
setting.version = NVDRS_SETTING_VER1;
|
||||
|
@ -2,6 +2,9 @@
|
||||
#include "nvprefs_common.h"
|
||||
#include "src/main.h" // sunshine boost::log severity levels
|
||||
|
||||
// read user override preferences from global sunshine config
|
||||
#include "src/config.h"
|
||||
|
||||
namespace nvprefs {
|
||||
|
||||
void
|
||||
@ -24,4 +27,12 @@ namespace nvprefs {
|
||||
BOOST_LOG(error) << "nvprefs: " << message;
|
||||
}
|
||||
|
||||
nvprefs_options
|
||||
get_nvprefs_options() {
|
||||
nvprefs_options options;
|
||||
options.opengl_vulkan_on_dxgi = config::video.nv_opengl_vulkan_on_dxgi;
|
||||
options.sunshine_high_power_mode = config::video.nv_sunshine_high_power_mode;
|
||||
return options;
|
||||
}
|
||||
|
||||
} // namespace nvprefs
|
||||
|
@ -45,4 +45,12 @@ namespace nvprefs {
|
||||
void
|
||||
error_message(const std::string &message);
|
||||
|
||||
struct nvprefs_options {
|
||||
bool opengl_vulkan_on_dxgi = true;
|
||||
bool sunshine_high_power_mode = true;
|
||||
};
|
||||
|
||||
nvprefs_options
|
||||
get_nvprefs_options();
|
||||
|
||||
} // namespace nvprefs
|
||||
|
Loading…
x
Reference in New Issue
Block a user