hwsd  1.1.1
 All Classes Files Functions Variables Enumerations Enumerator Pages
gpuInfo.h
1 
2 /* Copyright (c) 2011-2013, Stefan Eilemann <eile@eyescale.ch>
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 2.1 as published
6  * by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
18 #ifndef HWSD_GPUINFO_H
19 #define HWSD_GPUINFO_H
20 
21 #include <hwsd/api.h>
22 #include <hwsd/nodeInfo.h> // base class
23 
24 #include <climits>
25 #include <cstring>
26 #include <iostream>
27 #include <string>
28 
29 
30 namespace hwsd
31 {
33 struct GPUInfo : public NodeInfo
34 {
36  static const unsigned defaultValue = UINT_MAX;
37 
39  static const unsigned FLAG_VIRTUALGL = 0x1;
40 
42  static const unsigned FLAG_VIRTUALGL_DISPLAY = 0x2;
43 
45  HWSD_API GPUInfo();
46 
56  HWSD_API GPUInfo( const std::string& name );
57 
59  HWSD_API void invalidatePVP();
60 
62  HWSD_API bool operator == ( const GPUInfo& rhs ) const;
63 
65  HWSD_API bool operator != ( const GPUInfo& rhs ) const;
66 
68  HWSD_API std::string getName() const;
69 
71  unsigned type;
72 
74  unsigned port;
75 
80  unsigned device;
81 
83  int pvp[4];
84 
85  unsigned flags;
86  unsigned unused;
87 };
88 
89 inline std::ostream& operator << ( std::ostream& os, const GPUInfo& info )
90 {
91  os << "GPUInfo\n" << static_cast< const NodeInfo& >( info );
92  if( !info.getName().empty( ))
93  os << " Type " << info.getName() << std::endl;
94  if( info.port != GPUInfo::defaultValue )
95  os << " Port " << info.port << std::endl;
96  if( info.device != GPUInfo::defaultValue )
97  os << " Device " << info.device << std::endl;
98  if( info.pvp[2] >0 && info.pvp[3] > 0 )
99  os << " Viewport [" << info.pvp[0] << ' ' << info.pvp[1] << ' '
100  << info.pvp[2] << ' ' << info.pvp[3] << ']' << std::endl;
101  if( info.flags != 0 )
102  os << " Flags "
103  << (info.flags&GPUInfo::FLAG_VIRTUALGL ? "VirtualGL" : "")
104  << (info.flags&GPUInfo::FLAG_VIRTUALGL_DISPLAY ? "Display" : "")
105  << std::endl;
106  return os;
107 }
108 }
109 
110 #endif // HWSD_GPUINFO_H
Defines export visibility macros for hwsd.
int pvp[4]
The size and location of the GPU (x,y,w,h).
Definition: gpuInfo.h:83
A structure containing node-specific information.
Definition: nodeInfo.h:31
HWSD_API std::string getName() const
unsigned type
Four-character code of the GPU type.
Definition: gpuInfo.h:71
HWSD_API bool operator==(const GPUInfo &rhs) const
unsigned port
The display (GLX) or ignored (WGL, AGL).
Definition: gpuInfo.h:74
HWSD_API bool operator!=(const GPUInfo &rhs) const
static const unsigned FLAG_VIRTUALGL_DISPLAY
VirtualGL redirect GPU.
Definition: gpuInfo.h:42
static const unsigned defaultValue
A non-enumerated port or device.
Definition: gpuInfo.h:36
static const unsigned FLAG_VIRTUALGL
Process runs under VirtualGL.
Definition: gpuInfo.h:39
HWSD_API GPUInfo()
Default constructor pointing to the default display.
A structure containing GPU-specific information.
Definition: gpuInfo.h:33
HWSD_API void invalidatePVP()
Invalidate the pixel viewport.
unsigned device
The screen (GLX, WGL), GPU (WGLn, WGLa) or virtual screen (AGL).
Definition: gpuInfo.h:80
unsigned flags
bitmask of additional GPU capabilities
Definition: gpuInfo.h:85