changed: gcc8 base update
[opensg.git] / Source / Contrib / ComputeBase / ComputeShader / OSGComputeShaderChunkBase.cpp
blob55e06b184f8448bf83e4de6e422b280e60d27b08
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>(
226 reinterpret_cast<void *>(&ComputeShaderChunk::classDescInserter)),
227 false,
228 ComputeProgramFieldMask,
229 "<?xml version=\"1.0\"?>\n"
230 "\n"
231 "<FieldContainer\n"
232 " name=\"ComputeShaderChunk\"\n"
233 " parent=\"StateChunk\"\n"
234 " library=\"ContribComputeBase\"\n"
235 " pointerfieldtypes=\"both\"\n"
236 " structure=\"concrete\"\n"
237 " systemcomponent=\"true\"\n"
238 " parentsystemcomponent=\"true\"\n"
239 " decoratable=\"false\"\n"
240 " useLocalIncludes=\"false\"\n"
241 " fieldsUnmarkedOnCreate=\"ComputeProgramFieldMask\"\n"
242 " docGroupBase=\"GrpSystemShader\"\n"
243 " >\n"
244 " <Field\n"
245 "\t name=\"computeShader\"\n"
246 "\t type=\"ShaderProgram\"\n"
247 "\t cardinality=\"multi\"\n"
248 "\t visibility=\"external\"\n"
249 "\t access=\"public\"\n"
250 " category=\"pointer\"\n"
251 " \n"
252 " pushToFieldAs=\"addComputeShader\"\n"
253 " removeFromMFieldIndexAs=\"subComputeShader\"\n"
254 " clearFieldAs=\"clearComputeShaders\" \n"
255 "\t >\n"
256 "\tfragment program object\n"
257 " </Field>\n"
258 " <Field\n"
259 " name=\"computeProgram\"\n"
260 " type=\"std::string\"\n"
261 " cardinality=\"single\"\n"
262 " visibility=\"external\"\n"
263 " access=\"public\"\n"
264 " >\n"
265 "\tvertex program source\n"
266 " </Field>\n"
267 "\n"
268 " <Field\n"
269 " name=\"variables\"\n"
270 " type=\"ShaderProgramVariables\"\n"
271 " cardinality=\"single\"\n"
272 " visibility=\"external\"\n"
273 " access=\"public\"\n"
274 " category=\"childpointer\"\n"
275 " childParentType=\"FieldContainer\"\n"
276 " linkParentField=\"Parents\"\n"
277 " >\n"
278 "\tfragment program object\n"
279 " </Field>\n"
280 " <Field\n"
281 " name=\"variableLocations\"\n"
282 " type=\"Int32\"\n"
283 " cardinality=\"multi\"\n"
284 " visibility=\"internal\"\n"
285 " access=\"protected\"\n"
286 " >\n"
287 "\tfragment program object\n"
288 " </Field>\n"
289 " <Field\n"
290 " name=\"proceduralVariableLocations\"\n"
291 " type=\"Int32\"\n"
292 " cardinality=\"multi\"\n"
293 " visibility=\"internal\"\n"
294 " access=\"protected\"\n"
295 " >\n"
296 "\tfragment program object\n"
297 " </Field>\n"
298 " \n"
299 " <Field\n"
300 " name=\"GLId\"\n"
301 " type=\"UInt32\"\n"
302 " cardinality=\"single\"\n"
303 " visibility=\"internal\"\n"
304 " access=\"public\"\n"
305 " defaultValue=\"0\"\n"
306 " fieldFlags=\"FClusterLocal\"\n"
307 " >\n"
308 " </Field>\n"
309 "\n"
310 "</FieldContainer>\n",
314 /*------------------------------ get -----------------------------------*/
316 FieldContainerType &ComputeShaderChunkBase::getType(void)
318 return _type;
321 const FieldContainerType &ComputeShaderChunkBase::getType(void) const
323 return _type;
326 UInt32 ComputeShaderChunkBase::getContainerSize(void) const
328 return sizeof(ComputeShaderChunk);
331 /*------------------------- decorator get ------------------------------*/
334 //! Get the ComputeShaderChunk::_mfComputeShader field.
335 const MFUnrecShaderProgramPtr *ComputeShaderChunkBase::getMFComputeShader(void) const
337 return &_mfComputeShader;
340 MFUnrecShaderProgramPtr *ComputeShaderChunkBase::editMFComputeShader (void)
342 editMField(ComputeShaderFieldMask, _mfComputeShader);
344 return &_mfComputeShader;
346 ShaderProgram * ComputeShaderChunkBase::getComputeShader(const UInt32 index) const
348 return _mfComputeShader[index];
351 SFString *ComputeShaderChunkBase::editSFComputeProgram(void)
353 editSField(ComputeProgramFieldMask);
355 return &_sfComputeProgram;
358 const SFString *ComputeShaderChunkBase::getSFComputeProgram(void) const
360 return &_sfComputeProgram;
364 //! Get the ComputeShaderChunk::_sfVariables field.
365 const SFUnrecChildShaderProgramVariablesPtr *ComputeShaderChunkBase::getSFVariables(void) const
367 return &_sfVariables;
370 SFUnrecChildShaderProgramVariablesPtr *ComputeShaderChunkBase::editSFVariables (void)
372 editSField(VariablesFieldMask);
374 return &_sfVariables;
377 //! Get the value of the ComputeShaderChunk::_sfVariables field.
378 ShaderProgramVariables * ComputeShaderChunkBase::getVariables(void) const
380 return _sfVariables.getValue();
383 //! Set the value of the ComputeShaderChunk::_sfVariables field.
384 void ComputeShaderChunkBase::setVariables(ShaderProgramVariables * const value)
386 editSField(VariablesFieldMask);
388 _sfVariables.setValue(value);
392 MFInt32 *ComputeShaderChunkBase::editMFVariableLocations(void)
394 editMField(VariableLocationsFieldMask, _mfVariableLocations);
396 return &_mfVariableLocations;
399 const MFInt32 *ComputeShaderChunkBase::getMFVariableLocations(void) const
401 return &_mfVariableLocations;
405 MFInt32 *ComputeShaderChunkBase::editMFProceduralVariableLocations(void)
407 editMField(ProceduralVariableLocationsFieldMask, _mfProceduralVariableLocations);
409 return &_mfProceduralVariableLocations;
412 const MFInt32 *ComputeShaderChunkBase::getMFProceduralVariableLocations(void) const
414 return &_mfProceduralVariableLocations;
418 SFUInt32 *ComputeShaderChunkBase::editSFGLId(void)
420 editSField(GLIdFieldMask);
422 return &_sfGLId;
425 const SFUInt32 *ComputeShaderChunkBase::getSFGLId(void) const
427 return &_sfGLId;
433 void ComputeShaderChunkBase::addComputeShader(ShaderProgram * const value)
435 editMField(ComputeShaderFieldMask, _mfComputeShader);
437 _mfComputeShader.push_back(value);
440 void ComputeShaderChunkBase::assignComputeShader(const MFUnrecShaderProgramPtr &value)
442 MFUnrecShaderProgramPtr::const_iterator elemIt =
443 value.begin();
444 MFUnrecShaderProgramPtr::const_iterator elemEnd =
445 value.end ();
447 static_cast<ComputeShaderChunk *>(this)->clearComputeShaders();
449 while(elemIt != elemEnd)
451 this->addComputeShader(*elemIt);
453 ++elemIt;
457 void ComputeShaderChunkBase::subComputeShader(UInt32 uiIndex)
459 if(uiIndex < _mfComputeShader.size())
461 editMField(ComputeShaderFieldMask, _mfComputeShader);
463 _mfComputeShader.erase(uiIndex);
467 void ComputeShaderChunkBase::removeObjFromComputeShader(ShaderProgram * const value)
469 Int32 iElemIdx = _mfComputeShader.findIndex(value);
471 if(iElemIdx != -1)
473 editMField(ComputeShaderFieldMask, _mfComputeShader);
475 _mfComputeShader.erase(iElemIdx);
478 void ComputeShaderChunkBase::clearComputeShaders(void)
480 editMField(ComputeShaderFieldMask, _mfComputeShader);
483 _mfComputeShader.clear();
488 /*------------------------------ access -----------------------------------*/
490 SizeT ComputeShaderChunkBase::getBinSize(ConstFieldMaskArg whichField)
492 SizeT returnValue = Inherited::getBinSize(whichField);
494 if(FieldBits::NoField != (ComputeShaderFieldMask & whichField))
496 returnValue += _mfComputeShader.getBinSize();
498 if(FieldBits::NoField != (ComputeProgramFieldMask & whichField))
500 returnValue += _sfComputeProgram.getBinSize();
502 if(FieldBits::NoField != (VariablesFieldMask & whichField))
504 returnValue += _sfVariables.getBinSize();
506 if(FieldBits::NoField != (VariableLocationsFieldMask & whichField))
508 returnValue += _mfVariableLocations.getBinSize();
510 if(FieldBits::NoField != (ProceduralVariableLocationsFieldMask & whichField))
512 returnValue += _mfProceduralVariableLocations.getBinSize();
514 if(FieldBits::NoField != (GLIdFieldMask & whichField))
516 returnValue += _sfGLId.getBinSize();
519 return returnValue;
522 void ComputeShaderChunkBase::copyToBin(BinaryDataHandler &pMem,
523 ConstFieldMaskArg whichField)
525 Inherited::copyToBin(pMem, whichField);
527 if(FieldBits::NoField != (ComputeShaderFieldMask & whichField))
529 _mfComputeShader.copyToBin(pMem);
531 if(FieldBits::NoField != (ComputeProgramFieldMask & whichField))
533 _sfComputeProgram.copyToBin(pMem);
535 if(FieldBits::NoField != (VariablesFieldMask & whichField))
537 _sfVariables.copyToBin(pMem);
539 if(FieldBits::NoField != (VariableLocationsFieldMask & whichField))
541 _mfVariableLocations.copyToBin(pMem);
543 if(FieldBits::NoField != (ProceduralVariableLocationsFieldMask & whichField))
545 _mfProceduralVariableLocations.copyToBin(pMem);
547 if(FieldBits::NoField != (GLIdFieldMask & whichField))
549 _sfGLId.copyToBin(pMem);
553 void ComputeShaderChunkBase::copyFromBin(BinaryDataHandler &pMem,
554 ConstFieldMaskArg whichField)
556 Inherited::copyFromBin(pMem, whichField);
558 if(FieldBits::NoField != (ComputeShaderFieldMask & whichField))
560 editMField(ComputeShaderFieldMask, _mfComputeShader);
561 _mfComputeShader.copyFromBin(pMem);
563 if(FieldBits::NoField != (ComputeProgramFieldMask & whichField))
565 editSField(ComputeProgramFieldMask);
566 _sfComputeProgram.copyFromBin(pMem);
568 if(FieldBits::NoField != (VariablesFieldMask & whichField))
570 editSField(VariablesFieldMask);
571 _sfVariables.copyFromBin(pMem);
573 if(FieldBits::NoField != (VariableLocationsFieldMask & whichField))
575 editMField(VariableLocationsFieldMask, _mfVariableLocations);
576 _mfVariableLocations.copyFromBin(pMem);
578 if(FieldBits::NoField != (ProceduralVariableLocationsFieldMask & whichField))
580 editMField(ProceduralVariableLocationsFieldMask, _mfProceduralVariableLocations);
581 _mfProceduralVariableLocations.copyFromBin(pMem);
583 if(FieldBits::NoField != (GLIdFieldMask & whichField))
585 editSField(GLIdFieldMask);
586 _sfGLId.copyFromBin(pMem);
590 //! create a new instance of the class
591 ComputeShaderChunkTransitPtr ComputeShaderChunkBase::createLocal(BitVector bFlags)
593 ComputeShaderChunkTransitPtr fc;
595 if(getClassType().getPrototype() != NULL)
597 FieldContainerTransitPtr tmpPtr =
598 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
600 fc = dynamic_pointer_cast<ComputeShaderChunk>(tmpPtr);
603 return fc;
606 //! create a new instance of the class, copy the container flags
607 ComputeShaderChunkTransitPtr ComputeShaderChunkBase::createDependent(BitVector bFlags)
609 ComputeShaderChunkTransitPtr fc;
611 if(getClassType().getPrototype() != NULL)
613 FieldContainerTransitPtr tmpPtr =
614 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
616 fc = dynamic_pointer_cast<ComputeShaderChunk>(tmpPtr);
619 return fc;
622 //! create a new instance of the class
623 ComputeShaderChunkTransitPtr ComputeShaderChunkBase::create(void)
625 ComputeShaderChunkTransitPtr fc;
627 if(getClassType().getPrototype() != NULL)
629 FieldContainerTransitPtr tmpPtr =
630 getClassType().getPrototype()-> shallowCopy();
632 fc = dynamic_pointer_cast<ComputeShaderChunk>(tmpPtr);
635 return fc;
638 ComputeShaderChunk *ComputeShaderChunkBase::createEmptyLocal(BitVector bFlags)
640 ComputeShaderChunk *returnValue;
642 newPtr<ComputeShaderChunk>(returnValue, bFlags);
644 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
646 return returnValue;
649 //! create an empty new instance of the class, do not copy the prototype
650 ComputeShaderChunk *ComputeShaderChunkBase::createEmpty(void)
652 ComputeShaderChunk *returnValue;
654 newPtr<ComputeShaderChunk>(returnValue, Thread::getCurrentLocalFlags());
656 returnValue->_pFieldFlags->_bNamespaceMask &=
657 ~Thread::getCurrentLocalFlags();
659 return returnValue;
663 FieldContainerTransitPtr ComputeShaderChunkBase::shallowCopyLocal(
664 BitVector bFlags) const
666 ComputeShaderChunk *tmpPtr;
668 newPtr(tmpPtr, dynamic_cast<const ComputeShaderChunk *>(this), bFlags);
670 FieldContainerTransitPtr returnValue(tmpPtr);
672 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
674 return returnValue;
677 FieldContainerTransitPtr ComputeShaderChunkBase::shallowCopyDependent(
678 BitVector bFlags) const
680 ComputeShaderChunk *tmpPtr;
682 newPtr(tmpPtr, dynamic_cast<const ComputeShaderChunk *>(this), ~bFlags);
684 FieldContainerTransitPtr returnValue(tmpPtr);
686 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
688 return returnValue;
691 FieldContainerTransitPtr ComputeShaderChunkBase::shallowCopy(void) const
693 ComputeShaderChunk *tmpPtr;
695 newPtr(tmpPtr,
696 dynamic_cast<const ComputeShaderChunk *>(this),
697 Thread::getCurrentLocalFlags());
699 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
701 FieldContainerTransitPtr returnValue(tmpPtr);
703 return returnValue;
709 /*------------------------- constructors ----------------------------------*/
711 ComputeShaderChunkBase::ComputeShaderChunkBase(void) :
712 Inherited(),
713 _mfComputeShader (),
714 _sfComputeProgram (),
715 _sfVariables (this,
716 VariablesFieldId,
717 ShaderProgramVariables::ParentsFieldId),
718 _mfVariableLocations (),
719 _mfProceduralVariableLocations(),
720 _sfGLId (UInt32(0))
724 ComputeShaderChunkBase::ComputeShaderChunkBase(const ComputeShaderChunkBase &source) :
725 Inherited(source),
726 _mfComputeShader (),
727 _sfComputeProgram (source._sfComputeProgram ),
728 _sfVariables (this,
729 VariablesFieldId,
730 ShaderProgramVariables::ParentsFieldId),
731 _mfVariableLocations (source._mfVariableLocations ),
732 _mfProceduralVariableLocations(source._mfProceduralVariableLocations),
733 _sfGLId (source._sfGLId )
738 /*-------------------------- destructors ----------------------------------*/
740 ComputeShaderChunkBase::~ComputeShaderChunkBase(void)
744 /*-------------------------------------------------------------------------*/
745 /* Child linking */
747 bool ComputeShaderChunkBase::unlinkChild(
748 FieldContainer * const pChild,
749 UInt16 const childFieldId)
751 if(childFieldId == VariablesFieldId)
753 ShaderProgramVariables * pTypedChild =
754 dynamic_cast<ShaderProgramVariables *>(pChild);
756 if(pTypedChild != NULL)
758 if(_sfVariables.getValue() == pTypedChild)
760 editSField(VariablesFieldMask);
762 _sfVariables.setValue(NULL);
764 return true;
767 SWARNING << "Parent ([" << this
768 << "] id [" << this->getId()
769 << "] type [" << this->getType().getCName()
770 << "] childFieldId [" << childFieldId
771 << "]) - Child ([" << pChild
772 << "] id [" << pChild->getId()
773 << "] type [" << pChild->getType().getCName()
774 << "]): link inconsistent!"
775 << std::endl;
777 return false;
780 return false;
784 return Inherited::unlinkChild(pChild, childFieldId);
787 void ComputeShaderChunkBase::onCreate(const ComputeShaderChunk *source)
789 Inherited::onCreate(source);
791 if(source != NULL)
793 ComputeShaderChunk *pThis = static_cast<ComputeShaderChunk *>(this);
795 MFUnrecShaderProgramPtr::const_iterator ComputeShaderIt =
796 source->_mfComputeShader.begin();
797 MFUnrecShaderProgramPtr::const_iterator ComputeShaderEnd =
798 source->_mfComputeShader.end ();
800 while(ComputeShaderIt != ComputeShaderEnd)
802 pThis->addComputeShader(*ComputeShaderIt);
804 ++ComputeShaderIt;
807 pThis->setVariables(source->getVariables());
811 GetFieldHandlePtr ComputeShaderChunkBase::getHandleComputeShader (void) const
813 MFUnrecShaderProgramPtr::GetHandlePtr returnValue(
814 new MFUnrecShaderProgramPtr::GetHandle(
815 &_mfComputeShader,
816 this->getType().getFieldDesc(ComputeShaderFieldId),
817 const_cast<ComputeShaderChunkBase *>(this)));
819 return returnValue;
822 EditFieldHandlePtr ComputeShaderChunkBase::editHandleComputeShader (void)
824 MFUnrecShaderProgramPtr::EditHandlePtr returnValue(
825 new MFUnrecShaderProgramPtr::EditHandle(
826 &_mfComputeShader,
827 this->getType().getFieldDesc(ComputeShaderFieldId),
828 this));
830 returnValue->setAddMethod(
831 boost::bind(&ComputeShaderChunk::addComputeShader,
832 static_cast<ComputeShaderChunk *>(this), _1));
833 returnValue->setRemoveMethod(
834 boost::bind(&ComputeShaderChunk::subComputeShader,
835 static_cast<ComputeShaderChunk *>(this), _1));
836 returnValue->setRemoveObjMethod(
837 boost::bind(&ComputeShaderChunk::removeObjFromComputeShader,
838 static_cast<ComputeShaderChunk *>(this), _1));
839 returnValue->setClearMethod(
840 boost::bind(&ComputeShaderChunk::clearComputeShaders,
841 static_cast<ComputeShaderChunk *>(this)));
843 editMField(ComputeShaderFieldMask, _mfComputeShader);
845 return returnValue;
848 GetFieldHandlePtr ComputeShaderChunkBase::getHandleComputeProgram (void) const
850 SFString::GetHandlePtr returnValue(
851 new SFString::GetHandle(
852 &_sfComputeProgram,
853 this->getType().getFieldDesc(ComputeProgramFieldId),
854 const_cast<ComputeShaderChunkBase *>(this)));
856 return returnValue;
859 EditFieldHandlePtr ComputeShaderChunkBase::editHandleComputeProgram (void)
861 SFString::EditHandlePtr returnValue(
862 new SFString::EditHandle(
863 &_sfComputeProgram,
864 this->getType().getFieldDesc(ComputeProgramFieldId),
865 this));
868 editSField(ComputeProgramFieldMask);
870 return returnValue;
873 GetFieldHandlePtr ComputeShaderChunkBase::getHandleVariables (void) const
875 SFUnrecChildShaderProgramVariablesPtr::GetHandlePtr returnValue(
876 new SFUnrecChildShaderProgramVariablesPtr::GetHandle(
877 &_sfVariables,
878 this->getType().getFieldDesc(VariablesFieldId),
879 const_cast<ComputeShaderChunkBase *>(this)));
881 return returnValue;
884 EditFieldHandlePtr ComputeShaderChunkBase::editHandleVariables (void)
886 SFUnrecChildShaderProgramVariablesPtr::EditHandlePtr returnValue(
887 new SFUnrecChildShaderProgramVariablesPtr::EditHandle(
888 &_sfVariables,
889 this->getType().getFieldDesc(VariablesFieldId),
890 this));
892 returnValue->setSetMethod(
893 boost::bind(&ComputeShaderChunk::setVariables,
894 static_cast<ComputeShaderChunk *>(this), _1));
896 editSField(VariablesFieldMask);
898 return returnValue;
901 GetFieldHandlePtr ComputeShaderChunkBase::getHandleVariableLocations (void) const
903 MFInt32::GetHandlePtr returnValue(
904 new MFInt32::GetHandle(
905 &_mfVariableLocations,
906 this->getType().getFieldDesc(VariableLocationsFieldId),
907 const_cast<ComputeShaderChunkBase *>(this)));
909 return returnValue;
912 EditFieldHandlePtr ComputeShaderChunkBase::editHandleVariableLocations(void)
914 MFInt32::EditHandlePtr returnValue(
915 new MFInt32::EditHandle(
916 &_mfVariableLocations,
917 this->getType().getFieldDesc(VariableLocationsFieldId),
918 this));
921 editMField(VariableLocationsFieldMask, _mfVariableLocations);
923 return returnValue;
926 GetFieldHandlePtr ComputeShaderChunkBase::getHandleProceduralVariableLocations (void) const
928 MFInt32::GetHandlePtr returnValue(
929 new MFInt32::GetHandle(
930 &_mfProceduralVariableLocations,
931 this->getType().getFieldDesc(ProceduralVariableLocationsFieldId),
932 const_cast<ComputeShaderChunkBase *>(this)));
934 return returnValue;
937 EditFieldHandlePtr ComputeShaderChunkBase::editHandleProceduralVariableLocations(void)
939 MFInt32::EditHandlePtr returnValue(
940 new MFInt32::EditHandle(
941 &_mfProceduralVariableLocations,
942 this->getType().getFieldDesc(ProceduralVariableLocationsFieldId),
943 this));
946 editMField(ProceduralVariableLocationsFieldMask, _mfProceduralVariableLocations);
948 return returnValue;
951 GetFieldHandlePtr ComputeShaderChunkBase::getHandleGLId (void) const
953 SFUInt32::GetHandlePtr returnValue(
954 new SFUInt32::GetHandle(
955 &_sfGLId,
956 this->getType().getFieldDesc(GLIdFieldId),
957 const_cast<ComputeShaderChunkBase *>(this)));
959 return returnValue;
962 EditFieldHandlePtr ComputeShaderChunkBase::editHandleGLId (void)
964 SFUInt32::EditHandlePtr returnValue(
965 new SFUInt32::EditHandle(
966 &_sfGLId,
967 this->getType().getFieldDesc(GLIdFieldId),
968 this));
971 editSField(GLIdFieldMask);
973 return returnValue;
977 #ifdef OSG_MT_CPTR_ASPECT
978 void ComputeShaderChunkBase::execSyncV( FieldContainer &oFrom,
979 ConstFieldMaskArg whichField,
980 AspectOffsetStore &oOffsets,
981 ConstFieldMaskArg syncMode,
982 const UInt32 uiSyncInfo)
984 ComputeShaderChunk *pThis = static_cast<ComputeShaderChunk *>(this);
986 pThis->execSync(static_cast<ComputeShaderChunk *>(&oFrom),
987 whichField,
988 oOffsets,
989 syncMode,
990 uiSyncInfo);
992 #endif
995 #ifdef OSG_MT_CPTR_ASPECT
996 FieldContainer *ComputeShaderChunkBase::createAspectCopy(
997 const FieldContainer *pRefAspect) const
999 ComputeShaderChunk *returnValue;
1001 newAspectCopy(returnValue,
1002 dynamic_cast<const ComputeShaderChunk *>(pRefAspect),
1003 dynamic_cast<const ComputeShaderChunk *>(this));
1005 return returnValue;
1007 #endif
1009 void ComputeShaderChunkBase::resolveLinks(void)
1011 Inherited::resolveLinks();
1013 static_cast<ComputeShaderChunk *>(this)->clearComputeShaders();
1015 static_cast<ComputeShaderChunk *>(this)->setVariables(NULL);
1017 #ifdef OSG_MT_CPTR_ASPECT
1018 AspectOffsetStore oOffsets;
1020 _pAspectStore->fillOffsetArray(oOffsets, this);
1021 #endif
1023 #ifdef OSG_MT_CPTR_ASPECT
1024 _mfVariableLocations.terminateShare(Thread::getCurrentAspect(),
1025 oOffsets);
1026 #endif
1027 #ifdef OSG_MT_CPTR_ASPECT
1028 _mfProceduralVariableLocations.terminateShare(Thread::getCurrentAspect(),
1029 oOffsets);
1030 #endif
1034 OSG_END_NAMESPACE