changed: gcc8 base update
[opensg.git] / Source / System / Cluster / Window / SortLast / OSGPipelineComposer.h
blob3fbedea36d07c00ccb3d15bf0b1cac23ad9a551f
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGPIPELINECOMPOSER_H_
40 #define _OSGPIPELINECOMPOSER_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGGL.h"
46 #include "OSGGLU.h"
47 #include "OSGPipelineComposerBase.h"
48 #include "OSGBaseThread.h"
49 #include "OSGLock.h"
50 #include "OSGClusterNetwork.h"
52 //#define COMPRESS_IMAGES 1
54 #ifdef COMPRESS_IMAGES
55 #include <lzf.h>
56 #include <lzf_c.cpp>
57 #include <lzf_d.cpp>
58 #endif
60 OSG_BEGIN_NAMESPACE
62 //#define USE_NV_OCCLUSION 1
64 /*! \brief PipelineComposer class. See \ref
65 PageSystemPipelineComposer for a description.
67 \ingroup GrpClusterWindowComposer
68 \ingroup GrpLibOSGCluster
69 \includebasedoc
72 class OSG_CLUSTER_DLLMAPPING PipelineComposer : public PipelineComposerBase
74 private:
76 typedef PipelineComposerBase Inherited;
78 struct TileBuffer;
79 struct GroupInfo;
80 struct GroupInfoOrder;
82 friend struct TileBuffer;
83 friend struct GroupInfo;
84 friend struct GroupInfoOrder;
86 /*! \brief RGB Color value
87 \nohierarchy
90 struct RGBValue
92 UInt8 red;
93 UInt8 green;
94 UInt8 blue;
97 /*! \nohierarchy
100 struct DepthInfo
102 UInt32 min;
103 UInt32 max;
104 UInt8 occlude;
107 /*! \nohierarchy
110 struct TransInfo
112 unsigned int sendTo :13;
113 unsigned int empty :1;
114 unsigned int sendDepth:1;
115 unsigned int first :1;
118 /*! \nohierarchy
121 struct TileBuffer
123 bool empty;
124 UInt32 size;
125 UInt32 colorSize;
126 UInt32 depthSize;
127 UInt32 dataSize;
128 Connection *dstConnection;
129 struct DepthInfo depth;
130 struct TransInfo trans;
132 /*! \nohierarchy
135 struct
137 UInt32 count;
138 UInt16 x;
139 UInt16 y;
140 UInt16 w;
141 UInt16 h;
142 UInt16 depth;
143 } header;
144 UInt8 data[1];
147 /*! \nohierarchy
150 struct GroupInfo
152 UInt32 id;
153 struct DepthInfo depth;
154 struct TransInfo trans;
157 /*! \nohierarchy
160 struct GroupInfoOrder : public std::binary_function<
161 const GroupInfo*,const GroupInfo*, bool>
163 bool operator() (const GroupInfo *a, const GroupInfo *b);
166 /*! \nohierarchy
169 struct Statistics
171 UInt32 bytesIn;
172 UInt32 bytesOut;
173 UInt32 occluded;
174 UInt32 noDepth;
175 UInt32 noGeo;
176 UInt32 clipped;
177 double sortTime;
178 double pixelReadTime;
179 double composeTime;
182 typedef std::list<TileBuffer*> QueueT;
184 /*========================== PUBLIC =================================*/
186 public:
188 /*---------------------------------------------------------------------*/
189 /*! \name Sync */
190 /*! \{ */
192 virtual void changed(ConstFieldMaskArg whichField,
193 UInt32 origin,
194 BitVector detail);
196 /*! \} */
197 /*---------------------------------------------------------------------*/
198 /*! \name Output */
199 /*! \{ */
201 virtual void dump( UInt32 uiIndent = 0,
202 const BitVector bvFlags = 0) const;
204 /*! \} */
205 /*---------------------------------------------------------------------*/
206 /*! \name composition */
207 /*! \{ */
209 virtual void open (void );
210 virtual void startViewport (Viewport *port);
211 virtual void composeViewport(Viewport *port);
212 virtual void close (void );
214 /*! \} */
215 /*---------------------------------------------------------------------*/
216 /*! \name features */
217 /*! \{ */
219 virtual bool getClientRendering(void);
221 /*! \} */
222 /*========================= PROTECTED ===============================*/
224 protected:
226 UInt32 _tileBufferSize;
227 std::vector<UInt8> _tileA;
228 std::vector<UInt8> _tileB;
229 std::vector<UInt8> _workingTile;
230 std::vector<UInt8> *_readTilePtr;
231 std::vector<UInt8> *_composeTilePtr;
232 UInt32 _readTilesX;
233 UInt32 _readTilesY;
234 UInt32 _composeTilesX;
235 UInt32 _composeTilesY;
237 std::vector< TransInfo > _transInfo;
238 std::list < GroupInfo > _groupInfoPool;
239 std::vector< GroupInfo* > _groupInfo;
241 GLenum _colorFormat;
242 GLenum _colorType;
243 GLenum _depthType;
245 Statistics _statistics;
247 BaseThreadRefPtr _writer;
248 ThreadRefPtr _composer;
249 BarrierRefPtr _barrier;
250 BarrierRefPtr _composeBarrier;
251 BarrierRefPtr _frameEndBarrier;
252 LockRefPtr _lock;
253 QueueT _queue;
254 bool _waiting;
255 GLuint _occlusionQuery;
256 bool _firstFrame;
258 /*---------------------------------------------------------------------*/
259 /*! \name Constructors */
260 /*! \{ */
262 PipelineComposer(void);
263 PipelineComposer(const PipelineComposer &source);
265 /*! \} */
266 /*---------------------------------------------------------------------*/
267 /*! \name Destructors */
268 /*! \{ */
270 virtual ~PipelineComposer(void);
272 /*! \} */
273 /*---------------------------------------------------------------------*/
274 /*! \name helper function */
275 /*! \{ */
277 template<class DepthT,class ColorT>
278 UInt32 getMinMaxOcclude(DepthT &depth,ColorT &color,
279 DepthInfo *buffer);
281 template<class DepthT,class ColorT>
282 void setTransInfo(DepthT &depth,ColorT &color);
284 template<class DepthT,class ColorT>
285 void calculateTransInfo(DepthT &depth,ColorT &color);
287 template<class DepthT,class ColorT>
288 void clientCompose(DepthT &depth,ColorT &color);
290 template<class DepthT,class ColorT>
291 void serverCompose(DepthT &depth,ColorT &color);
293 template<class DepthT,class ColorT>
294 void writeResult(DepthT &depth,ColorT &color);
296 template<class DepthT,class ColorT>
297 void readBuffer(DepthT &depth,ColorT &color,
298 Viewport *port);
299 template<class DepthT,class ColorT>
300 void composeBuffer(DepthT &depth,ColorT &color);
302 UInt32 compressTransInfo(std::vector<TransInfo> &transInfo);
303 void uncompressTransInfo(std::vector<TransInfo> &transInfo,
304 UInt32 infoCount);
306 template <class T,T empty>
307 static bool checkDepth(T *buffer,T &front,T &back,int size);
309 TileBuffer *getComposeTileBuffer(UInt32 x,UInt32 y);
310 TileBuffer *getReadTileBuffer(UInt32 x,UInt32 y);
311 TileBuffer *getWorkingTileBuffer(void);
313 /*! \} */
314 /*---------------------------------------------------------------------*/
315 /*! \name Init */
316 /*! \{ */
318 static void initMethod(InitPhase ePhase);
320 /*! \} */
321 /*========================== PRIVATE ================================*/
322 private:
324 friend class FieldContainer;
325 friend class PipelineComposerBase;
327 static void writeProc(void *arg);
328 static void composeProc(void *arg);
330 // prohibit default functions (move to 'public' if you need one)
331 void operator =(const PipelineComposer &source);
334 typedef PipelineComposer *PipelineComposerP;
336 OSG_END_NAMESPACE
338 #include "OSGPipelineComposerBase.inl"
339 #include "OSGPipelineComposer.inl"
341 #endif /* _OSGPIPELINECOMPOSER_H_ */