hwsd  1.4.0
Local and remote ZeroConf service discovery for hardware resources
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 
47  static const unsigned FLAG_VNC = 0x4;
48 
50  HWSD_API GPUInfo();
51 
61  HWSD_API explicit GPUInfo( const std::string& name );
62 
64  HWSD_API void invalidatePVP();
65 
67  HWSD_API bool operator == ( const GPUInfo& rhs ) const;
68 
70  HWSD_API bool operator != ( const GPUInfo& rhs ) const;
71 
73  HWSD_API std::string getName() const;
74 
76  unsigned type;
77 
79  unsigned port;
80 
85  unsigned device;
86 
88  int pvp[4];
89 
90  unsigned flags;
91  unsigned unused;
92 };
93 
94 inline std::ostream& operator << ( std::ostream& os, const GPUInfo& info )
95 {
96  os << "GPUInfo\n" << static_cast< const NodeInfo& >( info );
97  if( !info.getName().empty( ))
98  os << " Type " << info.getName() << std::endl;
99  if( info.port != GPUInfo::defaultValue )
100  os << " Port " << info.port << std::endl;
101  if( info.device != GPUInfo::defaultValue )
102  os << " Device " << info.device << std::endl;
103  if( info.pvp[2] >0 && info.pvp[3] > 0 )
104  os << " Viewport [" << info.pvp[0] << ' ' << info.pvp[1] << ' '
105  << info.pvp[2] << ' ' << info.pvp[3] << ']' << std::endl;
106  if( info.flags != 0 )
107  os << " Flags "
108  << ((info.flags&GPUInfo::FLAG_VIRTUALGL) ? "VirtualGL" : "")
109  << ((info.flags&GPUInfo::FLAG_VIRTUALGL_DISPLAY) ? "Display" : "")
110  << std::endl;
111  return os;
112 }
113 }
114 
115 #endif // HWSD_GPUINFO_H
bool operator==(const GPUInfo &rhs) const
Defines export visibility macros for library hwsd.
int pvp[4]
The size and location of the GPU (x,y,w,h).
Definition: gpuInfo.h:88
GPUInfo()
Default constructor pointing to the default display.
A structure containing node-specific information.
Definition: nodeInfo.h:31
static const unsigned FLAG_VNC
Virtual device provided by a VNC X server.
Definition: gpuInfo.h:47
Definition: filter.h:27
unsigned type
Four-character code of the GPU type.
Definition: gpuInfo.h:76
unsigned port
The display (GLX) or ignored (WGL, AGL).
Definition: gpuInfo.h:79
static const unsigned FLAG_VIRTUALGL_DISPLAY
VirtualGL redirect GPU.
Definition: gpuInfo.h:42
void invalidatePVP()
Invalidate the pixel viewport.
bool operator!=(const GPUInfo &rhs) const
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
A structure containing GPU-specific information.
Definition: gpuInfo.h:33
std::string getName() const
unsigned device
The screen (GLX, WGL), GPU (WGLn, WGLa) or virtual screen (AGL).
Definition: gpuInfo.h:85
unsigned flags
bitmask of additional GPU capabilities
Definition: gpuInfo.h:90