diff --git a/source/nvidia/cuda/nvidia-cuda-context.cpp b/source/nvidia/cuda/nvidia-cuda-context.cpp index e2e0f6d9..fcfdf814 100644 --- a/source/nvidia/cuda/nvidia-cuda-context.cpp +++ b/source/nvidia/cuda/nvidia-cuda-context.cpp @@ -49,10 +49,6 @@ #define ENABLE_STACK_CHECKS -nvidia::cuda::context::context() : _cuda(::nvidia::cuda::cuda::get()), _ctx(), _has_device(false), _device() -{ - D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this); -} nvidia::cuda::context::~context() { D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this); @@ -63,6 +59,11 @@ nvidia::cuda::context::~context() _cuda->cuCtxDestroy(_ctx); } +nvidia::cuda::context::context() : _cuda(::nvidia::cuda::cuda::get()), _ctx(), _has_device(false), _device() +{ + D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this); +} + #ifdef WIN32 nvidia::cuda::context::context(ID3D11Device* device) : context() { diff --git a/source/nvidia/cuda/nvidia-cuda-context.hpp b/source/nvidia/cuda/nvidia-cuda-context.hpp index feeeafde..5305d68d 100644 --- a/source/nvidia/cuda/nvidia-cuda-context.hpp +++ b/source/nvidia/cuda/nvidia-cuda-context.hpp @@ -30,12 +30,13 @@ namespace nvidia::cuda { bool _has_device; ::nvidia::cuda::device_t _device; + public: + ~context(); + private: context(); public: - ~context(); - #ifdef WIN32 context(ID3D11Device* device); #endif diff --git a/source/nvidia/cuda/nvidia-cuda-gs-texture.cpp b/source/nvidia/cuda/nvidia-cuda-gs-texture.cpp index 18d1c2e9..127a10f7 100644 --- a/source/nvidia/cuda/nvidia-cuda-gs-texture.cpp +++ b/source/nvidia/cuda/nvidia-cuda-gs-texture.cpp @@ -35,6 +35,14 @@ #define D_LOG_DEBUG(...) P_LOG_DEBUG(ST_PREFIX __VA_ARGS__) #endif +nvidia::cuda::gstexture::~gstexture() +{ + D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this); + + unmap(); + _cuda->cuGraphicsUnregisterResource(_resource); +} + nvidia::cuda::gstexture::gstexture(std::shared_ptr texture) : _cuda(::nvidia::cuda::cuda::get()), _texture(texture), _resource(), _is_mapped(false), _pointer() { @@ -78,14 +86,6 @@ nvidia::cuda::gstexture::gstexture(std::shared_ptr texture) #endif } -nvidia::cuda::gstexture::~gstexture() -{ - D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this); - - unmap(); - _cuda->cuGraphicsUnregisterResource(_resource); -} - nvidia::cuda::array_t nvidia::cuda::gstexture::map(std::shared_ptr stream) { if (_is_mapped) { diff --git a/source/nvidia/cuda/nvidia-cuda-memory.cpp b/source/nvidia/cuda/nvidia-cuda-memory.cpp index 1727b53b..8e185fdf 100644 --- a/source/nvidia/cuda/nvidia-cuda-memory.cpp +++ b/source/nvidia/cuda/nvidia-cuda-memory.cpp @@ -35,6 +35,13 @@ #define D_LOG_DEBUG(...) P_LOG_DEBUG(ST_PREFIX __VA_ARGS__) #endif +nvidia::cuda::memory::~memory() +{ + D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this); + + _cuda->cuMemFree(_pointer); +} + nvidia::cuda::memory::memory(size_t size) : _cuda(::nvidia::cuda::cuda::get()), _pointer(), _size(size) { D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this); @@ -48,12 +55,6 @@ nvidia::cuda::memory::memory(size_t size) : _cuda(::nvidia::cuda::cuda::get()), } } -nvidia::cuda::memory::~memory() -{ - D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this); - - _cuda->cuMemFree(_pointer); -} nvidia::cuda::device_ptr_t nvidia::cuda::memory::get() { return _pointer; diff --git a/source/nvidia/cuda/nvidia-cuda-memory.hpp b/source/nvidia/cuda/nvidia-cuda-memory.hpp index ee40ee4f..69ad92d1 100644 --- a/source/nvidia/cuda/nvidia-cuda-memory.hpp +++ b/source/nvidia/cuda/nvidia-cuda-memory.hpp @@ -29,8 +29,8 @@ namespace nvidia::cuda { size_t _size; public: - memory(size_t size); ~memory(); + memory(size_t size); device_ptr_t get(); diff --git a/source/nvidia/cuda/nvidia-cuda-stream.cpp b/source/nvidia/cuda/nvidia-cuda-stream.cpp index f1acccc5..f4c971d2 100644 --- a/source/nvidia/cuda/nvidia-cuda-stream.cpp +++ b/source/nvidia/cuda/nvidia-cuda-stream.cpp @@ -35,6 +35,13 @@ #define D_LOG_DEBUG(...) P_LOG_DEBUG(ST_PREFIX __VA_ARGS__) #endif +nvidia::cuda::stream::~stream() +{ + D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this); + + _cuda->cuStreamDestroy(_stream); +} + nvidia::cuda::stream::stream(::nvidia::cuda::stream_flags flags, int32_t priority) : _cuda(::nvidia::cuda::cuda::get()) { D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this); @@ -53,13 +60,6 @@ nvidia::cuda::stream::stream(::nvidia::cuda::stream_flags flags, int32_t priorit } } -nvidia::cuda::stream::~stream() -{ - D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this); - - _cuda->cuStreamDestroy(_stream); -} - ::nvidia::cuda::stream_t nvidia::cuda::stream::get() { return _stream; diff --git a/source/nvidia/cuda/nvidia-cuda.hpp b/source/nvidia/cuda/nvidia-cuda.hpp index de8d8501..af9d6df9 100644 --- a/source/nvidia/cuda/nvidia-cuda.hpp +++ b/source/nvidia/cuda/nvidia-cuda.hpp @@ -130,8 +130,8 @@ namespace nvidia::cuda { ::nvidia::cuda::result _code; public: - cuda_error(::nvidia::cuda::result code) : _code(code) {} ~cuda_error(){}; + cuda_error(::nvidia::cuda::result code) : _code(code) {} ::nvidia::cuda::result code() { @@ -143,8 +143,8 @@ namespace nvidia::cuda { std::shared_ptr _library; public: - cuda(); ~cuda(); + cuda(); public: // Initialization