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 SoOpenCLCONTEXT_H
00024 #define SoOpenCLCONTEXT_H
00025
00026 #include <Inventor/devices/SoDeviceContext.h>
00027 #include <Inventor/threads/SbThread.h>
00028 #include <Inventor/threads/SbThreadMutex.h>
00029
00030 #include <Inventor/STL/map>
00031 #include <Inventor/STL/vector>
00032
00033 #include <Inventor/OpenCL/SoOpenCLDefs.h>
00034
00035 #include <Inventor/sys/SoCL.h>
00036
00037 #ifdef _MSC_VER
00038 #pragma warning( push )
00039 #pragma warning(disable:4251)
00040 #endif
00041
00042 class SoOpenCLDevice;
00043
00106 class INVENTOROPENCL_API SoOpenCLContext : public SoDeviceContext
00107 {
00108 public:
00114 SoOpenCLContext( SoOpenCLDevice* device );
00115
00123 void bind();
00124
00129 void unbind();
00130
00136 static SoOpenCLContext* getCurrent();
00137
00141 virtual bool isCurrent() const;
00142
00152 virtual bool isCompatible( SoDeviceContext* context ) const;
00153
00157 inline cl_context getOpenCLContext() const
00158 { return m_context; }
00159
00163 inline cl_command_queue getOpenCLCommandQueue() const
00164 { return m_command_queue; }
00165
00169 inline SoOpenCLDevice *getDevice() const
00170 { return m_device; }
00171
00172 private:
00174 virtual ~SoOpenCLContext();
00175
00177 static void lockListsMutex();
00178
00180 static void unlockListsMutex();
00181
00182 private:
00183
00185 cl_context m_context;
00186
00188 cl_command_queue m_command_queue;
00189
00191 static SbThreadMutex s_contextsMutex;
00192
00194 static std::map< SbThreadId_t, std::vector< SoOpenCLContext* > > s_bindedContexts;
00195
00197 SoOpenCLDevice *m_device;
00198
00199 private:
00200
00201 virtual SbString getInfos();
00202
00203 };
00204
00205 #ifdef _MSC_VER
00206 #pragma warning( pop )
00207 #endif
00208
00209
00210 #endif //SoOpenCLCONTEXT_H
00211
00212