Sunshine v2026.319.132152
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
40 public:
42
43 bool init();
44
45 void destroy();
46
47 bool load_settings();
48
49 bool save_settings();
50
51 bool restore_global_profile_to_undo(const undo_data_t &undo_data);
52
53 bool check_and_modify_global_profile(std::optional<undo_data_t> &undo_data);
54
55 bool check_and_modify_application_profile(bool &modified);
56
57 private:
58 NvDRSSessionHandle session_handle = nullptr;
59 };
60
61} // namespace nvprefs
Definition driver_settings.h:39
Definition undo_data.h:15
Declarations for undoing changes to nvidia preferences.