[145760] trunk/dports/graphics/opencv

stromnov at macports.org stromnov at macports.org
Tue Feb 16 01:36:56 PST 2016


Revision: 145760
          https://trac.macports.org/changeset/145760
Author:   stromnov at macports.org
Date:     2016-02-16 01:36:56 -0800 (Tue, 16 Feb 2016)
Log Message:
-----------
opencv: fix opencl support

Modified Paths:
--------------
    trunk/dports/graphics/opencv/Portfile

Added Paths:
-----------
    trunk/dports/graphics/opencv/files/patch-opencl-PR6052.diff

Modified: trunk/dports/graphics/opencv/Portfile
===================================================================
--- trunk/dports/graphics/opencv/Portfile	2016-02-16 09:07:39 UTC (rev 145759)
+++ trunk/dports/graphics/opencv/Portfile	2016-02-16 09:36:56 UTC (rev 145760)
@@ -175,7 +175,8 @@
     configure.args-append   -DEIGEN_INCLUDE_PATH=${prefix}/include/eigen3
 }
 
-variant opencl description {Enable OpenCL support (broken).} {
+variant opencl description {Enable OpenCL support.} {
+    patchfiles-append       patch-opencl-PR6052.diff
     pre-configure {
         if {${os.platform} eq "darwin" && ${os.major} < 11} {
             ui_error "The OpenCL variant only works with OS X 10.7 Lion or later."

Added: trunk/dports/graphics/opencv/files/patch-opencl-PR6052.diff
===================================================================
--- trunk/dports/graphics/opencv/files/patch-opencl-PR6052.diff	                        (rev 0)
+++ trunk/dports/graphics/opencv/files/patch-opencl-PR6052.diff	2016-02-16 09:36:56 UTC (rev 145760)
@@ -0,0 +1,245 @@
+diff --git a/cmake/checks/opencl.cpp b/cmake/checks/opencl.cpp
+index 95a36f3..b71b92f 100644
+--- cmake/checks/opencl.cpp
++++ cmake/checks/opencl.cpp
+@@ -1,8 +1,5 @@
+-#if defined __APPLE__
+-#include <OpenCL/cl.h>
+-#else
++// custom OpenCL headers are located in "CL" subfolder (3rdparty/include/...)
+ #include <CL/cl.h>
+-#endif
+ 
+ #ifndef _MSC_VER
+ #ifdef CL_VERSION_1_2
+diff --git a/modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp b/modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp
+index f824ce9..801709e 100644
+--- modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp
++++ modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp
+@@ -95,11 +95,7 @@
+ #define clUnloadPlatformCompiler clUnloadPlatformCompiler_
+ #define clWaitForEvents clWaitForEvents_
+ 
+-#if defined __APPLE__
+-#include <OpenCL/cl.h>
+-#else
+ #include <CL/cl.h>
+-#endif
+ 
+ // generated by parser_cl.py
+ #undef clBuildProgram
+diff --git a/modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp b/modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp
+index 64a7fed..1ad4a6a 100644
+--- modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp
++++ modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp
+@@ -41,6 +41,8 @@
+ #undef clGetGLTextureInfo
+ #define clGetGLTextureInfo clGetGLTextureInfo_pfn
+ 
++#ifdef cl_khr_gl_sharing
++
+ // generated by parser_cl.py
+ extern CL_RUNTIME_EXPORT cl_mem (CL_API_CALL*clCreateFromGLBuffer)(cl_context, cl_mem_flags, cl_GLuint, int*);
+ extern CL_RUNTIME_EXPORT cl_mem (CL_API_CALL*clCreateFromGLRenderbuffer)(cl_context, cl_mem_flags, cl_GLuint, cl_int*);
+@@ -52,3 +54,5 @@ extern CL_RUNTIME_EXPORT cl_int (CL_API_CALL*clEnqueueReleaseGLObjects)(cl_comma
+ extern CL_RUNTIME_EXPORT cl_int (CL_API_CALL*clGetGLContextInfoKHR)(const cl_context_properties*, cl_gl_context_info, size_t, void*, size_t*);
+ extern CL_RUNTIME_EXPORT cl_int (CL_API_CALL*clGetGLObjectInfo)(cl_mem, cl_gl_object_type*, cl_GLuint*);
+ extern CL_RUNTIME_EXPORT cl_int (CL_API_CALL*clGetGLTextureInfo)(cl_mem, cl_gl_texture_info, size_t, void*, size_t*);
++
++#endif // cl_khr_gl_sharing
+diff --git a/modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp b/modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp
+index 105867f..8338ac6 100644
+--- modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp
++++ modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp
+@@ -5,6 +5,8 @@
+ #error "Invalid usage"
+ #endif
+ 
++#ifdef cl_khr_gl_sharing
++
+ // generated by parser_cl.py
+ #undef clCreateFromGLBuffer
+ #define clCreateFromGLBuffer clCreateFromGLBuffer_fn
+@@ -36,3 +38,5 @@ inline cl_int clGetGLObjectInfo(cl_mem p0, cl_gl_object_type* p1, cl_GLuint* p2)
+ #undef clGetGLTextureInfo
+ #define clGetGLTextureInfo clGetGLTextureInfo_fn
+ inline cl_int clGetGLTextureInfo(cl_mem p0, cl_gl_texture_info p1, size_t p2, void* p3, size_t* p4) { return clGetGLTextureInfo_pfn(p0, p1, p2, p3, p4); }
++
++#endif // cl_khr_gl_sharing
+diff --git a/modules/core/src/opencl/runtime/autogenerated/opencl_gl_impl.hpp b/modules/core/src/opencl/runtime/autogenerated/opencl_gl_impl.hpp
+index 6d97180..5b37133 100644
+--- modules/core/src/opencl/runtime/autogenerated/opencl_gl_impl.hpp
++++ modules/core/src/opencl/runtime/autogenerated/opencl_gl_impl.hpp
+@@ -139,6 +139,8 @@ struct opencl_gl_fn14
+ 
+ } // anonymous namespace
+ 
++#ifdef cl_khr_gl_sharing
++
+ // generated by parser_cl.py
+ cl_mem (CL_API_CALL*clCreateFromGLBuffer)(cl_context, cl_mem_flags, cl_GLuint, int*) =
+         opencl_gl_fn4<OPENCL_GL_FN_clCreateFromGLBuffer, cl_mem, cl_context, cl_mem_flags, cl_GLuint, int*>::switch_fn;
+@@ -196,3 +198,5 @@ static const struct DynamicFnEntry* opencl_gl_fn_list[] = {
+ };
+ 
+ // number of enabled functions: 10
++
++#endif // cl_khr_gl_sharing
+diff --git a/modules/core/src/opencl/runtime/generator/common.py b/modules/core/src/opencl/runtime/generator/common.py
+index 80c5452..5f81e8e 100644
+--- modules/core/src/opencl/runtime/generator/common.py
++++ modules/core/src/opencl/runtime/generator/common.py
+@@ -254,6 +254,6 @@ def ProcessTemplate(inputFile, ctx, noteLine='//\n// AUTOGENERATED, DO NOT EDIT\
+             assert line[-1] == '@'
+             name = line[1:-1]
+             assert ctx.has_key(name), name
+-            line = ctx[name]
+-        print line,
++            line = ctx[name] + ('\n' if len(ctx[name]) > 0 and ctx[name][-1] != '\n' else '')
++        sys.stdout.write(line)
+     f.close()
+diff --git a/modules/core/src/opencl/runtime/generator/generate.sh b/modules/core/src/opencl/runtime/generator/generate.sh
+old mode 100644
+new mode 100755
+diff --git a/modules/core/src/opencl/runtime/generator/template/opencl_core.hpp.in b/modules/core/src/opencl/runtime/generator/template/opencl_core.hpp.in
+index 4196622..b6c8f05 100644
+--- modules/core/src/opencl/runtime/generator/template/opencl_core.hpp.in
++++ modules/core/src/opencl/runtime/generator/template/opencl_core.hpp.in
+@@ -4,11 +4,7 @@
+ 
+ @CL_REMAP_ORIGIN@
+ 
+-#if defined __APPLE__
+-#include <OpenCL/cl.h>
+-#else
+ #include <CL/cl.h>
+-#endif
+ 
+ @CL_REMAP_DYNAMIC@
+ 
+diff --git a/modules/core/src/opencl/runtime/generator/template/opencl_gl.hpp.in b/modules/core/src/opencl/runtime/generator/template/opencl_gl.hpp.in
+index 4bed423..13a33c7 100644
+--- modules/core/src/opencl/runtime/generator/template/opencl_gl.hpp.in
++++ modules/core/src/opencl/runtime/generator/template/opencl_gl.hpp.in
+@@ -8,4 +8,8 @@
+ 
+ @CL_REMAP_DYNAMIC@
+ 
++#ifdef cl_khr_gl_sharing
++
+ @CL_FN_DECLARATIONS@
++
++#endif // cl_khr_gl_sharing
+diff --git a/modules/core/src/opencl/runtime/generator/template/opencl_gl_impl.hpp.in b/modules/core/src/opencl/runtime/generator/template/opencl_gl_impl.hpp.in
+index 1458601..cba1278 100644
+--- modules/core/src/opencl/runtime/generator/template/opencl_gl_impl.hpp.in
++++ modules/core/src/opencl/runtime/generator/template/opencl_gl_impl.hpp.in
+@@ -4,8 +4,12 @@ namespace {
+ @CL_FN_SWITCH@
+ } // anonymous namespace
+ 
++#ifdef cl_khr_gl_sharing
++
+ @CL_FN_ENTRY_DEFINITIONS@
+ 
+ @CL_FN_ENTRY_LIST@
+ 
+ @CL_NUMBER_OF_ENABLED_FUNCTIONS@
++
++#endif // cl_khr_gl_sharing
+diff --git a/modules/core/src/opencl/runtime/generator/template/opencl_gl_wrappers.hpp.in b/modules/core/src/opencl/runtime/generator/template/opencl_gl_wrappers.hpp.in
+index 0aeefb4..fc03179 100644
+--- modules/core/src/opencl/runtime/generator/template/opencl_gl_wrappers.hpp.in
++++ modules/core/src/opencl/runtime/generator/template/opencl_gl_wrappers.hpp.in
+@@ -2,4 +2,8 @@
+ #error "Invalid usage"
+ #endif
+ 
++#ifdef cl_khr_gl_sharing
++
+ @CL_FN_INLINE_WRAPPERS@
++
++#endif // cl_khr_gl_sharing
+diff --git a/modules/core/src/opencl/runtime/opencl_core.cpp b/modules/core/src/opencl/runtime/opencl_core.cpp
+index 0ab3381..405a593 100644
+--- modules/core/src/opencl/runtime/opencl_core.cpp
++++ modules/core/src/opencl/runtime/opencl_core.cpp
+@@ -286,6 +286,8 @@ static void* opencl_check_fn(int ID)
+ 
+ #include "opencv2/core/opencl/runtime/opencl_gl.hpp"
+ 
++#ifdef cl_khr_gl_sharing
++
+ static void* opencl_gl_check_fn(int ID);
+ 
+ #include "autogenerated/opencl_gl_impl.hpp"
+@@ -306,6 +308,8 @@ static void* opencl_gl_check_fn(int ID)
+     return func;
+ }
+ 
++#endif // cl_khr_gl_sharing
++
+ #endif // HAVE_OPENGL
+ 
+ #endif
+diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp
+index 3bbc0f8..f3d106f 100644
+--- modules/core/src/opengl.cpp
++++ modules/core/src/opengl.cpp
+@@ -1580,6 +1580,11 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala
+ 
+ #ifdef HAVE_OPENCL
+ #  include "opencv2/core/opencl/runtime/opencl_gl.hpp"
++#  ifdef cl_khr_gl_sharing
++#    define HAVE_OPENCL_OPENGL_SHARING
++#  else
++#    define NO_OPENCL_SHARING_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without OpenCL/OpenGL sharing support")
++#  endif
+ #else // HAVE_OPENCL
+ #  define NO_OPENCL_SUPPORT_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without OpenCL support")
+ #endif // HAVE_OPENCL
+@@ -1602,6 +1607,8 @@ Context& initializeContextFromGL()
+     NO_OPENGL_SUPPORT_ERROR;
+ #elif !defined(HAVE_OPENCL)
+     NO_OPENCL_SUPPORT_ERROR;
++#elif !defined(HAVE_OPENCL_OPENGL_SHARING)
++    NO_OPENCL_SHARING_ERROR;
+ #else
+     cl_uint numPlatforms;
+     cl_int status = clGetPlatformIDs(0, NULL, &numPlatforms);
+@@ -1701,6 +1708,8 @@ void convertToGLTexture2D(InputArray src, Texture2D& texture)
+     NO_OPENGL_SUPPORT_ERROR;
+ #elif !defined(HAVE_OPENCL)
+     NO_OPENCL_SUPPORT_ERROR;
++#elif !defined(HAVE_OPENCL_OPENGL_SHARING)
++    NO_OPENCL_SHARING_ERROR;
+ #else
+     Size srcSize = src.size();
+     CV_Assert(srcSize.width == (int)texture.cols() && srcSize.height == (int)texture.rows());
+@@ -1753,6 +1762,8 @@ void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst)
+     NO_OPENGL_SUPPORT_ERROR;
+ #elif !defined(HAVE_OPENCL)
+     NO_OPENCL_SUPPORT_ERROR;
++#elif !defined(HAVE_OPENCL_OPENGL_SHARING)
++    NO_OPENCL_SHARING_ERROR;
+ #else
+     // check texture format
+     const int dtype = CV_8UC4;
+@@ -1812,6 +1823,8 @@ UMat mapGLBuffer(const Buffer& buffer, int accessFlags)
+     NO_OPENGL_SUPPORT_ERROR;
+ #elif !defined(HAVE_OPENCL)
+     NO_OPENCL_SUPPORT_ERROR;
++#elif !defined(HAVE_OPENCL_OPENGL_SHARING)
++    NO_OPENCL_SHARING_ERROR;
+ #else
+     using namespace cv::ocl;
+     Context& ctx = Context::getDefault();
+@@ -1862,6 +1875,8 @@ void unmapGLBuffer(UMat& u)
+     NO_OPENGL_SUPPORT_ERROR;
+ #elif !defined(HAVE_OPENCL)
+     NO_OPENCL_SUPPORT_ERROR;
++#elif !defined(HAVE_OPENCL_OPENGL_SHARING)
++    NO_OPENCL_SHARING_ERROR;
+ #else
+     using namespace cv::ocl;
+     cl_command_queue clQueue = (cl_command_queue)Queue::getDefault().ptr();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160216/43875c86/attachment-0001.html>


More information about the macports-changes mailing list