00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined SoOpenCL_H
00024 #define SoOpenCL_H
00025
00026 #include <Inventor/SbString.h>
00027 #include <Inventor/STL/vector>
00028 #include <Inventor/threads/SbThreadMutex.h>
00029
00030 #include <Inventor/OpenCL/SoOpenCLDefs.h>
00031
00032 #include <Inventor/SoModule.h>
00033 SO_MODULE_HEADER(SoOpenCL,__INVOPENCLDLL)
00034
00035 class SoOpenCLHandle;
00036
00110 class INVENTOROPENCL_API SoOpenCL
00111 {
00112 public:
00113
00117 enum SoOpenCLError
00118 {
00120 SO_OPENCL_SUCCESS,
00121
00123 SO_OPENCL_MODULE_LOAD_ERROR,
00124
00126 SO_OPENCL_MODULE_FUNCTION_ERROR,
00127
00129 SO_OPENCL_INVALID_PARAMETER,
00130
00135 SO_OPENCL_INVALID_CONTEXT
00136 };
00137
00138
00143 static void init();
00144
00149 static void finish();
00150
00155 static bool isInitialized();
00156
00162 static SbBool isAvailable();
00163
00172 static SoOpenCLError loadSourceModule( const SbString& filename, const SbString& moduleName );
00173
00182 static SoOpenCLHandle* findFunction( const SbString& moduleName, const SbString& functionName );
00183
00184
00194 static SoOpenCLError findFunction( SoOpenCLHandle* handle, const SbString& moduleName,
00195 const SbString& functionName );
00196
00197 private:
00198
00200 struct SoOpenCLModule
00201 {
00203 SbString name;
00204
00206 std::vector< SbString > functions;
00207
00209 void* data;
00210
00212 bool allocated;
00213 };
00214
00220 static void registerModule( SoOpenCLModule* module );
00221
00229 static void extractFunctionNames( SoOpenCLModule* module, const char* buffer );
00230 static void declareModule(const SbString& moduleName, const char* codeStr, bool isAllocated );
00231
00237 static void removeModule( const SbString& moduleName );
00238
00242 static void initGLInterop();
00243
00247 static void throwCLError( const char* str, const char* function, int errorCode );
00248
00249 private:
00250
00251 static SbThreadMutex s_initThreadMutex;
00252
00253 static int s_initRefCount;
00254
00255 static bool s_glOpInitialized;
00256 };
00257
00258 #endif //SoOpenCL_H
00259
00260