From 5279993f4ba75a2025e9d89258135c8f35028fc9 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Thu, 17 Jun 2021 13:28:13 +0200 Subject: [PATCH] plugin: If CUDA is requested, ensure it is loaded first --- CMakeLists.txt | 3 +++ source/plugin.cpp | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a32330f..864c3fac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -975,6 +975,9 @@ if(HAVE_NVIDIA_CUDA) "source/nvidia/cuda/nvidia-cuda-stream.hpp" "source/nvidia/cuda/nvidia-cuda-stream.cpp" ) + list(APPEND PROJECT_DEFINITIONS + ENABLE_NVIDIA_CUDA + ) endif() if(REQUIRE_OBSFE AND HAVE_OBSFE) diff --git a/source/plugin.cpp b/source/plugin.cpp index ab505216..9d5518a5 100644 --- a/source/plugin.cpp +++ b/source/plugin.cpp @@ -24,6 +24,10 @@ #include "obs/gs/gs-vertexbuffer.hpp" #include "obs/obs-source-tracker.hpp" +#ifdef ENABLE_NVIDIA_CUDA +#include "nvidia/cuda/nvidia-cuda-obs.hpp" +#endif + #ifdef ENABLE_ENCODER_FFMPEG #include "encoders/encoder-ffmpeg.hpp" #endif @@ -89,6 +93,11 @@ try { // Initialize Source Tracker streamfx::obs::source_tracker::initialize(); +#ifdef ENABLE_NVIDIA_CUDA + // Initialize CUDA if features requested it. + auto cuda = ::streamfx::nvidia::cuda::obs::get(); +#endif + // GS Stuff { _gs_fstri_vb = std::make_shared(uint32_t(3), uint8_t(1));