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_UNKNOWN
00208 };
00209
00210 void getMemoryInfo( unsigned long long& allocatedMemory, unsigned long long& availableMemory ) const;
00211
00212
00213 static void defaultDeviceInit();
00214
00215
00216 unsigned long long m_totalMemory;
00217
00218
00219 unsigned int m_logicalUnitsCount;
00220
00221
00222 SbString m_name;
00223
00224
00225 SbString m_drvVer;
00226
00227 VideoCardType m_vcType;
00228
00229
00230 static std::vector<SoGLDevice*> s_glDevices;
00231
00232
00233 std::vector<SoGLScreenDevice*> m_screenDevices;
00234
00235
00236 static SbThreadMutex s_initThreadMutex;
00237
00238
00239 static int s_initRefCount;
00240 };
00241
00242
00243 inline unsigned long long
00244 SoGLDevice::getTotalMemory() const
00245 {
00246 return m_totalMemory;
00247 }
00248
00249 inline unsigned int
00250 SoGLDevice::getLogicalUnits() const
00251 {
00252 return m_logicalUnitsCount;
00253 }
00254
00255 inline SbString
00256 SoGLDevice::getDeviceName() const
00257 {
00258 return m_name;
00259 }
00260
00261 #endif // SO_GL_DEVICE
00262
00263
00264