未验证 提交 5ac0712c 编写于 作者: M masa-iwm 提交者: GitHub

Merge pull request #18593 from masa-iwm:master

Add support thread-local directx (OpenCL interop) initialization

* support thread-local directx (OpenCL interop) initialization

* reflect reviews

* Remove verbose function prototype declarations

* Countermeasures for VC warnings. (declaration of 'platform' hides class member)

* core(directx): remove internal stuff from public headers
上级 adac1da6
此差异已折叠。
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_CORE_SRC_DIRECTX_HPP
#define OPENCV_CORE_SRC_DIRECTX_HPP
#ifndef HAVE_DIRECTX
#error Invalid build configuration
#endif
namespace cv {
namespace directx {
namespace internal {
struct OpenCLDirectXImpl;
OpenCLDirectXImpl* createDirectXImpl();
void deleteDirectXImpl(OpenCLDirectXImpl**);
OpenCLDirectXImpl* getDirectXImpl(ocl::Context& ctx);
}}} // namespace internal
#endif // OPENCV_CORE_SRC_DIRECTX_HPP
...@@ -113,6 +113,10 @@ ...@@ -113,6 +113,10 @@
#include "opencv2/core/opencl/runtime/opencl_core.hpp" #include "opencv2/core/opencl/runtime/opencl_core.hpp"
#ifdef HAVE_DIRECTX
#include "directx.hpp"
#endif
#ifdef HAVE_OPENCL_SVM #ifdef HAVE_OPENCL_SVM
#include "opencv2/core/opencl/runtime/opencl_svm_20.hpp" #include "opencv2/core/opencl/runtime/opencl_svm_20.hpp"
#include "opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp" #include "opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp"
...@@ -2327,6 +2331,9 @@ protected: ...@@ -2327,6 +2331,9 @@ protected:
, contextId(CV_XADD(&g_contextId, 1)) , contextId(CV_XADD(&g_contextId, 1))
, configuration(configuration_) , configuration(configuration_)
, handle(0) , handle(0)
#ifdef HAVE_DIRECTX
, p_directx_impl(0)
#endif
#ifdef HAVE_OPENCL_SVM #ifdef HAVE_OPENCL_SVM
, svmInitialized(false) , svmInitialized(false)
#endif #endif
...@@ -2352,6 +2359,9 @@ protected: ...@@ -2352,6 +2359,9 @@ protected:
handle = NULL; handle = NULL;
} }
devices.clear(); devices.clear();
#ifdef HAVE_DIRECTX
directx::internal::deleteDirectXImpl(&p_directx_impl);
#endif
} }
{ {
...@@ -2658,6 +2668,19 @@ public: ...@@ -2658,6 +2668,19 @@ public:
return *bufferPoolHostPtr_.get(); return *bufferPoolHostPtr_.get();
} }
#ifdef HAVE_DIRECTX
directx::internal::OpenCLDirectXImpl* p_directx_impl;
directx::internal::OpenCLDirectXImpl* getDirectXImpl()
{
if (!p_directx_impl)
{
p_directx_impl = directx::internal::createDirectXImpl();
}
return p_directx_impl;
}
#endif
#ifdef HAVE_OPENCL_SVM #ifdef HAVE_OPENCL_SVM
bool svmInitialized; bool svmInitialized;
bool svmAvailable; bool svmAvailable;
...@@ -7286,4 +7309,15 @@ uint64 Timer::durationNS() const ...@@ -7286,4 +7309,15 @@ uint64 Timer::durationNS() const
}} // namespace }} // namespace
#ifdef HAVE_DIRECTX
namespace cv { namespace directx { namespace internal {
OpenCLDirectXImpl* getDirectXImpl(ocl::Context& ctx)
{
ocl::Context::Impl* i = ctx.getImpl();
CV_Assert(i);
return i->getDirectXImpl();
}
}}} // namespace cv::directx::internal
#endif
#endif // HAVE_OPENCL #endif // HAVE_OPENCL
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册