mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
ocl: update generator scripts
This commit is contained in:
parent
8298644b85
commit
ee68d26f99
@ -0,0 +1,65 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * 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 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.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the OpenCV Foundation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_HPP__
|
||||
#define __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_HPP__
|
||||
|
||||
#if defined HAVE_OPENCL && defined HAVE_OPENGL
|
||||
|
||||
#include "opencl_core.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCL_STATIC)
|
||||
|
||||
#if defined __APPLE__
|
||||
#include <OpenCL/cl_gl.h>
|
||||
#else
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
#else // HAVE_OPENCL_STATIC
|
||||
|
||||
#include "autogenerated/opencl_gl.hpp"
|
||||
|
||||
#endif // HAVE_OPENCL_STATIC
|
||||
|
||||
#endif // defined HAVE_OPENCL && defined HAVE_OPENGL
|
||||
|
||||
#endif // __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_HPP__
|
@ -0,0 +1,47 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * 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 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.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the OpenCV Foundation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_WRAPPERS_HPP__
|
||||
#define __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_WRAPPERS_HPP__
|
||||
|
||||
#include "autogenerated/opencl_gl_wrappers.hpp"
|
||||
|
||||
#endif // __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_WRAPPERS_HPP__
|
@ -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)
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user