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
00064 class SoGLDevice : public SoDevice
00065 {
00066
00067 public:
00068
00072 virtual unsigned long long getTotalMemory() const;
00073
00080 virtual unsigned long long getAvailableMemory() const;
00081
00086 virtual unsigned int getLogicalUnits() const;
00087
00091 virtual SbString getDriverVersion() const;
00092
00099 virtual SoGLDeviceSettings* getDeviceSettings() const;
00100
00104 virtual SbString getDeviceName() const;
00105
00112 static SoGLDevice* findFirstAvailableDevice();
00113
00117 static unsigned int getDevicesCount();
00118
00124 static SoGLDevice* getDevice( int index );
00125
00130 SoGLScreenDevice* getMainScreenDevice();
00131
00135 unsigned int getScreenDevicesCount();
00136
00142 SoGLScreenDevice* getScreenDevice( int index );
00143
00147 static void initClass();
00148
00152 static void exitClass();
00153
00157 friend std::ostream& operator << ( std::ostream& os, const SoGLDevice& dev )
00158 {
00159 unsigned long long allocatedMemory, availableMemory;
00160 dev.getMemoryInfo( allocatedMemory, availableMemory );
00161
00162 return os << "[GPU name]: " << dev.m_name.toLatin1() << "\n" << \
00163 "[Driver ver]: " << dev.m_drvVer.toLatin1() << "\n" << \
00164 "[Vram size]: " << (dev.m_totalMemory)/(1024*1024) << "MB" << "\n" <<
00165 "[Available Vram size]: " << availableMemory/(1024*1024) << "MB" << "\n" <<
00166 "[LogicalUnits]: " << dev.m_logicalUnitsCount;
00167 }
00168
00169
00170 private:
00171
00175 SoGLDevice();
00176
00180 virtual ~SoGLDevice();
00181
00185 static bool findFirstDeviceFunc( SoDevice* device );
00186
00187
00188 private:
00189
00190
00192 enum VideoCardType
00193 {
00197 VC_ATI,
00201 VC_NVIDIA,
00205 VC_VIRTUALBOX,
00209 VC_UNKNOWN
00210 };
00211
00212 void getMemoryInfo( unsigned long long& allocatedMemory, unsigned long long& availableMemory ) const;
00213
00214
00215 static void defaultDeviceInit();
00216
00217
00218 unsigned long long m_totalMemory;
00219
00220
00221 unsigned int m_logicalUnitsCount;
00222
00223
00224 SbString m_name;
00225
00226
00227 SbString m_drvVer;
00228
00229 VideoCardType m_vcType;
00230
00231
00232 static std::vector<SoGLDevice*> s_glDevices;
00233
00234
00235 std::vector<SoGLScreenDevice*> m_screenDevices;
00236
00237
00238 static SbThreadMutex s_initThreadMutex;
00239
00240
00241 static int s_initRefCount;
00242 };
00243
00244
00245 inline unsigned long long
00246 SoGLDevice::getTotalMemory() const
00247 {
00248 return m_totalMemory;
00249 }
00250
00251 inline unsigned int
00252 SoGLDevice::getLogicalUnits() const
00253 {
00254 return m_logicalUnitsCount;
00255 }
00256
00257 inline SbString
00258 SoGLDevice::getDeviceName() const
00259 {
00260 return m_name;
00261 }
00262
00263 #endif // SO_GL_DEVICE
00264
00265
00266