Line data Source code
1 :
2 : /* Copyright (c) 2009-2012, Stefan Eilemann <eile@equalizergraphics.com>
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 EQ_STATISTIC_H
19 : #define EQ_STATISTIC_H
20 :
21 : #include <eq/client/api.h>
22 : #include <eq/client/types.h>
23 :
24 : #include <iostream>
25 :
26 : namespace eq
27 : {
28 : /**
29 : * A statistics event.
30 : *
31 : * Statistics are events generated by various Equalizer entities, typically
32 : * using StatisticSampler. They are used by the server for load-balancing
33 : * and to render the statistics overlay.
34 : * @sa Channel::drawStatistics
35 : */
36 : struct Statistic
37 : {
38 : /** The type of the statistics event. */
39 : enum Type // Also update string and color table in statistic.cpp
40 : {
41 : NONE = 0,
42 : CHANNEL_CLEAR, //!< Sampling of Channel::frameClear
43 : CHANNEL_DRAW, //!< Sampling of Channel::frameDraw
44 : CHANNEL_DRAW_FINISH, //!< Sampling of Channel::frameDrawFinish
45 : CHANNEL_ASSEMBLE, //!< Sampling of Channel::frameAssemble
46 : CHANNEL_FRAME_WAIT_READY, //!< Sampling of Frame::waitReady
47 : CHANNEL_READBACK, //!< Sampling of Channel::frameReadback
48 : CHANNEL_ASYNC_READBACK, //!< Sampling of async readback
49 : CHANNEL_VIEW_FINISH, //!< Sampling of Channel::frameViewFinish
50 : CHANNEL_FRAME_TRANSMIT, //!< Sampling of frame transmission
51 : CHANNEL_FRAME_COMPRESS, //!< Sampling of frame compression
52 : /** Sampling of waiting for a send token from the receiver */
53 : CHANNEL_FRAME_WAIT_SENDTOKEN,
54 : WINDOW_FINISH, //!< Sampling of Window::finish before a swap barrier
55 : /** Sampling of throttling of framerate_equalizer */
56 : WINDOW_THROTTLE_FRAMERATE,
57 : WINDOW_SWAP_BARRIER, //!< Sampling of swap barrier block
58 : WINDOW_SWAP, //!< Sampling of Window::swapBuffers
59 : WINDOW_FPS, //!< Framerate sampling
60 : PIPE_IDLE, //!< Pipe thread idle ratio
61 : NODE_FRAME_DECOMPRESS, //!< Sampling of frame decompression
62 : CONFIG_START_FRAME, //!< Sampling of Config::startFrame
63 : CONFIG_FINISH_FRAME, //!< Sampling of Config::finishFrame
64 : /** Sampling of synchronization time during Config::finishFrame */
65 : CONFIG_WAIT_FINISH_FRAME,
66 : ALL // must be last
67 : };
68 :
69 : Type type; //!< The type of statistic
70 : uint32_t frameNumber; //!< The frame during when the sampling happened
71 : uint32_t task; //!< @internal
72 : uint32_t plugins[2]; //!< color,depth plugins (readback, compression)
73 :
74 : int64_t startTime; //!< Absolute start time of the operation
75 : int64_t endTime; //!< Absolute end time of the operation
76 : int64_t idleTime; //!< Absolute idle time of PIPE_IDLE
77 : int64_t totalTime; //!< Total time of a pipe frame (PIPE_IDLE)
78 :
79 : float ratio; //!< compression ratio (transfer, compression)
80 : float currentFPS; //!< FPS of last frame (WINDOW_FPS)
81 : float averageFPS; //!< Weighted sum averaging of FPS (WINDOW_FPS)
82 : float pad; //!< @internal
83 :
84 : char resourceName[32]; //!< A non-unique name of the originator
85 :
86 : /** Translate the Type to a string representation. @version 1.0 */
87 : static const std::string& getName( const Type type );
88 : /** Translate the Type to a color value. @version 1.0 */
89 : static const Vector3f& getColor( const Type type );
90 : };
91 :
92 : /** Output the statistic type to an std::ostream. @version 1.0 */
93 : EQ_API std::ostream& operator << ( std::ostream&, const Statistic::Type& );
94 :
95 : /** Output the statistic to an std::ostream. @version 1.0 */
96 : EQ_API std::ostream& operator << ( std::ostream&, const Statistic& );
97 : }
98 :
99 : namespace lunchbox
100 : {
101 0 : template<> inline void byteswap( eq::Statistic::Type& value )
102 0 : { byteswap( reinterpret_cast< uint32_t& >( value )); }
103 :
104 0 : template<> inline void byteswap( eq::Statistic& value )
105 : {
106 0 : byteswap( value.type );
107 0 : byteswap( value.frameNumber );
108 0 : byteswap( value.task );
109 0 : byteswap( value.plugins[0] );
110 0 : byteswap( value.plugins[1] );
111 :
112 0 : byteswap( value.startTime );
113 0 : byteswap( value.endTime );
114 0 : byteswap( value.idleTime );
115 0 : byteswap( value.totalTime );
116 :
117 0 : byteswap( value.ratio );
118 0 : byteswap( value.currentFPS );
119 0 : byteswap( value.averageFPS );
120 0 : }
121 : }
122 :
123 : #endif // EQ_STATISTIC_H
124 :
|