Merge pull request #6060 from alalek:fix_opencl_opengl_sharing_6052
This commit is contained in:
commit
8c591ebd77
@ -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
|
||||
|
@ -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
|
||||
|
@ -17,11 +17,7 @@
|
||||
#define clGetGLObjectInfo clGetGLObjectInfo_
|
||||
#define clGetGLTextureInfo clGetGLTextureInfo_
|
||||
|
||||
#if defined __APPLE__
|
||||
#include <OpenCL/cl_gl.h>
|
||||
#else
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
// generated by parser_cl.py
|
||||
#undef clCreateFromGLBuffer
|
||||
@ -45,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*);
|
||||
@ -56,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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
0
modules/core/src/opencl/runtime/generator/generate.sh
Normal file → Executable file
0
modules/core/src/opencl/runtime/generator/generate.sh
Normal file → Executable file
@ -4,11 +4,7 @@
|
||||
|
||||
@CL_REMAP_ORIGIN@
|
||||
|
||||
#if defined __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
@CL_REMAP_DYNAMIC@
|
||||
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
@CL_REMAP_ORIGIN@
|
||||
|
||||
#if defined __APPLE__
|
||||
#include <OpenCL/cl_gl.h>
|
||||
#else
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
@CL_REMAP_DYNAMIC@
|
||||
|
||||
#ifdef cl_khr_gl_sharing
|
||||
|
||||
@CL_FN_DECLARATIONS@
|
||||
|
||||
#endif // cl_khr_gl_sharing
|
||||
|
@ -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
|
||||
|
@ -2,4 +2,8 @@
|
||||
#error "Invalid usage"
|
||||
#endif
|
||||
|
||||
#ifdef cl_khr_gl_sharing
|
||||
|
||||
@CL_FN_INLINE_WRAPPERS@
|
||||
|
||||
#endif // cl_khr_gl_sharing
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user