Voxel
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
opencl_program.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef OPENCL_PROGRAM_H
4 #define OPENCL_PROGRAM_H
5 
6 
7 /**
8  \file
9  \brief Contains OpenCL::Program class.
10 */
11 
12 
13 
14 
15 #include "settings.h"
16 
17 
18 
19 
20 #if ( SETTING_OPENCL != 0 )
21 
22 
23 
24 
25 #include "opencl_state.h"
26 #include "opencl_deleter.h"
27 
28 #include <CL/cl.h>
29 
30 #include <memory>
31 
32 
33 
34 
35 namespace OpenCL {
36 
37 
38 
39 
40 /*==============================================================================
41  Program class
42 ==============================================================================*/
43 
44 
45 /**
46  \brief OpenCL program class.
47 
48  The constructor attempts to create and build a program from a list of
49  source files. If any of the OpenCL calls which perform this task fail, than
50  an OpenCL Exception will be thrown. The compiled program can be accessed
51  via the \c BuiltProgram accessor function.
52 */
53 struct Program {
54 
55  /**
56  \brief Constructs and builds an OpenCL program.
57 
58  \param pState Pointer to the OpenCL State for which to build this program.
59  \param filenames <tt>NULL</tt>-terminated list of <tt>'\0'</tt>-terminated strings containing the files to build (each containing OpenCL source).
60  \param options Compiler options to pass to \c clBuildProgram.
61  \param logFilename File to which to write a build log, on failure. If NULL, no log will be written.
62  */
63  Program(
64  std::shared_ptr< State > const& pState,
65  char const* const* const filenames,
66  char const* const options,
67  char const* const logFilename = NULL
68  );
69 
70 
71  inline cl_program BuiltProgram() const; ///< \brief Returns built OpenCL program.
72 
73 
74 private:
75 
76  std::shared_ptr< State > m_pState;
77  std::unique_ptr< _cl_program, Deleter< _cl_program > > m_program;
78 };
79 
80 
81 
82 
83 /*==============================================================================
84  Program methods
85 ==============================================================================*/
86 
87 
88 cl_program Program::BuiltProgram() const {
89 
90  return m_program.get();
91 }
92 
93 
94 
95 
96 } // namespace OpenCL
97 
98 
99 
100 
101 #endif // SETTING_OPENCL
102 
103 
104 
105 
106 #endif // OPENCL_PROGRAM_H