Commit 7f0680fc authored by Alexander Alekhin's avatar Alexander Alekhin

ocl: workaround for OpenCL C++ bindings usage: CL/cl.hpp

parent 8beb514e
......@@ -50,6 +50,15 @@
#include <fstream>
#include "cl_programcache.hpp"
// workaround for OpenCL C++ bindings
#if defined(HAVE_OPENCL12)
#include "opencv2/ocl/cl_runtime/cl_runtime_opencl12_wrappers.hpp"
#elif defined(HAVE_OPENCL11)
#include "opencv2/ocl/cl_runtime/cl_runtime_opencl11_wrappers.hpp"
#else
#error Invalid OpenCL configuration
#endif
#if defined _MSC_VER && _MSC_VER >= 1200
#pragma warning( disable: 4100 4101 4127 4244 4267 4510 4512 4610)
#endif
......
......@@ -50,6 +50,15 @@
#include <fstream>
#include "cl_programcache.hpp"
// workaround for OpenCL C++ bindings
#if defined(HAVE_OPENCL12)
#include "opencv2/ocl/cl_runtime/cl_runtime_opencl12_wrappers.hpp"
#elif defined(HAVE_OPENCL11)
#include "opencv2/ocl/cl_runtime/cl_runtime_opencl11_wrappers.hpp"
#else
#error Invalid OpenCL configuration
#endif
#if defined _MSC_VER && _MSC_VER >= 1200
# pragma warning( disable: 4100 4244 4267 4510 4512 4610)
#endif
......
......@@ -182,6 +182,29 @@ def generateTemplates(sz, lprefix, switch_name, calling_convention=''):
print '};'
print ''
@outputToString
def generateInlineWrappers(fns):
print '// generated by %s' % os.path.basename(sys.argv[0])
for fn in fns:
print '#undef %s' % (fn['name'])
print '#define %s %s_fn' % (fn['name'], fn['name'])
params = []
call_params = []
for i in range(0, len(fn['params'])):
t = fn['params'][i]
if t.find('*)') >= 0:
p = re.sub(r'\*\)', (' *p%d)' % i), t, 1)
params.append(p)
else:
params.append('%s p%d' % (t, i))
call_params.append('p%d' % (i))
if len(fn['ret']) == 1 and fn['ret'][0] == 'void':
print 'inline void %s(%s) { %s_pfn(%s); }' \
% (fn['name'], ', '.join(params), fn['name'], ', '.join(call_params))
else:
print 'inline %s %s(%s) { return %s_pfn(%s); }' \
% (' '.join(fn['ret']), fn['name'], ', '.join(params), fn['name'], ', '.join(call_params))
def ProcessTemplate(inputFile, ctx, noteLine='//\n// AUTOGENERATED, DO NOT EDIT\n//'):
f = open(inputFile, "r")
......
......@@ -10,6 +10,7 @@ try:
if len(sys.argv) > 1:
outfile = open('../../../include/opencv2/ocl/cl_runtime/' + sys.argv[1] + '.hpp', "w")
outfile_impl = open('../' + sys.argv[1] + '_impl.hpp', "w")
outfile_wrappers = open('../../../include/opencv2/ocl/cl_runtime/' + sys.argv[1] + '_wrappers.hpp', "w")
if len(sys.argv) > 2:
f = open(sys.argv[2], "r")
else:
......@@ -102,6 +103,11 @@ ctx['CL_FN_DECLARATIONS'] = generateFnDeclaration(fns)
sys.stdout = outfile
ProcessTemplate('template/cl_runtime_opencl.hpp.in', ctx)
ctx['CL_FN_INLINE_WRAPPERS'] = generateInlineWrappers(fns)
sys.stdout = outfile_wrappers
ProcessTemplate('template/cl_runtime_opencl_wrappers.hpp.in', ctx)
ctx['CL_FN_ENUMS'] = generateEnums(fns)
ctx['CL_FN_NAMES'] = generateNames(fns)
ctx['CL_FN_DEFINITIONS'] = generateFnDefinition(fns)
......
#ifndef __OPENCV_OCL_CL_RUNTIME_OPENCL_WRAPPERS_HPP__
#define __OPENCV_OCL_CL_RUNTIME_OPENCL_WRAPPERS_HPP__
@CL_FN_INLINE_WRAPPERS@
#endif // __OPENCV_OCL_CL_RUNTIME_OPENCL_WRAPPERS_HPP__
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment