Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
eqPixelBench/config.cpp
1 
2 /* Copyright (c) 2007-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2012, Daniel Nachbaur <danielnachbaur@gmail.com>
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * - Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  * - Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * - Neither the name of Eyescale Software GmbH nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include "config.h"
31 #include "configEvent.h"
32 
33 
34 namespace eqPixelBench
35 {
36 Config::Config( eq::ServerPtr parent )
37  : eq::Config( parent )
38  , _clock(0)
39 {
40 }
41 
43 {
44  delete _clock;
45  _clock = 0;
46 }
47 
48 uint32_t Config::startFrame( const eq::uint128_t& frameID )
49 {
50  if( !_clock )
51  _clock = new lunchbox::Clock;
52 
53  _clock->reset();
54  return eq::Config::startFrame( frameID );
55 }
56 
58 {
59  switch( command.getEventType( ))
60  {
61  case READBACK:
62  case ASSEMBLE:
63  case START_LATENCY:
64  {
65  switch( command.getEventType( ))
66  {
67  case READBACK:
68  std::cout << "readback";
69  break;
70  case ASSEMBLE:
71  std::cout << "assemble";
72  break;
73  case START_LATENCY:
74  default:
75  std::cout << " ";
76  }
77 
78  const float msec = command.read< float >();
79  const std::string& name = command.read< std::string >();
80  const eq::Vector2i& area = command.read< eq::Vector2i >();
81  const std::string& formatType = command.read< std::string >();
82  const uint64_t dataSizeGPU = command.read< uint64_t >();
83  const uint64_t dataSizeCPU = command.read< uint64_t >();
84 
85  std::cout << " \"" << name << "\" " << formatType
86  << std::string( 32-formatType.length(), ' ' ) << area.x()
87  << "x" << area.y() << ": ";
88 
89  if( msec < 0.0f )
90  std::cout << "error 0x" << std::hex << static_cast< int >( -msec )
91  << std::dec;
92  else
93  std::cout << static_cast< uint32_t >( area.x() * area.y() /
94  msec / 1048.576f )
95  << "MPix/sec (" << msec << "ms, "
96  << unsigned(1000.0f / msec) << "FPS)";
97 
98  if( command.getEventType() == READBACK )
99  {
100  std::cout << area << "( size GPU : " << dataSizeGPU << " bytes ";
101  std::cout << "/ size CPU : " << dataSizeCPU << " bytes ";
102  std::cout << "/ time : " << msec << "ms )";
103  }
104  else if( command.getEventType() == ASSEMBLE )
105  {
106  std::cout << area << "( size CPU : " << dataSizeCPU << " bytes ";
107  std::cout << "/ time : " << msec << "ms )";
108  }
109 
110  std::cout << std::endl;
111  return true;
112  }
113 
114  default:
115  return eq::Config::handleEvent( command );
116  }
117 }
118 }
virtual EQ_API uint32_t startFrame(const uint128_t &frameID)
Request a new frame of rendering.
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
A command specialization for config events.
Definition: eventICommand.h:38
virtual EQ_API ~Config()
Destruct a config.
virtual EQ_API bool handleEvent(const ConfigEvent *event)
Handle one (old) config event.
EQ_API uint32_t getEventType() const
Returns the event type.