1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
48 ** class ShaderExecutableChunk!
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
64 #include "OSGGL.h" // GeometryInputType default header
65 #include "OSGGL.h" // GeometryOutputType default header
67 #include "OSGShaderProgram.h" // VertexShader Class
68 #include "OSGShaderProgramVariables.h" // Variables Class
70 #include "OSGShaderExecutableChunkBase.h"
71 #include "OSGShaderExecutableChunk.h"
73 #include <boost/bind.hpp>
77 /***************************************************************************\
79 \***************************************************************************/
81 /*! \class OSG::ShaderExecutableChunk
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var ShaderProgram * ShaderExecutableChunkBase::_mfVertexShader
90 fragment program object
93 /*! \var ShaderProgram * ShaderExecutableChunkBase::_mfTessControlShader
94 fragment program object
97 /*! \var ShaderProgram * ShaderExecutableChunkBase::_mfTessEvaluationShader
98 fragment program object
101 /*! \var ShaderProgram * ShaderExecutableChunkBase::_mfGeometryShader
102 fragment program object
105 /*! \var ShaderProgram * ShaderExecutableChunkBase::_mfFragmentShader
106 fragment program object
109 /*! \var ShaderProgramVariables * ShaderExecutableChunkBase::_sfVariables
110 fragment program object
113 /*! \var Int32 ShaderExecutableChunkBase::_mfVariableLocations
114 fragment program object
117 /*! \var Int32 ShaderExecutableChunkBase::_mfProceduralVariableLocations
118 fragment program object
121 /*! \var UInt32 ShaderExecutableChunkBase::_sfGeometryVerticesOut
125 /*! \var GLenum ShaderExecutableChunkBase::_sfGeometryInputType
129 /*! \var GLenum ShaderExecutableChunkBase::_sfGeometryOutputType
133 /*! \var ShaderAttribute ShaderExecutableChunkBase::_mfAttributes
137 /*! \var UInt32 ShaderExecutableChunkBase::_sfGLId
141 /*! \var bool ShaderExecutableChunkBase::_sfPointSize
142 Flag to set whether the shader can change the point size.
146 /***************************************************************************\
147 * FieldType/FieldTrait Instantiation *
148 \***************************************************************************/
150 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
151 PointerType FieldTraits
<ShaderExecutableChunk
*, nsOSG
>::_type(
152 "ShaderExecutableChunkPtr",
154 ShaderExecutableChunk::getClassType(),
158 OSG_FIELDTRAITS_GETTYPE_NS(ShaderExecutableChunk
*, nsOSG
)
160 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
161 ShaderExecutableChunk
*,
164 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
165 ShaderExecutableChunk
*,
168 /***************************************************************************\
169 * Field Description *
170 \***************************************************************************/
172 void ShaderExecutableChunkBase::classDescInserter(TypeObject
&oType
)
174 FieldDescriptionBase
*pDesc
= NULL
;
177 pDesc
= new MFUncountedShaderProgramPtr::Description(
178 MFUncountedShaderProgramPtr::getClassType(),
180 "fragment program object\n",
181 VertexShaderFieldId
, VertexShaderFieldMask
,
183 (Field::MFDefaultFlags
| Field::FStdAccess
),
184 static_cast <FieldEditMethodSig
>(&ShaderExecutableChunk::invalidEditField
),
185 static_cast <FieldGetMethodSig
>(&ShaderExecutableChunk::invalidGetField
));
187 oType
.addInitialDesc(pDesc
);
189 pDesc
= new MFUncountedShaderProgramPtr::Description(
190 MFUncountedShaderProgramPtr::getClassType(),
192 "fragment program object\n",
193 TessControlShaderFieldId
, TessControlShaderFieldMask
,
195 (Field::MFDefaultFlags
| Field::FStdAccess
),
196 static_cast <FieldEditMethodSig
>(&ShaderExecutableChunk::invalidEditField
),
197 static_cast <FieldGetMethodSig
>(&ShaderExecutableChunk::invalidGetField
));
199 oType
.addInitialDesc(pDesc
);
201 pDesc
= new MFUncountedShaderProgramPtr::Description(
202 MFUncountedShaderProgramPtr::getClassType(),
203 "tessEvaluationShader",
204 "fragment program object\n",
205 TessEvaluationShaderFieldId
, TessEvaluationShaderFieldMask
,
207 (Field::MFDefaultFlags
| Field::FStdAccess
),
208 static_cast <FieldEditMethodSig
>(&ShaderExecutableChunk::invalidEditField
),
209 static_cast <FieldGetMethodSig
>(&ShaderExecutableChunk::invalidGetField
));
211 oType
.addInitialDesc(pDesc
);
213 pDesc
= new MFUncountedShaderProgramPtr::Description(
214 MFUncountedShaderProgramPtr::getClassType(),
216 "fragment program object\n",
217 GeometryShaderFieldId
, GeometryShaderFieldMask
,
219 (Field::MFDefaultFlags
| Field::FStdAccess
),
220 static_cast <FieldEditMethodSig
>(&ShaderExecutableChunk::invalidEditField
),
221 static_cast <FieldGetMethodSig
>(&ShaderExecutableChunk::invalidGetField
));
223 oType
.addInitialDesc(pDesc
);
225 pDesc
= new MFUncountedShaderProgramPtr::Description(
226 MFUncountedShaderProgramPtr::getClassType(),
228 "fragment program object\n",
229 FragmentShaderFieldId
, FragmentShaderFieldMask
,
231 (Field::MFDefaultFlags
| Field::FStdAccess
),
232 static_cast <FieldEditMethodSig
>(&ShaderExecutableChunk::invalidEditField
),
233 static_cast <FieldGetMethodSig
>(&ShaderExecutableChunk::invalidGetField
));
235 oType
.addInitialDesc(pDesc
);
237 pDesc
= new SFUnrecChildShaderProgramVariablesPtr::Description(
238 SFUnrecChildShaderProgramVariablesPtr::getClassType(),
240 "fragment program object\n",
241 VariablesFieldId
, VariablesFieldMask
,
243 (Field::SFDefaultFlags
| Field::FStdAccess
),
244 static_cast<FieldEditMethodSig
>(&ShaderExecutableChunk::editHandleVariables
),
245 static_cast<FieldGetMethodSig
>(&ShaderExecutableChunk::getHandleVariables
));
247 oType
.addInitialDesc(pDesc
);
249 pDesc
= new MFInt32::Description(
250 MFInt32::getClassType(),
252 "fragment program object\n",
253 VariableLocationsFieldId
, VariableLocationsFieldMask
,
255 (Field::MFDefaultFlags
| Field::FStdAccess
),
256 static_cast<FieldEditMethodSig
>(&ShaderExecutableChunk::editHandleVariableLocations
),
257 static_cast<FieldGetMethodSig
>(&ShaderExecutableChunk::getHandleVariableLocations
));
259 oType
.addInitialDesc(pDesc
);
261 pDesc
= new MFInt32::Description(
262 MFInt32::getClassType(),
263 "proceduralVariableLocations",
264 "fragment program object\n",
265 ProceduralVariableLocationsFieldId
, ProceduralVariableLocationsFieldMask
,
267 (Field::MFDefaultFlags
| Field::FStdAccess
),
268 static_cast<FieldEditMethodSig
>(&ShaderExecutableChunk::editHandleProceduralVariableLocations
),
269 static_cast<FieldGetMethodSig
>(&ShaderExecutableChunk::getHandleProceduralVariableLocations
));
271 oType
.addInitialDesc(pDesc
);
273 pDesc
= new SFUInt32::Description(
274 SFUInt32::getClassType(),
275 "geometryVerticesOut",
277 GeometryVerticesOutFieldId
, GeometryVerticesOutFieldMask
,
279 (Field::SFDefaultFlags
| Field::FStdAccess
),
280 static_cast<FieldEditMethodSig
>(&ShaderExecutableChunk::editHandleGeometryVerticesOut
),
281 static_cast<FieldGetMethodSig
>(&ShaderExecutableChunk::getHandleGeometryVerticesOut
));
283 oType
.addInitialDesc(pDesc
);
285 pDesc
= new SFGLenum::Description(
286 SFGLenum::getClassType(),
289 GeometryInputTypeFieldId
, GeometryInputTypeFieldMask
,
291 (Field::SFDefaultFlags
| Field::FStdAccess
),
292 static_cast<FieldEditMethodSig
>(&ShaderExecutableChunk::editHandleGeometryInputType
),
293 static_cast<FieldGetMethodSig
>(&ShaderExecutableChunk::getHandleGeometryInputType
));
295 oType
.addInitialDesc(pDesc
);
297 pDesc
= new SFGLenum::Description(
298 SFGLenum::getClassType(),
299 "geometryOutputType",
301 GeometryOutputTypeFieldId
, GeometryOutputTypeFieldMask
,
303 (Field::SFDefaultFlags
| Field::FStdAccess
),
304 static_cast<FieldEditMethodSig
>(&ShaderExecutableChunk::editHandleGeometryOutputType
),
305 static_cast<FieldGetMethodSig
>(&ShaderExecutableChunk::getHandleGeometryOutputType
));
307 oType
.addInitialDesc(pDesc
);
309 pDesc
= new MFShaderAttribute::Description(
310 MFShaderAttribute::getClassType(),
313 AttributesFieldId
, AttributesFieldMask
,
315 (Field::MFDefaultFlags
| Field::FStdAccess
),
316 static_cast<FieldEditMethodSig
>(&ShaderExecutableChunk::editHandleAttributes
),
317 static_cast<FieldGetMethodSig
>(&ShaderExecutableChunk::getHandleAttributes
));
319 oType
.addInitialDesc(pDesc
);
321 pDesc
= new SFUInt32::Description(
322 SFUInt32::getClassType(),
325 GLIdFieldId
, GLIdFieldMask
,
327 (Field::FClusterLocal
),
328 static_cast<FieldEditMethodSig
>(&ShaderExecutableChunk::editHandleGLId
),
329 static_cast<FieldGetMethodSig
>(&ShaderExecutableChunk::getHandleGLId
));
331 oType
.addInitialDesc(pDesc
);
333 pDesc
= new SFBool::Description(
334 SFBool::getClassType(),
336 "Flag to set whether the shader can change the point size.\n",
337 PointSizeFieldId
, PointSizeFieldMask
,
339 (Field::SFDefaultFlags
| Field::FStdAccess
),
340 static_cast<FieldEditMethodSig
>(&ShaderExecutableChunk::editHandlePointSize
),
341 static_cast<FieldGetMethodSig
>(&ShaderExecutableChunk::getHandlePointSize
));
343 oType
.addInitialDesc(pDesc
);
347 ShaderExecutableChunkBase::TypeObject
ShaderExecutableChunkBase::_type(
348 ShaderExecutableChunkBase::getClassname(),
349 Inherited::getClassname(),
352 reinterpret_cast<PrototypeCreateF
>(&ShaderExecutableChunkBase::createEmptyLocal
),
353 reinterpret_cast<InitContainerF
>(&ShaderExecutableChunk::initMethod
),
354 reinterpret_cast<ExitContainerF
>(&ShaderExecutableChunk::exitMethod
),
355 reinterpret_cast<InitalInsertDescFunc
>(
356 reinterpret_cast<void *>(&ShaderExecutableChunk::classDescInserter
)),
359 "<?xml version=\"1.0\"?>\n"
362 " name=\"ShaderExecutableChunk\"\n"
363 " parent=\"StateChunk\"\n"
364 " library=\"System\"\n"
365 " pointerfieldtypes=\"both\"\n"
366 " structure=\"concrete\"\n"
367 " systemcomponent=\"true\"\n"
368 " parentsystemcomponent=\"true\"\n"
369 " decoratable=\"false\"\n"
370 " useLocalIncludes=\"false\"\n"
371 " docGroupBase=\"GrpSystemShader\"\n"
374 " name=\"vertexShader\"\n"
375 " type=\"ShaderProgram\"\n"
376 " cardinality=\"multi\"\n"
377 " visibility=\"external\"\n"
379 " category=\"uncountedpointer\"\n"
382 " pushToFieldAs=\"addVertexShader\"\n"
383 " removeFromMFieldIndexAs=\"subVertexShader\"\n"
384 " clearFieldAs=\"clearVertexShaders\" -->\n"
386 "\tfragment program object\n"
389 " name=\"tessControlShader\"\n"
390 " type=\"ShaderProgram\"\n"
391 " cardinality=\"multi\"\n"
392 " visibility=\"external\"\n"
394 " category=\"uncountedpointer\"\n"
398 " pushToFieldAs=\"addGeometryShader\"\n"
399 " removeFromMFieldIndexAs=\"subGeometryShader\"\n"
400 " clearFieldAs=\"clearGeometryShaders\" -->\n"
401 "\tfragment program object\n"
404 " name=\"tessEvaluationShader\"\n"
405 " type=\"ShaderProgram\"\n"
406 " cardinality=\"multi\"\n"
407 " visibility=\"external\"\n"
409 " category=\"uncountedpointer\"\n"
413 " pushToFieldAs=\"addGeometryShader\"\n"
414 " removeFromMFieldIndexAs=\"subGeometryShader\"\n"
415 " clearFieldAs=\"clearGeometryShaders\" -->\n"
416 "\tfragment program object\n"
419 " name=\"geometryShader\"\n"
420 " type=\"ShaderProgram\"\n"
421 " cardinality=\"multi\"\n"
422 " visibility=\"external\"\n"
424 " category=\"uncountedpointer\"\n"
428 " pushToFieldAs=\"addGeometryShader\"\n"
429 " removeFromMFieldIndexAs=\"subGeometryShader\"\n"
430 " clearFieldAs=\"clearGeometryShaders\" -->\n"
431 "\tfragment program object\n"
434 " name=\"fragmentShader\"\n"
435 " type=\"ShaderProgram\"\n"
436 " cardinality=\"multi\"\n"
437 " visibility=\"external\"\n"
439 " category=\"uncountedpointer\"\n"
443 " pushToFieldAs=\"addFragmentShader\"\n"
444 " removeFromMFieldIndexAs=\"subFragmentShader\"\n"
445 " clearFieldAs=\"clearFragmentShaders\" -->\n"
446 "\tfragment program object\n"
450 " name=\"variables\"\n"
451 " type=\"ShaderProgramVariables\"\n"
452 " cardinality=\"single\"\n"
453 " visibility=\"external\"\n"
454 " access=\"public\"\n"
455 " category=\"childpointer\"\n"
456 " childParentType=\"FieldContainer\"\n"
457 " linkParentField=\"Parents\"\n"
459 "\tfragment program object\n"
462 " name=\"variableLocations\"\n"
464 " cardinality=\"multi\"\n"
465 " visibility=\"internal\"\n"
466 " access=\"protected\"\n"
468 "\tfragment program object\n"
471 " name=\"proceduralVariableLocations\"\n"
473 " cardinality=\"multi\"\n"
474 " visibility=\"internal\"\n"
475 " access=\"protected\"\n"
477 "\tfragment program object\n"
481 " name=\"geometryVerticesOut\"\n"
483 " cardinality=\"single\"\n"
484 " visibility=\"external\"\n"
485 " defaultValue=\"0\"\n"
489 " name=\"geometryInputType\"\n"
491 " cardinality=\"single\"\n"
492 " visibility=\"external\"\n"
493 " defaultValue=\"GL_TRIANGLES\"\n"
494 " defaultHeader=\""OSGGL.h"\"\n"
498 " name=\"geometryOutputType\"\n"
500 " cardinality=\"single\"\n"
501 " visibility=\"external\"\n"
502 " defaultValue=\"GL_TRIANGLE_STRIP\"\n"
503 " defaultHeader=\""OSGGL.h"\"\n"
508 " name=\"attributes\"\n"
509 " type=\"ShaderAttribute\"\n"
510 " cardinality=\"multi\"\n"
511 " visibility=\"external\"\n"
512 " access=\"public\"\n"
519 " cardinality=\"single\"\n"
520 " visibility=\"internal\"\n"
521 " access=\"public\"\n"
522 " defaultValue=\"0\"\n"
523 " fieldFlags=\"FClusterLocal\"\n"
528 " name=\"pointSize\"\n"
530 " cardinality=\"single\"\n"
531 " visibility=\"external\"\n"
532 " defaultValue=\"false\"\n"
533 " access=\"public\"\n"
535 "\tFlag to set whether the shader can change the point size.\n"
538 "</FieldContainer>\n",
542 /*------------------------------ get -----------------------------------*/
544 FieldContainerType
&ShaderExecutableChunkBase::getType(void)
549 const FieldContainerType
&ShaderExecutableChunkBase::getType(void) const
554 UInt32
ShaderExecutableChunkBase::getContainerSize(void) const
556 return sizeof(ShaderExecutableChunk
);
559 /*------------------------- decorator get ------------------------------*/
567 //! Get the ShaderExecutableChunk::_sfVariables field.
568 const SFUnrecChildShaderProgramVariablesPtr
*ShaderExecutableChunkBase::getSFVariables(void) const
570 return &_sfVariables
;
573 SFUnrecChildShaderProgramVariablesPtr
*ShaderExecutableChunkBase::editSFVariables (void)
575 editSField(VariablesFieldMask
);
577 return &_sfVariables
;
580 //! Get the value of the ShaderExecutableChunk::_sfVariables field.
581 ShaderProgramVariables
* ShaderExecutableChunkBase::getVariables(void) const
583 return _sfVariables
.getValue();
586 //! Set the value of the ShaderExecutableChunk::_sfVariables field.
587 void ShaderExecutableChunkBase::setVariables(ShaderProgramVariables
* const value
)
589 editSField(VariablesFieldMask
);
591 _sfVariables
.setValue(value
);
595 MFInt32
*ShaderExecutableChunkBase::editMFVariableLocations(void)
597 editMField(VariableLocationsFieldMask
, _mfVariableLocations
);
599 return &_mfVariableLocations
;
602 const MFInt32
*ShaderExecutableChunkBase::getMFVariableLocations(void) const
604 return &_mfVariableLocations
;
608 MFInt32
*ShaderExecutableChunkBase::editMFProceduralVariableLocations(void)
610 editMField(ProceduralVariableLocationsFieldMask
, _mfProceduralVariableLocations
);
612 return &_mfProceduralVariableLocations
;
615 const MFInt32
*ShaderExecutableChunkBase::getMFProceduralVariableLocations(void) const
617 return &_mfProceduralVariableLocations
;
621 SFUInt32
*ShaderExecutableChunkBase::editSFGeometryVerticesOut(void)
623 editSField(GeometryVerticesOutFieldMask
);
625 return &_sfGeometryVerticesOut
;
628 const SFUInt32
*ShaderExecutableChunkBase::getSFGeometryVerticesOut(void) const
630 return &_sfGeometryVerticesOut
;
634 SFGLenum
*ShaderExecutableChunkBase::editSFGeometryInputType(void)
636 editSField(GeometryInputTypeFieldMask
);
638 return &_sfGeometryInputType
;
641 const SFGLenum
*ShaderExecutableChunkBase::getSFGeometryInputType(void) const
643 return &_sfGeometryInputType
;
647 SFGLenum
*ShaderExecutableChunkBase::editSFGeometryOutputType(void)
649 editSField(GeometryOutputTypeFieldMask
);
651 return &_sfGeometryOutputType
;
654 const SFGLenum
*ShaderExecutableChunkBase::getSFGeometryOutputType(void) const
656 return &_sfGeometryOutputType
;
660 MFShaderAttribute
*ShaderExecutableChunkBase::editMFAttributes(void)
662 editMField(AttributesFieldMask
, _mfAttributes
);
664 return &_mfAttributes
;
667 const MFShaderAttribute
*ShaderExecutableChunkBase::getMFAttributes(void) const
669 return &_mfAttributes
;
673 SFUInt32
*ShaderExecutableChunkBase::editSFGLId(void)
675 editSField(GLIdFieldMask
);
680 const SFUInt32
*ShaderExecutableChunkBase::getSFGLId(void) const
686 SFBool
*ShaderExecutableChunkBase::editSFPointSize(void)
688 editSField(PointSizeFieldMask
);
690 return &_sfPointSize
;
693 const SFBool
*ShaderExecutableChunkBase::getSFPointSize(void) const
695 return &_sfPointSize
;
703 /*------------------------------ access -----------------------------------*/
705 SizeT
ShaderExecutableChunkBase::getBinSize(ConstFieldMaskArg whichField
)
707 SizeT returnValue
= Inherited::getBinSize(whichField
);
709 if(FieldBits::NoField
!= (VertexShaderFieldMask
& whichField
))
711 returnValue
+= _mfVertexShader
.getBinSize();
713 if(FieldBits::NoField
!= (TessControlShaderFieldMask
& whichField
))
715 returnValue
+= _mfTessControlShader
.getBinSize();
717 if(FieldBits::NoField
!= (TessEvaluationShaderFieldMask
& whichField
))
719 returnValue
+= _mfTessEvaluationShader
.getBinSize();
721 if(FieldBits::NoField
!= (GeometryShaderFieldMask
& whichField
))
723 returnValue
+= _mfGeometryShader
.getBinSize();
725 if(FieldBits::NoField
!= (FragmentShaderFieldMask
& whichField
))
727 returnValue
+= _mfFragmentShader
.getBinSize();
729 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
731 returnValue
+= _sfVariables
.getBinSize();
733 if(FieldBits::NoField
!= (VariableLocationsFieldMask
& whichField
))
735 returnValue
+= _mfVariableLocations
.getBinSize();
737 if(FieldBits::NoField
!= (ProceduralVariableLocationsFieldMask
& whichField
))
739 returnValue
+= _mfProceduralVariableLocations
.getBinSize();
741 if(FieldBits::NoField
!= (GeometryVerticesOutFieldMask
& whichField
))
743 returnValue
+= _sfGeometryVerticesOut
.getBinSize();
745 if(FieldBits::NoField
!= (GeometryInputTypeFieldMask
& whichField
))
747 returnValue
+= _sfGeometryInputType
.getBinSize();
749 if(FieldBits::NoField
!= (GeometryOutputTypeFieldMask
& whichField
))
751 returnValue
+= _sfGeometryOutputType
.getBinSize();
753 if(FieldBits::NoField
!= (AttributesFieldMask
& whichField
))
755 returnValue
+= _mfAttributes
.getBinSize();
757 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
759 returnValue
+= _sfGLId
.getBinSize();
761 if(FieldBits::NoField
!= (PointSizeFieldMask
& whichField
))
763 returnValue
+= _sfPointSize
.getBinSize();
769 void ShaderExecutableChunkBase::copyToBin(BinaryDataHandler
&pMem
,
770 ConstFieldMaskArg whichField
)
772 Inherited::copyToBin(pMem
, whichField
);
774 if(FieldBits::NoField
!= (VertexShaderFieldMask
& whichField
))
776 _mfVertexShader
.copyToBin(pMem
);
778 if(FieldBits::NoField
!= (TessControlShaderFieldMask
& whichField
))
780 _mfTessControlShader
.copyToBin(pMem
);
782 if(FieldBits::NoField
!= (TessEvaluationShaderFieldMask
& whichField
))
784 _mfTessEvaluationShader
.copyToBin(pMem
);
786 if(FieldBits::NoField
!= (GeometryShaderFieldMask
& whichField
))
788 _mfGeometryShader
.copyToBin(pMem
);
790 if(FieldBits::NoField
!= (FragmentShaderFieldMask
& whichField
))
792 _mfFragmentShader
.copyToBin(pMem
);
794 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
796 _sfVariables
.copyToBin(pMem
);
798 if(FieldBits::NoField
!= (VariableLocationsFieldMask
& whichField
))
800 _mfVariableLocations
.copyToBin(pMem
);
802 if(FieldBits::NoField
!= (ProceduralVariableLocationsFieldMask
& whichField
))
804 _mfProceduralVariableLocations
.copyToBin(pMem
);
806 if(FieldBits::NoField
!= (GeometryVerticesOutFieldMask
& whichField
))
808 _sfGeometryVerticesOut
.copyToBin(pMem
);
810 if(FieldBits::NoField
!= (GeometryInputTypeFieldMask
& whichField
))
812 _sfGeometryInputType
.copyToBin(pMem
);
814 if(FieldBits::NoField
!= (GeometryOutputTypeFieldMask
& whichField
))
816 _sfGeometryOutputType
.copyToBin(pMem
);
818 if(FieldBits::NoField
!= (AttributesFieldMask
& whichField
))
820 _mfAttributes
.copyToBin(pMem
);
822 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
824 _sfGLId
.copyToBin(pMem
);
826 if(FieldBits::NoField
!= (PointSizeFieldMask
& whichField
))
828 _sfPointSize
.copyToBin(pMem
);
832 void ShaderExecutableChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
833 ConstFieldMaskArg whichField
)
835 Inherited::copyFromBin(pMem
, whichField
);
837 if(FieldBits::NoField
!= (VertexShaderFieldMask
& whichField
))
839 editMField(VertexShaderFieldMask
, _mfVertexShader
);
840 _mfVertexShader
.copyFromBin(pMem
);
842 if(FieldBits::NoField
!= (TessControlShaderFieldMask
& whichField
))
844 editMField(TessControlShaderFieldMask
, _mfTessControlShader
);
845 _mfTessControlShader
.copyFromBin(pMem
);
847 if(FieldBits::NoField
!= (TessEvaluationShaderFieldMask
& whichField
))
849 editMField(TessEvaluationShaderFieldMask
, _mfTessEvaluationShader
);
850 _mfTessEvaluationShader
.copyFromBin(pMem
);
852 if(FieldBits::NoField
!= (GeometryShaderFieldMask
& whichField
))
854 editMField(GeometryShaderFieldMask
, _mfGeometryShader
);
855 _mfGeometryShader
.copyFromBin(pMem
);
857 if(FieldBits::NoField
!= (FragmentShaderFieldMask
& whichField
))
859 editMField(FragmentShaderFieldMask
, _mfFragmentShader
);
860 _mfFragmentShader
.copyFromBin(pMem
);
862 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
864 editSField(VariablesFieldMask
);
865 _sfVariables
.copyFromBin(pMem
);
867 if(FieldBits::NoField
!= (VariableLocationsFieldMask
& whichField
))
869 editMField(VariableLocationsFieldMask
, _mfVariableLocations
);
870 _mfVariableLocations
.copyFromBin(pMem
);
872 if(FieldBits::NoField
!= (ProceduralVariableLocationsFieldMask
& whichField
))
874 editMField(ProceduralVariableLocationsFieldMask
, _mfProceduralVariableLocations
);
875 _mfProceduralVariableLocations
.copyFromBin(pMem
);
877 if(FieldBits::NoField
!= (GeometryVerticesOutFieldMask
& whichField
))
879 editSField(GeometryVerticesOutFieldMask
);
880 _sfGeometryVerticesOut
.copyFromBin(pMem
);
882 if(FieldBits::NoField
!= (GeometryInputTypeFieldMask
& whichField
))
884 editSField(GeometryInputTypeFieldMask
);
885 _sfGeometryInputType
.copyFromBin(pMem
);
887 if(FieldBits::NoField
!= (GeometryOutputTypeFieldMask
& whichField
))
889 editSField(GeometryOutputTypeFieldMask
);
890 _sfGeometryOutputType
.copyFromBin(pMem
);
892 if(FieldBits::NoField
!= (AttributesFieldMask
& whichField
))
894 editMField(AttributesFieldMask
, _mfAttributes
);
895 _mfAttributes
.copyFromBin(pMem
);
897 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
899 editSField(GLIdFieldMask
);
900 _sfGLId
.copyFromBin(pMem
);
902 if(FieldBits::NoField
!= (PointSizeFieldMask
& whichField
))
904 editSField(PointSizeFieldMask
);
905 _sfPointSize
.copyFromBin(pMem
);
909 //! create a new instance of the class
910 ShaderExecutableChunkTransitPtr
ShaderExecutableChunkBase::createLocal(BitVector bFlags
)
912 ShaderExecutableChunkTransitPtr fc
;
914 if(getClassType().getPrototype() != NULL
)
916 FieldContainerTransitPtr tmpPtr
=
917 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
919 fc
= dynamic_pointer_cast
<ShaderExecutableChunk
>(tmpPtr
);
925 //! create a new instance of the class, copy the container flags
926 ShaderExecutableChunkTransitPtr
ShaderExecutableChunkBase::createDependent(BitVector bFlags
)
928 ShaderExecutableChunkTransitPtr fc
;
930 if(getClassType().getPrototype() != NULL
)
932 FieldContainerTransitPtr tmpPtr
=
933 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
935 fc
= dynamic_pointer_cast
<ShaderExecutableChunk
>(tmpPtr
);
941 //! create a new instance of the class
942 ShaderExecutableChunkTransitPtr
ShaderExecutableChunkBase::create(void)
944 ShaderExecutableChunkTransitPtr fc
;
946 if(getClassType().getPrototype() != NULL
)
948 FieldContainerTransitPtr tmpPtr
=
949 getClassType().getPrototype()-> shallowCopy();
951 fc
= dynamic_pointer_cast
<ShaderExecutableChunk
>(tmpPtr
);
957 ShaderExecutableChunk
*ShaderExecutableChunkBase::createEmptyLocal(BitVector bFlags
)
959 ShaderExecutableChunk
*returnValue
;
961 newPtr
<ShaderExecutableChunk
>(returnValue
, bFlags
);
963 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
968 //! create an empty new instance of the class, do not copy the prototype
969 ShaderExecutableChunk
*ShaderExecutableChunkBase::createEmpty(void)
971 ShaderExecutableChunk
*returnValue
;
973 newPtr
<ShaderExecutableChunk
>(returnValue
, Thread::getCurrentLocalFlags());
975 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
976 ~Thread::getCurrentLocalFlags();
982 FieldContainerTransitPtr
ShaderExecutableChunkBase::shallowCopyLocal(
983 BitVector bFlags
) const
985 ShaderExecutableChunk
*tmpPtr
;
987 newPtr(tmpPtr
, dynamic_cast<const ShaderExecutableChunk
*>(this), bFlags
);
989 FieldContainerTransitPtr
returnValue(tmpPtr
);
991 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
996 FieldContainerTransitPtr
ShaderExecutableChunkBase::shallowCopyDependent(
997 BitVector bFlags
) const
999 ShaderExecutableChunk
*tmpPtr
;
1001 newPtr(tmpPtr
, dynamic_cast<const ShaderExecutableChunk
*>(this), ~bFlags
);
1003 FieldContainerTransitPtr
returnValue(tmpPtr
);
1005 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
1010 FieldContainerTransitPtr
ShaderExecutableChunkBase::shallowCopy(void) const
1012 ShaderExecutableChunk
*tmpPtr
;
1015 dynamic_cast<const ShaderExecutableChunk
*>(this),
1016 Thread::getCurrentLocalFlags());
1018 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
1020 FieldContainerTransitPtr
returnValue(tmpPtr
);
1028 /*------------------------- constructors ----------------------------------*/
1030 ShaderExecutableChunkBase::ShaderExecutableChunkBase(void) :
1033 _mfTessControlShader (),
1034 _mfTessEvaluationShader (),
1035 _mfGeometryShader (),
1036 _mfFragmentShader (),
1039 ShaderProgramVariables::ParentsFieldId
),
1040 _mfVariableLocations (),
1041 _mfProceduralVariableLocations(),
1042 _sfGeometryVerticesOut (UInt32(0)),
1043 _sfGeometryInputType (GLenum(GL_TRIANGLES
)),
1044 _sfGeometryOutputType (GLenum(GL_TRIANGLE_STRIP
)),
1046 _sfGLId (UInt32(0)),
1047 _sfPointSize (bool(false))
1051 ShaderExecutableChunkBase::ShaderExecutableChunkBase(const ShaderExecutableChunkBase
&source
) :
1054 _mfTessControlShader (),
1055 _mfTessEvaluationShader (),
1056 _mfGeometryShader (),
1057 _mfFragmentShader (),
1060 ShaderProgramVariables::ParentsFieldId
),
1061 _mfVariableLocations (source
._mfVariableLocations
),
1062 _mfProceduralVariableLocations(source
._mfProceduralVariableLocations
),
1063 _sfGeometryVerticesOut (source
._sfGeometryVerticesOut
),
1064 _sfGeometryInputType (source
._sfGeometryInputType
),
1065 _sfGeometryOutputType (source
._sfGeometryOutputType
),
1066 _mfAttributes (source
._mfAttributes
),
1067 _sfGLId (source
._sfGLId
),
1068 _sfPointSize (source
._sfPointSize
)
1073 /*-------------------------- destructors ----------------------------------*/
1075 ShaderExecutableChunkBase::~ShaderExecutableChunkBase(void)
1079 /*-------------------------------------------------------------------------*/
1082 bool ShaderExecutableChunkBase::unlinkChild(
1083 FieldContainer
* const pChild
,
1084 UInt16
const childFieldId
)
1086 if(childFieldId
== VariablesFieldId
)
1088 ShaderProgramVariables
* pTypedChild
=
1089 dynamic_cast<ShaderProgramVariables
*>(pChild
);
1091 if(pTypedChild
!= NULL
)
1093 if(_sfVariables
.getValue() == pTypedChild
)
1095 editSField(VariablesFieldMask
);
1097 _sfVariables
.setValue(NULL
);
1102 SWARNING
<< "Parent ([" << this
1103 << "] id [" << this->getId()
1104 << "] type [" << this->getType().getCName()
1105 << "] childFieldId [" << childFieldId
1106 << "]) - Child ([" << pChild
1107 << "] id [" << pChild
->getId()
1108 << "] type [" << pChild
->getType().getCName()
1109 << "]): link inconsistent!"
1119 return Inherited::unlinkChild(pChild
, childFieldId
);
1122 void ShaderExecutableChunkBase::onCreate(const ShaderExecutableChunk
*source
)
1124 Inherited::onCreate(source
);
1128 ShaderExecutableChunk
*pThis
= static_cast<ShaderExecutableChunk
*>(this);
1130 pThis
->setVariables(source
->getVariables());
1134 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleVertexShader (void) const
1136 MFUncountedShaderProgramPtr::GetHandlePtr returnValue
;
1141 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleVertexShader (void)
1143 EditFieldHandlePtr returnValue
;
1148 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleTessControlShader (void) const
1150 MFUncountedShaderProgramPtr::GetHandlePtr returnValue
;
1155 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleTessControlShader(void)
1157 EditFieldHandlePtr returnValue
;
1162 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleTessEvaluationShader (void) const
1164 MFUncountedShaderProgramPtr::GetHandlePtr returnValue
;
1169 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleTessEvaluationShader(void)
1171 EditFieldHandlePtr returnValue
;
1176 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleGeometryShader (void) const
1178 MFUncountedShaderProgramPtr::GetHandlePtr returnValue
;
1183 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleGeometryShader (void)
1185 EditFieldHandlePtr returnValue
;
1190 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleFragmentShader (void) const
1192 MFUncountedShaderProgramPtr::GetHandlePtr returnValue
;
1197 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleFragmentShader (void)
1199 EditFieldHandlePtr returnValue
;
1204 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleVariables (void) const
1206 SFUnrecChildShaderProgramVariablesPtr::GetHandlePtr
returnValue(
1207 new SFUnrecChildShaderProgramVariablesPtr::GetHandle(
1209 this->getType().getFieldDesc(VariablesFieldId
),
1210 const_cast<ShaderExecutableChunkBase
*>(this)));
1215 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleVariables (void)
1217 SFUnrecChildShaderProgramVariablesPtr::EditHandlePtr
returnValue(
1218 new SFUnrecChildShaderProgramVariablesPtr::EditHandle(
1220 this->getType().getFieldDesc(VariablesFieldId
),
1223 returnValue
->setSetMethod(
1224 boost::bind(&ShaderExecutableChunk::setVariables
,
1225 static_cast<ShaderExecutableChunk
*>(this), _1
));
1227 editSField(VariablesFieldMask
);
1232 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleVariableLocations (void) const
1234 MFInt32::GetHandlePtr
returnValue(
1235 new MFInt32::GetHandle(
1236 &_mfVariableLocations
,
1237 this->getType().getFieldDesc(VariableLocationsFieldId
),
1238 const_cast<ShaderExecutableChunkBase
*>(this)));
1243 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleVariableLocations(void)
1245 MFInt32::EditHandlePtr
returnValue(
1246 new MFInt32::EditHandle(
1247 &_mfVariableLocations
,
1248 this->getType().getFieldDesc(VariableLocationsFieldId
),
1252 editMField(VariableLocationsFieldMask
, _mfVariableLocations
);
1257 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleProceduralVariableLocations (void) const
1259 MFInt32::GetHandlePtr
returnValue(
1260 new MFInt32::GetHandle(
1261 &_mfProceduralVariableLocations
,
1262 this->getType().getFieldDesc(ProceduralVariableLocationsFieldId
),
1263 const_cast<ShaderExecutableChunkBase
*>(this)));
1268 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleProceduralVariableLocations(void)
1270 MFInt32::EditHandlePtr
returnValue(
1271 new MFInt32::EditHandle(
1272 &_mfProceduralVariableLocations
,
1273 this->getType().getFieldDesc(ProceduralVariableLocationsFieldId
),
1277 editMField(ProceduralVariableLocationsFieldMask
, _mfProceduralVariableLocations
);
1282 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleGeometryVerticesOut (void) const
1284 SFUInt32::GetHandlePtr
returnValue(
1285 new SFUInt32::GetHandle(
1286 &_sfGeometryVerticesOut
,
1287 this->getType().getFieldDesc(GeometryVerticesOutFieldId
),
1288 const_cast<ShaderExecutableChunkBase
*>(this)));
1293 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleGeometryVerticesOut(void)
1295 SFUInt32::EditHandlePtr
returnValue(
1296 new SFUInt32::EditHandle(
1297 &_sfGeometryVerticesOut
,
1298 this->getType().getFieldDesc(GeometryVerticesOutFieldId
),
1302 editSField(GeometryVerticesOutFieldMask
);
1307 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleGeometryInputType (void) const
1309 SFGLenum::GetHandlePtr
returnValue(
1310 new SFGLenum::GetHandle(
1311 &_sfGeometryInputType
,
1312 this->getType().getFieldDesc(GeometryInputTypeFieldId
),
1313 const_cast<ShaderExecutableChunkBase
*>(this)));
1318 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleGeometryInputType(void)
1320 SFGLenum::EditHandlePtr
returnValue(
1321 new SFGLenum::EditHandle(
1322 &_sfGeometryInputType
,
1323 this->getType().getFieldDesc(GeometryInputTypeFieldId
),
1327 editSField(GeometryInputTypeFieldMask
);
1332 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleGeometryOutputType (void) const
1334 SFGLenum::GetHandlePtr
returnValue(
1335 new SFGLenum::GetHandle(
1336 &_sfGeometryOutputType
,
1337 this->getType().getFieldDesc(GeometryOutputTypeFieldId
),
1338 const_cast<ShaderExecutableChunkBase
*>(this)));
1343 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleGeometryOutputType(void)
1345 SFGLenum::EditHandlePtr
returnValue(
1346 new SFGLenum::EditHandle(
1347 &_sfGeometryOutputType
,
1348 this->getType().getFieldDesc(GeometryOutputTypeFieldId
),
1352 editSField(GeometryOutputTypeFieldMask
);
1357 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleAttributes (void) const
1359 MFShaderAttribute::GetHandlePtr
returnValue(
1360 new MFShaderAttribute::GetHandle(
1362 this->getType().getFieldDesc(AttributesFieldId
),
1363 const_cast<ShaderExecutableChunkBase
*>(this)));
1368 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleAttributes (void)
1370 MFShaderAttribute::EditHandlePtr
returnValue(
1371 new MFShaderAttribute::EditHandle(
1373 this->getType().getFieldDesc(AttributesFieldId
),
1377 editMField(AttributesFieldMask
, _mfAttributes
);
1382 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandleGLId (void) const
1384 SFUInt32::GetHandlePtr
returnValue(
1385 new SFUInt32::GetHandle(
1387 this->getType().getFieldDesc(GLIdFieldId
),
1388 const_cast<ShaderExecutableChunkBase
*>(this)));
1393 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandleGLId (void)
1395 SFUInt32::EditHandlePtr
returnValue(
1396 new SFUInt32::EditHandle(
1398 this->getType().getFieldDesc(GLIdFieldId
),
1402 editSField(GLIdFieldMask
);
1407 GetFieldHandlePtr
ShaderExecutableChunkBase::getHandlePointSize (void) const
1409 SFBool::GetHandlePtr
returnValue(
1410 new SFBool::GetHandle(
1412 this->getType().getFieldDesc(PointSizeFieldId
),
1413 const_cast<ShaderExecutableChunkBase
*>(this)));
1418 EditFieldHandlePtr
ShaderExecutableChunkBase::editHandlePointSize (void)
1420 SFBool::EditHandlePtr
returnValue(
1421 new SFBool::EditHandle(
1423 this->getType().getFieldDesc(PointSizeFieldId
),
1427 editSField(PointSizeFieldMask
);
1433 #ifdef OSG_MT_CPTR_ASPECT
1434 void ShaderExecutableChunkBase::execSyncV( FieldContainer
&oFrom
,
1435 ConstFieldMaskArg whichField
,
1436 AspectOffsetStore
&oOffsets
,
1437 ConstFieldMaskArg syncMode
,
1438 const UInt32 uiSyncInfo
)
1440 ShaderExecutableChunk
*pThis
= static_cast<ShaderExecutableChunk
*>(this);
1442 pThis
->execSync(static_cast<ShaderExecutableChunk
*>(&oFrom
),
1451 #ifdef OSG_MT_CPTR_ASPECT
1452 FieldContainer
*ShaderExecutableChunkBase::createAspectCopy(
1453 const FieldContainer
*pRefAspect
) const
1455 ShaderExecutableChunk
*returnValue
;
1457 newAspectCopy(returnValue
,
1458 dynamic_cast<const ShaderExecutableChunk
*>(pRefAspect
),
1459 dynamic_cast<const ShaderExecutableChunk
*>(this));
1465 void ShaderExecutableChunkBase::resolveLinks(void)
1467 Inherited::resolveLinks();
1469 static_cast<ShaderExecutableChunk
*>(this)->setVariables(NULL
);
1471 #ifdef OSG_MT_CPTR_ASPECT
1472 AspectOffsetStore oOffsets
;
1474 _pAspectStore
->fillOffsetArray(oOffsets
, this);
1477 #ifdef OSG_MT_CPTR_ASPECT
1478 _mfVariableLocations
.terminateShare(Thread::getCurrentAspect(),
1481 #ifdef OSG_MT_CPTR_ASPECT
1482 _mfProceduralVariableLocations
.terminateShare(Thread::getCurrentAspect(),
1485 #ifdef OSG_MT_CPTR_ASPECT
1486 _mfAttributes
.terminateShare(Thread::getCurrentAspect(),