Sunshine master
Self-hosted game stream host for Moonlight.
driver_settings.h
Go to the documentation of this file.
1
5#pragma once
6
7// local includes first so standard library headers are pulled in before nvapi's SAL macros
8#include "undo_data.h"
9
10// nvapi headers
11// disable clang-format header reordering
12// as <NvApiDriverSettings.h> needs types from <nvapi.h>
13// clang-format off
14
15// With GCC/MinGW, nvapi_lite_salend.h (included transitively via nvapi_lite_d3dext.h)
16// undefines all SAL annotation macros (e.g. __success, __in, __out, __inout) after
17// nvapi_lite_salstart.h had defined them. This leaves NVAPI_INTERFACE and other macros
18// that use SAL annotations broken for the rest of nvapi.h. Defining __NVAPI_EMPTY_SAL
19// makes nvapi_lite_salend.h a no-op, preserving the SAL macro definitions throughout.
20// After nvapi.h, we include nvapi_lite_salend.h explicitly (without __NVAPI_EMPTY_SAL)
21// to clean up the SAL macros and prevent them from polluting subsequent includes.
22#if defined(__GNUC__)
23 #define __NVAPI_EMPTY_SAL
24#endif
25
26#include <nvapi.h>
27#include <NvApiDriverSettings.h>
28
29#if defined(__GNUC__)
30 #undef __NVAPI_EMPTY_SAL
31 // Clean up SAL macros that nvapi_lite_salstart.h defined and salend.h was
32 // prevented from cleaning up (due to __NVAPI_EMPTY_SAL above).
33 #include <nvapi_lite_salend.h>
34#endif
35// clang-format on
36
37namespace nvprefs {
38
43 public:
45
51 bool init();
52
56 void destroy();
57
63 bool load_settings();
64
70 bool save_settings();
71
78 bool restore_global_profile_to_undo(const undo_data_t &undo_data);
79
86 bool check_and_modify_global_profile(std::optional<undo_data_t> &undo_data);
87
94 bool check_and_modify_application_profile(bool &modified);
95
96 private:
97 NvDRSSessionHandle session_handle = nullptr;
98 };
99
100} // namespace nvprefs
NVIDIA driver profile settings loaded for inspection or modification.
Definition driver_settings.h:42
void destroy()
Destroy the native resource owned by the wrapper.
Definition driver_settings.cpp:60
bool load_settings()
Load settings data from the backing API or store.
Definition driver_settings.cpp:68
bool check_and_modify_global_profile(std::optional< undo_data_t > &undo_data)
Compare and update global NVIDIA profile settings.
Definition driver_settings.cpp:158
bool init()
Load NVIDIA profile settings for the current driver state.
Definition driver_settings.cpp:37
bool restore_global_profile_to_undo(const undo_data_t &undo_data)
Restore global NVIDIA profile settings from undo data.
Definition driver_settings.cpp:99
bool check_and_modify_application_profile(bool &modified)
Compare and update Sunshine NVIDIA application profile settings.
Definition driver_settings.cpp:216
bool save_settings()
Save settings data through the backing API or store.
Definition driver_settings.cpp:84
Serializable NVIDIA profile state saved before preference changes.
Definition undo_data.h:18
Declarations for undoing changes to nvidia preferences.