Sunshine master
Self-hosted game stream host for Moonlight.
nvenc_dynamic_factory.h
Go to the documentation of this file.
1
5#pragma once
6#ifdef _WIN32
7
8// standard includes
9 #include <functional>
10 #include <memory>
11
12 // local includes
14 #include "nvenc_shared_dll.h"
15 #include "nvenc_version.h"
16
17namespace nvenc {
18
23 using load_driver_fn = std::function<shared_dll()>;
24
28 using get_symbol_fn = std::function<FARPROC(HMODULE, const char *)>;
29
32 };
33
38 public:
43 std::function<std::unique_ptr<nvenc_d3d11_interface>(ID3D11Device *, shared_dll)>;
44
54 shared_dll dll,
56 create_encoder_fn create_native,
57 create_encoder_fn create_on_cuda
58 );
59
65 static std::shared_ptr<nvenc_dynamic_factory> get();
66
73 static std::shared_ptr<nvenc_dynamic_factory> get(const nvenc_runtime_api &runtime_api);
74
81 std::unique_ptr<nvenc_d3d11_interface> create_nvenc_d3d11_native(ID3D11Device *d3d_device) const;
82
89 std::unique_ptr<nvenc_d3d11_interface> create_nvenc_d3d11_on_cuda(ID3D11Device *d3d_device) const;
90
97
98 private:
99 shared_dll dll;
100 nvenc_sdk_version selected_sdk_version;
101 create_encoder_fn create_native;
102 create_encoder_fn create_on_cuda;
103 };
104
105} // namespace nvenc
106#endif
Factory bound to the newest NVENC SDK supported by the installed driver.
Definition nvenc_dynamic_factory.h:37
std::unique_ptr< nvenc_d3d11_interface > create_nvenc_d3d11_native(ID3D11Device *d3d_device) const
Create a native Direct3D11 NVENC encoder.
Definition nvenc_dynamic_factory.cpp:112
static std::shared_ptr< nvenc_dynamic_factory > get()
Load the NVENC driver and select a compatible SDK implementation.
Definition nvenc_dynamic_factory.cpp:46
nvenc_sdk_version sdk_version() const
Get the SDK implementation selected for this factory.
Definition nvenc_dynamic_factory.cpp:124
std::function< std::unique_ptr< nvenc_d3d11_interface >(ID3D11Device *, shared_dll)> create_encoder_fn
SDK-specific encoder constructor.
Definition nvenc_dynamic_factory.h:42
std::unique_ptr< nvenc_d3d11_interface > create_nvenc_d3d11_on_cuda(ID3D11Device *d3d_device) const
Create a CUDA NVENC encoder with Direct3D11 input surfaces.
Definition nvenc_dynamic_factory.cpp:118
nvenc_dynamic_factory(shared_dll dll, nvenc_sdk_version sdk_version, create_encoder_fn create_native, create_encoder_fn create_on_cuda)
Construct a factory bound to one NVENC SDK implementation.
Definition nvenc_dynamic_factory.cpp:34
Standalone NVENC encoder.
Definition nvenc_base.cpp:185
std::shared_ptr< std::remove_pointer_t< HMODULE > > shared_dll
Shared ownership wrapper for a loaded Windows module.
Definition nvenc_shared_dll.h:20
nvenc_sdk_version
NVENC SDK implementations compiled into Sunshine.
Definition nvenc_version.h:16
Declarations for the SDK-neutral Direct3D11 NVENC interface.
Windows module lifetime helpers shared by NVENC factories and encoders.
NVENC SDK version selection helpers.
Windows runtime operations used to discover the installed NVENC API.
Definition nvenc_dynamic_factory.h:22
std::function< FARPROC(HMODULE, const char *)> get_symbol_fn
Resolve an export from the loaded NVENC driver module.
Definition nvenc_dynamic_factory.h:28
std::function< shared_dll()> load_driver_fn
Load the NVENC driver module.
Definition nvenc_dynamic_factory.h:23
load_driver_fn load_driver
Function that loads the NVENC driver module.
Definition nvenc_dynamic_factory.h:30
get_symbol_fn get_symbol
Resolve a driver export.
Definition nvenc_dynamic_factory.h:31