-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvidia.hpp
71 lines (56 loc) · 1.79 KB
/
nvidia.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef SHADOW_CAST_NVIDIA_HPP_INCLUDED
#define SHADOW_CAST_NVIDIA_HPP_INCLUDED
#include "./nvidia/NvFBC.h"
#include "./nvidia/cuda.hpp"
#include "./utils.hpp"
#include "error.hpp"
#include <array>
#include <cinttypes>
#include <memory>
#include <stdexcept>
namespace sc
{
[[maybe_unused]] auto constexpr kNvFBCKeyEnvVar = "SHADOW_CAST_NVFBC_KEY";
using NvFBC = NVFBC_API_FUNCTION_LIST;
struct NvFBCHandleDeleter
{
using pointer = NonPointer<NVFBC_SESSION_HANDLE>;
NvFBCHandleDeleter(NvFBC fbc) noexcept;
protected:
NvFBC fbc_;
};
struct NvFBCError : std::runtime_error
{
explicit NvFBCError(NvFBC, NVFBC_SESSION_HANDLE);
};
struct NvFBCSessionHandleDeleter : NvFBCHandleDeleter
{
using NvFBCHandleDeleter::NvFBCHandleDeleter;
auto operator()(pointer) noexcept -> void;
};
struct NvFBCCaptureSessionHandleDeleter : NvFBCHandleDeleter
{
using NvFBCHandleDeleter::NvFBCHandleDeleter;
auto operator()(pointer) noexcept -> void;
};
using NvFBCSessionHandlePtr =
std::unique_ptr<NVFBC_SESSION_HANDLE, NvFBCSessionHandleDeleter>;
using NvFBCCaptureSessionHandlePtr =
std::unique_ptr<NVFBC_SESSION_HANDLE, NvFBCCaptureSessionHandleDeleter>;
struct NvFBCLib
{
friend auto load_nvfbc() -> NvFBCLib;
auto NvFBCCreateInstance() -> NvFBC;
private:
PNVFBCCREATEINSTANCE NvFBCCreateInstance_;
};
auto load_nvfbc() -> NvFBCLib;
[[nodiscard]] auto create_nvfbc_session(sc::NvFBC instance)
-> NvFBCSessionHandlePtr;
auto create_nvfbc_capture_session(NVFBC_SESSION_HANDLE nvfbc_handle,
NvFBC nvfbc,
FrameTime const&) -> void;
auto destroy_nvfbc_capture_session(NVFBC_SESSION_HANDLE nvfbc_handle,
NvFBC nvfbc) -> void;
} // namespace sc
#endif // SHADOW_CAST_NVIDIA_HPP_INCLUDED