Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
eqPixelBench/main.cpp
1 
2 /* Copyright (c) 2007-2014, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * - Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  * - Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * - Neither the name of Eyescale Software GmbH nor the names of its
13  * contributors may be used to endorse or promote products derived from this
14  * software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "channel.h"
30 #include "config.h"
31 #include "window.h"
32 
33 
34 class NodeFactory : public eq::NodeFactory
35 {
36 public:
38  { return new eqPixelBench::Config( parent ); }
39  virtual eq::Window* createWindow( eq::Pipe* parent )
40  { return new eqPixelBench::Window( parent ); }
41  virtual eq::Channel* createChannel( eq::Window* parent )
42  { return new eqPixelBench::Channel( parent ); }
43 };
44 
45 int main( int argc, char** argv )
46 {
47  // 1. initialization of local node
48  NodeFactory nodeFactory;
49  if( !eq::init( argc, argv, &nodeFactory ))
50  {
51  LBERROR << "Equalizer init failed" << std::endl;
52  eq::exit();
53  return EXIT_FAILURE;
54  }
55 
56  eq::ClientPtr client = new eq::Client;
57  if( !client->initLocal( argc, argv ))
58  {
59  LBERROR << "Can't init client" << std::endl;
60  eq::exit();
61  return EXIT_FAILURE;
62  }
63 
64  // 2. connect to server
65  eq::ServerPtr server = new eq::Server;
66  if( !client->connectServer( server ))
67  {
68  LBERROR << "Can't open server" << std::endl;
69  client->exitLocal();
70  eq::exit();
71  return EXIT_FAILURE;
72  }
73 
74  // 3. choose config
75  eq::fabric::ConfigParams configParams;
76  eqPixelBench::Config* config = static_cast<eqPixelBench::Config*>(
77  server->chooseConfig( configParams ));
78 
79  if( !config )
80  {
81  LBERROR << "No matching config on server" << std::endl;
82  client->disconnectServer( server );
83  client->exitLocal();
84  eq::exit();
85  return EXIT_FAILURE;
86  }
87 
88  // 4. init config
89  lunchbox::Clock clock;
90 
91  if( !config->init( co::uint128_t( )))
92  {
93  server->releaseConfig( config );
94  client->disconnectServer( server );
95  client->exitLocal();
96  eq::exit();
97  return EXIT_FAILURE;
98  }
99 
100  LBLOG( eq::LOG_CUSTOM ) << "Config init took " << clock.getTimef() << " ms"
101  << std::endl;
102 
103  // 5. render three frames
104  clock.reset();
105  for( uint32_t i = 0; i < 3; ++i )
106  {
107  config->startFrame( co::uint128_t( ));
108  config->finishAllFrames();
109  }
110  LBLOG( eq::LOG_CUSTOM ) << "Rendering took " << clock.getTimef() << " ms ("
111  << ( 1.0f / clock.getTimef() * 1000.f) << " FPS)"
112  << std::endl;
113 
114  // 6. exit config
115  clock.reset();
116  config->exit();
117  LBLOG( eq::LOG_CUSTOM ) << "Exit took " << clock.getTimef() << " ms"
118  << std::endl;
119 
120  // 7. cleanup and exit
121  server->releaseConfig( config );
122  if( !client->disconnectServer( server ))
123  LBERROR << "Client::disconnectServer failed" << std::endl;
124  server = 0;
125 
126  client->exitLocal();
127  client = 0;
128 
129  eq::exit();
130  return EXIT_SUCCESS;
131 }
Parameters for running a configuration.
Definition: configParams.h:34
virtual EQ_API bool init(const uint128_t &initID)
Initialize this configuration.
A channel represents a two-dimensional viewport within a Window.
A configuration is a visualization session driven by an application.
Proxy object for the connection to an Equalizer server.
Definition: client/server.h:40
virtual EQ_API bool exit()
Exit this configuration.
A Pipe represents a graphics card (GPU) on a Node.
User-defined log topics (65536)
Definition: client/log.h:36
virtual EQ_API uint32_t finishAllFrames()
Finish rendering all pending frames.
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
A Window represents an on-screen or off-screen drawable.
virtual eq::Channel * createChannel(eq::Window *parent)
Create a new channel.
lunchbox::RefPtr< Client > ClientPtr
A reference-counted pointer to an eq::Client.
virtual eq::Window * createWindow(eq::Pipe *parent)
Create a new window.
bool init(const int argc, char **argv, NodeFactory *nodeFactory)
Initialize the Equalizer client library.
Definition: client/init.h:58
The client represents a network node of the application in the cluster.
Definition: client/client.h:39
EQ_API bool exit()
De-initialize the Equalizer client library.
The node factory is a per-node singleton used to create and release Equalizer resource instances...
Definition: nodeFactory.h:36
virtual uint32_t startFrame(const eq::uint128_t &frameID)
virtual eq::Config * createConfig(eq::ServerPtr parent)
Create a new config.