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