LCOV - code coverage report
Current view: top level - eq/server - tileQueue.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 80 1.2 %
Date: 2017-12-16 05:07:20 Functions: 2 15 13.3 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011-2016, Stefan Eilemann <eile@eyescale.ch>
       3             :  *                          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 <co/dataIStream.h>
      22             : #include <co/dataOStream.h>
      23             : #include <co/queueItem.h>
      24             : #include <eq/fabric/tile.h>
      25             : 
      26             : namespace eq
      27             : {
      28             : namespace server
      29             : {
      30           0 : TileQueue::TileQueue()
      31             :     : co::Object()
      32             :     , _compound(0)
      33             :     , _name()
      34           0 :     , _size(0, 0)
      35             : {
      36           0 :     for (unsigned i = 0; i < NUM_EYES; ++i)
      37             :     {
      38           0 :         _queueMaster[i] = 0;
      39           0 :         _outputQueue[i] = 0;
      40             :     }
      41           0 : }
      42             : 
      43           0 : TileQueue::TileQueue(const TileQueue& from)
      44             :     : co::Object()
      45             :     , _compound(0)
      46             :     , _name(from._name)
      47           0 :     , _size(from._size)
      48             : {
      49           0 :     for (unsigned i = 0; i < NUM_EYES; ++i)
      50             :     {
      51           0 :         _queueMaster[i] = 0;
      52           0 :         _outputQueue[i] = 0;
      53             :     }
      54           0 : }
      55             : 
      56           0 : TileQueue::~TileQueue()
      57             : {
      58           0 :     _compound = 0;
      59           0 : }
      60             : 
      61           0 : void TileQueue::addTile(const Tile& tile, const fabric::Eye eye)
      62             : {
      63           0 :     uint32_t index = lunchbox::getIndexOfLastBit(eye);
      64           0 :     LBASSERT(index < NUM_EYES);
      65           0 :     _queueMaster[index]->_queue.push() << tile;
      66           0 : }
      67             : 
      68           0 : void TileQueue::cycleData(const uint32_t frameNumber, const Compound* compound)
      69             : {
      70           0 :     for (unsigned i = 0; i < NUM_EYES; ++i)
      71             :     {
      72           0 :         if (!compound->isInheritActive(Eye(1 << i))) // eye pass not used
      73             :         {
      74           0 :             _queueMaster[i] = 0;
      75           0 :             continue;
      76             :         }
      77             : 
      78             :         // reuse unused queues
      79           0 :         LatencyQueue* queue = _queues.empty() ? 0 : _queues.back();
      80           0 :         const uint32_t latency = getAutoObsolete();
      81           0 :         const uint32_t dataAge = queue ? queue->_frameNumber : 0;
      82             : 
      83           0 :         if (queue && dataAge < frameNumber - latency && frameNumber > latency)
      84             :             // not used anymore
      85           0 :             _queues.pop_back();
      86             :         else // still used - allocate new data
      87             :         {
      88           0 :             queue = new LatencyQueue;
      89             : 
      90           0 :             getLocalNode()->registerObject(&queue->_queue);
      91           0 :             queue->_queue.setAutoObsolete(
      92           0 :                 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           0 : }
     133             : 
     134           0 : void TileQueue::unsetData()
     135             : {
     136           0 :     for (unsigned i = 0; i < NUM_EYES; ++i)
     137             :     {
     138           0 :         _queueMaster[i] = 0;
     139           0 :         _outputQueue[i] = 0;
     140             :     }
     141           0 : }
     142             : 
     143           0 : uint128_t TileQueue::getQueueMasterID(const Eye eye) const
     144             : {
     145           0 :     uint32_t index = lunchbox::getIndexOfLastBit(eye);
     146           0 :     LatencyQueue* queue = _queueMaster[index];
     147           0 :     if (queue)
     148           0 :         return queue->_queue.getID();
     149           0 :     return uint128_t();
     150             : }
     151             : 
     152           0 : std::ostream& operator<<(std::ostream& os, const TileQueue* tileQueue)
     153             : {
     154           0 :     if (!tileQueue)
     155           0 :         return os;
     156             : 
     157           0 :     os << lunchbox::disableFlush << "tiles" << std::endl;
     158           0 :     os << "{" << std::endl << lunchbox::indent;
     159             : 
     160           0 :     const std::string& name = tileQueue->getName();
     161           0 :     os << "name      \"" << name << "\"" << std::endl;
     162             : 
     163           0 :     const Vector2i& size = tileQueue->getTileSize();
     164           0 :     if (size != Vector2i())
     165           0 :         os << "size      " << size << std::endl;
     166             : 
     167           0 :     os << lunchbox::exdent << "}" << std::endl << lunchbox::enableFlush;
     168           0 :     return os;
     169             : }
     170             : }
     171          60 : }

Generated by: LCOV version 1.11