@@ -282,9 +282,10 @@ class cv::cuda::Stream::Impl
282
282
cudaStream_t stream;
283
283
bool ownStream;
284
284
285
- Ptr<StackAllocator> stackAllocator ;
285
+ Ptr<GpuMat::Allocator> allocator ;
286
286
287
287
Impl ();
288
+ Impl (const Ptr<GpuMat::Allocator>& allocator);
288
289
explicit Impl (cudaStream_t stream);
289
290
290
291
~Impl ();
@@ -295,17 +296,23 @@ cv::cuda::Stream::Impl::Impl() : stream(0), ownStream(false)
295
296
cudaSafeCall ( cudaStreamCreate (&stream) );
296
297
ownStream = true ;
297
298
298
- stackAllocator = makePtr<StackAllocator>(stream);
299
+ allocator = makePtr<StackAllocator>(stream);
300
+ }
301
+
302
+ cv::cuda::Stream::Impl::Impl (const Ptr<GpuMat::Allocator>& allocator) : stream(0 ), ownStream(false ), allocator(allocator)
303
+ {
304
+ cudaSafeCall ( cudaStreamCreate (&stream) );
305
+ ownStream = true ;
299
306
}
300
307
301
308
cv::cuda::Stream::Impl::Impl (cudaStream_t stream_) : stream(stream_), ownStream(false )
302
309
{
303
- stackAllocator = makePtr<StackAllocator>(stream);
310
+ allocator = makePtr<StackAllocator>(stream);
304
311
}
305
312
306
313
cv::cuda::Stream::Impl::~Impl ()
307
314
{
308
- stackAllocator .release ();
315
+ allocator .release ();
309
316
310
317
if (stream && ownStream)
311
318
{
@@ -417,6 +424,16 @@ cv::cuda::Stream::Stream()
417
424
#endif
418
425
}
419
426
427
+ cv::cuda::Stream::Stream (const Ptr<GpuMat::Allocator>& allocator)
428
+ {
429
+ #ifndef HAVE_CUDA
430
+ (void ) allocator;
431
+ throw_no_cuda ();
432
+ #else
433
+ impl_ = makePtr<Impl>(allocator);
434
+ #endif
435
+ }
436
+
420
437
bool cv::cuda::Stream::queryIfComplete () const
421
438
{
422
439
#ifndef HAVE_CUDA
@@ -675,7 +692,7 @@ cv::cuda::BufferPool::BufferPool(Stream& stream)
675
692
throw_no_cuda ();
676
693
}
677
694
#else
678
- cv::cuda::BufferPool::BufferPool (Stream& stream) : allocator_(stream.impl_->stackAllocator )
695
+ cv::cuda::BufferPool::BufferPool (Stream& stream) : allocator_(stream.impl_->allocator )
679
696
{
680
697
}
681
698
#endif
0 commit comments