mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
nvidia/cuda/cuda: Convert to global Singleton
This commit is contained in:
parent
9658c1ee0f
commit
5530d2d416
3 changed files with 17 additions and 3 deletions
|
@ -606,7 +606,7 @@ bool face_tracking_instance::button_profile(obs_properties_t* props, obs_propert
|
|||
face_tracking_factory::face_tracking_factory()
|
||||
{
|
||||
// Try and load CUDA.
|
||||
_cuda = std::make_shared<::nvidia::cuda::cuda>();
|
||||
_cuda = ::nvidia::cuda::cuda::get();
|
||||
|
||||
// Try and load AR.
|
||||
_ar = std::make_shared<::nvidia::ar::ar>();
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
|
||||
#include "nvidia-cuda.hpp"
|
||||
#include <stdexcept>
|
||||
#include <util/platform.h>
|
||||
#include "common.hpp"
|
||||
#include <mutex>
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define CUDA_NAME "nvcuda.dll"
|
||||
|
@ -121,3 +121,15 @@ nvidia::cuda::cuda::~cuda()
|
|||
{
|
||||
os_dlclose(_library);
|
||||
}
|
||||
|
||||
std::shared_ptr<nvidia::cuda::cuda> nvidia::cuda::cuda::get()
|
||||
{
|
||||
static std::shared_ptr<nvidia::cuda::cuda> instance;
|
||||
static std::mutex lock;
|
||||
|
||||
std::unique_lock<std::mutex> ul(lock);
|
||||
if (!instance) {
|
||||
instance = std::make_shared<nvidia::cuda::cuda>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -396,6 +396,8 @@ namespace nvidia::cuda {
|
|||
CUDA_DEFINE_FUNCTION(cuGraphicsD3D11RegisterResource, graphics_resource_t* resource,
|
||||
ID3D11Resource* d3dresource, std::uint32_t flags);
|
||||
#endif
|
||||
public:
|
||||
static std::shared_ptr<cuda> get();
|
||||
};
|
||||
} // namespace nvidia::cuda
|
||||
|
||||
|
|
Loading…
Reference in a new issue