Equalizer  1.6.1
eqPixelBench/main.cpp
1 
2 /* Copyright (c) 2007-2010, 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  return EXIT_FAILURE;
53  }
54 
55  eq::ClientPtr client = new eq::Client;
56  if( !client->initLocal( argc, argv ))
57  {
58  LBERROR << "Can't init client" << std::endl;
59  eq::exit();
60  return EXIT_FAILURE;
61  }
62 
63  // 2. connect to server
64  eq::ServerPtr server = new eq::Server;
65  if( !client->connectServer( server ))
66  {
67  LBERROR << "Can't open server" << std::endl;
68  client->exitLocal();
69  eq::exit();
70  return EXIT_FAILURE;
71  }
72 
73  // 3. choose config
74  eq::fabric::ConfigParams configParams;
75  eqPixelBench::Config* config = static_cast<eqPixelBench::Config*>(
76  server->chooseConfig( configParams ));
77 
78  if( !config )
79  {
80  LBERROR << "No matching config on server" << std::endl;
81  client->disconnectServer( server );
82  client->exitLocal();
83  eq::exit();
84  return EXIT_FAILURE;
85  }
86 
87  // 4. init config
88  lunchbox::Clock clock;
89 
90  if( !config->init( eq::uint128_t( )))
91  {
92  server->releaseConfig( config );
93  client->disconnectServer( server );
94  client->exitLocal();
95  eq::exit();
96  return EXIT_FAILURE;
97  }
98  else if( config->getError( ))
99  LBWARN << "Error during initialization: " << config->getError()
100  << std::endl;
101 
102  LBLOG( eq::LOG_CUSTOM ) << "Config init took " << clock.getTimef() << " ms"
103  << std::endl;
104 
105  // 5. render three frames
106  clock.reset();
107  for( uint32_t i = 0; i < 3; ++i )
108  {
109  config->startFrame( eq::uint128_t( ));
110  config->finishAllFrames();
111  }
112  LBLOG( eq::LOG_CUSTOM ) << "Rendering took " << clock.getTimef() << " ms ("
113  << ( 1.0f / clock.getTimef() * 1000.f) << " FPS)"
114  << std::endl;
115 
116  // 6. exit config
117  clock.reset();
118  config->exit();
119  LBLOG( eq::LOG_CUSTOM ) << "Exit took " << clock.getTimef() << " ms"
120  << std::endl;
121 
122  // 7. cleanup and exit
123  server->releaseConfig( config );
124  if( !client->disconnectServer( server ))
125  LBERROR << "Client::disconnectServer failed" << std::endl;
126  server = 0;
127 
128  client->exitLocal();
129  client = 0;
130 
131  eq::exit();
132  return EXIT_SUCCESS;
133 }
virtual eq::Window * createWindow(eq::Pipe *parent)
Create a new window.
A configuration is a visualization session driven by an application.
virtual eq::Config * createConfig(eq::ServerPtr parent)
Create a new config.
virtual uint32_t finishAllFrames()
Finish rendering all pending frames.
A channel represents a two-dimensional viewport within a Window.
eq::fabric::Error getError() const
Definition: object.h:82
virtual bool init(const uint128_t &initID)
Initialize this configuration.
A Window represents an on-screen or off-screen drawable.
User-defined log topics (65536)
Definition: client/log.h:35
A Pipe represents a graphics card (GPU) on a Node.
Proxy object for the connection to an Equalizer server.
Definition: client/server.h:38
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
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)
The client represents a network node of the application in the cluster.
Definition: client/client.h:38
lunchbox::RefPtr< Client > ClientPtr
A reference-counted pointer to an eq::Client.
bool init(const int argc, char **argv, NodeFactory *nodeFactory)
Initialize the Equalizer client library.
Definition: client/init.h:57
bool exit()
De-initialize the Equalizer client library.
virtual bool exit()
Exit this configuration.
Parameters for running a configuration.
virtual eq::Channel * createChannel(eq::Window *parent)
Create a new channel.