Line data Source code
1 :
2 : /* Copyright (c) 2011-2012, 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 : #ifndef EQSERVER_TILEQUEUE_H
20 : #define EQSERVER_TILEQUEUE_H
21 :
22 : #include "compound.h"
23 : #include "types.h"
24 :
25 : #include <co/queueMaster.h>
26 : #include <lunchbox/bitOperation.h> // function getIndexOfLastBit
27 :
28 : namespace eq
29 : {
30 : namespace server
31 : {
32 : /** A holder for tile data and parameters. */
33 : class TileQueue : public co::Object
34 : {
35 : public:
36 : /**
37 : * Constructs a new TileQueue.
38 : */
39 : EQSERVER_API TileQueue();
40 : EQSERVER_API virtual ~TileQueue();
41 : TileQueue(const TileQueue& from);
42 :
43 : /**
44 : * @name Data Access
45 : */
46 : //@{
47 0 : void setCompound(Compound* compound)
48 : {
49 0 : LBASSERT(!_compound);
50 0 : _compound = compound;
51 0 : }
52 : Compound* getCompound() const { return _compound; }
53 : Channel* getChannel() const
54 : {
55 : return _compound ? _compound->getChannel() : 0;
56 : }
57 : Node* getNode() const { return _compound ? _compound->getNode() : 0; }
58 0 : void setName(const std::string& name) { _name = name; }
59 0 : const std::string& getName() const { return _name; }
60 : /** Set the size of the tiles. */
61 0 : void setTileSize(const Vector2i& size) { _size = size; }
62 : /** @return the tile size. */
63 0 : const Vector2i& getTileSize() const { return _size; }
64 : /** Add a tile to the queue. */
65 : void addTile(const Tile& tile, const Eye eye);
66 :
67 : /**
68 : * Cycle the current tile queue.
69 : *
70 : * Used for output tile queues to allocate/recycle queue masters.
71 : *
72 : * @param frameNumber the current frame number.
73 : * @param compound the compound holding the output frame.
74 : */
75 : void cycleData(const uint32_t frameNumber, const Compound* compound);
76 :
77 : void setOutputQueue(TileQueue* queue, const Compound* compound);
78 0 : const TileQueue* getOutputQueue(const Eye eye) const
79 : {
80 0 : return _outputQueue[lunchbox::getIndexOfLastBit(eye)];
81 : }
82 :
83 : /**
84 : * @name Operations
85 : */
86 : //@{
87 : /** Unset the tile data. */
88 : void unsetData();
89 :
90 : /** Reset the frame and delete all tile datas. */
91 : void flush();
92 : //@}
93 :
94 : uint128_t getQueueMasterID(const Eye eye) const;
95 :
96 : protected:
97 0 : EQSERVER_API virtual ChangeType getChangeType() const { return INSTANCE; }
98 : EQSERVER_API virtual void getInstanceData(co::DataOStream& os);
99 : EQSERVER_API virtual void applyInstanceData(co::DataIStream& is);
100 :
101 : private:
102 0 : struct LatencyQueue
103 : {
104 : uint32_t _frameNumber;
105 : co::QueueMaster _queue;
106 : };
107 :
108 : /** The parent compound. */
109 : Compound* _compound;
110 :
111 : /** The name which associates input to output frames. */
112 : std::string _name;
113 :
114 : /** The size of each tile in the queue. */
115 : Vector2i _size;
116 :
117 : /** The collage queue pool. */
118 : std::deque<LatencyQueue*> _queues;
119 :
120 : /** the currently used tile queues */
121 : LatencyQueue* _queueMaster[NUM_EYES];
122 :
123 : /** The current output queue. */
124 : TileQueue* _outputQueue[NUM_EYES];
125 : };
126 :
127 : std::ostream& operator<<(std::ostream& os, const TileQueue* frame);
128 : }
129 : }
130 : #endif // EQSERVER_TILEQUEUE_H
|