Skip to content

Commit

Permalink
Change Deflect streaming activation, according to BlueBrain/Deflect#98
Browse files Browse the repository at this point in the history
  • Loading branch information
tribal-tec committed Jun 7, 2016
1 parent ca608dd commit f5bcf04
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .gitsubprojects
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ git_subproject(Pression https://github.com/Eyescale/Pression.git 6d3b6ed)
git_subproject(hwsd https://github.com/Eyescale/hwsd.git 6211d53)
git_subproject(Collage https://github.com/Eyescale/Collage.git 3f2ed88)
git_subproject(GLStats https://github.com/Eyescale/GLStats.git 2ba6dbc)
git_subproject(Deflect https://github.com/BlueBrain/Deflect.git 04a99f3)
git_subproject(Deflect https://github.com/BlueBrain/Deflect.git 1cb94bc)
6 changes: 6 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Changelog {#Changelog}

# git master

* [561](https://github.com/Eyescale/Equalizer/pull/561):
Change Deflect streaming activation

* Use environment variable from
[Deflect#98](https://github.com/BlueBrain/Deflect/pull/98)
* Obsolete DisplayCluster view attributes, use deflect_host attribute now
* [560](https://github.com/Eyescale/Equalizer/pull/560):
Add seq::Renderer::bindDrawFrameBuffer()
* [554](https://github.com/Eyescale/Equalizer/pull/554):
Expand Down
2 changes: 1 addition & 1 deletion eq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ set(EQUALIZER_LINK_LIBRARIES
${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})

if(DEFLECT_FOUND)
if(TARGET Deflect)
list(APPEND EQUALIZER_SOURCES
deflect/connection.h
deflect/eventHandler.cpp
Expand Down
11 changes: 8 additions & 3 deletions eq/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,16 @@ bool Channel::configExit()
bool Channel::configInit( const uint128_t& )
{
#ifdef EQUALIZER_USE_DEFLECT
if( getView() &&
!getView()->getSAttribute( View::SATTR_DISPLAYCLUSTER ).empty( ))
if( getView( ))
{
LBASSERT( !_impl->_deflectProxy );
_impl->_deflectProxy = new deflect::Proxy( this );
try
{
// Try to create Deflect proxy from env vars or
// config values, silently ignore failure
_impl->_deflectProxy = new deflect::Proxy( *this );
}
catch( ... ) {}
}
#endif
return true;
Expand Down
16 changes: 8 additions & 8 deletions eq/deflect/eventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ EventHandler::EventHandler( Proxy* proxy )
_eventHandlers = new EventHandlers;
_eventHandlers->push_back( this );

Pipe* pipe = proxy->getChannel()->getPipe();
Pipe* pipe = proxy->getChannel().getPipe();
MessagePump* messagePump = pipe->isThreaded() ? pipe->getMessagePump() :
pipe->getConfig()->getMessagePump();
if( messagePump )
Expand All @@ -110,7 +110,7 @@ EventHandler::EventHandler( Proxy* proxy )

EventHandler::~EventHandler()
{
Pipe* pipe = _proxy->getChannel()->getPipe();
Pipe* pipe = _proxy->getChannel().getPipe();
MessagePump* messagePump =
dynamic_cast<MessagePump*>( pipe->isThreaded() ?
pipe->getMessagePump() :
Expand Down Expand Up @@ -146,9 +146,9 @@ void EventHandler::_processEvents( const Proxy* proxy )
if( !_proxy || (proxy && _proxy != proxy ))
return;

const PixelViewport& pvp = _proxy->getChannel()->getPixelViewport();
Channel* channel = _proxy->getChannel();
Window* window = channel->getWindow();
Channel& channel = _proxy->getChannel();
const PixelViewport& pvp = channel.getPixelViewport();
Window* window = channel.getWindow();

while( _proxy->hasNewEvent( ))
{
Expand All @@ -164,8 +164,8 @@ void EventHandler::_processEvents( const Proxy* proxy )
}

Event event;
event.originator = channel->getID();
event.serial = channel->getSerial();
event.originator = channel.getID();
event.serial = channel.getSerial();
event.type = Event::UNKNOWN;

const float x = deflectEvent.mouseX * pvp.w;
Expand Down Expand Up @@ -250,7 +250,7 @@ void EventHandler::_processEvents( const Proxy* proxy )
if( !window->getRenderContext( x, y, event.context ))
LBVERB << "No rendering context for pointer event at " << x
<< ", " << y << std::endl;
channel->processEvent( event );
channel.processEvent( event );
}
}
}
Expand Down
39 changes: 17 additions & 22 deletions eq/deflect/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ ::deflect::Stream::Future make_ready_future( const bool value )
class Proxy::Impl : public boost::noncopyable
{
public:
explicit Impl( Channel* channel )
: _stream( 0 )
, _eventHandler( 0 )
, _channel( channel )
explicit Impl( Channel& channel )
: _channel( channel )
, _sendFuture( make_ready_future( false ))
, _running( false )
, _navigationMode( Proxy::MODE_ROTATE )
{
const DrawableConfig& dc = _channel->getDrawableConfig();
const DrawableConfig& dc = _channel.getDrawableConfig();
if( dc.colorBits != 8 )
{
LBWARN << "Can only stream 8-bit RGB(A) framebuffers to "
Expand All @@ -67,10 +65,10 @@ class Proxy::Impl : public boost::noncopyable
}

const std::string& deflectHost =
_channel->getView()->getSAttribute( View::SATTR_DISPLAYCLUSTER );
_channel.getView()->getSAttribute( View::SATTR_DEFLECT_HOST );
const std::string& name =
_channel->getView()->getSAttribute( View::SATTR_PIXELSTREAM_NAME );
_stream = new ::deflect::Stream( name, deflectHost );
_channel.getView()->getSAttribute( View::SATTR_DEFLECT_ID );
_stream.reset( new ::deflect::Stream( name, deflectHost ));
if( !_stream->isConnected( ))
{
LBWARN << "Could not connect to Deflect host: " << deflectHost
Expand All @@ -86,14 +84,11 @@ class Proxy::Impl : public boost::noncopyable
{
// wait for completion of previous send
_sendFuture.wait();

delete _eventHandler;
delete _stream;
}

void notifyNewImage( Channel& channel LB_UNUSED, const Image& image )
void notifyNewImage( Channel& channel, const Image& image )
{
LBASSERT( &channel == _channel );
LBASSERT( &channel == &_channel );

// wait for completion of previous send
_running = _sendFuture.get();
Expand All @@ -106,7 +101,7 @@ class Proxy::Impl : public boost::noncopyable
image.getPixelSize( Frame::BUFFER_COLOR ));

// determine image offset wrt global view
const Viewport& vp = _channel->getViewport();
const Viewport& vp = channel.getViewport();
const int32_t width = pvp.w / vp.w;
const int32_t height = pvp.h / vp.h;
const int32_t offsX = vp.x * width;
Expand All @@ -120,25 +115,25 @@ class Proxy::Impl : public boost::noncopyable
_sendFuture = _stream->asyncSend( imageWrapper );
}

::deflect::Stream* _stream;
EventHandler* _eventHandler;
Channel* _channel;
std::unique_ptr< ::deflect::Stream > _stream;
std::unique_ptr< EventHandler > _eventHandler;
Channel& _channel;
lunchbox::Bufferb _buffer;
::deflect::Stream::Future _sendFuture;
bool _running;
Proxy::NavigationMode _navigationMode;
};

Proxy::Proxy( Channel* channel )
Proxy::Proxy( Channel& channel )
: ResultImageListener()
, _impl( new Impl( channel ))
{
channel->addResultImageListener( this );
channel.addResultImageListener( this );
}

Proxy::~Proxy()
{
_impl->_channel->removeResultImageListener( this );
_impl->_channel.removeResultImageListener( this );
}

void Proxy::notifyNewImage( Channel& channel, const Image& image )
Expand All @@ -147,12 +142,12 @@ void Proxy::notifyNewImage( Channel& channel, const Image& image )

if( !_impl->_eventHandler && _impl->_stream->registerForEvents( true ))
{
_impl->_eventHandler = new EventHandler( this );
_impl->_eventHandler.reset( new EventHandler( this ));
LBDEBUG << "Installed event handler for Deflect proxy" << std::endl;
}
}

Channel* Proxy::getChannel()
Channel& Proxy::getChannel()
{
return _impl->_channel;
}
Expand Down
4 changes: 2 additions & 2 deletions eq/deflect/proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Proxy : public ResultImageListener
{
public:
/** Construct a Deflect proxy associated to a destination channel. */
explicit Proxy( Channel* channel );
explicit Proxy( Channel& channel );

/** Destruct the Deflect proxy. */
~Proxy();
Expand All @@ -40,7 +40,7 @@ class Proxy : public ResultImageListener
void notifyNewImage( Channel& channel, const Image& image ) final;

/** @return the associated destination channel. */
Channel* getChannel();
Channel& getChannel();

/** @return the underlying socket descriptor. */
int getSocketDescriptor() const;
Expand Down
4 changes: 2 additions & 2 deletions eq/fabric/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ class View : public Object, public Frustum
/** String attributes. */
enum SAttribute
{
SATTR_DISPLAYCLUSTER,
SATTR_PIXELSTREAM_NAME,
SATTR_DEFLECT_HOST,
SATTR_DEFLECT_ID,
SATTR_LAST,
SATTR_ALL = SATTR_LAST + 5
};
Expand Down
4 changes: 2 additions & 2 deletions eq/fabric/view.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace
{
#define _MAKE_ATTR_STRING( attr ) ( std::string("EQ_VIEW_") + #attr )
static std::string _sAttributeStrings[] = {
_MAKE_ATTR_STRING( SATTR_DISPLAYCLUSTER ),
_MAKE_ATTR_STRING( SATTR_PIXELSTREAM_NAME )
_MAKE_ATTR_STRING( SATTR_DEFLECT_HOST ),
_MAKE_ATTR_STRING( SATTR_DEFLECT_ID )
};
}

Expand Down
22 changes: 14 additions & 8 deletions eq/server/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,16 +785,22 @@ bool Config::_init( const uint128_t& initID )
_finishedFrame = 0;
_initID = initID;

for( CompoundsCIter i = _compounds.begin(); i != _compounds.end(); ++i )
(*i)->init();
for( auto compound : _compounds )
compound->init();

const Observers& observers = getObservers();
for( ObserversCIter i = observers.begin(); i != observers.end(); ++i )
(*i)->init();
for( auto observer : getObservers( ))
observer->init();

const Canvases& canvases = getCanvases();
for( CanvasesCIter i = canvases.begin(); i != canvases.end(); ++i )
(*i)->init();
for( auto canvas : getCanvases( ))
canvas->init();

const auto& layouts = getLayouts();
for( auto layout : layouts )
for( auto view : layout->getViews( ))
view->init();

// any of the above entities might have been updated
commit();

if( !_updateRunning( false ))
return false;
Expand Down
4 changes: 2 additions & 2 deletions eq/server/loader.l
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ EQ_NODE_IATTR_HINT_STATISTICS { return EQTOKEN_NODE_IATTR_HINT_STATISTICS; }
EQ_PIPE_IATTR_HINT_THREAD { return EQTOKEN_PIPE_IATTR_HINT_THREAD; }
EQ_PIPE_IATTR_HINT_AFFINITY { return EQTOKEN_PIPE_IATTR_HINT_AFFINITY; }
EQ_PIPE_IATTR_HINT_CUDA_GL_INTEROP { return EQTOKEN_PIPE_IATTR_HINT_CUDA_GL_INTEROP; }
EQ_VIEW_SATTR_DISPLAYCLUSTER { return EQTOKEN_VIEW_SATTR_DISPLAYCLUSTER; }
EQ_VIEW_SATTR_DEFLECT_HOST { return EQTOKEN_VIEW_SATTR_DEFLECT_HOST; }
EQ_WINDOW_IATTR_HINT_CORE_PROFILE { return EQTOKEN_WINDOW_IATTR_HINT_CORE_PROFILE; }
EQ_WINDOW_IATTR_HINT_OPENGL_MAJOR { return EQTOKEN_WINDOW_IATTR_HINT_OPENGL_MAJOR; }
EQ_WINDOW_IATTR_HINT_OPENGL_MINOR { return EQTOKEN_WINDOW_IATTR_HINT_OPENGL_MINOR; }
Expand Down Expand Up @@ -294,7 +294,7 @@ zoom { return EQTOKEN_ZOOM; }
MONO { return EQTOKEN_MONO; }
STEREO { return EQTOKEN_STEREO; }
size { return EQTOKEN_SIZE; }
DisplayCluster { return EQTOKEN_DISPLAYCLUSTER; }
deflect_host { return EQTOKEN_DEFLECT_HOST; }
dump_image { return EQTOKEN_DUMP_IMAGE; }

[+-]?[0-9]+[\.][0-9]* { return EQTOKEN_FLOAT; }
Expand Down
16 changes: 6 additions & 10 deletions eq/server/loader.y
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
%token EQTOKEN_PIPE_IATTR_HINT_CUDA_GL_INTEROP
%token EQTOKEN_PIPE_IATTR_HINT_THREAD
%token EQTOKEN_PIPE_IATTR_HINT_AFFINITY
%token EQTOKEN_VIEW_SATTR_DISPLAYCLUSTER
%token EQTOKEN_VIEW_SATTR_DEFLECT_HOST
%token EQTOKEN_WINDOW_IATTR_HINT_CORE_PROFILE
%token EQTOKEN_WINDOW_IATTR_HINT_OPENGL_MAJOR
%token EQTOKEN_WINDOW_IATTR_HINT_OPENGL_MINOR
Expand Down Expand Up @@ -298,7 +298,7 @@
%token EQTOKEN_SIZE
%token EQTOKEN_CORE
%token EQTOKEN_SOCKET
%token EQTOKEN_DISPLAYCLUSTER
%token EQTOKEN_DEFLECT_HOST
%token EQTOKEN_DUMP_IMAGE

%union{
Expand Down Expand Up @@ -550,10 +550,10 @@ global:
eq::server::Global::instance()->setChannelSAttribute(
eq::server::Channel::SATTR_DUMP_IMAGE, $2 );
}
| EQTOKEN_VIEW_SATTR_DISPLAYCLUSTER STRING
| EQTOKEN_VIEW_SATTR_DEFLECT_HOST STRING
{
eq::server::Global::instance()->setViewSAttribute(
eq::server::View::SATTR_DISPLAYCLUSTER, $2 );
eq::server::View::SATTR_DEFLECT_HOST, $2 );
}

connectionType:
Expand Down Expand Up @@ -834,10 +834,6 @@ viewFields: /*null*/ | viewFields viewField
viewField:
EQTOKEN_ATTRIBUTES '{' viewAttributes '}'
| EQTOKEN_NAME STRING { view->setName( $2 ); }
| EQTOKEN_DISPLAYCLUSTER STRING /* backward compat */
{
view->setSAttribute( eq::server::View::SATTR_DISPLAYCLUSTER, $2 );
}
| EQTOKEN_MODE { view->changeMode( eq::server::View::MODE_MONO ); }
viewMode
| EQTOKEN_VIEWPORT viewport
Expand Down Expand Up @@ -875,9 +871,9 @@ viewMode:

viewAttributes: /*null*/ | viewAttributes viewAttribute
viewAttribute:
EQTOKEN_DISPLAYCLUSTER STRING
EQTOKEN_DEFLECT_HOST STRING
{
view->setSAttribute( eq::server::View::SATTR_DISPLAYCLUSTER, $2 );
view->setSAttribute( eq::server::View::SATTR_DEFLECT_HOST, $2 );
}

canvas: EQTOKEN_CANVAS '{' { canvas = new eq::server::Canvas( config ); }
Expand Down
17 changes: 9 additions & 8 deletions eq/server/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ View::View( Layout* parent )
const SAttribute attr = static_cast< SAttribute >( i );
setSAttribute( attr, global->getViewSAttribute( attr ));
}

// All processes must share a common, unique pixelstream name
if( getSAttribute( View::SATTR_PIXELSTREAM_NAME ).empty( ))
{
const std::string name = "Equalizer_" +
lunchbox::make_UUID().getShortString();
setSAttribute( View::SATTR_PIXELSTREAM_NAME, name);
}
}

View::~View()
Expand Down Expand Up @@ -314,6 +306,15 @@ ViewPath View::getPath() const
return path;
}

void View::init()
{
// All contributors to the same view must share the same Deflect ID for
// streaming to the same target.
if( getSAttribute( View::SATTR_DEFLECT_ID ).empty( ))
setSAttribute( View::SATTR_DEFLECT_ID, getName().empty()
? "View " + getID().getShortString() : getName( ));
}

void View::trigger( const Canvas* canvas, const bool active )
{
const Mode mode = getMode();
Expand Down
Loading

0 comments on commit f5bcf04

Please sign in to comment.