nvidia/cuda/context: Don't try to destroy device contexts

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2021-06-17 12:13:22 +02:00
parent 6ba51efceb
commit 0f56f822c3

View file

@ -55,9 +55,10 @@ streamfx::nvidia::cuda::context::~context()
if (_has_device) {
_cuda->cuDevicePrimaryCtxRelease(_device);
}
} else {
_cuda->cuCtxDestroy(_ctx);
}
}
streamfx::nvidia::cuda::context::context()
: _cuda(::streamfx::nvidia::cuda::cuda::get()), _ctx(), _has_device(false), _device()
@ -85,6 +86,8 @@ streamfx::nvidia::cuda::context::context(ID3D11Device* device) : context()
throw std::runtime_error("Failed to get device index for device.");
}
_cuda->cuDevicePrimaryCtxSetFlags(_device, context_flags::SCHEDULER_BLOCKING_SYNC);
// Acquire Context
if (result res = _cuda->cuDevicePrimaryCtxRetain(&_ctx, _device); res != result::SUCCESS) {
throw std::runtime_error("Failed to acquire primary device context.");