00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SO_GL_DEVICE
00025 #define SO_GL_DEVICE
00026
00028
00029
00030
00031
00032
00033
00035
00036 #include <Inventor/devices/SoDevice.h>
00037 #include <Inventor/devices/SoGLScreenDevice.h>
00038 #include <Inventor/STL/vector>
00039 #include <Inventor/devices/SoGLDeviceSettings.h>
00040
00062 class SoGLDevice : public SoDevice
00063 {
00064
00065 public:
00066
00070 virtual unsigned long long getTotalMemory() const;
00071
00078 virtual unsigned long long getAvailableMemory() const;
00079
00084 virtual unsigned int getLogicalUnits() const;
00085
00089 virtual SbString getDriverVersion() const;
00090
00097 virtual SoGLDeviceSettings* getDeviceSettings() const;
00098
00102 virtual SbString getDeviceName() const;
00103
00110 static SoGLDevice* findFirstAvailableDevice();
00111
00115 static unsigned int getDevicesCount();
00116
00122 static SoGLDevice* getDevice( int index );
00123
00128 SoGLScreenDevice* getMainScreenDevice();
00129
00133 unsigned int getScreenDevicesCount();
00134
00140 SoGLScreenDevice* getScreenDevice( int index );
00141
00145 static void initClass();
00146
00150 static void exitClass();
00151
00155 friend std::ostream& operator << ( std::ostream& os, const SoGLDevice& dev )
00156 {
00157 unsigned long long allocatedMemory, availableMemory;
00158 dev.getMemoryInfo( allocatedMemory, availableMemory );
00159
00160 return os << "[GPU name]: " << dev.m_name.toLatin1() << "\n" << \
00161 "[Driver ver]: " << dev.m_drvVer.toLatin1() << "\n" << \
00162 "[Vram size]: " << (dev.m_totalMemory)/(1024*1024) << "MB" << "\n" <<
00163 "[Available Vram size]: " << availableMemory/(1024*1024) << "MB" << "\n" <<
00164 "[LogicalUnits]: " << dev.m_logicalUnitsCount;
00165 }
00166
00167
00168 private:
00169
00173 SoGLDevice();
00174
00178 virtual ~SoGLDevice();
00179
00183 static bool findFirstDeviceFunc( SoDevice* device );
00184
00185
00186 private:
00187
00188
00190 enum VideoCardType
00191 {
00195 VC_ATI,
00199 VC_NVIDIA,
00203 VC_VIRTUALBOX,
00207 VC_MESA,
00211 VC_UNKNOWN
00212 };
00213
00214 void getMemoryInfo( unsigned long long& allocatedMemory, unsigned long long& availableMemory ) const;
00215
00216
00217 static void defaultDeviceInit();
00218
00219
00220 unsigned long long m_totalMemory;
00221
00222
00223 unsigned int m_logicalUnitsCount;
00224
00225
00226 SbString m_name;
00227
00228
00229 SbString m_drvVer;
00230
00231 VideoCardType m_vcType;
00232
00233
00234 static std::vector<SoGLDevice*> s_glDevices;
00235
00236
00237 std::vector<SoGLScreenDevice*> m_screenDevices;
00238
00239
00240 static SbThreadMutex s_initThreadMutex;
00241
00242
00243 static int s_initRefCount;
00244 };
00245
00246
00247 inline unsigned long long
00248 SoGLDevice::getTotalMemory() const
00249 {
00250 return m_totalMemory;
00251 }
00252
00253 inline unsigned int
00254 SoGLDevice::getLogicalUnits() const
00255 {
00256 return m_logicalUnitsCount;
00257 }
00258
00259 inline SbString
00260 SoGLDevice::getDeviceName() const
00261 {
00262 return m_name;
00263 }
00264
00265 #endif // SO_GL_DEVICE
00266
00267
00268