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 SOCUDA_H
00024 #define SOCUDA_H
00025
00026 #include <Inventor/SbString.h>
00027 #include <Inventor/STL/vector>
00028 #include <Inventor/threads/SbThreadMutex.h>
00029
00030 #include <Inventor/cuda/SoCudaDefs.h>
00031
00032 #include <Inventor/SoModule.h>
00033 SO_MODULE_HEADER(SoCuda,__INVCUDADLL)
00034
00035 class SoCudaHandle;
00036
00102 class SoCuda
00103 {
00104 public:
00105
00109 enum SoCudaError
00110 {
00112 SO_CUDA_SUCCESS,
00113
00115 SO_CUDA_MODULE_LOAD_ERROR,
00116
00118 SO_CUDA_MODULE_FUNCTION_ERROR,
00119
00121 SO_CUDA_INVALID_PARAMETER,
00122
00127 SO_CUDA_INVALID_CONTEXT
00128 };
00129
00130
00135 static void init();
00136
00141 static void finish();
00142
00147 static bool isInitialized();
00148
00154 static SbBool isAvailable();
00155
00164 static SoCudaError loadBinaryModule( const SbString& filename, const SbString& moduleName );
00165
00175 static SoCudaError loadBinaryModule( const void* moduleData, size_t dataSize, const SbString& moduleName );
00176
00185 static SoCudaHandle* findFunction( const SbString& moduleName, const SbString& functionName );
00186
00187
00197 static SoCudaError findFunction( SoCudaHandle* handle, const SbString& moduleName,
00198 const SbString& functionName );
00199
00200 private:
00201
00203 struct SoCudaModule
00204 {
00206 SbString name;
00207
00209 void* data;
00210
00212 bool allocated;
00213 };
00214
00220 static void registerModule( SoCudaModule* module );
00221
00222 static void declareModule(const SbString& moduleName, const unsigned char* codeStr, bool isAllocated );
00223
00229 static void removeModule( const SbString& moduleName );
00230
00234 static void initGLInterop();
00235
00239 static void throwCudaError( const char* function, const char* str, int errorCode );
00240
00241 private:
00242
00243 static SbThreadMutex s_initThreadMutex;
00244
00245 static int s_initRefCount;
00246
00247 static bool s_glOpInitialized;
00248 };
00249
00250 #endif //SOCUDA_H
00251
00252