changed: gcc8 base update
[opensg.git] / Source / Contrib / ComputeBase / ComputeShader / OSGComputeShaderChunk.h
blob557e8893571ebed389e9c35e356c5efc314e3a67
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 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 _OSGCOMPUTESHADERCHUNK_H_
40 #define _OSGCOMPUTESHADERCHUNK_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGComputeShaderChunkBase.h"
46 #include "OSGShaderProgram.h"
47 #include "OSGShaderExecutableChunk.h"
49 OSG_BEGIN_NAMESPACE
51 class Window;
53 /*! \brief ComputeShaderChunk class. See \ref
54 PageStateComputeShaderChunk for a description.
55 \ingroup GrpSystemShaderSHLChunk
56 \ingroup GrpLibOSGSystem
57 \includebasedoc
60 class OSG_CONTRIBCOMPUTEBASE_DLLMAPPING ComputeShaderChunk :
61 public ComputeShaderChunkBase
63 protected:
65 /*========================== PUBLIC =================================*/
67 public:
69 typedef ComputeShaderChunkBase Inherited;
70 typedef ComputeShaderChunk Self;
72 typedef ShaderVariableFunctor::GetUniformLocProc GetUniformLocProc;
73 typedef ShaderVariableFunctor::ProcVarFunctor ProcVarFunctor;
74 typedef ShaderVariableFunctor::ProcVarNodeFunctor ProcVarNodeFunctor;
76 static const UInt32 KeepProgActive = ShaderProgram::KeepProgActive;
78 static const UInt32 ProgActive = ShaderProgram::ProgActive;
80 /*---------------------------------------------------------------------*/
81 /*! \name Chunk Class Access */
82 /*! \{ */
84 virtual const StateChunkClass *getClass(void) const;
86 /*! \} */
87 /*---------------------------------------------------------------------*/
88 /*! \name Static Chunk Class Access */
89 /*! \{ */
91 static UInt32 getStaticClassId(void);
92 static const StateChunkClass *getStaticClass (void);
94 /*! \} */
95 /*---------------------------------------------------------------------*/
96 /*! \name Chunk Id */
97 /*! \{ */
99 virtual UInt16 getChunkId(void);
101 /*! \} */
102 /*---------------------------------------------------------------------*/
103 /*! \name Sync */
104 /*! \{ */
106 virtual void changed(ConstFieldMaskArg whichField,
107 UInt32 origin,
108 BitVector details );
110 /*! \} */
111 /*---------------------------------------------------------------------*/
112 /*! \name Output */
113 /*! \{ */
115 virtual void activate (DrawEnv *pEnv,
116 UInt32 uiIdx = 0);
117 virtual void changeFrom(DrawEnv *pEnv,
118 StateChunk *pOld,
119 UInt32 uiIdx = 0);
120 virtual void deactivate(DrawEnv *pEnv,
121 UInt32 uiIdx = 0);
122 /*! \} */
123 /*---------------------------------------------------------------------*/
124 /*! \name Output */
125 /*! \{ */
127 bool readComputeProgram (const Char8 *file);
129 /*! \} */
130 /*---------------------------------------------------------------------*/
131 /*! \name Program Parameter */
132 /*! \{ */
134 /*! \} */
135 /*---------------------------------------------------------------------*/
136 /*! \name Init */
137 /*! \{ */
139 #if 0
140 virtual void update (DrawEnv *pEnv );
141 #endif
143 /*! \} */
144 /*---------------------------------------------------------------------*/
145 /*! \name Output */
146 /*! \{ */
148 template<class ValueT>
149 bool addUniformVariable (const Char8 *name, const ValueT &value);
151 template<class ValueT>
152 bool updateUniformVariable (const Char8 *name, const ValueT &value);
154 template<class ValueT>
155 bool getUniformVariable (const Char8 *name, ValueT &value);
157 bool subUniformVariable (const Char8 *name );
158 void clearUniformVariables ( void );
160 bool addOSGVariable (const Char8 *name );
162 /*! \} */
163 /*---------------------------------------------------------------------*/
164 /*! \name Output */
165 /*! \{ */
167 bool addProceduralVariable (const Char8 *name,
168 ProcVarFunctor pFunc,
169 UInt32 uiDependency =
170 ShaderProcVariable::SHDObject);
172 bool updateProceduralVariable (const Char8 *name,
173 ProcVarFunctor pFunc,
174 UInt32 uiDependency =
175 ShaderProcVariable::SHDObject);
177 bool addNodeProceduralVariable (const Char8 *name,
178 ProcVarNodeFunctor pFunc,
179 UInt32 uiDependency =
180 ShaderProcVariable::SHDObject);
182 bool updateNodeProceduralVariable(const Char8 *name,
183 ProcVarNodeFunctor pFunc,
184 UInt32 uiDependency =
185 ShaderProcVariable::SHDObject);
188 /*! \} */
189 /*---------------------------------------------------------------------*/
190 /*! \name Output */
191 /*! \{ */
193 /*! \} */
194 /*---------------------------------------------------------------------*/
195 /*! \name Output */
196 /*! \{ */
198 #if 0
199 void updateParameters(
200 Window *win,
201 const UInt32 &parameters,
202 bool useProgram = true,
203 bool force = false,
204 bool keepProgramActive=false);
206 const UInt32 *getMFParameters(void) const;
207 #endif
209 /*! \} */
210 /*---------------------------------------------------------------------*/
211 /*! \name Output */
212 /*! \{ */
214 virtual void dump( UInt32 uiIndent = 0,
215 const BitVector bvFlags = 0) const;
217 /*! \} */
218 /*---------------------------------------------------------------------*/
219 /*! \name Output */
220 /*! \{ */
222 /*! \} */
223 /*========================= PROTECTED ===============================*/
225 protected:
227 static UInt32 _arbComputeShader;
229 /*---------------------------------------------------------------------*/
231 static volatile UInt16 _uiChunkCounter;
233 UInt16 _uiChunkId;
235 // Variables should all be in ComputeShaderChunkBase.
237 typedef MFComputeShaderType::const_iterator ComputeShaderIt;
239 /*---------------------------------------------------------------------*/
240 /*! \name Constructors */
241 /*! \{ */
243 ComputeShaderChunk(void);
244 ComputeShaderChunk(const ComputeShaderChunk &source);
246 /*! \} */
247 /*---------------------------------------------------------------------*/
248 /*! \name Destructors */
249 /*! \{ */
251 virtual ~ComputeShaderChunk(void);
253 /*! \} */
254 /*---------------------------------------------------------------------*/
255 /*! \name Init */
256 /*! \{ */
258 static void initMethod(InitPhase ePhase);
260 /*! \} */
261 /*---------------------------------------------------------------------*/
262 /*! \name Init */
263 /*! \{ */
265 UInt32 handleGL (DrawEnv *pEnv,
266 UInt32 id,
267 Window::GLObjectStatusE mode,
268 UInt64 uiOptions);
269 static void handleDestroyGL(DrawEnv *pEnv,
270 UInt32 id,
271 Window::GLObjectStatusE mode );
273 /*! \} */
274 /*---------------------------------------------------------------------*/
275 /*! \name Init */
276 /*! \{ */
278 void onCreate (const ComputeShaderChunk *source = NULL);
279 void onCreateAspect(const ComputeShaderChunk *createAspect,
280 const ComputeShaderChunk *source = NULL);
281 void onDestroy( UInt32 uiId );
283 /*! \} */
284 /*---------------------------------------------------------------------*/
285 /*! \name Init */
286 /*! \{ */
288 void updateVariableLocations (DrawEnv *pEnv,
289 UInt32 uiProgram);
290 void updateVariables (DrawEnv *pEnv,
291 UInt32 uiProgram);
292 void updateProceduralVariables(DrawEnv *pEnv,
293 UInt32 uiUpdateDependents);
295 /*! \} */
296 /*---------------------------------------------------------------------*/
297 /*! \name Init */
298 /*! \{ */
300 bool readProgram( std::string &szTarget,
301 const Char8 *szFilename);
303 bool readProgram( std::string &szTarget,
304 std::istream &iStream);
306 /*! \} */
307 /*---------------------------------------------------------------------*/
308 /*! \name Init */
309 /*! \{ */
311 /*! \} */
312 /*========================== PRIVATE ================================*/
314 private:
316 // class. Used for indexing in State
317 static StateChunkClass _class;
319 friend class FieldContainer;
320 friend class ComputeShaderChunkBase;
322 // prohibit default functions (move to 'public' if you need one)
323 void operator =(const ComputeShaderChunk &source);
326 typedef ComputeShaderChunk *ComputeShaderChunkP;
328 OSG_END_NAMESPACE
330 #include "OSGComputeShaderChunkBase.inl"
331 #include "OSGComputeShaderChunk.inl"
333 #endif /* _OSGCOMPUTESHADERCHUNK_H_ */