Skip to content

Commit

Permalink
Migrate NodeFrameDataTransmitPacket, build fixes (Eyescale#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
tribal-tec committed Aug 22, 2012
1 parent 2dd73d8 commit 09ace6d
Show file tree
Hide file tree
Showing 24 changed files with 147 additions and 167 deletions.
4 changes: 2 additions & 2 deletions libs/eq/admin/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 2.1 as published
* by the Free Software Foundation.
*
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Expand Down
3 changes: 3 additions & 0 deletions libs/eq/admin/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include "config.h"
#include "nodeFactory.h"

#include <eq/fabric/commands.h>
#include <eq/fabric/packetType.h>

#include <co/command.h>
#include <co/dispatcher.h>

Expand Down
54 changes: 26 additions & 28 deletions libs/eq/client/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1402,10 +1402,9 @@ void Channel::_frameTiles( const RenderContext& context, const bool isLocal,

co::QueueSlave* queue = _getQueue( queueVersion );
LBASSERT( queue );
for( co::ObjectCommand queuePacket = queue->pop(); queuePacket;
queuePacket = queue->pop( ))
for( co::ObjectCommand tile = queue->pop(); tile; tile = queue->pop( ))
{
queuePacket >> context.frustum >> context.ortho
tile >> context.frustum >> context.ortho
>> context.pvp >> context.vp;

const PixelViewport tilePVP = context.pvp;
Expand Down Expand Up @@ -1521,7 +1520,7 @@ void Channel::_unrefFrame( const uint32_t frameNumber )
}

void Channel::_setOutputFrames( const uint32_t nFrames,
const co::ObjectVersion* frames )
const co::ObjectVersions frames )
{
LB_TS_THREAD( _pipeThread );
LBASSERT( _impl->outputFrames.empty( ))
Expand Down Expand Up @@ -1711,22 +1710,12 @@ void Channel::_transmitImage( const co::ObjectVersion& frameDataVersion,
// use compression on links up to 2 GBit/s
const bool useCompression = ( description->bandwidth <= 262144 );

NodeFrameDataTransmitPacket packet;
const uint64_t packetSize = sizeof( packet ) - 8 * sizeof( uint8_t );

packet.objectID = nodeID;
packet.frameData = frameData;
packet.frameNumber = frameNumber;

std::vector< const PixelData* > pixelDatas;
std::vector< float > qualities;

packet.size = packetSize;
packet.buffers = Frame::BUFFER_NONE;
packet.pvp = image->getPixelViewport();
packet.useAlpha = image->getAlphaUsage();
packet.zoom = image->getZoom();
LBASSERT( packet.pvp.isValid( ));
uint32_t buffers = Frame::BUFFER_NONE;
uint64_t dataSize = 0;


{
uint64_t rawSize( 0 );
Expand All @@ -1748,7 +1737,7 @@ void Channel::_transmitImage( const co::ObjectVersion& frameDataVersion,
if( image->hasPixelData( buffer ))
{
// format, type, nChunks, compressor name
packet.size += sizeof( FrameData::ImageHeader );
dataSize += sizeof( FrameData::ImageHeader );

const PixelData& data = useCompression ?
image->compressPixelData( buffer ) :
Expand All @@ -1762,26 +1751,26 @@ void Channel::_transmitImage( const co::ObjectVersion& frameDataVersion,
uint32_t( data.compressedSize.size( ));
for( uint32_t k = 0 ; k < nElements; ++k )
{
packet.size += sizeof( uint64_t );
packet.size += data.compressedSize[ k ];
dataSize += sizeof( uint64_t );
dataSize += data.compressedSize[ k ];
}
compressEvent.event.data.statistic.plugins[j] =
data.compressorName;
}
else
{
packet.size += sizeof( uint64_t );
packet.size += image->getPixelDataSize( buffer );
dataSize += sizeof( uint64_t );
dataSize += image->getPixelDataSize( buffer );
}

packet.buffers |= buffer;
buffers |= buffer;
rawSize += image->getPixelDataSize( buffer );
}
}

if( rawSize > 0 )
compressEvent.event.data.statistic.ratio =
static_cast< float >( packet.size ) /
static_cast< float >( dataSize ) /
static_cast< float >( rawSize );
}

Expand All @@ -1798,10 +1787,19 @@ void Channel::_transmitImage( const co::ObjectVersion& frameDataVersion,
token = getLocalNode()->acquireSendToken( toNode );
}

co::ObjectOCommand packet( co::Connections( 1, connection ),
co::COMMANDTYPE_CO_OBJECT,
fabric::CMD_NODE_FRAMEDATA_TRANSMIT,
nodeID, EQ_INSTANCE_ALL );
LBASSERT( image->getPixelViewport().isValid( ));
packet << frameDataVersion << image->getPixelViewport() << image->getZoom()
<< buffers << frameNumber << image->getAlphaUsage();

connection->lockSend();
connection->send( &packet, packetSize, true );
packet.sendUnlocked( dataSize );

#ifndef NDEBUG
size_t sentBytes = packetSize;
size_t sentBytes = dataSize;
#endif

for( uint32_t j=0; j < pixelDatas.size(); ++j )
Expand Down Expand Up @@ -1846,8 +1844,8 @@ void Channel::_transmitImage( const co::ObjectVersion& frameDataVersion,
}
}
#ifndef NDEBUG
LBASSERTINFO( sentBytes == packet.size,
sentBytes << " != " << packet.size );
LBASSERTINFO( sentBytes == dataSize,
sentBytes << " != " << dataSize );
#endif

connection->unlockSend();
Expand Down
2 changes: 1 addition & 1 deletion libs/eq/client/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ namespace detail { class Channel; struct RBStat; }
co::QueueSlave* _getQueue( const co::ObjectVersion& queueVersion );

void _setOutputFrames( const uint32_t nFrames,
const co::ObjectVersion* frames );
const co::ObjectVersions frames );
void _resetOutputFrames();

void _deleteTransferContext();
Expand Down
1 change: 1 addition & 0 deletions libs/eq/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <eq/fabric/leafVisitor.h>
#include <eq/fabric/elementVisitor.h>
#include <eq/fabric/nodeType.h>
#include <eq/fabric/packetType.h>
#include <eq/fabric/view.h>

#include <co/buffer.h>
Expand Down
2 changes: 2 additions & 0 deletions libs/eq/client/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
#include "window.h"

#include <eq/fabric/configVisitor.h>
#include <eq/fabric/commands.h>
#include <eq/fabric/task.h>

#include <co/exception.h>
#include <co/object.h>
#include <co/command.h>
Expand Down
8 changes: 4 additions & 4 deletions libs/eq/client/configEvent.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

/* Copyright (c) 2006, Stefan Eilemann <eile@equalizergraphics.com>
/* Copyright (c) 2006, Stefan Eilemann <eile@equalizergraphics.com>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 2.1 as published
* by the Free Software Foundation.
*
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Expand All @@ -21,7 +21,7 @@ using namespace eq;

std::ostream& eq::operator << ( std::ostream& os, const ConfigEvent* event )
{
os << "config event " << (ConfigPacket*)event << ", event "
os << "config event " << ", event "
<< event->data;

return os;
Expand Down
1 change: 0 additions & 1 deletion libs/eq/client/files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ set(CLIENT_HEADERS
log.h
messagePump.h
node.h
nodePackets.h
nodeFactory.h
observer.h
os.h
Expand Down
20 changes: 9 additions & 11 deletions libs/eq/client/frameData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,25 +397,23 @@ void FrameData::removeListener( lunchbox::Monitor<uint32_t>& listener )
_listeners->erase( i );
}

bool FrameData::addImage( const NodeFrameDataTransmitPacket* packet )
bool FrameData::addImage( const co::ObjectVersion& frameDataVersion,
const PixelViewport& pvp, const Zoom& zoom,
const uint32_t buffers_, const bool useAlpha,
uint8_t* data )
{
Image* image = _allocImage( Frame::TYPE_MEMORY, DrawableConfig(),
false /* set quality */ );

// Note on the const_cast: since the PixelData structure stores non-const
// pointers, we have to go non-const at some point, even though we do not
// modify the data.
uint8_t* data = const_cast< uint8_t* >( packet->data );

image->setPixelViewport( packet->pvp );
image->setAlphaUsage( packet->useAlpha );
image->setPixelViewport( pvp );
image->setAlphaUsage( useAlpha );

Frame::Buffer buffers[] = { Frame::BUFFER_COLOR, Frame::BUFFER_DEPTH };
for( unsigned i = 0; i < 2; ++i )
{
const Frame::Buffer buffer = buffers[i];

if( packet->buffers & buffer )
if( buffers_ & buffer )
{
PixelData pixelData;
const ImageHeader* header = reinterpret_cast<ImageHeader*>( data );
Expand Down Expand Up @@ -455,13 +453,13 @@ bool FrameData::addImage( const NodeFrameDataTransmitPacket* packet )
LBASSERT( size == pixelData.pvp.getArea()*pixelData.pixelSize );
}

image->setZoom( packet->zoom );
image->setZoom( zoom );
image->setQuality( buffer, header->quality );
image->setPixelData( buffer, pixelData );
}
}

LBASSERT( _readyVersion < packet->frameData.version.low( ));
LBASSERT( _readyVersion < frameDataVersion.version.low( ));
_pendingImages.push_back( image );
return true;
}
Expand Down
9 changes: 6 additions & 3 deletions libs/eq/client/frameData.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ namespace eq
{
namespace server { class FrameData; }

class ROIFinder;
struct NodeFrameDataTransmitPacket;
class ROIFinder;

/**
* A holder for multiple images.
Expand Down Expand Up @@ -296,7 +295,11 @@ namespace server { class FrameData; }
//@}

/** @internal */
bool addImage( const NodeFrameDataTransmitPacket* packet );
bool addImage( const co::ObjectVersion& frameDataVersion,
const PixelViewport& pvp, const Zoom& zoom,
const uint32_t buffers, const bool useAlpha,
uint8_t* data );
struct Data;
void setReady( const co::ObjectVersion& frameData,
const FrameData::Data& data ); //!< @internal

Expand Down
47 changes: 31 additions & 16 deletions libs/eq/client/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
#include "pipe.h"
#include "server.h"

#include <eq/fabric/commands.h>
#include <eq/fabric/elementVisitor.h>
#include <eq/fabric/task.h>

#include <co/barrier.h>
#include <co/buffer.h>
#include <co/command.h>
#include <co/connection.h>
#include <lunchbox/scopedMutex.h>
Expand Down Expand Up @@ -406,11 +409,12 @@ void Node::TransmitThread::run()
lunchbox::className( _node ));
while( true )
{
co::CommandPtr command = _queue.pop();
if( !command )
co::BufferPtr buffer = _queue.pop();
if( !buffer )
return; // exit thread

LBCHECK( (*command)( ));
co::Command command( buffer );
LBCHECK( command( ));
}
}

Expand Down Expand Up @@ -460,15 +464,15 @@ bool Node::_cmdDestroyPipe( co::Command& command )
LBASSERT( pipe );
pipe->exitThread();

const bool isStopped = pipe->isStopped();
const bool stopped = pipe->isStopped();

Config* config = getConfig();
config->unmapObject( pipe );
Global::getNodeFactory()->releasePipe( pipe );

// send to config object
getServer()->send( fabric::CMD_PIPE_CONFIG_EXIT_REPLY,
pipeID ) << isStopped;
pipeID ) << stopped;
return true;
}

Expand Down Expand Up @@ -531,7 +535,7 @@ bool Node::_cmdFrameStart( co::Command& command )
const uint128_t version = command.get< uint128_t >();
const uint128_t configVersion = command.get< uint128_t >();
const uint128_t frameID = command.get< uint128_t >();
const uint32_t frameNumber = command.get< uint128_t >();
const uint32_t frameNumber = command.get< uint32_t >();

LBASSERT( _currentFrame == frameNumber-1 );

Expand Down Expand Up @@ -566,7 +570,7 @@ bool Node::_cmdFrameFinish( co::Command& command )

const uint128_t version = commit();
if( version != co::VERSION_NONE )
send( command.getNode(), CMD_OBJECT_SYNC );
send( command.getNode(), fabric::CMD_OBJECT_SYNC );
return true;
}

Expand All @@ -590,21 +594,32 @@ bool Node::_cmdFrameTasksFinish( co::Command& command )

bool Node::_cmdFrameDataTransmit( co::Command& command )
{
const NodeFrameDataTransmitPacket* packet =
command.get<NodeFrameDataTransmitPacket>();
const co::ObjectVersion frameDataVersion = command.get< co::ObjectVersion >();
const PixelViewport pvp = command.get< PixelViewport >();
const Zoom zoom = command.get< Zoom >();
const uint32_t buffers = command.get< uint32_t >();
const uint32_t frameNumber = command.get< uint32_t >();
const bool useAlpha = command.get< bool >();
const uint8_t* data = reinterpret_cast< const uint8_t* >(
command.getRemainingBuffer( command.getRemainingBufferSize( )));

LBLOG( LOG_ASSEMBLY )
<< "received image data for " << packet->frameData << ", buffers "
<< packet->buffers << " pvp " << packet->pvp << std::endl;
<< "received image data for " << frameDataVersion << ", buffers "
<< buffers << " pvp " << pvp << std::endl;

LBASSERT( packet->pvp.isValid( ));
LBASSERT( pvp.isValid( ));

FrameDataPtr frameData = getFrameData( packet->frameData );
FrameDataPtr frameData = getFrameData( frameDataVersion );
LBASSERT( !frameData->isReady() );

NodeStatistics event( Statistic::NODE_FRAME_DECOMPRESS, this,
packet->frameNumber );
LBCHECK( frameData->addImage( packet ));
frameNumber );

// Note on the const_cast: since the PixelData structure stores non-const
// pointers, we have to go non-const at some point, even though we do not
// modify the data.
LBCHECK( frameData->addImage( frameDataVersion, pvp, zoom, buffers,
useAlpha, const_cast< uint8_t* >( data )));
return true;
}

Expand All @@ -613,7 +628,7 @@ bool Node::_cmdFrameDataReady( co::Command& command )
const co::ObjectVersion frameDataVersion = command.get< co::ObjectVersion >();
const FrameData::Data data = command.get< FrameData::Data >();

LBLOG( LOG_ASSEMBLY ) << "received ready for " << packet->frameData
LBLOG( LOG_ASSEMBLY ) << "received ready for " << frameDataVersion
<< std::endl;
FrameDataPtr frameData = getFrameData( frameDataVersion );
LBASSERT( frameData );
Expand Down
Loading

0 comments on commit 09ace6d

Please sign in to comment.