Skip to content

Commit

Permalink
Merge pull request #392 from tribal-tec/master
Browse files Browse the repository at this point in the history
Add default connection for autoconfigured server, Fix async texture readback
  • Loading branch information
eile committed Nov 27, 2014
2 parents 8059745 + 98d5380 commit 6e7cad8
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 37 deletions.
2 changes: 1 addition & 1 deletion eq/admin/CMakeLists.txt
Expand Up @@ -43,7 +43,7 @@ source_group(fabric REGULAR_EXPRESSION .*)
source_group(\\ FILES CMakeLists.txt ${ADMIN_HEADERS} ${ADMIN_SOURCES})

add_library(EqualizerAdmin SHARED ${ADMIN_HEADERS} ${ADMIN_SOURCES})
target_link_libraries(EqualizerAdmin EqualizerFabric)
target_link_libraries(EqualizerAdmin EqualizerFabric EqualizerServer)
set_target_properties(EqualizerAdmin
PROPERTIES VERSION ${VERSION} SOVERSION ${VERSION_ABI})

Expand Down
13 changes: 12 additions & 1 deletion eq/admin/client.cpp
Expand Up @@ -20,6 +20,8 @@
#include "server.h"
#include <co/global.h>

#include <eq/server/localServer.h>

namespace eq
{
namespace admin
Expand All @@ -42,7 +44,16 @@ Client::~Client()

bool Client::connectServer( ServerPtr server )
{
if( !Super::connectServer( server.get( )))
// connect to local server, if any
co::ConnectionPtr connection = server::connectLocalServer();
if( connection && connect( server, connection ))
{
server->setClient( this );
server->map();
return true;
}

if( !Super::connectServer( server ))
return false;

server->setClient( this );
Expand Down
10 changes: 4 additions & 6 deletions eq/client/client.cpp
Expand Up @@ -102,7 +102,7 @@ Client::~Client()

bool Client::connectServer( ServerPtr server )
{
if( Super::connectServer( server.get( )))
if( Super::connectServer( server ))
{
server->setClient( this );
return true;
Expand All @@ -115,13 +115,11 @@ bool Client::connectServer( ServerPtr server )
}

// Use app-local server if no explicit server was set
co::ConnectionPtr connection =
server::startLocalServer( Global::getConfigFile( ));
if( !connection )
if( !server::startLocalServer( Global::getConfigFile( )))
return false;

if( !connect( server.get(), connection ))
// giving up
co::ConnectionPtr connection = server::connectLocalServer();
if( !connection || !connect( server, connection ))
return false;

server->setClient( this );
Expand Down
31 changes: 18 additions & 13 deletions eq/client/compressor/compressorReadDrawPixels.cpp
Expand Up @@ -25,7 +25,6 @@
#include <lunchbox/buffer.h>

#define glewGetContext() glewContext
#define EQ_ASYNC_PBO // remove to use textures for async RB instead of PBOs

namespace eq
{
Expand Down Expand Up @@ -460,7 +459,17 @@ void CompressorReadDrawPixels::startDownload( const GLEWContext* glewContext,
const eq_uint64_t size = dims[1] * dims[3] * _depth;
if( flags & EQ_COMPRESSOR_USE_FRAMEBUFFER )
{
#ifdef EQ_ASYNC_PBO
// async RB through texture
if( !GLEW_ARB_pixel_buffer_object )
{
const PixelViewport pvp( dims[0], dims[2], dims[1], dims[3] );
_initAsyncTexture( glewContext, pvp.w, pvp.h );
_texture->setExternalFormat( _format, _type );
_texture->copyFromFrameBuffer( _internalFormat, pvp );
_resizeBuffer( size );
return;
}

if( _initPBO( glewContext, size ))
{
EQ_GL_CALL( glReadPixels( dims[0], dims[2], dims[1], dims[3],
Expand All @@ -469,13 +478,6 @@ void CompressorReadDrawPixels::startDownload( const GLEWContext* glewContext,
glFlush(); // Fixes https://github.com/Eyescale/Equalizer/issues/118
return;
}
#else // else async RB through texture
const PixelViewport pvp( dims[0], dims[2], dims[1], dims[3] );
_initAsyncTexture( glewContext, pvp.w, pvp.h );
_asyncTexture->setExternalFormat( _format, _type );
_asyncTexture->copyFromFrameBuffer( _internalFormat, pvp );
return;
#endif
// else
_resizeBuffer( size );
EQ_GL_CALL( glReadPixels( dims[0], dims[2], dims[1], dims[3],
Expand Down Expand Up @@ -518,7 +520,13 @@ void CompressorReadDrawPixels::finishDownload(

LBASSERT( flags & EQ_COMPRESSOR_USE_FRAMEBUFFER );

#ifdef EQ_ASYNC_PBO
// async RB through texture
if( !GLEW_ARB_pixel_buffer_object )
{
*out = _downloadTexture( glewContext, KEEP_TEXTURE );
return;
}

if( _pbo && _pbo->isInitialized( ))
{
const eq_uint64_t size = inDims[1] * inDims[3] * _depth;
Expand All @@ -537,9 +545,6 @@ void CompressorReadDrawPixels::finishDownload(
}
}
*out = _buffer.getData();
#else // async RB through texture
*out = _downloadTexture( glewContext, KEEP_TEXTURE );
#endif
}

}
Expand Down
2 changes: 1 addition & 1 deletion eq/client/detail/channel.ipp
Expand Up @@ -63,7 +63,7 @@ public:

void frameViewFinish( eq::Channel * channel )
{
if( !channel->getSAttribute(channel->SATTR_DUMP_IMAGE).empty( ))
if( !channel->getSAttribute( channel->SATTR_DUMP_IMAGE ).empty( ))
frameWriter.write( channel );

#ifdef EQUALIZER_USE_DISPLAYCLUSTER
Expand Down
41 changes: 27 additions & 14 deletions eq/server/localServer.cpp
Expand Up @@ -49,9 +49,14 @@ class ServerThread : public lunchbox::Thread
return Thread::start();
}

eq::server::ServerPtr getServer()
{
return _server;
}

protected:

virtual void run()
void run() final
{
_server->run();
_server->close();
Expand All @@ -72,12 +77,12 @@ class ServerThread : public lunchbox::Thread
static ServerThread _serverThread;
}

co::ConnectionPtr startLocalServer( const std::string& config )
bool startLocalServer( const std::string& config )
{
if( _serverThread.isRunning( ))
{
LBWARN << "Only one app-local per process server allowed" << std::endl;
return 0;
return false;
}

eq::server::Loader loader;
Expand All @@ -95,7 +100,7 @@ co::ConnectionPtr startLocalServer( const std::string& config )
if( !server )
{
LBERROR << "Failed to load configuration" << std::endl;
return 0;
return false;
}

eq::server::Loader::addOutputCompounds( server );
Expand All @@ -106,6 +111,23 @@ co::ConnectionPtr startLocalServer( const std::string& config )
// TODO: ref count is 2 since config holds ServerPtr
// LBASSERTINFO( server->getRefCount() == 1, server );

if( !server->listen( ))
{
LBERROR << "Failed to setup server listener" << std::endl;
return false;
}

if( !_serverThread.start( server ))
{
LBERROR << "Failed to start server thread" << std::endl;
return false;
}

return true;
}

co::ConnectionPtr connectLocalServer()
{
co::ConnectionDescriptionPtr desc = new co::ConnectionDescription;
desc->type = co::CONNECTIONTYPE_PIPE;
co::ConnectionPtr connection = co::Connection::create( desc );
Expand All @@ -116,17 +138,8 @@ co::ConnectionPtr startLocalServer( const std::string& config )
}

co::ConnectionPtr sibling = connection->acceptSync();
if( !server->listen( sibling ))
{
LBERROR << "Failed to setup server listener" << std::endl;
return 0;
}

if( !_serverThread.start( server ))
{
LBERROR << "Failed to start server thread" << std::endl;
return 0;
}
_serverThread.getServer()->addConnection( sibling );

return connection;
}
Expand Down
4 changes: 3 additions & 1 deletion eq/server/localServer.h
Expand Up @@ -26,7 +26,9 @@ namespace eq
namespace server
{

EQSERVER_API co::ConnectionPtr startLocalServer( const std::string& config );
EQSERVER_API bool startLocalServer( const std::string& config );

EQSERVER_API co::ConnectionPtr connectLocalServer();

EQSERVER_API void joinLocalServer();

Expand Down

0 comments on commit 6e7cad8

Please sign in to comment.