Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_OPENCL_PROGRAM_H__
00009 #define __SP_OPENCL_PROGRAM_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #if defined(SP_COMPILE_WITH_OPENCL)
00015
00016
00017 #include "Base/spInputOutputString.hpp"
00018 #include "Framework/OpenCL/spOpenCLCoreHeader.hpp"
00019 #include "Framework/OpenCL/spOpenCLBuffer.hpp"
00020
00021 #include <map>
00022
00023
00024 namespace sp
00025 {
00026 namespace video
00027 {
00028
00029
00034 class SP_EXPORT OpenCLProgram
00035 {
00036
00037 public:
00038
00039 OpenCLProgram(const io::stringc &SourceString, const io::stringc &CompilationOptions = "");
00040 ~OpenCLProgram();
00041
00042
00043
00044 bool compile(const io::stringc &SourceString, const io::stringc &CompilationOptions = "");
00045
00046 bool addKernel(const io::stringc &EntryPoint);
00047
00056 bool run(
00057 const io::stringc &EntryPoint, s32 Dimensions, const size_t* GlobalWorkSizes, const size_t* LocalWorkSizes
00058 );
00059
00060 bool setParameter(const io::stringc &EntryPoint, u32 Index, const void* Buffer, u32 Size);
00061 bool setParameter(const io::stringc &EntryPoint, u32 Index, OpenCLBuffer* Buffer);
00062
00063
00064
00065 inline bool run(
00066 const io::stringc &KernelEntryPoint, size_t GlobalWorkSize, size_t LocalWorkSize)
00067 {
00068 return run(KernelEntryPoint, 1, &GlobalWorkSize, &LocalWorkSize);
00069 }
00070
00071 template <typename T> bool setParameter(const io::stringc &EntryPoint, u32 Index, const T &Value)
00072 {
00073 return setParameter(EntryPoint, Index, &Value, sizeof(T));
00074 }
00075
00077 inline bool valid() const
00078 {
00079 return BuildSuccessful_;
00080 }
00081
00082 private:
00083
00084
00085
00086 void releaseProgram();
00087
00088 bool buildProgram(const io::stringc &SourceString, const io::stringc &CompilationOptions);
00089
00090
00091
00092 cl_program clProgram_;
00093 std::map<std::string, cl_kernel> clKernelList_;
00094
00095 bool BuildSuccessful_;
00096
00097 };
00098
00099
00100 }
00101
00102 }
00103
00104
00105 #endif
00106
00107 #endif
00108
00109
00110
00111