Skip to content

Commit 925594d

Browse files
committed
Merge pull request opencv#7894 from alalek:ocl_program
2 parents dd81c29 + c3e409f commit 925594d

File tree

5 files changed

+1361
-1270
lines changed

5 files changed

+1361
-1270
lines changed

cmake/cl2cpp.cmake

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,8 @@ endif()
1212
string(REGEX REPLACE "\\.cpp$" ".hpp" OUTPUT_HPP "${OUTPUT}")
1313
get_filename_component(OUTPUT_HPP_NAME "${OUTPUT_HPP}" NAME)
1414

15-
if("${MODULE_NAME}" STREQUAL "ocl")
16-
set(nested_namespace_start "")
17-
set(nested_namespace_end "")
18-
else()
19-
set(new_mode ON)
20-
set(nested_namespace_start "namespace ${MODULE_NAME}\n{")
21-
set(nested_namespace_end "}")
22-
endif()
15+
set(nested_namespace_start "namespace ${MODULE_NAME}\n{")
16+
set(nested_namespace_end "}")
2317

2418
set(STR_CPP "// This file is auto-generated. Do not edit!
2519
@@ -35,6 +29,8 @@ namespace ocl
3529
{
3630
${nested_namespace_start}
3731
32+
static const char* const moduleName = \"${MODULE_NAME}\";
33+
3834
")
3935

4036
set(STR_HPP "// This file is auto-generated. Do not edit!
@@ -76,27 +72,23 @@ foreach(cl ${cl_list})
7672

7773
string(MD5 hash "${lines}")
7874

79-
set(STR_CPP_DECL "const struct ProgramEntry ${cl_filename}={\"${cl_filename}\",\n\"${lines}, \"${hash}\"};\n")
80-
set(STR_HPP_DECL "extern const struct ProgramEntry ${cl_filename};\n")
81-
if(new_mode)
82-
set(STR_CPP_DECL "${STR_CPP_DECL}ProgramSource ${cl_filename}_oclsrc(${cl_filename}.programStr);\n")
83-
set(STR_HPP_DECL "${STR_HPP_DECL}extern ProgramSource ${cl_filename}_oclsrc;\n")
84-
endif()
75+
set(STR_CPP_DECL "struct cv::ocl::internal::ProgramEntry ${cl_filename}_oclsrc={moduleName, \"${cl_filename}\",\n\"${lines}, \"${hash}\", NULL};\n")
76+
set(STR_HPP_DECL "extern struct cv::ocl::internal::ProgramEntry ${cl_filename}_oclsrc;\n")
8577

8678
set(STR_CPP "${STR_CPP}${STR_CPP_DECL}")
8779
set(STR_HPP "${STR_HPP}${STR_HPP_DECL}")
8880
endforeach()
8981

90-
set(STR_CPP "${STR_CPP}}\n${nested_namespace_end}}\n#endif\n")
91-
set(STR_HPP "${STR_HPP}}\n${nested_namespace_end}}\n#endif\n")
82+
set(STR_CPP "${STR_CPP}\n${nested_namespace_end}}}\n#endif\n")
83+
set(STR_HPP "${STR_HPP}\n${nested_namespace_end}}}\n#endif\n")
9284

9385
file(WRITE "${OUTPUT}" "${STR_CPP}")
9486

9587
if(EXISTS "${OUTPUT_HPP}")
9688
file(READ "${OUTPUT_HPP}" hpp_lines)
9789
endif()
9890
if("${hpp_lines}" STREQUAL "${STR_HPP}")
99-
message(STATUS "${OUTPUT_HPP} contains same content")
91+
message(STATUS "${OUTPUT_HPP} contains the same content")
10092
else()
10193
file(WRITE "${OUTPUT_HPP}" "${STR_HPP}")
10294
endif()

modules/core/include/opencv2/core/ocl.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,17 +629,18 @@ class CV_EXPORTS Program
629629
class CV_EXPORTS ProgramSource
630630
{
631631
public:
632-
typedef uint64 hash_t;
632+
typedef uint64 hash_t; // deprecated
633633

634634
ProgramSource();
635-
explicit ProgramSource(const String& prog);
636-
explicit ProgramSource(const char* prog);
635+
explicit ProgramSource(const String& module, const String& name, const String& codeStr, const String& codeHash);
636+
explicit ProgramSource(const String& prog); // deprecated
637+
explicit ProgramSource(const char* prog); // deprecated
637638
~ProgramSource();
638639
ProgramSource(const ProgramSource& prog);
639640
ProgramSource& operator = (const ProgramSource& prog);
640641

641642
const String& source() const;
642-
hash_t hash() const;
643+
hash_t hash() const; // deprecated
643644

644645
protected:
645646
struct Impl;

modules/core/include/opencv2/core/ocl_genbase.hpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,28 @@
4242
#ifndef OPENCV_OPENCL_GENBASE_HPP
4343
#define OPENCV_OPENCL_GENBASE_HPP
4444

45-
namespace cv
46-
{
47-
namespace ocl
48-
{
49-
5045
//! @cond IGNORED
5146

52-
struct ProgramEntry
47+
namespace cv {
48+
namespace ocl {
49+
50+
class ProgramSource;
51+
52+
namespace internal {
53+
54+
struct CV_EXPORTS ProgramEntry
5355
{
56+
const char* module;
5457
const char* name;
55-
const char* programStr;
58+
const char* programCode;
5659
const char* programHash;
60+
ProgramSource* pProgramSource;
61+
62+
operator ProgramSource& () const;
5763
};
5864

59-
//! @endcond
65+
} } } // namespace
6066

61-
}
62-
}
67+
//! @endcond
6368

6469
#endif

0 commit comments

Comments
 (0)