LCOV - code coverage report
Current view: top level - eq/server - tileQueue.cpp (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 1 79 1.3 %
Date: 2014-06-18 Functions: 2 15 13.3 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011-2014, Stefan Eilemann <eile@eyescale.ch>
       3             :  *               2011-2012, Daniel Nachbaur <danielnachbaur@googlemail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #include "tileQueue.h"
      20             : 
      21             : #include <eq/fabric/tile.h>
      22             : #include <co/dataIStream.h>
      23             : #include <co/dataOStream.h>
      24             : #include <co/queueItem.h>
      25             : 
      26             : namespace eq
      27             : {
      28             : namespace server
      29             : {
      30             : 
      31           0 : TileQueue::TileQueue()
      32             :         : co::Object()
      33             :         , _compound( 0 )
      34             :         , _name()
      35           0 :         , _size( 0, 0 )
      36             : {
      37           0 :     for( unsigned i = 0; i < NUM_EYES; ++i )
      38             :     {
      39           0 :         _queueMaster[i] = 0;
      40           0 :         _outputQueue[i] = 0;
      41             :     }
      42           0 : }
      43             : 
      44           0 : TileQueue::TileQueue( const TileQueue& from )
      45             :         : co::Object()
      46             :         , _compound( 0 )
      47             :         , _name( from._name )
      48           0 :         , _size( from._size )
      49             : {
      50           0 :     for( unsigned i = 0; i < NUM_EYES; ++i )
      51             :     {
      52           0 :         _queueMaster[i] = 0;
      53           0 :         _outputQueue[i] = 0;
      54             :     }
      55           0 : }
      56             : 
      57           0 : TileQueue::~TileQueue()
      58             : {
      59           0 :     _compound = 0;
      60           0 : }
      61             : 
      62           0 : void TileQueue::addTile( const Tile& tile, const fabric::Eye eye )
      63             : {
      64           0 :     uint32_t index = lunchbox::getIndexOfLastBit(eye);
      65           0 :     LBASSERT( index < NUM_EYES );
      66           0 :     _queueMaster[index]->_queue.push() << tile;
      67           0 : }
      68             : 
      69           0 : void TileQueue::cycleData( const uint32_t frameNumber, const Compound* compound)
      70             : {
      71           0 :     for( unsigned i = 0; i < NUM_EYES; ++i )
      72             :     {
      73           0 :         if( !compound->isInheritActive( Eye( 1<<i )))// eye pass not used
      74             :         {
      75           0 :             _queueMaster[i] = 0;
      76           0 :             continue;
      77             :         }
      78             : 
      79             :         // reuse unused queues
      80           0 :         LatencyQueue* queue    = _queues.empty() ? 0 : _queues.back();
      81           0 :         const uint32_t latency = getAutoObsolete();
      82           0 :         const uint32_t dataAge = queue ? queue->_frameNumber : 0;
      83             : 
      84           0 :         if( queue && dataAge < frameNumber-latency && frameNumber > latency )
      85             :             // not used anymore
      86           0 :             _queues.pop_back();
      87             :         else // still used - allocate new data
      88             :         {
      89           0 :             queue = new LatencyQueue;
      90             : 
      91           0 :             getLocalNode()->registerObject( &queue->_queue );
      92           0 :             queue->_queue.setAutoObsolete( 1 ); // current + in use by render nodes
      93             :         }
      94             : 
      95           0 :         queue->_queue.clear();
      96           0 :         queue->_frameNumber = frameNumber;
      97             : 
      98           0 :         _queues.push_front( queue );
      99           0 :         _queueMaster[i] = queue;
     100             :     }
     101           0 : }
     102             : 
     103           0 : void TileQueue::setOutputQueue( TileQueue* queue, const Compound* compound )
     104             : {
     105           0 :     for( unsigned i = 0; i < NUM_EYES; ++i )
     106             :     {
     107             :         // eye pass not used && no output frame for eye pass
     108           0 :         if( compound->isInheritActive( Eye( 1<<i )))
     109           0 :             _outputQueue[i] =queue;
     110             :     }
     111           0 : }
     112             : 
     113           0 : void TileQueue::getInstanceData( co::DataOStream& )
     114             : {
     115           0 : }
     116             : 
     117           0 : void TileQueue::applyInstanceData( co::DataIStream& )
     118             : {
     119           0 : }
     120             : 
     121           0 : void TileQueue::flush()
     122             : {
     123           0 :     unsetData();
     124             : 
     125           0 :     while( !_queues.empty( ))
     126             :     {
     127           0 :         LatencyQueue* queue = _queues.front();
     128           0 :         _queues.pop_front();
     129           0 :         getLocalNode()->deregisterObject( &queue->_queue );
     130           0 :         delete queue;
     131             :     }
     132             : 
     133           0 : }
     134             : 
     135           0 : void TileQueue::unsetData()
     136             : {
     137           0 :     for( unsigned i = 0; i < NUM_EYES; ++i )
     138             :     {
     139           0 :         _queueMaster[i] = 0;
     140           0 :         _outputQueue[i] = 0;
     141             :     }
     142           0 : }
     143             : 
     144           0 : uint128_t TileQueue::getQueueMasterID( const Eye eye ) const
     145             : {
     146           0 :     uint32_t index = lunchbox::getIndexOfLastBit(eye);
     147           0 :     LatencyQueue* queue = _queueMaster[ index ];
     148           0 :     if ( queue )
     149           0 :         return queue->_queue.getID();
     150           0 :     return uint128_t();
     151             : }
     152             : 
     153           0 : std::ostream& operator << ( std::ostream& os, const TileQueue* tileQueue )
     154             : {
     155           0 :     if( !tileQueue )
     156           0 :         return os;
     157             : 
     158           0 :     os << lunchbox::disableFlush << "tiles" << std::endl;
     159           0 :     os << "{" << std::endl << lunchbox::indent;
     160             : 
     161           0 :     const std::string& name = tileQueue->getName();
     162           0 :     os << "name      \"" << name << "\"" << std::endl;
     163             : 
     164           0 :     const eq::Vector2i& size = tileQueue->getTileSize();
     165           0 :     if( size != Vector2i::ZERO )
     166           0 :         os << "size      " << size << std::endl;
     167             : 
     168           0 :     os << lunchbox::exdent << "}" << std::endl << lunchbox::enableFlush;
     169           0 :     return os;
     170             : }
     171             : 
     172             : }
     173          27 : }

Generated by: LCOV version 1.10