ocl: update generator scripts
This commit is contained in:
@@ -3,4 +3,6 @@ echo "Generate files for CL runtime..."
|
||||
python parser_cl.py opencl_core < sources/cl.h
|
||||
python parser_clamdblas.py < sources/clAmdBlas.h
|
||||
python parser_clamdfft.py < sources/clAmdFft.h
|
||||
|
||||
python parser_cl.py opencl_gl < sources/cl_gl.h
|
||||
echo "Generate files for CL runtime... Done"
|
||||
|
@@ -8,9 +8,10 @@ from common import remove_comments, getTokens, getParameters, postProcessParamet
|
||||
|
||||
try:
|
||||
if len(sys.argv) > 1:
|
||||
outfile = open('../../../../include/opencv2/core/opencl/runtime/autogenerated/' + sys.argv[1] + '.hpp', 'wb')
|
||||
outfile_impl = open('../autogenerated/' + sys.argv[1] + '_impl.hpp', 'wb')
|
||||
outfile_wrappers = open('../../../../include/opencv2/core/opencl/runtime/autogenerated/' + sys.argv[1] + '_wrappers.hpp', 'wb')
|
||||
module_name = sys.argv[1]
|
||||
outfile = open('../../../../include/opencv2/core/opencl/runtime/autogenerated/%s.hpp' % module_name, 'wb')
|
||||
outfile_impl = open('../autogenerated/%s_impl.hpp' % module_name, 'wb')
|
||||
outfile_wrappers = open('../../../../include/opencv2/core/opencl/runtime/autogenerated/%s_wrappers.hpp' % module_name, 'wb')
|
||||
if len(sys.argv) > 2:
|
||||
f = open(sys.argv[2], "r")
|
||||
else:
|
||||
@@ -95,7 +96,7 @@ pprint(fns)
|
||||
|
||||
from common import *
|
||||
|
||||
filterFileName='./filter/opencl_core_functions.list'
|
||||
filterFileName = './filter/%s_functions.list' % module_name
|
||||
numEnabled = readFunctionFilter(fns, filterFileName)
|
||||
|
||||
functionsFilter = generateFilterNames(fns)
|
||||
@@ -108,18 +109,27 @@ ctx['CL_REMAP_DYNAMIC'] = generateRemapDynamic(fns)
|
||||
ctx['CL_FN_DECLARATIONS'] = generateFnDeclaration(fns)
|
||||
|
||||
sys.stdout = outfile
|
||||
ProcessTemplate('template/opencl_core.hpp.in', ctx)
|
||||
ProcessTemplate('template/%s.hpp.in' % module_name, ctx)
|
||||
|
||||
ctx['CL_FN_INLINE_WRAPPERS'] = generateInlineWrappers(fns)
|
||||
|
||||
sys.stdout = outfile_wrappers
|
||||
ProcessTemplate('template/opencl_core_wrappers.hpp.in', ctx)
|
||||
ProcessTemplate('template/%s_wrappers.hpp.in' % module_name, ctx)
|
||||
|
||||
ctx['CL_FN_ENTRY_DEFINITIONS'] = generateStructDefinitions(fns)
|
||||
ctx['CL_FN_ENTRY_LIST'] = generateListOfDefinitions(fns)
|
||||
ctx['CL_FN_ENUMS'] = generateEnums(fns)
|
||||
ctx['CL_FN_SWITCH'] = generateTemplates(15, 'opencl_fn', 'opencl_check_fn', 'CL_API_CALL')
|
||||
if module_name == 'opencl_core':
|
||||
ctx['CL_FN_ENTRY_DEFINITIONS'] = generateStructDefinitions(fns)
|
||||
ctx['CL_FN_ENTRY_LIST'] = generateListOfDefinitions(fns)
|
||||
ctx['CL_FN_ENUMS'] = generateEnums(fns)
|
||||
ctx['CL_FN_SWITCH'] = generateTemplates(15, 'opencl_fn', 'opencl_check_fn', 'CL_API_CALL')
|
||||
else:
|
||||
lprefix = module_name + '_fn'
|
||||
enumprefix = module_name.upper() + '_FN'
|
||||
fn_list_name = module_name + '_fn_list'
|
||||
ctx['CL_FN_ENTRY_DEFINITIONS'] = generateStructDefinitions(fns, lprefix=lprefix, enumprefix=enumprefix)
|
||||
ctx['CL_FN_ENTRY_LIST'] = generateListOfDefinitions(fns, fn_list_name)
|
||||
ctx['CL_FN_ENUMS'] = generateEnums(fns, prefix=enumprefix)
|
||||
ctx['CL_FN_SWITCH'] = generateTemplates(15, lprefix, '%s_check_fn' % module_name, 'CL_API_CALL')
|
||||
ctx['CL_NUMBER_OF_ENABLED_FUNCTIONS'] = '// number of enabled functions: %d' % (numEnabled)
|
||||
|
||||
sys.stdout = outfile_impl
|
||||
ProcessTemplate('template/opencl_core_impl.hpp.in', ctx)
|
||||
ProcessTemplate('template/%s_impl.hpp.in' % module_name, ctx)
|
||||
|
@@ -0,0 +1,17 @@
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_HPP__
|
||||
#error "Invalid usage"
|
||||
#endif
|
||||
|
||||
@CL_REMAP_ORIGIN@
|
||||
|
||||
#if defined __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#include <OpenCL/cl_gl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
@CL_REMAP_DYNAMIC@
|
||||
|
||||
@CL_FN_DECLARATIONS@
|
@@ -0,0 +1,11 @@
|
||||
@CL_FN_ENUMS@
|
||||
|
||||
namespace {
|
||||
@CL_FN_SWITCH@
|
||||
} // anonymous namespace
|
||||
|
||||
@CL_FN_ENTRY_DEFINITIONS@
|
||||
|
||||
@CL_FN_ENTRY_LIST@
|
||||
|
||||
@CL_NUMBER_OF_ENABLED_FUNCTIONS@
|
@@ -0,0 +1,5 @@
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_WRAPPERS_HPP__
|
||||
#error "Invalid usage"
|
||||
#endif
|
||||
|
||||
@CL_FN_INLINE_WRAPPERS@
|
@@ -279,4 +279,30 @@ static void* opencl_check_fn(int ID)
|
||||
return func;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
|
||||
#include "opencv2/core/opencl/runtime/opencl_gl.hpp"
|
||||
|
||||
static void* opencl_gl_check_fn(int ID);
|
||||
|
||||
#include "autogenerated/opencl_gl_impl.hpp"
|
||||
|
||||
static void* opencl_gl_check_fn(int ID)
|
||||
{
|
||||
const struct DynamicFnEntry* e = NULL;
|
||||
assert(ID >= 0 && ID < (int)(sizeof(opencl_gl_fn_list)/sizeof(opencl_gl_fn_list[0])));
|
||||
e = opencl_gl_fn_list[ID];
|
||||
void* func = CV_CL_GET_PROC_ADDRESS(e->fnName);
|
||||
if (!func)
|
||||
{
|
||||
throw cv::Exception(cv::Error::OpenCLApiCallError,
|
||||
cv::format("OpenCL function is not available: [%s]", e->fnName),
|
||||
CV_Func, __FILE__, __LINE__);
|
||||
}
|
||||
*(e->ppFn) = func;
|
||||
return func;
|
||||
}
|
||||
|
||||
#endif // HAVE_OPENGL
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user