hwsd  2.0.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 namespace hwsd
30 {
32 struct GPUInfo : public NodeInfo
33 {
35  static const unsigned FLAG_VIRTUALGL = 0x1;
36 
38  static const unsigned FLAG_VIRTUALGL_DISPLAY = 0x2;
39 
43  static const unsigned FLAG_VNC = 0x4;
44 
46  static const unsigned FLAG_DEFAULT = 0x8;
47 
52  HWSD_API GPUInfo();
53 
65  HWSD_API explicit GPUInfo(const std::string& name);
66 
68  HWSD_API void invalidatePVP();
69 
71  HWSD_API bool operator==(const GPUInfo& rhs) const;
72 
74  HWSD_API bool operator!=(const GPUInfo& rhs) const;
75 
77  HWSD_API std::string getName() const;
78 
80  unsigned type;
81 
83  unsigned port;
84 
89  unsigned device;
90 
92  int pvp[4];
93 
94  unsigned flags;
95  unsigned unused;
96 };
97 
98 inline std::ostream& operator<<(std::ostream& os, const GPUInfo& info)
99 {
100  os << "GPUInfo\n" << static_cast<const NodeInfo&>(info);
101  if (!info.getName().empty())
102  os << " Type " << info.getName() << std::endl;
103  os << " Port " << info.port << std::endl;
104  os << " Device " << info.device << std::endl;
105  if (info.pvp[2] > 0 && info.pvp[3] > 0)
106  os << " Viewport [" << info.pvp[0] << ' ' << info.pvp[1] << ' '
107  << info.pvp[2] << ' ' << info.pvp[3] << ']' << std::endl;
108  if (info.flags != 0)
109  os << " Flags "
110  << ((info.flags & GPUInfo::FLAG_VIRTUALGL) ? "VirtualGL" : "")
111  << ((info.flags & GPUInfo::FLAG_VIRTUALGL_DISPLAY) ? "Display" : "")
112  << std::endl;
113  return os;
114 }
115 }
116 
117 #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:92
GPUInfo()
Default constructor.
A structure containing node-specific information.
Definition: nodeInfo.h:30
static const unsigned FLAG_VNC
Virtual device provided by a VNC X server.
Definition: gpuInfo.h:43
Definition: filter.h:27
unsigned type
Four-character code of the GPU type.
Definition: gpuInfo.h:80
unsigned port
The display (GLX) or ignored (WGL, AGL).
Definition: gpuInfo.h:83
static const unsigned FLAG_DEFAULT
Default GPU pointed by the DISPLAY variable (GLX only).
Definition: gpuInfo.h:46
static const unsigned FLAG_VIRTUALGL_DISPLAY
VirtualGL redirect GPU.
Definition: gpuInfo.h:38
void invalidatePVP()
Invalidate the pixel viewport.
bool operator!=(const GPUInfo &rhs) const
static const unsigned FLAG_VIRTUALGL
Process runs under VirtualGL.
Definition: gpuInfo.h:35
A structure containing GPU-specific information.
Definition: gpuInfo.h:32
std::string getName() const
unsigned device
The screen (GLX, WGL), GPU (WGLn, WGLa) or virtual screen (AGL).
Definition: gpuInfo.h:89
unsigned flags
bitmask of additional GPU capabilities
Definition: gpuInfo.h:94