fixed: gcc8 compile issues
[opensg.git] / Source / Contrib / ComputeBase / ComputeShader / OSGComputeShaderChunkBase.cpp
blob82aa3cfea86ded481a20ffa6d70095c659fa2152
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
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 /*****************************************************************************\
40 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class ComputeShaderChunk!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
65 #include "OSGShaderProgram.h" // ComputeShader Class
66 #include "OSGShaderProgramVariables.h" // Variables Class
68 #include "OSGComputeShaderChunkBase.h"
69 #include "OSGComputeShaderChunk.h"
71 #include <boost/bind.hpp>
73 OSG_BEGIN_NAMESPACE
75 /***************************************************************************\
76 * Description *
77 \***************************************************************************/
79 /*! \class OSG::ComputeShaderChunk
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var ShaderProgram * ComputeShaderChunkBase::_mfComputeShader
88 fragment program object
91 /*! \var std::string ComputeShaderChunkBase::_sfComputeProgram
92 vertex program source
95 /*! \var ShaderProgramVariables * ComputeShaderChunkBase::_sfVariables
96 fragment program object
99 /*! \var Int32 ComputeShaderChunkBase::_mfVariableLocations
100 fragment program object
103 /*! \var Int32 ComputeShaderChunkBase::_mfProceduralVariableLocations
104 fragment program object
107 /*! \var UInt32 ComputeShaderChunkBase::_sfGLId
112 /***************************************************************************\
113 * FieldType/FieldTrait Instantiation *
114 \***************************************************************************/
116 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
117 PointerType FieldTraits<ComputeShaderChunk *, nsOSG>::_type(
118 "ComputeShaderChunkPtr",
119 "StateChunkPtr",
120 ComputeShaderChunk::getClassType(),
121 nsOSG);
122 #endif
124 OSG_FIELDTRAITS_GETTYPE_NS(ComputeShaderChunk *, nsOSG)
126 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
127 ComputeShaderChunk *,
128 nsOSG)
130 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
131 ComputeShaderChunk *,
132 nsOSG)
134 /***************************************************************************\
135 * Field Description *
136 \***************************************************************************/
138 void ComputeShaderChunkBase::classDescInserter(TypeObject &oType)
140 FieldDescriptionBase *pDesc = NULL;
143 pDesc = new MFUnrecShaderProgramPtr::Description(
144 MFUnrecShaderProgramPtr::getClassType(),
145 "computeShader",
146 "fragment program object\n",
147 ComputeShaderFieldId, ComputeShaderFieldMask,
148 false,
149 (Field::MFDefaultFlags | Field::FStdAccess),
150 static_cast<FieldEditMethodSig>(&ComputeShaderChunk::editHandleComputeShader),
151 static_cast<FieldGetMethodSig >(&ComputeShaderChunk::getHandleComputeShader));
153 oType.addInitialDesc(pDesc);
155 pDesc = new SFString::Description(
156 SFString::getClassType(),
157 "computeProgram",
158 "vertex program source\n",
159 ComputeProgramFieldId, ComputeProgramFieldMask,
160 false,
161 (Field::SFDefaultFlags | Field::FStdAccess),
162 static_cast<FieldEditMethodSig>(&ComputeShaderChunk::editHandleComputeProgram),
163 static_cast<FieldGetMethodSig >(&ComputeShaderChunk::getHandleComputeProgram));
165 oType.addInitialDesc(pDesc);
167 pDesc = new SFUnrecChildShaderProgramVariablesPtr::Description(
168 SFUnrecChildShaderProgramVariablesPtr::getClassType(),
169 "variables",
170 "fragment program object\n",
171 VariablesFieldId, VariablesFieldMask,
172 false,
173 (Field::SFDefaultFlags | Field::FStdAccess),
174 static_cast<FieldEditMethodSig>(&ComputeShaderChunk::editHandleVariables),
175 static_cast<FieldGetMethodSig >(&ComputeShaderChunk::getHandleVariables));
177 oType.addInitialDesc(pDesc);
179 pDesc = new MFInt32::Description(
180 MFInt32::getClassType(),
181 "variableLocations",
182 "fragment program object\n",
183 VariableLocationsFieldId, VariableLocationsFieldMask,
184 true,
185 (Field::MFDefaultFlags | Field::FStdAccess),
186 static_cast<FieldEditMethodSig>(&ComputeShaderChunk::editHandleVariableLocations),
187 static_cast<FieldGetMethodSig >(&ComputeShaderChunk::getHandleVariableLocations));
189 oType.addInitialDesc(pDesc);
191 pDesc = new MFInt32::Description(
192 MFInt32::getClassType(),
193 "proceduralVariableLocations",
194 "fragment program object\n",
195 ProceduralVariableLocationsFieldId, ProceduralVariableLocationsFieldMask,
196 true,
197 (Field::MFDefaultFlags | Field::FStdAccess),
198 static_cast<FieldEditMethodSig>(&ComputeShaderChunk::editHandleProceduralVariableLocations),
199 static_cast<FieldGetMethodSig >(&ComputeShaderChunk::getHandleProceduralVariableLocations));
201 oType.addInitialDesc(pDesc);
203 pDesc = new SFUInt32::Description(
204 SFUInt32::getClassType(),
205 "GLId",
207 GLIdFieldId, GLIdFieldMask,
208 true,
209 (Field::FClusterLocal),
210 static_cast<FieldEditMethodSig>(&ComputeShaderChunk::editHandleGLId),
211 static_cast<FieldGetMethodSig >(&ComputeShaderChunk::getHandleGLId));
213 oType.addInitialDesc(pDesc);
217 ComputeShaderChunkBase::TypeObject ComputeShaderChunkBase::_type(
218 ComputeShaderChunkBase::getClassname(),
219 Inherited::getClassname(),
220 "NULL",
221 nsOSG, //Namespace
222 reinterpret_cast<PrototypeCreateF>(&ComputeShaderChunkBase::createEmptyLocal),
223 reinterpret_cast<InitContainerF>(&ComputeShaderChunk::initMethod),
224 reinterpret_cast<ExitContainerF>(&ComputeShaderChunk::exitMethod),
225 reinterpret_cast<InitalInsertDescFunc>(&ComputeShaderChunk::classDescInserter),
226 false,
227 ComputeProgramFieldMask,
228 "<?xml version=\"1.0\"?>\n"
229 "\n"
230 "<FieldContainer\n"
231 " name=\"ComputeShaderChunk\"\n"
232 " parent=\"StateChunk\"\n"
233 " library=\"ContribComputeBase\"\n"
234 " pointerfieldtypes=\"both\"\n"
235 " structure=\"concrete\"\n"
236 " systemcomponent=\"true\"\n"
237 " parentsystemcomponent=\"true\"\n"
238 " decoratable=\"false\"\n"
239 " useLocalIncludes=\"false\"\n"
240 " fieldsUnmarkedOnCreate=\"ComputeProgramFieldMask\"\n"
241 " docGroupBase=\"GrpSystemShader\"\n"
242 " >\n"
243 " <Field\n"
244 "\t name=\"computeShader\"\n"
245 "\t type=\"ShaderProgram\"\n"
246 "\t cardinality=\"multi\"\n"
247 "\t visibility=\"external\"\n"
248 "\t access=\"public\"\n"
249 " category=\"pointer\"\n"
250 " \n"
251 " pushToFieldAs=\"addComputeShader\"\n"
252 " removeFromMFieldIndexAs=\"subComputeShader\"\n"
253 " clearFieldAs=\"clearComputeShaders\" \n"
254 "\t >\n"
255 "\tfragment program object\n"
256 " </Field>\n"
257 " <Field\n"
258 " name=\"computeProgram\"\n"
259 " type=\"std::string\"\n"
260 " cardinality=\"single\"\n"
261 " visibility=\"external\"\n"
262 " access=\"public\"\n"
263 " >\n"
264 "\tvertex program source\n"
265 " </Field>\n"
266 "\n"
267 " <Field\n"
268 " name=\"variables\"\n"
269 " type=\"ShaderProgramVariables\"\n"
270 " cardinality=\"single\"\n"
271 " visibility=\"external\"\n"
272 " access=\"public\"\n"
273 " category=\"childpointer\"\n"
274 " childParentType=\"FieldContainer\"\n"
275 " linkParentField=\"Parents\"\n"
276 " >\n"
277 "\tfragment program object\n"
278 " </Field>\n"
279 " <Field\n"
280 " name=\"variableLocations\"\n"
281 " type=\"Int32\"\n"
282 " cardinality=\"multi\"\n"
283 " visibility=\"internal\"\n"
284 " access=\"protected\"\n"
285 " >\n"
286 "\tfragment program object\n"
287 " </Field>\n"
288 " <Field\n"
289 " name=\"proceduralVariableLocations\"\n"
290 " type=\"Int32\"\n"
291 " cardinality=\"multi\"\n"
292 " visibility=\"internal\"\n"
293 " access=\"protected\"\n"
294 " >\n"
295 "\tfragment program object\n"
296 " </Field>\n"
297 " \n"
298 " <Field\n"
299 " name=\"GLId\"\n"
300 " type=\"UInt32\"\n"
301 " cardinality=\"single\"\n"
302 " visibility=\"internal\"\n"
303 " access=\"public\"\n"
304 " defaultValue=\"0\"\n"
305 " fieldFlags=\"FClusterLocal\"\n"
306 " >\n"
307 " </Field>\n"
308 "\n"
309 "</FieldContainer>\n",
313 /*------------------------------ get -----------------------------------*/
315 FieldContainerType &ComputeShaderChunkBase::getType(void)
317 return _type;
320 const FieldContainerType &ComputeShaderChunkBase::getType(void) const
322 return _type;
325 UInt32 ComputeShaderChunkBase::getContainerSize(void) const
327 return sizeof(ComputeShaderChunk);
330 /*------------------------- decorator get ------------------------------*/
333 //! Get the ComputeShaderChunk::_mfComputeShader field.
334 const MFUnrecShaderProgramPtr *ComputeShaderChunkBase::getMFComputeShader(void) const
336 return &_mfComputeShader;
339 MFUnrecShaderProgramPtr *ComputeShaderChunkBase::editMFComputeShader (void)
341 editMField(ComputeShaderFieldMask, _mfComputeShader);
343 return &_mfComputeShader;
345 ShaderProgram * ComputeShaderChunkBase::getComputeShader(const UInt32 index) const
347 return _mfComputeShader[index];
350 SFString *ComputeShaderChunkBase::editSFComputeProgram(void)
352 editSField(ComputeProgramFieldMask);
354 return &_sfComputeProgram;
357 const SFString *ComputeShaderChunkBase::getSFComputeProgram(void) const
359 return &_sfComputeProgram;
363 //! Get the ComputeShaderChunk::_sfVariables field.
364 const SFUnrecChildShaderProgramVariablesPtr *ComputeShaderChunkBase::getSFVariables(void) const
366 return &_sfVariables;
369 SFUnrecChildShaderProgramVariablesPtr *ComputeShaderChunkBase::editSFVariables (void)
371 editSField(VariablesFieldMask);
373 return &_sfVariables;
376 //! Get the value of the ComputeShaderChunk::_sfVariables field.
377 ShaderProgramVariables * ComputeShaderChunkBase::getVariables(void) const
379 return _sfVariables.getValue();
382 //! Set the value of the ComputeShaderChunk::_sfVariables field.
383 void ComputeShaderChunkBase::setVariables(ShaderProgramVariables * const value)
385 editSField(VariablesFieldMask);
387 _sfVariables.setValue(value);
391 MFInt32 *ComputeShaderChunkBase::editMFVariableLocations(void)
393 editMField(VariableLocationsFieldMask, _mfVariableLocations);
395 return &_mfVariableLocations;
398 const MFInt32 *ComputeShaderChunkBase::getMFVariableLocations(void) const
400 return &_mfVariableLocations;
404 MFInt32 *ComputeShaderChunkBase::editMFProceduralVariableLocations(void)
406 editMField(ProceduralVariableLocationsFieldMask, _mfProceduralVariableLocations);
408 return &_mfProceduralVariableLocations;
411 const MFInt32 *ComputeShaderChunkBase::getMFProceduralVariableLocations(void) const
413 return &_mfProceduralVariableLocations;
417 SFUInt32 *ComputeShaderChunkBase::editSFGLId(void)
419 editSField(GLIdFieldMask);
421 return &_sfGLId;
424 const SFUInt32 *ComputeShaderChunkBase::getSFGLId(void) const
426 return &_sfGLId;
432 void ComputeShaderChunkBase::addComputeShader(ShaderProgram * const value)
434 editMField(ComputeShaderFieldMask, _mfComputeShader);
436 _mfComputeShader.push_back(value);
439 void ComputeShaderChunkBase::assignComputeShader(const MFUnrecShaderProgramPtr &value)
441 MFUnrecShaderProgramPtr::const_iterator elemIt =
442 value.begin();
443 MFUnrecShaderProgramPtr::const_iterator elemEnd =
444 value.end ();
446 static_cast<ComputeShaderChunk *>(this)->clearComputeShaders();
448 while(elemIt != elemEnd)
450 this->addComputeShader(*elemIt);
452 ++elemIt;
456 void ComputeShaderChunkBase::subComputeShader(UInt32 uiIndex)
458 if(uiIndex < _mfComputeShader.size())
460 editMField(ComputeShaderFieldMask, _mfComputeShader);
462 _mfComputeShader.erase(uiIndex);
466 void ComputeShaderChunkBase::removeObjFromComputeShader(ShaderProgram * const value)
468 Int32 iElemIdx = _mfComputeShader.findIndex(value);
470 if(iElemIdx != -1)
472 editMField(ComputeShaderFieldMask, _mfComputeShader);
474 _mfComputeShader.erase(iElemIdx);
477 void ComputeShaderChunkBase::clearComputeShaders(void)
479 editMField(ComputeShaderFieldMask, _mfComputeShader);
482 _mfComputeShader.clear();
487 /*------------------------------ access -----------------------------------*/
489 SizeT ComputeShaderChunkBase::getBinSize(ConstFieldMaskArg whichField)
491 SizeT returnValue = Inherited::getBinSize(whichField);
493 if(FieldBits::NoField != (ComputeShaderFieldMask & whichField))
495 returnValue += _mfComputeShader.getBinSize();
497 if(FieldBits::NoField != (ComputeProgramFieldMask & whichField))
499 returnValue += _sfComputeProgram.getBinSize();
501 if(FieldBits::NoField != (VariablesFieldMask & whichField))
503 returnValue += _sfVariables.getBinSize();
505 if(FieldBits::NoField != (VariableLocationsFieldMask & whichField))
507 returnValue += _mfVariableLocations.getBinSize();
509 if(FieldBits::NoField != (ProceduralVariableLocationsFieldMask & whichField))
511 returnValue += _mfProceduralVariableLocations.getBinSize();
513 if(FieldBits::NoField != (GLIdFieldMask & whichField))
515 returnValue += _sfGLId.getBinSize();
518 return returnValue;
521 void ComputeShaderChunkBase::copyToBin(BinaryDataHandler &pMem,
522 ConstFieldMaskArg whichField)
524 Inherited::copyToBin(pMem, whichField);
526 if(FieldBits::NoField != (ComputeShaderFieldMask & whichField))
528 _mfComputeShader.copyToBin(pMem);
530 if(FieldBits::NoField != (ComputeProgramFieldMask & whichField))
532 _sfComputeProgram.copyToBin(pMem);
534 if(FieldBits::NoField != (VariablesFieldMask & whichField))
536 _sfVariables.copyToBin(pMem);
538 if(FieldBits::NoField != (VariableLocationsFieldMask & whichField))
540 _mfVariableLocations.copyToBin(pMem);
542 if(FieldBits::NoField != (ProceduralVariableLocationsFieldMask & whichField))
544 _mfProceduralVariableLocations.copyToBin(pMem);
546 if(FieldBits::NoField != (GLIdFieldMask & whichField))
548 _sfGLId.copyToBin(pMem);
552 void ComputeShaderChunkBase::copyFromBin(BinaryDataHandler &pMem,
553 ConstFieldMaskArg whichField)
555 Inherited::copyFromBin(pMem, whichField);
557 if(FieldBits::NoField != (ComputeShaderFieldMask & whichField))
559 editMField(ComputeShaderFieldMask, _mfComputeShader);
560 _mfComputeShader.copyFromBin(pMem);
562 if(FieldBits::NoField != (ComputeProgramFieldMask & whichField))
564 editSField(ComputeProgramFieldMask);
565 _sfComputeProgram.copyFromBin(pMem);
567 if(FieldBits::NoField != (VariablesFieldMask & whichField))
569 editSField(VariablesFieldMask);
570 _sfVariables.copyFromBin(pMem);
572 if(FieldBits::NoField != (VariableLocationsFieldMask & whichField))
574 editMField(VariableLocationsFieldMask, _mfVariableLocations);
575 _mfVariableLocations.copyFromBin(pMem);
577 if(FieldBits::NoField != (ProceduralVariableLocationsFieldMask & whichField))
579 editMField(ProceduralVariableLocationsFieldMask, _mfProceduralVariableLocations);
580 _mfProceduralVariableLocations.copyFromBin(pMem);
582 if(FieldBits::NoField != (GLIdFieldMask & whichField))
584 editSField(GLIdFieldMask);
585 _sfGLId.copyFromBin(pMem);
589 //! create a new instance of the class
590 ComputeShaderChunkTransitPtr ComputeShaderChunkBase::createLocal(BitVector bFlags)
592 ComputeShaderChunkTransitPtr fc;
594 if(getClassType().getPrototype() != NULL)
596 FieldContainerTransitPtr tmpPtr =
597 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
599 fc = dynamic_pointer_cast<ComputeShaderChunk>(tmpPtr);
602 return fc;
605 //! create a new instance of the class, copy the container flags
606 ComputeShaderChunkTransitPtr ComputeShaderChunkBase::createDependent(BitVector bFlags)
608 ComputeShaderChunkTransitPtr fc;
610 if(getClassType().getPrototype() != NULL)
612 FieldContainerTransitPtr tmpPtr =
613 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
615 fc = dynamic_pointer_cast<ComputeShaderChunk>(tmpPtr);
618 return fc;
621 //! create a new instance of the class
622 ComputeShaderChunkTransitPtr ComputeShaderChunkBase::create(void)
624 ComputeShaderChunkTransitPtr fc;
626 if(getClassType().getPrototype() != NULL)
628 FieldContainerTransitPtr tmpPtr =
629 getClassType().getPrototype()-> shallowCopy();
631 fc = dynamic_pointer_cast<ComputeShaderChunk>(tmpPtr);
634 return fc;
637 ComputeShaderChunk *ComputeShaderChunkBase::createEmptyLocal(BitVector bFlags)
639 ComputeShaderChunk *returnValue;
641 newPtr<ComputeShaderChunk>(returnValue, bFlags);
643 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
645 return returnValue;
648 //! create an empty new instance of the class, do not copy the prototype
649 ComputeShaderChunk *ComputeShaderChunkBase::createEmpty(void)
651 ComputeShaderChunk *returnValue;
653 newPtr<ComputeShaderChunk>(returnValue, Thread::getCurrentLocalFlags());
655 returnValue->_pFieldFlags->_bNamespaceMask &=
656 ~Thread::getCurrentLocalFlags();
658 return returnValue;
662 FieldContainerTransitPtr ComputeShaderChunkBase::shallowCopyLocal(
663 BitVector bFlags) const
665 ComputeShaderChunk *tmpPtr;
667 newPtr(tmpPtr, dynamic_cast<const ComputeShaderChunk *>(this), bFlags);
669 FieldContainerTransitPtr returnValue(tmpPtr);
671 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
673 return returnValue;
676 FieldContainerTransitPtr ComputeShaderChunkBase::shallowCopyDependent(
677 BitVector bFlags) const
679 ComputeShaderChunk *tmpPtr;
681 newPtr(tmpPtr, dynamic_cast<const ComputeShaderChunk *>(this), ~bFlags);
683 FieldContainerTransitPtr returnValue(tmpPtr);
685 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
687 return returnValue;
690 FieldContainerTransitPtr ComputeShaderChunkBase::shallowCopy(void) const
692 ComputeShaderChunk *tmpPtr;
694 newPtr(tmpPtr,
695 dynamic_cast<const ComputeShaderChunk *>(this),
696 Thread::getCurrentLocalFlags());
698 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
700 FieldContainerTransitPtr returnValue(tmpPtr);
702 return returnValue;
708 /*------------------------- constructors ----------------------------------*/
710 ComputeShaderChunkBase::ComputeShaderChunkBase(void) :
711 Inherited(),
712 _mfComputeShader (),
713 _sfComputeProgram (),
714 _sfVariables (this,
715 VariablesFieldId,
716 ShaderProgramVariables::ParentsFieldId),
717 _mfVariableLocations (),
718 _mfProceduralVariableLocations(),
719 _sfGLId (UInt32(0))
723 ComputeShaderChunkBase::ComputeShaderChunkBase(const ComputeShaderChunkBase &source) :
724 Inherited(source),
725 _mfComputeShader (),
726 _sfComputeProgram (source._sfComputeProgram ),
727 _sfVariables (this,
728 VariablesFieldId,
729 ShaderProgramVariables::ParentsFieldId),
730 _mfVariableLocations (source._mfVariableLocations ),
731 _mfProceduralVariableLocations(source._mfProceduralVariableLocations),
732 _sfGLId (source._sfGLId )
737 /*-------------------------- destructors ----------------------------------*/
739 ComputeShaderChunkBase::~ComputeShaderChunkBase(void)
743 /*-------------------------------------------------------------------------*/
744 /* Child linking */
746 bool ComputeShaderChunkBase::unlinkChild(
747 FieldContainer * const pChild,
748 UInt16 const childFieldId)
750 if(childFieldId == VariablesFieldId)
752 ShaderProgramVariables * pTypedChild =
753 dynamic_cast<ShaderProgramVariables *>(pChild);
755 if(pTypedChild != NULL)
757 if(_sfVariables.getValue() == pTypedChild)
759 editSField(VariablesFieldMask);
761 _sfVariables.setValue(NULL);
763 return true;
766 SWARNING << "Parent ([" << this
767 << "] id [" << this->getId()
768 << "] type [" << this->getType().getCName()
769 << "] childFieldId [" << childFieldId
770 << "]) - Child ([" << pChild
771 << "] id [" << pChild->getId()
772 << "] type [" << pChild->getType().getCName()
773 << "]): link inconsistent!"
774 << std::endl;
776 return false;
779 return false;
783 return Inherited::unlinkChild(pChild, childFieldId);
786 void ComputeShaderChunkBase::onCreate(const ComputeShaderChunk *source)
788 Inherited::onCreate(source);
790 if(source != NULL)
792 ComputeShaderChunk *pThis = static_cast<ComputeShaderChunk *>(this);
794 MFUnrecShaderProgramPtr::const_iterator ComputeShaderIt =
795 source->_mfComputeShader.begin();
796 MFUnrecShaderProgramPtr::const_iterator ComputeShaderEnd =
797 source->_mfComputeShader.end ();
799 while(ComputeShaderIt != ComputeShaderEnd)
801 pThis->addComputeShader(*ComputeShaderIt);
803 ++ComputeShaderIt;
806 pThis->setVariables(source->getVariables());
810 GetFieldHandlePtr ComputeShaderChunkBase::getHandleComputeShader (void) const
812 MFUnrecShaderProgramPtr::GetHandlePtr returnValue(
813 new MFUnrecShaderProgramPtr::GetHandle(
814 &_mfComputeShader,
815 this->getType().getFieldDesc(ComputeShaderFieldId),
816 const_cast<ComputeShaderChunkBase *>(this)));
818 return returnValue;
821 EditFieldHandlePtr ComputeShaderChunkBase::editHandleComputeShader (void)
823 MFUnrecShaderProgramPtr::EditHandlePtr returnValue(
824 new MFUnrecShaderProgramPtr::EditHandle(
825 &_mfComputeShader,
826 this->getType().getFieldDesc(ComputeShaderFieldId),
827 this));
829 returnValue->setAddMethod(
830 boost::bind(&ComputeShaderChunk::addComputeShader,
831 static_cast<ComputeShaderChunk *>(this), _1));
832 returnValue->setRemoveMethod(
833 boost::bind(&ComputeShaderChunk::subComputeShader,
834 static_cast<ComputeShaderChunk *>(this), _1));
835 returnValue->setRemoveObjMethod(
836 boost::bind(&ComputeShaderChunk::removeObjFromComputeShader,
837 static_cast<ComputeShaderChunk *>(this), _1));
838 returnValue->setClearMethod(
839 boost::bind(&ComputeShaderChunk::clearComputeShaders,
840 static_cast<ComputeShaderChunk *>(this)));
842 editMField(ComputeShaderFieldMask, _mfComputeShader);
844 return returnValue;
847 GetFieldHandlePtr ComputeShaderChunkBase::getHandleComputeProgram (void) const
849 SFString::GetHandlePtr returnValue(
850 new SFString::GetHandle(
851 &_sfComputeProgram,
852 this->getType().getFieldDesc(ComputeProgramFieldId),
853 const_cast<ComputeShaderChunkBase *>(this)));
855 return returnValue;
858 EditFieldHandlePtr ComputeShaderChunkBase::editHandleComputeProgram (void)
860 SFString::EditHandlePtr returnValue(
861 new SFString::EditHandle(
862 &_sfComputeProgram,
863 this->getType().getFieldDesc(ComputeProgramFieldId),
864 this));
867 editSField(ComputeProgramFieldMask);
869 return returnValue;
872 GetFieldHandlePtr ComputeShaderChunkBase::getHandleVariables (void) const
874 SFUnrecChildShaderProgramVariablesPtr::GetHandlePtr returnValue(
875 new SFUnrecChildShaderProgramVariablesPtr::GetHandle(
876 &_sfVariables,
877 this->getType().getFieldDesc(VariablesFieldId),
878 const_cast<ComputeShaderChunkBase *>(this)));
880 return returnValue;
883 EditFieldHandlePtr ComputeShaderChunkBase::editHandleVariables (void)
885 SFUnrecChildShaderProgramVariablesPtr::EditHandlePtr returnValue(
886 new SFUnrecChildShaderProgramVariablesPtr::EditHandle(
887 &_sfVariables,
888 this->getType().getFieldDesc(VariablesFieldId),
889 this));
891 returnValue->setSetMethod(
892 boost::bind(&ComputeShaderChunk::setVariables,
893 static_cast<ComputeShaderChunk *>(this), _1));
895 editSField(VariablesFieldMask);
897 return returnValue;
900 GetFieldHandlePtr ComputeShaderChunkBase::getHandleVariableLocations (void) const
902 MFInt32::GetHandlePtr returnValue(
903 new MFInt32::GetHandle(
904 &_mfVariableLocations,
905 this->getType().getFieldDesc(VariableLocationsFieldId),
906 const_cast<ComputeShaderChunkBase *>(this)));
908 return returnValue;
911 EditFieldHandlePtr ComputeShaderChunkBase::editHandleVariableLocations(void)
913 MFInt32::EditHandlePtr returnValue(
914 new MFInt32::EditHandle(
915 &_mfVariableLocations,
916 this->getType().getFieldDesc(VariableLocationsFieldId),
917 this));
920 editMField(VariableLocationsFieldMask, _mfVariableLocations);
922 return returnValue;
925 GetFieldHandlePtr ComputeShaderChunkBase::getHandleProceduralVariableLocations (void) const
927 MFInt32::GetHandlePtr returnValue(
928 new MFInt32::GetHandle(
929 &_mfProceduralVariableLocations,
930 this->getType().getFieldDesc(ProceduralVariableLocationsFieldId),
931 const_cast<ComputeShaderChunkBase *>(this)));
933 return returnValue;
936 EditFieldHandlePtr ComputeShaderChunkBase::editHandleProceduralVariableLocations(void)
938 MFInt32::EditHandlePtr returnValue(
939 new MFInt32::EditHandle(
940 &_mfProceduralVariableLocations,
941 this->getType().getFieldDesc(ProceduralVariableLocationsFieldId),
942 this));
945 editMField(ProceduralVariableLocationsFieldMask, _mfProceduralVariableLocations);
947 return returnValue;
950 GetFieldHandlePtr ComputeShaderChunkBase::getHandleGLId (void) const
952 SFUInt32::GetHandlePtr returnValue(
953 new SFUInt32::GetHandle(
954 &_sfGLId,
955 this->getType().getFieldDesc(GLIdFieldId),
956 const_cast<ComputeShaderChunkBase *>(this)));
958 return returnValue;
961 EditFieldHandlePtr ComputeShaderChunkBase::editHandleGLId (void)
963 SFUInt32::EditHandlePtr returnValue(
964 new SFUInt32::EditHandle(
965 &_sfGLId,
966 this->getType().getFieldDesc(GLIdFieldId),
967 this));
970 editSField(GLIdFieldMask);
972 return returnValue;
976 #ifdef OSG_MT_CPTR_ASPECT
977 void ComputeShaderChunkBase::execSyncV( FieldContainer &oFrom,
978 ConstFieldMaskArg whichField,
979 AspectOffsetStore &oOffsets,
980 ConstFieldMaskArg syncMode,
981 const UInt32 uiSyncInfo)
983 ComputeShaderChunk *pThis = static_cast<ComputeShaderChunk *>(this);
985 pThis->execSync(static_cast<ComputeShaderChunk *>(&oFrom),
986 whichField,
987 oOffsets,
988 syncMode,
989 uiSyncInfo);
991 #endif
994 #ifdef OSG_MT_CPTR_ASPECT
995 FieldContainer *ComputeShaderChunkBase::createAspectCopy(
996 const FieldContainer *pRefAspect) const
998 ComputeShaderChunk *returnValue;
1000 newAspectCopy(returnValue,
1001 dynamic_cast<const ComputeShaderChunk *>(pRefAspect),
1002 dynamic_cast<const ComputeShaderChunk *>(this));
1004 return returnValue;
1006 #endif
1008 void ComputeShaderChunkBase::resolveLinks(void)
1010 Inherited::resolveLinks();
1012 static_cast<ComputeShaderChunk *>(this)->clearComputeShaders();
1014 static_cast<ComputeShaderChunk *>(this)->setVariables(NULL);
1016 #ifdef OSG_MT_CPTR_ASPECT
1017 AspectOffsetStore oOffsets;
1019 _pAspectStore->fillOffsetArray(oOffsets, this);
1020 #endif
1022 #ifdef OSG_MT_CPTR_ASPECT
1023 _mfVariableLocations.terminateShare(Thread::getCurrentAspect(),
1024 oOffsets);
1025 #endif
1026 #ifdef OSG_MT_CPTR_ASPECT
1027 _mfProceduralVariableLocations.terminateShare(Thread::getCurrentAspect(),
1028 oOffsets);
1029 #endif
1033 OSG_END_NAMESPACE