From c7fe162829bdf9952bd65e6365dab64c8416e184 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 31 Jan 2014 20:23:01 +0400 Subject: [PATCH 1/2] renamed **2 -> ** --- .project | 100 +++++++++++++ cmake/cl2cpp.cmake | 4 +- modules/core/include/opencv2/core/directx.hpp | 8 +- modules/core/include/opencv2/core/ocl.hpp | 72 +++++----- modules/core/src/directx.cpp | 40 +++--- modules/core/src/dxt.cpp | 12 +- modules/core/src/ocl.cpp | 136 +++++++++--------- modules/imgproc/src/imgwarp.cpp | 2 +- modules/imgproc/src/pyramids.cpp | 24 ++-- modules/ts/src/ocl_test.cpp | 4 +- samples/directx/d3d_base.inl.hpp | 12 +- 11 files changed, 254 insertions(+), 160 deletions(-) create mode 100644 .project diff --git a/.project b/.project new file mode 100644 index 0000000000..bf2777f200 --- /dev/null +++ b/.project @@ -0,0 +1,100 @@ + + + opencv + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?children? + ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\|| + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + /home/ilya/Documents/Programming/Builds/opencv_debug/bin + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + org.eclipse.cdt.codan.core.codanBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.codan.core.codanNature + + + + bin + 2 + /home/ilya/Documents/Programming/Builds/opencv_debug/bin + + + diff --git a/cmake/cl2cpp.cmake b/cmake/cl2cpp.cmake index 84be36a982..09cac6c4ca 100644 --- a/cmake/cl2cpp.cmake +++ b/cmake/cl2cpp.cmake @@ -65,8 +65,8 @@ foreach(cl ${cl_list}) set(STR_CPP_DECL "const struct ProgramEntry ${cl_filename}={\"${cl_filename}\",\n\"${lines}, \"${hash}\"};\n") set(STR_HPP_DECL "extern const struct ProgramEntry ${cl_filename};\n") if(new_mode) - set(STR_CPP_DECL "${STR_CPP_DECL}ProgramSource2 ${cl_filename}_oclsrc(${cl_filename}.programStr);\n") - set(STR_HPP_DECL "${STR_HPP_DECL}extern ProgramSource2 ${cl_filename}_oclsrc;\n") + set(STR_CPP_DECL "${STR_CPP_DECL}ProgramSource ${cl_filename}_oclsrc(${cl_filename}.programStr);\n") + set(STR_HPP_DECL "${STR_HPP_DECL}extern ProgramSource ${cl_filename}_oclsrc;\n") endif() set(STR_CPP "${STR_CPP}${STR_CPP_DECL}") diff --git a/modules/core/include/opencv2/core/directx.hpp b/modules/core/include/opencv2/core/directx.hpp index 2a8991ad58..d7e38a12a1 100644 --- a/modules/core/include/opencv2/core/directx.hpp +++ b/modules/core/include/opencv2/core/directx.hpp @@ -67,10 +67,10 @@ namespace ocl { using namespace cv::ocl; // TODO static functions in the Context class -CV_EXPORTS Context2& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device); -CV_EXPORTS Context2& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device); -CV_EXPORTS Context2& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDevice9Ex); -CV_EXPORTS Context2& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9); +CV_EXPORTS Context& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device); +CV_EXPORTS Context& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device); +CV_EXPORTS Context& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDevice9Ex); +CV_EXPORTS Context& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9); } // namespace cv::directx::ocl diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp index 0df3b8148c..c6b0cf2d0f 100644 --- a/modules/core/include/opencv2/core/ocl.hpp +++ b/modules/core/include/opencv2/core/ocl.hpp @@ -51,15 +51,15 @@ CV_EXPORTS bool useOpenCL(); CV_EXPORTS bool haveAmdBlas(); CV_EXPORTS bool haveAmdFft(); CV_EXPORTS void setUseOpenCL(bool flag); -CV_EXPORTS void finish2(); +CV_EXPORTS void finish(); -class CV_EXPORTS Context2; +class CV_EXPORTS Context; class CV_EXPORTS Device; class CV_EXPORTS Kernel; class CV_EXPORTS Program; -class CV_EXPORTS ProgramSource2; +class CV_EXPORTS ProgramSource; class CV_EXPORTS Queue; -class CV_EXPORTS PlatformInfo2; +class CV_EXPORTS PlatformInfo; class CV_EXPORTS Image2D; class CV_EXPORTS Device @@ -206,26 +206,26 @@ protected: }; -class CV_EXPORTS Context2 +class CV_EXPORTS Context { public: - Context2(); - explicit Context2(int dtype); - ~Context2(); - Context2(const Context2& c); - Context2& operator = (const Context2& c); + Context(); + explicit Context(int dtype); + ~Context(); + Context(const Context& c); + Context& operator = (const Context& c); bool create(); bool create(int dtype); size_t ndevices() const; const Device& device(size_t idx) const; - Program getProg(const ProgramSource2& prog, + Program getProg(const ProgramSource& prog, const String& buildopt, String& errmsg); - static Context2& getDefault(bool initialize = true); + static Context& getDefault(bool initialize = true); void* ptr() const; - friend void initializeContextFromHandle(Context2& ctx, void* platform, void* context, void* device); + friend void initializeContextFromHandle(Context& ctx, void* platform, void* context, void* device); protected: struct Impl; Impl* p; @@ -242,25 +242,25 @@ public: void* ptr() const; static Platform& getDefault(); - friend void initializeContextFromHandle(Context2& ctx, void* platform, void* context, void* device); + friend void initializeContextFromHandle(Context& ctx, void* platform, void* context, void* device); protected: struct Impl; Impl* p; }; // TODO Move to internal header -void initializeContextFromHandle(Context2& ctx, void* platform, void* context, void* device); +void initializeContextFromHandle(Context& ctx, void* platform, void* context, void* device); class CV_EXPORTS Queue { public: Queue(); - explicit Queue(const Context2& c, const Device& d=Device()); + explicit Queue(const Context& c, const Device& d=Device()); ~Queue(); Queue(const Queue& q); Queue& operator = (const Queue& q); - bool create(const Context2& c=Context2(), const Device& d=Device()); + bool create(const Context& c=Context(), const Device& d=Device()); void finish(); void* ptr() const; static Queue& getDefault(); @@ -314,7 +314,7 @@ class CV_EXPORTS Kernel public: Kernel(); Kernel(const char* kname, const Program& prog); - Kernel(const char* kname, const ProgramSource2& prog, + Kernel(const char* kname, const ProgramSource& prog, const String& buildopts = String(), String* errmsg=0); ~Kernel(); Kernel(const Kernel& k); @@ -322,7 +322,7 @@ public: bool empty() const; bool create(const char* kname, const Program& prog); - bool create(const char* kname, const ProgramSource2& prog, + bool create(const char* kname, const ProgramSource& prog, const String& buildopts, String* errmsg=0); int set(int i, const void* value, size_t sz); @@ -508,7 +508,7 @@ class CV_EXPORTS Program { public: Program(); - Program(const ProgramSource2& src, + Program(const ProgramSource& src, const String& buildflags, String& errmsg); explicit Program(const String& buf); Program(const Program& prog); @@ -516,12 +516,12 @@ public: Program& operator = (const Program& prog); ~Program(); - bool create(const ProgramSource2& src, + bool create(const ProgramSource& src, const String& buildflags, String& errmsg); bool read(const String& buf, const String& buildflags); bool write(String& buf) const; - const ProgramSource2& source() const; + const ProgramSource& source() const; void* ptr() const; String getPrefix() const; @@ -533,17 +533,17 @@ protected: }; -class CV_EXPORTS ProgramSource2 +class CV_EXPORTS ProgramSource { public: typedef uint64 hash_t; - ProgramSource2(); - explicit ProgramSource2(const String& prog); - explicit ProgramSource2(const char* prog); - ~ProgramSource2(); - ProgramSource2(const ProgramSource2& prog); - ProgramSource2& operator = (const ProgramSource2& prog); + ProgramSource(); + explicit ProgramSource(const String& prog); + explicit ProgramSource(const char* prog); + ~ProgramSource(); + ProgramSource(const ProgramSource& prog); + ProgramSource& operator = (const ProgramSource& prog); const String& source() const; hash_t hash() const; @@ -553,15 +553,15 @@ protected: Impl* p; }; -class CV_EXPORTS PlatformInfo2 +class CV_EXPORTS PlatformInfo { public: - PlatformInfo2(); - explicit PlatformInfo2(void* id); - ~PlatformInfo2(); + PlatformInfo(); + explicit PlatformInfo(void* id); + ~PlatformInfo(); - PlatformInfo2(const PlatformInfo2& i); - PlatformInfo2& operator =(const PlatformInfo2& i); + PlatformInfo(const PlatformInfo& i); + PlatformInfo& operator =(const PlatformInfo& i); String name() const; String vendor() const; @@ -578,7 +578,7 @@ CV_EXPORTS const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf) CV_EXPORTS const char* typeToStr(int t); CV_EXPORTS const char* memopTypeToStr(int t); CV_EXPORTS String kernelToStr(InputArray _kernel, int ddepth = -1); -CV_EXPORTS void getPlatfomsInfo(std::vector& platform_info); +CV_EXPORTS void getPlatfomsInfo(std::vector& platform_info); class CV_EXPORTS Image2D { diff --git a/modules/core/src/directx.cpp b/modules/core/src/directx.cpp index 071df0352a..23addbf618 100644 --- a/modules/core/src/directx.cpp +++ b/modules/core/src/directx.cpp @@ -236,7 +236,7 @@ namespace ocl { static bool g_isDirect3DDevice9Ex = false; // Direct3DDevice9Ex or Direct3DDevice9 was used #endif -Context2& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device) +Context& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device) { (void)pD3D11Device; #if !defined(HAVE_DIRECTX) @@ -338,13 +338,13 @@ Context2& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device) } - Context2& ctx = Context2::getDefault(false); + Context& ctx = Context::getDefault(false); initializeContextFromHandle(ctx, platforms[found], context, device); return ctx; #endif } -Context2& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device) +Context& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device) { (void)pD3D10Device; #if !defined(HAVE_DIRECTX) @@ -446,13 +446,13 @@ Context2& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device) } - Context2& ctx = Context2::getDefault(false); + Context& ctx = Context::getDefault(false); initializeContextFromHandle(ctx, platforms[found], context, device); return ctx; #endif } -Context2& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDevice9Ex) +Context& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDevice9Ex) { (void)pDirect3DDevice9Ex; #if !defined(HAVE_DIRECTX) @@ -555,14 +555,14 @@ Context2& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDe CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't create context for DirectX interop"); } - Context2& ctx = Context2::getDefault(false); + Context& ctx = Context::getDefault(false); initializeContextFromHandle(ctx, platforms[found], context, device); g_isDirect3DDevice9Ex = true; return ctx; #endif } -Context2& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9) +Context& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9) { (void)pDirect3DDevice9; #if !defined(HAVE_DIRECTX) @@ -665,7 +665,7 @@ Context2& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't create context for DirectX interop"); } - Context2& ctx = Context2::getDefault(false); + Context& ctx = Context::getDefault(false); initializeContextFromHandle(ctx, platforms[found], context, device); g_isDirect3DDevice9Ex = false; return ctx; @@ -720,7 +720,7 @@ void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D) CV_Assert(srcSize.width == (int)desc.Width && srcSize.height == (int)desc.Height); using namespace cv::ocl; - Context2& ctx = Context2::getDefault(); + Context& ctx = Context::getDefault(); cl_context context = (cl_context)ctx.ptr(); UMat u = src.getUMat(); @@ -736,7 +736,7 @@ void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D) cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed"); @@ -777,7 +777,7 @@ void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst CV_Assert(textureType >= 0); using namespace cv::ocl; - Context2& ctx = Context2::getDefault(); + Context& ctx = Context::getDefault(); cl_context context = (cl_context)ctx.ptr(); // TODO Need to specify ACCESS_WRITE here somehow to prevent useless data copying! @@ -795,7 +795,7 @@ void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed"); @@ -868,7 +868,7 @@ void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D) CV_Assert(srcSize.width == (int)desc.Width && srcSize.height == (int)desc.Height); using namespace cv::ocl; - Context2& ctx = Context2::getDefault(); + Context& ctx = Context::getDefault(); cl_context context = (cl_context)ctx.ptr(); UMat u = src.getUMat(); @@ -884,7 +884,7 @@ void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D) cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); status = clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed"); @@ -925,7 +925,7 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst CV_Assert(textureType >= 0); using namespace cv::ocl; - Context2& ctx = Context2::getDefault(); + Context& ctx = Context::getDefault(); cl_context context = (cl_context)ctx.ptr(); // TODO Need to specify ACCESS_WRITE here somehow to prevent useless data copying! @@ -943,7 +943,7 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); status = clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed"); @@ -1019,7 +1019,7 @@ void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurfa CV_Assert(srcSize.width == (int)desc.Width && srcSize.height == (int)desc.Height); using namespace cv::ocl; - Context2& ctx = Context2::getDefault(); + Context& ctx = Context::getDefault(); cl_context context = (cl_context)ctx.ptr(); UMat u = src.getUMat(); @@ -1038,7 +1038,7 @@ void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurfa cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); status = clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed"); @@ -1083,7 +1083,7 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr CV_Assert(surfaceType >= 0); using namespace cv::ocl; - Context2& ctx = Context2::getDefault(); + Context& ctx = Context::getDefault(); cl_context context = (cl_context)ctx.ptr(); // TODO Need to specify ACCESS_WRITE here somehow to prevent useless data copying! @@ -1104,7 +1104,7 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr cl_mem clBuffer = (cl_mem)u.handle(ACCESS_WRITE); - cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); status = clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed"); diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp index e57343038c..1d3a67b5e8 100644 --- a/modules/core/src/dxt.cpp +++ b/modules/core/src/dxt.cpp @@ -1545,7 +1545,7 @@ class PlanCache clStridesOut[2] = dft_rows ? clStridesOut[1] : dft_size.width * clStridesOut[1]; // TODO remove all plans if context changed - CLAMDDFT_Assert(clAmdFftCreateDefaultPlan(&plHandle, (cl_context)ocl::Context2::getDefault().ptr(), dim, clLengthsIn)) + CLAMDDFT_Assert(clAmdFftCreateDefaultPlan(&plHandle, (cl_context)ocl::Context::getDefault().ptr(), dim, clLengthsIn)) // setting plan properties CLAMDDFT_Assert(clAmdFftSetPlanPrecision(plHandle, doubleFP ? CLFFT_DOUBLE : CLFFT_SINGLE)); @@ -1560,8 +1560,8 @@ class PlanCache CLAMDDFT_Assert(clAmdFftSetPlanScale(plHandle, dft_inverse ? CLFFT_BACKWARD : CLFFT_FORWARD, scale)) // ready to bake - cl_command_queue commandQueue = (cl_command_queue)ocl::Queue::getDefault().ptr(); - CLAMDDFT_Assert(clAmdFftBakePlan(plHandle, 1, &commandQueue, NULL, NULL)) + cl_command_queue queue = (cl_command_queue)ocl::Queue::getDefault().ptr(); + CLAMDDFT_Assert(clAmdFftBakePlan(plHandle, 1, &queue, NULL, NULL)) } ~FftPlan() @@ -1593,7 +1593,7 @@ public: clAmdFftPlanHandle getPlanHandle(const Size & dft_size, int src_step, int dst_step, bool doubleFP, bool inplace, int flags, FftType fftType) { - cl_context currentContext = (cl_context)ocl::Context2::getDefault().ptr(); + cl_context currentContext = (cl_context)ocl::Context::getDefault().ptr(); for (size_t i = 0, size = planStorage.size(); i < size; i ++) { @@ -1704,11 +1704,11 @@ static bool ocl_dft(InputArray _src, OutputArray _dst, int flags) cl_mem srcarg = (cl_mem)src.handle(ACCESS_READ); cl_mem dstarg = (cl_mem)dst.handle(ACCESS_RW); - cl_command_queue commandQueue = (cl_command_queue)ocl::Queue::getDefault().ptr(); + cl_command_queue queue = (cl_command_queue)ocl::Queue::getDefault().ptr(); cl_event e = 0; CLAMDDFT_Assert(clAmdFftEnqueueTransform(plHandle, dft_inverse ? CLFFT_BACKWARD : CLFFT_FORWARD, - 1, &commandQueue, 0, NULL, &e, + 1, &queue, 0, NULL, &e, &srcarg, &dstarg, (cl_mem)tmpBuffer.handle(ACCESS_RW))) tmpBuffer.addref(); diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 6f19b56eb5..43a96a2c65 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -1572,7 +1572,7 @@ bool haveAmdFft() #endif -void finish2() +void finish() { Queue::getDefault().finish(); } @@ -2025,7 +2025,7 @@ size_t Device::profilingTimerResolution() const const Device& Device::getDefault() { - const Context2& ctx = Context2::getDefault(); + const Context& ctx = Context::getDefault(); int idx = coreTlsData.get()->device; return ctx.device(idx); } @@ -2230,7 +2230,7 @@ not_found: return NULL; } -struct Context2::Impl +struct Context::Impl { Impl() { @@ -2337,7 +2337,7 @@ struct Context2::Impl devices.clear(); } - Program getProg(const ProgramSource2& src, + Program getProg(const ProgramSource& src, const String& buildflags, String& errmsg) { String prefix = Program::getPrefix(buildflags); @@ -2357,7 +2357,7 @@ struct Context2::Impl cl_context handle; std::vector devices; - typedef ProgramSource2::hash_t hash_t; + typedef ProgramSource::hash_t hash_t; struct HashKey { @@ -2372,18 +2372,18 @@ struct Context2::Impl }; -Context2::Context2() +Context::Context() { p = 0; } -Context2::Context2(int dtype) +Context::Context(int dtype) { p = 0; create(dtype); } -bool Context2::create() +bool Context::create() { if( !haveOpenCL() ) return false; @@ -2398,7 +2398,7 @@ bool Context2::create() return p != 0; } -bool Context2::create(int dtype0) +bool Context::create(int dtype0) { if( !haveOpenCL() ) return false; @@ -2413,7 +2413,7 @@ bool Context2::create(int dtype0) return p != 0; } -Context2::~Context2() +Context::~Context() { if (p) { @@ -2422,14 +2422,14 @@ Context2::~Context2() } } -Context2::Context2(const Context2& c) +Context::Context(const Context& c) { p = (Impl*)c.p; if(p) p->addref(); } -Context2& Context2::operator = (const Context2& c) +Context& Context::operator = (const Context& c) { Impl* newp = (Impl*)c.p; if(newp) @@ -2440,34 +2440,34 @@ Context2& Context2::operator = (const Context2& c) return *this; } -void* Context2::ptr() const +void* Context::ptr() const { return p == NULL ? NULL : p->handle; } -size_t Context2::ndevices() const +size_t Context::ndevices() const { return p ? p->devices.size() : 0; } -const Device& Context2::device(size_t idx) const +const Device& Context::device(size_t idx) const { static Device dummy; return !p || idx >= p->devices.size() ? dummy : p->devices[idx]; } -Context2& Context2::getDefault(bool initialize) +Context& Context::getDefault(bool initialize) { - static Context2 ctx; + static Context ctx; if(!ctx.p && haveOpenCL()) { if (!ctx.p) ctx.p = new Impl(); if (initialize) { - // do not create new Context2 right away. + // do not create new Context right away. // First, try to retrieve existing context of the same type. - // In its turn, Platform::getContext() may call Context2::create() + // In its turn, Platform::getContext() may call Context::create() // if there is no such context. if (ctx.p->handle == NULL) ctx.p->setDefault(); @@ -2477,19 +2477,19 @@ Context2& Context2::getDefault(bool initialize) return ctx; } -Program Context2::getProg(const ProgramSource2& prog, +Program Context::getProg(const ProgramSource& prog, const String& buildopts, String& errmsg) { return p ? p->getProg(prog, buildopts, errmsg) : Program(); } -void initializeContextFromHandle(Context2& ctx, void* platform, void* _context, void* _device) +void initializeContextFromHandle(Context& ctx, void* platform, void* _context, void* _device) { cl_context context = (cl_context)_context; cl_device_id device = (cl_device_id)_device; // cleanup old context - Context2::Impl * impl = ctx.p; + Context::Impl * impl = ctx.p; if (impl->handle) { CV_OclDbgAssert(clReleaseContext(impl->handle) == CL_SUCCESS); @@ -2509,14 +2509,14 @@ void initializeContextFromHandle(Context2& ctx, void* platform, void* _context, struct Queue::Impl { - Impl(const Context2& c, const Device& d) + Impl(const Context& c, const Device& d) { refcount = 1; - const Context2* pc = &c; + const Context* pc = &c; cl_context ch = (cl_context)pc->ptr(); if( !ch ) { - pc = &Context2::getDefault(); + pc = &Context::getDefault(); ch = (cl_context)pc->ptr(); } cl_device_id dh = (cl_device_id)d.ptr(); @@ -2553,7 +2553,7 @@ Queue::Queue() p = 0; } -Queue::Queue(const Context2& c, const Device& d) +Queue::Queue(const Context& c, const Device& d) { p = 0; create(c, d); @@ -2583,7 +2583,7 @@ Queue::~Queue() p->release(); } -bool Queue::create(const Context2& c, const Device& d) +bool Queue::create(const Context& c, const Device& d) { if(p) p->release(); @@ -2608,7 +2608,7 @@ Queue& Queue::getDefault() { Queue& q = coreTlsData.get()->oclQueue; if( !q.p && haveOpenCL() ) - q.create(Context2::getDefault()); + q.create(Context::getDefault()); return q; } @@ -2725,7 +2725,7 @@ Kernel::Kernel(const char* kname, const Program& prog) create(kname, prog); } -Kernel::Kernel(const char* kname, const ProgramSource2& src, +Kernel::Kernel(const char* kname, const ProgramSource& src, const String& buildopts, String* errmsg) { p = 0; @@ -2769,7 +2769,7 @@ bool Kernel::create(const char* kname, const Program& prog) return p != 0; } -bool Kernel::create(const char* kname, const ProgramSource2& src, +bool Kernel::create(const char* kname, const ProgramSource& src, const String& buildopts, String* errmsg) { if(p) @@ -2779,7 +2779,7 @@ bool Kernel::create(const char* kname, const ProgramSource2& src, } String tempmsg; if( !errmsg ) errmsg = &tempmsg; - const Program& prog = Context2::getDefault().getProg(src, buildopts, *errmsg); + const Program& prog = Context::getDefault().getProg(src, buildopts, *errmsg); return create(kname, prog); } @@ -2984,11 +2984,11 @@ size_t Kernel::localMemSize() const struct Program::Impl { - Impl(const ProgramSource2& _src, + Impl(const ProgramSource& _src, const String& _buildflags, String& errmsg) { refcount = 1; - const Context2& ctx = Context2::getDefault(); + const Context& ctx = Context::getDefault(); src = _src; buildflags = _buildflags; const String& srcstr = src.source(); @@ -3044,7 +3044,7 @@ struct Program::Impl if(_buf.empty()) return; String prefix0 = Program::getPrefix(buildflags); - const Context2& ctx = Context2::getDefault(); + const Context& ctx = Context::getDefault(); const Device& dev = Device::getDefault(); const char* pos0 = _buf.c_str(); const char* pos1 = strchr(pos0, '\n'); @@ -3099,7 +3099,7 @@ struct Program::Impl IMPLEMENT_REFCOUNTABLE(); - ProgramSource2 src; + ProgramSource src; String buildflags; cl_program handle; }; @@ -3107,7 +3107,7 @@ struct Program::Impl Program::Program() { p = 0; } -Program::Program(const ProgramSource2& src, +Program::Program(const ProgramSource& src, const String& buildflags, String& errmsg) { p = 0; @@ -3138,7 +3138,7 @@ Program::~Program() p->release(); } -bool Program::create(const ProgramSource2& src, +bool Program::create(const ProgramSource& src, const String& buildflags, String& errmsg) { if(p) @@ -3152,9 +3152,9 @@ bool Program::create(const ProgramSource2& src, return p != 0; } -const ProgramSource2& Program::source() const +const ProgramSource& Program::source() const { - static ProgramSource2 dummy; + static ProgramSource dummy; return p ? p->src : dummy; } @@ -3188,15 +3188,15 @@ String Program::getPrefix() const String Program::getPrefix(const String& buildflags) { - const Context2& ctx = Context2::getDefault(); + const Context& ctx = Context::getDefault(); const Device& dev = ctx.device(0); return format("name=%s\ndriver=%s\nbuildflags=%s\n", dev.name().c_str(), dev.driverVersion().c_str(), buildflags.c_str()); } -///////////////////////////////////////// ProgramSource2 /////////////////////////////////////////////// +///////////////////////////////////////// ProgramSource /////////////////////////////////////////////// -struct ProgramSource2::Impl +struct ProgramSource::Impl { Impl(const char* _src) { @@ -3215,39 +3215,39 @@ struct ProgramSource2::Impl IMPLEMENT_REFCOUNTABLE(); String src; - ProgramSource2::hash_t h; + ProgramSource::hash_t h; }; -ProgramSource2::ProgramSource2() +ProgramSource::ProgramSource() { p = 0; } -ProgramSource2::ProgramSource2(const char* prog) +ProgramSource::ProgramSource(const char* prog) { p = new Impl(prog); } -ProgramSource2::ProgramSource2(const String& prog) +ProgramSource::ProgramSource(const String& prog) { p = new Impl(prog); } -ProgramSource2::~ProgramSource2() +ProgramSource::~ProgramSource() { if(p) p->release(); } -ProgramSource2::ProgramSource2(const ProgramSource2& prog) +ProgramSource::ProgramSource(const ProgramSource& prog) { p = prog.p; if(p) p->addref(); } -ProgramSource2& ProgramSource2::operator = (const ProgramSource2& prog) +ProgramSource& ProgramSource::operator = (const ProgramSource& prog) { Impl* newp = (Impl*)prog.p; if(newp) @@ -3258,13 +3258,13 @@ ProgramSource2& ProgramSource2::operator = (const ProgramSource2& prog) return *this; } -const String& ProgramSource2::source() const +const String& ProgramSource::source() const { static String dummy; return p ? p->src : dummy; } -ProgramSource2::hash_t ProgramSource2::hash() const +ProgramSource::hash_t ProgramSource::hash() const { return p ? p->h : 0; } @@ -3482,7 +3482,7 @@ public: return u; } - void getBestFlags(const Context2& ctx, int /*flags*/, int& createFlags, int& flags0) const + void getBestFlags(const Context& ctx, int /*flags*/, int& createFlags, int& flags0) const { const Device& dev = ctx.device(0); createFlags = CL_MEM_READ_WRITE; @@ -3507,7 +3507,7 @@ public: total *= sizes[i]; } - Context2& ctx = Context2::getDefault(); + Context& ctx = Context::getDefault(); int createFlags = 0, flags0 = 0; getBestFlags(ctx, flags, createFlags, flags0); @@ -3536,7 +3536,7 @@ public: if(u->handle == 0) { CV_Assert(u->origdata != 0); - Context2& ctx = Context2::getDefault(); + Context& ctx = Context::getDefault(); int createFlags = 0, flags0 = 0; getBestFlags(ctx, accessFlags, createFlags, flags0); @@ -3982,7 +3982,7 @@ static void getDevices(std::vector& devices, cl_platform_id platfo numDevices, &devices[0], &numDevices) == CL_SUCCESS); } -struct PlatformInfo2::Impl +struct PlatformInfo::Impl { Impl(void* id) { @@ -4004,30 +4004,30 @@ struct PlatformInfo2::Impl cl_platform_id handle; }; -PlatformInfo2::PlatformInfo2() +PlatformInfo::PlatformInfo() { p = 0; } -PlatformInfo2::PlatformInfo2(void* platform_id) +PlatformInfo::PlatformInfo(void* platform_id) { p = new Impl(platform_id); } -PlatformInfo2::~PlatformInfo2() +PlatformInfo::~PlatformInfo() { if(p) p->release(); } -PlatformInfo2::PlatformInfo2(const PlatformInfo2& i) +PlatformInfo::PlatformInfo(const PlatformInfo& i) { if (i.p) i.p->addref(); p = i.p; } -PlatformInfo2& PlatformInfo2::operator =(const PlatformInfo2& i) +PlatformInfo& PlatformInfo::operator =(const PlatformInfo& i) { if (i.p != p) { @@ -4040,29 +4040,29 @@ PlatformInfo2& PlatformInfo2::operator =(const PlatformInfo2& i) return *this; } -int PlatformInfo2::deviceNumber() const +int PlatformInfo::deviceNumber() const { return p ? (int)p->devices.size() : 0; } -void PlatformInfo2::getDevice(Device& device, int d) const +void PlatformInfo::getDevice(Device& device, int d) const { CV_Assert(p && d < (int)p->devices.size() ); if(p) device.set(p->devices[d]); } -String PlatformInfo2::name() const +String PlatformInfo::name() const { return p ? p->getStrProp(CL_PLATFORM_NAME) : String(); } -String PlatformInfo2::vendor() const +String PlatformInfo::vendor() const { return p ? p->getStrProp(CL_PLATFORM_VENDOR) : String(); } -String PlatformInfo2::version() const +String PlatformInfo::version() const { return p ? p->getStrProp(CL_PLATFORM_VERSION) : String(); } @@ -4082,13 +4082,13 @@ static void getPlatforms(std::vector& platforms) CV_OclDbgAssert(clGetPlatformIDs(numPlatforms, &platforms[0], &numPlatforms) == CL_SUCCESS); } -void getPlatfomsInfo(std::vector& platformsInfo) +void getPlatfomsInfo(std::vector& platformsInfo) { std::vector platforms; getPlatforms(platforms); for (size_t i = 0; i < platforms.size(); i++) - platformsInfo.push_back( PlatformInfo2((void*)&platforms[i]) ); + platformsInfo.push_back( PlatformInfo((void*)&platforms[i]) ); } const char* typeToStr(int type) @@ -4233,7 +4233,7 @@ struct Image2D::Impl format.image_channel_data_type = (cl_channel_type)channelType; format.image_channel_order = (cl_channel_order)channelOrder; - cl_context context = (cl_context)Context2::getDefault().ptr(); + cl_context context = (cl_context)Context::getDefault().ptr(); cl_command_queue queue = (cl_command_queue)Queue::getDefault().ptr(); #ifdef CL_VERSION_1_2 diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index af961ee5b1..f30c9b68b2 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -3900,7 +3900,7 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0, return false; const char * const interpolationMap[3] = { "NEAREST", "LINEAR", "CUBIC" }; - ocl::ProgramSource2 program = op_type == OCL_OP_AFFINE ? + ocl::ProgramSource program = op_type == OCL_OP_AFFINE ? ocl::imgproc::warp_affine_oclsrc : ocl::imgproc::warp_perspective_oclsrc; const char * const kernelName = op_type == OCL_OP_AFFINE ? "warpAffine" : "warpPerspective"; diff --git a/modules/imgproc/src/pyramids.cpp b/modules/imgproc/src/pyramids.cpp index f5bced3a9f..23a132f9be 100644 --- a/modules/imgproc/src/pyramids.cpp +++ b/modules/imgproc/src/pyramids.cpp @@ -407,8 +407,7 @@ static bool ocl_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, in { int type = _src.type(), depth = CV_MAT_DEPTH(type), channels = CV_MAT_CN(type); - if (((channels != 1) && (channels != 2) && (channels != 4)) - || (borderType != BORDER_DEFAULT)) + if ((channels != 1 && channels != 2 && channels != 4) || borderType != BORDER_DEFAULT) return false; bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -425,18 +424,16 @@ static bool ocl_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, in _dst.create( dsize, src.type() ); UMat dst = _dst.getUMat(); - const char * const kernelName = "pyrDown"; - ocl::ProgramSource2 program = ocl::imgproc::pyr_down_oclsrc; - ocl::Kernel k; - int float_depth = depth == CV_64F ? CV_64F : CV_32F; char cvt[2][50]; - k.create(kernelName, program, + ocl::Kernel k("pyrDown", ocl::imgproc::pyr_down_oclsrc, format("-D T=%s -D FT=%s -D convertToT=%s -D convertToFT=%s%s", ocl::typeToStr(type), ocl::typeToStr(CV_MAKETYPE(float_depth, channels)), ocl::convertTypeStr(float_depth, depth, channels, cvt[0]), ocl::convertTypeStr(depth, float_depth, channels, cvt[1]), doubleSupport ? " -D DOUBLE_SUPPORT" : "")); + if (k.empty()) + return false; k.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnly(dst)); @@ -449,12 +446,11 @@ static bool ocl_pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int { int type = _src.type(), depth = CV_MAT_DEPTH(type), channels = CV_MAT_CN(type); - if (((channels != 1) && (channels != 2) && (channels != 4)) - || (borderType != BORDER_DEFAULT)) + if ((channels != 1 && channels != 2 && channels != 4) || borderType != BORDER_DEFAULT) return false; bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; - if ((depth == CV_64F) && !(doubleSupport)) + if (depth == CV_64F && !doubleSupport) return false; Size ssize = _src.size(); @@ -466,18 +462,16 @@ static bool ocl_pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int _dst.create( dsize, src.type() ); UMat dst = _dst.getUMat(); - const char * const kernelName = "pyrUp"; - ocl::ProgramSource2 program = ocl::imgproc::pyr_up_oclsrc; - ocl::Kernel k; - int float_depth = depth == CV_64F ? CV_64F : CV_32F; char cvt[2][50]; - k.create(kernelName, program, + ocl::Kernel k("pyrUp", ocl::imgproc::pyr_up_oclsrc, format("-D T=%s -D FT=%s -D convertToT=%s -D convertToFT=%s%s", ocl::typeToStr(type), ocl::typeToStr(CV_MAKETYPE(float_depth, channels)), ocl::convertTypeStr(float_depth, depth, channels, cvt[0]), ocl::convertTypeStr(depth, float_depth, channels, cvt[1]), doubleSupport ? " -D DOUBLE_SUPPORT" : "")); + if (k.empty()) + return false; k.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnly(dst)); size_t globalThreads[2] = {dst.cols, dst.rows}; diff --git a/modules/ts/src/ocl_test.cpp b/modules/ts/src/ocl_test.cpp index 389b2aefc1..3387b193b9 100644 --- a/modules/ts/src/ocl_test.cpp +++ b/modules/ts/src/ocl_test.cpp @@ -98,14 +98,14 @@ void dumpOpenCLDevice() using namespace cv::ocl; try { - std::vector platforms; + std::vector platforms; cv::ocl::getPlatfomsInfo(platforms); if (platforms.size() > 0) { DUMP_MESSAGE_STDOUT("OpenCL Platforms: "); for (size_t i = 0; i < platforms.size(); i++) { - const PlatformInfo2* platform = &platforms[i]; + const PlatformInfo* platform = &platforms[i]; DUMP_MESSAGE_STDOUT(" " << platform->name().c_str()); Device current_device; for (int j = 0; j < platform->deviceNumber(); j++) diff --git a/samples/directx/d3d_base.inl.hpp b/samples/directx/d3d_base.inl.hpp index 6b6de300d2..0ef5c00a00 100644 --- a/samples/directx/d3d_base.inl.hpp +++ b/samples/directx/d3d_base.inl.hpp @@ -134,7 +134,7 @@ static void renderToD3DObject(void) const float fps = getFps(); - String deviceName = cv::ocl::useOpenCL() ? cv::ocl::Context2::getDefault().device(0).name() : "No OpenCL device"; + String deviceName = cv::ocl::useOpenCL() ? cv::ocl::Context::getDefault().device(0).name() : "No OpenCL device"; if ((frame % std::max(1, (int)(fps / 25))) == 0) { @@ -360,7 +360,7 @@ static cv::Mat getInputTexture() { cv::resize(inputMat, inputMat, cv::Size(WIDTH, HEIGHT)); } - String deviceName = cv::ocl::useOpenCL() ? cv::ocl::Context2::getDefault().device(0).name() : "No OpenCL device"; + String deviceName = cv::ocl::useOpenCL() ? cv::ocl::Context::getDefault().device(0).name() : "No OpenCL device"; cv::Scalar color(64, 255, 64, 255); cv::putText(inputMat, cv::format("OpenCL Device name: %s", deviceName.c_str()), @@ -396,13 +396,13 @@ static int mainLoop() if (cv::ocl::haveOpenCL()) { #if defined(USE_D3D9) - cv::ocl::Context2& ctx = cv::directx::ocl::initializeContextFromDirect3DDevice9(dev); + cv::ocl::Context& ctx = cv::directx::ocl::initializeContextFromDirect3DDevice9(dev); #elif defined (USE_D3DEX) - cv::ocl::Context2& ctx = cv::directx::ocl::initializeContextFromDirect3DDevice9Ex(dev); + cv::ocl::Context& ctx = cv::directx::ocl::initializeContextFromDirect3DDevice9Ex(dev); #elif defined(USE_D3D10) - cv::ocl::Context2& ctx = cv::directx::ocl::initializeContextFromD3D10Device(dev); + cv::ocl::Context& ctx = cv::directx::ocl::initializeContextFromD3D10Device(dev); #elif defined(USE_D3D11) - cv::ocl::Context2& ctx = cv::directx::ocl::initializeContextFromD3D11Device(dev); + cv::ocl::Context& ctx = cv::directx::ocl::initializeContextFromD3D11Device(dev); #else #error "Invalid USE_D3D value" #endif From 2e8579fe9b91a1186f41fca348ed351f1d6f4307 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 31 Jan 2014 21:00:16 +0400 Subject: [PATCH 2/2] cleaned up super_resolution sample from old OCL --- .project | 100 ---------------- modules/core/include/opencv2/core/mat.hpp | 7 +- modules/core/src/directx.cpp | 12 +- modules/core/src/matrix.cpp | 17 +-- modules/core/src/ocl.cpp | 2 +- modules/core/src/opencl/mulspectrums.cl | 2 +- modules/ts/include/opencv2/ts/ocl_perf.hpp | 2 +- samples/gpu/super_resolution.cpp | 130 +++------------------ 8 files changed, 27 insertions(+), 245 deletions(-) delete mode 100644 .project diff --git a/.project b/.project deleted file mode 100644 index bf2777f200..0000000000 --- a/.project +++ /dev/null @@ -1,100 +0,0 @@ - - - opencv - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - /home/ilya/Documents/Programming/Builds/opencv_debug/bin - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.eclipse.cdt.codan.core.codanBuilder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.codan.core.codanNature - - - - bin - 2 - /home/ilya/Documents/Programming/Builds/opencv_debug/bin - - - diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 8099520ec5..6409222599 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -85,10 +85,9 @@ public: OPENGL_BUFFER = 7 << KIND_SHIFT, CUDA_MEM = 8 << KIND_SHIFT, GPU_MAT = 9 << KIND_SHIFT, - OCL_MAT =10 << KIND_SHIFT, - UMAT =11 << KIND_SHIFT, - STD_VECTOR_UMAT =12 << KIND_SHIFT, - UEXPR =13 << KIND_SHIFT + UMAT =10 << KIND_SHIFT, + STD_VECTOR_UMAT =11 << KIND_SHIFT, + UEXPR =12 << KIND_SHIFT }; _InputArray(); diff --git a/modules/core/src/directx.cpp b/modules/core/src/directx.cpp index 23addbf618..4d9fd6c9e9 100644 --- a/modules/core/src/directx.cpp +++ b/modules/core/src/directx.cpp @@ -736,7 +736,7 @@ void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D) cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed"); @@ -795,7 +795,7 @@ void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed"); @@ -884,7 +884,7 @@ void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D) cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); status = clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed"); @@ -943,7 +943,7 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); status = clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed"); @@ -1038,7 +1038,7 @@ void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurfa cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ); - cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); status = clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed"); @@ -1104,7 +1104,7 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr cl_mem clBuffer = (cl_mem)u.handle(ACCESS_WRITE); - cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr(); + cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); status = clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL); if (status != CL_SUCCESS) CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed"); diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 8a11d093e1..6e5aceebcb 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -1496,11 +1496,6 @@ Size _InputArray::size(int i) const return d_mat->size(); } - if( k == OCL_MAT ) - { - CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet"); - } - CV_Assert( k == CUDA_MEM ); //if( k == CUDA_MEM ) { @@ -1680,11 +1675,6 @@ int _InputArray::dims(int i) const return 2; } - if( k == OCL_MAT ) - { - return 2; - } - CV_Assert( k == CUDA_MEM ); //if( k == CUDA_MEM ) { @@ -1842,11 +1832,6 @@ bool _InputArray::empty() const if( k == OPENGL_BUFFER ) return ((const ogl::Buffer*)obj)->empty(); - if( k == OCL_MAT ) - { - CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet"); - } - if( k == GPU_MAT ) return ((const cuda::GpuMat*)obj)->empty(); @@ -1882,7 +1867,7 @@ bool _InputArray::isContinuous(int i) const return vv[i].isContinuous(); } - CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet"); + CV_Error(CV_StsNotImplemented, "Unknown/unsupported array type"); return false; } diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 43a96a2c65..331a9ba033 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -3365,7 +3365,7 @@ protected: { CV_DbgAssert(entry.clBuffer_ == NULL); entry.capacity_ = alignSize(size, (int)_allocationGranularity(size)); - Context2& ctx = Context2::getDefault(); + Context& ctx = Context::getDefault(); cl_int retval = CL_SUCCESS; entry.clBuffer_ = clCreateBuffer((cl_context)ctx.ptr(), CL_MEM_READ_WRITE, entry.capacity_, 0, &retval); CV_Assert(retval == CL_SUCCESS); diff --git a/modules/core/src/opencl/mulspectrums.cl b/modules/core/src/opencl/mulspectrums.cl index 65f0edf6a1..248ff006fb 100644 --- a/modules/core/src/opencl/mulspectrums.cl +++ b/modules/core/src/opencl/mulspectrums.cl @@ -25,7 +25,7 @@ // // * Redistribution's in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation -// and/or other oclMaterials provided with the distribution. +// and/or other materials provided with the distribution. // // * The name of the copyright holders may not be used to endorse or promote products // derived from this software without specific prior written permission. diff --git a/modules/ts/include/opencv2/ts/ocl_perf.hpp b/modules/ts/include/opencv2/ts/ocl_perf.hpp index 8a92faad41..8e5b4d0049 100644 --- a/modules/ts/include/opencv2/ts/ocl_perf.hpp +++ b/modules/ts/include/opencv2/ts/ocl_perf.hpp @@ -119,7 +119,7 @@ CV_EXPORTS void randu(InputOutputArray dst); inline void safeFinish() { if (cv::ocl::useOpenCL()) - cv::ocl::finish2(); + cv::ocl::finish(); } } // namespace perf diff --git a/samples/gpu/super_resolution.cpp b/samples/gpu/super_resolution.cpp index 67d0532a69..23f9c6f9fd 100644 --- a/samples/gpu/super_resolution.cpp +++ b/samples/gpu/super_resolution.cpp @@ -10,14 +10,10 @@ #include "opencv2/superres/optical_flow.hpp" #include "opencv2/opencv_modules.hpp" -#if defined(HAVE_OPENCV_OCL) -#include "opencv2/ocl/ocl.hpp" -#endif - using namespace std; using namespace cv; using namespace cv::superres; -bool useOclChanged; + #define MEASURE_TIME(op) \ { \ TickMeter tm; \ @@ -50,40 +46,11 @@ static Ptr createOptFlow(const string& name, bool useGpu) else if (name == "pyrlk") return createOptFlow_PyrLK_CUDA(); else - { cerr << "Incorrect Optical Flow algorithm - " << name << endl; - } + return Ptr(); } -#if defined(HAVE_OPENCV_OCL) -static Ptr createOptFlow(const string& name) -{ - if (name == "farneback") - { - return createOptFlow_Farneback_OCL(); - } - else if (name == "simple") - { - useOclChanged = true; - std::cout<<"simple on OpenCL has not been implemented. Use CPU instead!\n"; - return createOptFlow_Simple(); - } - else if (name == "tvl1") - return createOptFlow_DualTVL1_OCL(); - else if (name == "brox") - { - std::cout<<"brox has not been implemented!\n"; - return Ptr(); - } - else if (name == "pyrlk") - return createOptFlow_PyrLK_OCL(); - else - { - cerr << "Incorrect Optical Flow algorithm - " << name << endl; - } - return Ptr(); -} -#endif + int main(int argc, const char* argv[]) { useOclChanged = false; @@ -94,7 +61,7 @@ int main(int argc, const char* argv[]) "{ i iterations | 180 | Iteration count }" "{ t temporal | 4 | Radius of the temporal search area }" "{ f flow | farneback | Optical flow algorithm (farneback, simple, tvl1, brox, pyrlk) }" - "{ g | false | CPU as default device, cuda for CUDA and ocl for OpenCL }" + "{ g | false | CPU as default device, cuda for CUDA }" "{ h help | false | Print help message }" ); @@ -102,7 +69,7 @@ int main(int argc, const char* argv[]) { cout << "This sample demonstrates Super Resolution algorithms for video sequence" << endl; cmd.printMessage(); - return 0; + return EXIT_SUCCESS; } const string inputVideoName = cmd.get("video"); @@ -115,60 +82,19 @@ int main(int argc, const char* argv[]) std::transform(gpuOption.begin(), gpuOption.end(), gpuOption.begin(), ::tolower); - bool useCuda = false; - bool useOcl = false; - - if(gpuOption.compare("ocl") == 0) - useOcl = true; - else if(gpuOption.compare("cuda") == 0) - useCuda = true; - -#ifndef HAVE_OPENCV_OCL - if(useOcl) - { - { - cout<<"OPENCL is not compiled\n"; - return 0; - } - } -#endif -#if defined(HAVE_OPENCV_OCL) - if(useCuda) - { - CV_Assert(!useOcl); - } -#endif + bool useCuda = gpuOption.compare("cuda") == 0; Ptr superRes; - -#if defined(HAVE_OPENCV_OCL) - if(useOcl) - { - Ptr of = createOptFlow(optFlow); - if (of.empty()) - exit(-1); - if(useOclChanged) - { - superRes = createSuperResolution_BTVL1(); - useOcl = !useOcl; - }else - superRes = createSuperResolution_BTVL1_OCL(); - superRes->set("opticalFlow", of); - } + if (useCuda) + superRes = createSuperResolution_BTVL1_CUDA(); else -#endif - { - if (useCuda) - superRes = createSuperResolution_BTVL1_CUDA(); - else - superRes = createSuperResolution_BTVL1(); + superRes = createSuperResolution_BTVL1(); - Ptr of = createOptFlow(optFlow, useCuda); + Ptr of = createOptFlow(optFlow, useCuda); - if (of.empty()) - exit(-1); - superRes->set("opticalFlow", of); - } + if (of.empty()) + return EXIT_FAILURE; + superRes->set("opticalFlow", of); superRes->set("scale", scale); superRes->set("iterations", iterations); @@ -201,11 +127,7 @@ int main(int argc, const char* argv[]) cout << "Iterations : " << iterations << endl; cout << "Temporal radius : " << temporalAreaRadius << endl; cout << "Optical Flow : " << optFlow << endl; -#if defined(HAVE_OPENCV_OCL) - cout << "Mode : " << (useCuda ? "CUDA" : useOcl? "OpenCL" : "CPU") << endl; -#else cout << "Mode : " << (useCuda ? "CUDA" : "CPU") << endl; -#endif } superRes->setInput(frameSource); @@ -217,32 +139,8 @@ int main(int argc, const char* argv[]) cout << '[' << setw(3) << i << "] : "; Mat result; -#if defined(HAVE_OPENCV_OCL) - cv::ocl::oclMat result_; + MEASURE_TIME(superRes->nextFrame(result)); - if(useOcl) - { - MEASURE_TIME( - { - superRes->nextFrame(result_); - ocl::finish(); - }); - } - else -#endif - { - MEASURE_TIME(superRes->nextFrame(result)); - } - -#ifdef HAVE_OPENCV_OCL - if(useOcl) - { - if(!result_.empty()) - { - result_.download(result); - } - } -#endif if (result.empty()) break;