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 ShaderStorageBufferObjRefChunk!
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"
66 #include "OSGShaderStorageBufferObjRefChunkBase.h"
67 #include "OSGShaderStorageBufferObjRefChunk.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::ShaderStorageBufferObjRefChunk
78 See \ref PageSystemShaderStorageBufferObjRefChunk for a description.
80 This chunk wraps the OpenGL shader storage buffer object extension (ARB_shader_storage_buffer_object).
81 Basically, it holds a raw memory buffer and a buffer object binding point. The raw memory
82 buffer is expected to be provided by the chunk user in either an OpenGL std140 or std430 compatible format.
83 Any shader, binding a shader storage block to the very same binding point, is expected to respect
84 the corresponding block layout.
86 This one differs from the ShaderStorageBufferObjStdLayoutChunk in that it does not manage the buffer by
87 itself , but just takes the GLid of that buffer. The idea is that the buffer of a GeoVectorPropertyBuffer can be
88 used if its layout is compatible to std140 or std430 format.
91 /***************************************************************************\
92 * Field Documentation *
93 \***************************************************************************/
95 /*! \var GLenum ShaderStorageBufferObjRefChunkBase::_sfOglGLId
96 The external OpenGL object id for this shader storage buffer object. This id is used as the GL object id iff the osgGLId is set to 0.
99 /*! \var GLenum ShaderStorageBufferObjRefChunkBase::_sfOsgGLId
100 The OpenSG GL object id for this shader storage buffer object. If this id is set the GL object id is determined by OpenSG. If this id equals 0, the oglGLId is used directly as the GL object id.
104 /***************************************************************************\
105 * FieldType/FieldTrait Instantiation *
106 \***************************************************************************/
108 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
109 PointerType FieldTraits
<ShaderStorageBufferObjRefChunk
*, nsOSG
>::_type(
110 "ShaderStorageBufferObjRefChunkPtr",
111 "ShaderStorageBufferObjBaseChunkPtr",
112 ShaderStorageBufferObjRefChunk::getClassType(),
116 OSG_FIELDTRAITS_GETTYPE_NS(ShaderStorageBufferObjRefChunk
*, nsOSG
)
118 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
119 ShaderStorageBufferObjRefChunk
*,
122 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
123 ShaderStorageBufferObjRefChunk
*,
126 /***************************************************************************\
127 * Field Description *
128 \***************************************************************************/
130 void ShaderStorageBufferObjRefChunkBase::classDescInserter(TypeObject
&oType
)
132 FieldDescriptionBase
*pDesc
= NULL
;
135 pDesc
= new SFGLenum::Description(
136 SFGLenum::getClassType(),
138 "The external OpenGL object id for this shader storage buffer object. This id is used as the GL object id iff the osgGLId is set to 0.\n",
139 OglGLIdFieldId
, OglGLIdFieldMask
,
141 (Field::FClusterLocal
),
142 static_cast<FieldEditMethodSig
>(&ShaderStorageBufferObjRefChunk::editHandleOglGLId
),
143 static_cast<FieldGetMethodSig
>(&ShaderStorageBufferObjRefChunk::getHandleOglGLId
));
145 oType
.addInitialDesc(pDesc
);
147 pDesc
= new SFGLenum::Description(
148 SFGLenum::getClassType(),
150 "The OpenSG GL object id for this shader storage buffer object. If this id is set the GL object id is determined by OpenSG. If this id equals 0, the oglGLId is used directly as the GL object id.\n",
151 OsgGLIdFieldId
, OsgGLIdFieldMask
,
153 (Field::FClusterLocal
),
154 static_cast<FieldEditMethodSig
>(&ShaderStorageBufferObjRefChunk::editHandleOsgGLId
),
155 static_cast<FieldGetMethodSig
>(&ShaderStorageBufferObjRefChunk::getHandleOsgGLId
));
157 oType
.addInitialDesc(pDesc
);
161 ShaderStorageBufferObjRefChunkBase::TypeObject
ShaderStorageBufferObjRefChunkBase::_type(
162 ShaderStorageBufferObjRefChunkBase::getClassname(),
163 Inherited::getClassname(),
166 reinterpret_cast<PrototypeCreateF
>(&ShaderStorageBufferObjRefChunkBase::createEmptyLocal
),
167 reinterpret_cast<InitContainerF
>(&ShaderStorageBufferObjRefChunk::initMethod
),
168 reinterpret_cast<ExitContainerF
>(&ShaderStorageBufferObjRefChunk::exitMethod
),
169 reinterpret_cast<InitalInsertDescFunc
>(
170 reinterpret_cast<void *>(&ShaderStorageBufferObjRefChunk::classDescInserter
)),
173 "<?xml version=\"1.0\"?>\n"
176 " name=\"ShaderStorageBufferObjRefChunk\"\n"
177 " parent=\"ShaderStorageBufferObjBaseChunk\"\n"
178 " library=\"System\"\n"
179 " pointerfieldtypes=\"both\"\n"
180 " structure=\"concrete\"\n"
181 " systemcomponent=\"true\"\n"
182 " parentsystemcomponent=\"true\"\n"
183 " decoratable=\"false\"\n"
184 " useLocalIncludes=\"false\"\n"
185 " docGroupBase=\"GrpSystemState\"\n"
187 " See \\ref PageSystemShaderStorageBufferObjRefChunk for a description.\n"
189 " This chunk wraps the OpenGL shader storage buffer object extension (ARB_shader_storage_buffer_object). \n"
190 " Basically, it holds a raw memory buffer and a buffer object binding point. The raw memory \n"
191 " buffer is expected to be provided by the chunk user in either an OpenGL std140 or std430 compatible format. \n"
192 " Any shader, binding a shader storage block to the very same binding point, is expected to respect \n"
193 " the corresponding block layout.\n"
195 " This one differs from the ShaderStorageBufferObjStdLayoutChunk in that it does not manage the buffer by\n"
196 " itself , but just takes the GLid of that buffer. The idea is that the buffer of a GeoVectorPropertyBuffer can be \n"
197 " used if its layout is compatible to std140 or std430 format.\n"
200 " name=\"oglGLId\"\n"
202 " cardinality=\"single\"\n"
203 " visibility=\"internal\"\n"
204 " access=\"public\"\n"
205 " defaultValue=\"0\"\n"
206 " fieldFlags=\"FClusterLocal\"\n"
208 " The external OpenGL object id for this shader storage buffer object. This id is used as the GL object id iff the osgGLId is set to 0.\n"
212 " name=\"osgGLId\"\n"
214 " cardinality=\"single\"\n"
215 " visibility=\"internal\"\n"
216 " access=\"public\"\n"
217 " defaultValue=\"0\"\n"
218 " fieldFlags=\"FClusterLocal\"\n"
220 " The OpenSG GL object id for this shader storage buffer object. If this id is set the GL object id is determined by OpenSG. If this id equals 0, the oglGLId is used directly as the GL object id.\n"
222 "</FieldContainer>\n",
223 "See \\ref PageSystemShaderStorageBufferObjRefChunk for a description.\n"
225 "This chunk wraps the OpenGL shader storage buffer object extension (ARB_shader_storage_buffer_object). \n"
226 "Basically, it holds a raw memory buffer and a buffer object binding point. The raw memory \n"
227 "buffer is expected to be provided by the chunk user in either an OpenGL std140 or std430 compatible format. \n"
228 "Any shader, binding a shader storage block to the very same binding point, is expected to respect \n"
229 "the corresponding block layout.\n"
231 "This one differs from the ShaderStorageBufferObjStdLayoutChunk in that it does not manage the buffer by\n"
232 "itself , but just takes the GLid of that buffer. The idea is that the buffer of a GeoVectorPropertyBuffer can be \n"
233 "used if its layout is compatible to std140 or std430 format.\n"
236 /*------------------------------ get -----------------------------------*/
238 FieldContainerType
&ShaderStorageBufferObjRefChunkBase::getType(void)
243 const FieldContainerType
&ShaderStorageBufferObjRefChunkBase::getType(void) const
248 UInt32
ShaderStorageBufferObjRefChunkBase::getContainerSize(void) const
250 return sizeof(ShaderStorageBufferObjRefChunk
);
253 /*------------------------- decorator get ------------------------------*/
256 SFGLenum
*ShaderStorageBufferObjRefChunkBase::editSFOglGLId(void)
258 editSField(OglGLIdFieldMask
);
263 const SFGLenum
*ShaderStorageBufferObjRefChunkBase::getSFOglGLId(void) const
269 SFGLenum
*ShaderStorageBufferObjRefChunkBase::editSFOsgGLId(void)
271 editSField(OsgGLIdFieldMask
);
276 const SFGLenum
*ShaderStorageBufferObjRefChunkBase::getSFOsgGLId(void) const
286 /*------------------------------ access -----------------------------------*/
288 SizeT
ShaderStorageBufferObjRefChunkBase::getBinSize(ConstFieldMaskArg whichField
)
290 SizeT returnValue
= Inherited::getBinSize(whichField
);
292 if(FieldBits::NoField
!= (OglGLIdFieldMask
& whichField
))
294 returnValue
+= _sfOglGLId
.getBinSize();
296 if(FieldBits::NoField
!= (OsgGLIdFieldMask
& whichField
))
298 returnValue
+= _sfOsgGLId
.getBinSize();
304 void ShaderStorageBufferObjRefChunkBase::copyToBin(BinaryDataHandler
&pMem
,
305 ConstFieldMaskArg whichField
)
307 Inherited::copyToBin(pMem
, whichField
);
309 if(FieldBits::NoField
!= (OglGLIdFieldMask
& whichField
))
311 _sfOglGLId
.copyToBin(pMem
);
313 if(FieldBits::NoField
!= (OsgGLIdFieldMask
& whichField
))
315 _sfOsgGLId
.copyToBin(pMem
);
319 void ShaderStorageBufferObjRefChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
320 ConstFieldMaskArg whichField
)
322 Inherited::copyFromBin(pMem
, whichField
);
324 if(FieldBits::NoField
!= (OglGLIdFieldMask
& whichField
))
326 editSField(OglGLIdFieldMask
);
327 _sfOglGLId
.copyFromBin(pMem
);
329 if(FieldBits::NoField
!= (OsgGLIdFieldMask
& whichField
))
331 editSField(OsgGLIdFieldMask
);
332 _sfOsgGLId
.copyFromBin(pMem
);
336 //! create a new instance of the class
337 ShaderStorageBufferObjRefChunkTransitPtr
ShaderStorageBufferObjRefChunkBase::createLocal(BitVector bFlags
)
339 ShaderStorageBufferObjRefChunkTransitPtr fc
;
341 if(getClassType().getPrototype() != NULL
)
343 FieldContainerTransitPtr tmpPtr
=
344 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
346 fc
= dynamic_pointer_cast
<ShaderStorageBufferObjRefChunk
>(tmpPtr
);
352 //! create a new instance of the class, copy the container flags
353 ShaderStorageBufferObjRefChunkTransitPtr
ShaderStorageBufferObjRefChunkBase::createDependent(BitVector bFlags
)
355 ShaderStorageBufferObjRefChunkTransitPtr fc
;
357 if(getClassType().getPrototype() != NULL
)
359 FieldContainerTransitPtr tmpPtr
=
360 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
362 fc
= dynamic_pointer_cast
<ShaderStorageBufferObjRefChunk
>(tmpPtr
);
368 //! create a new instance of the class
369 ShaderStorageBufferObjRefChunkTransitPtr
ShaderStorageBufferObjRefChunkBase::create(void)
371 ShaderStorageBufferObjRefChunkTransitPtr fc
;
373 if(getClassType().getPrototype() != NULL
)
375 FieldContainerTransitPtr tmpPtr
=
376 getClassType().getPrototype()-> shallowCopy();
378 fc
= dynamic_pointer_cast
<ShaderStorageBufferObjRefChunk
>(tmpPtr
);
384 ShaderStorageBufferObjRefChunk
*ShaderStorageBufferObjRefChunkBase::createEmptyLocal(BitVector bFlags
)
386 ShaderStorageBufferObjRefChunk
*returnValue
;
388 newPtr
<ShaderStorageBufferObjRefChunk
>(returnValue
, bFlags
);
390 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
395 //! create an empty new instance of the class, do not copy the prototype
396 ShaderStorageBufferObjRefChunk
*ShaderStorageBufferObjRefChunkBase::createEmpty(void)
398 ShaderStorageBufferObjRefChunk
*returnValue
;
400 newPtr
<ShaderStorageBufferObjRefChunk
>(returnValue
, Thread::getCurrentLocalFlags());
402 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
403 ~Thread::getCurrentLocalFlags();
409 FieldContainerTransitPtr
ShaderStorageBufferObjRefChunkBase::shallowCopyLocal(
410 BitVector bFlags
) const
412 ShaderStorageBufferObjRefChunk
*tmpPtr
;
414 newPtr(tmpPtr
, dynamic_cast<const ShaderStorageBufferObjRefChunk
*>(this), bFlags
);
416 FieldContainerTransitPtr
returnValue(tmpPtr
);
418 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
423 FieldContainerTransitPtr
ShaderStorageBufferObjRefChunkBase::shallowCopyDependent(
424 BitVector bFlags
) const
426 ShaderStorageBufferObjRefChunk
*tmpPtr
;
428 newPtr(tmpPtr
, dynamic_cast<const ShaderStorageBufferObjRefChunk
*>(this), ~bFlags
);
430 FieldContainerTransitPtr
returnValue(tmpPtr
);
432 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
437 FieldContainerTransitPtr
ShaderStorageBufferObjRefChunkBase::shallowCopy(void) const
439 ShaderStorageBufferObjRefChunk
*tmpPtr
;
442 dynamic_cast<const ShaderStorageBufferObjRefChunk
*>(this),
443 Thread::getCurrentLocalFlags());
445 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
447 FieldContainerTransitPtr
returnValue(tmpPtr
);
455 /*------------------------- constructors ----------------------------------*/
457 ShaderStorageBufferObjRefChunkBase::ShaderStorageBufferObjRefChunkBase(void) :
459 _sfOglGLId (GLenum(0)),
460 _sfOsgGLId (GLenum(0))
464 ShaderStorageBufferObjRefChunkBase::ShaderStorageBufferObjRefChunkBase(const ShaderStorageBufferObjRefChunkBase
&source
) :
466 _sfOglGLId (source
._sfOglGLId
),
467 _sfOsgGLId (source
._sfOsgGLId
)
472 /*-------------------------- destructors ----------------------------------*/
474 ShaderStorageBufferObjRefChunkBase::~ShaderStorageBufferObjRefChunkBase(void)
479 GetFieldHandlePtr
ShaderStorageBufferObjRefChunkBase::getHandleOglGLId (void) const
481 SFGLenum::GetHandlePtr
returnValue(
482 new SFGLenum::GetHandle(
484 this->getType().getFieldDesc(OglGLIdFieldId
),
485 const_cast<ShaderStorageBufferObjRefChunkBase
*>(this)));
490 EditFieldHandlePtr
ShaderStorageBufferObjRefChunkBase::editHandleOglGLId (void)
492 SFGLenum::EditHandlePtr
returnValue(
493 new SFGLenum::EditHandle(
495 this->getType().getFieldDesc(OglGLIdFieldId
),
499 editSField(OglGLIdFieldMask
);
504 GetFieldHandlePtr
ShaderStorageBufferObjRefChunkBase::getHandleOsgGLId (void) const
506 SFGLenum::GetHandlePtr
returnValue(
507 new SFGLenum::GetHandle(
509 this->getType().getFieldDesc(OsgGLIdFieldId
),
510 const_cast<ShaderStorageBufferObjRefChunkBase
*>(this)));
515 EditFieldHandlePtr
ShaderStorageBufferObjRefChunkBase::editHandleOsgGLId (void)
517 SFGLenum::EditHandlePtr
returnValue(
518 new SFGLenum::EditHandle(
520 this->getType().getFieldDesc(OsgGLIdFieldId
),
524 editSField(OsgGLIdFieldMask
);
530 #ifdef OSG_MT_CPTR_ASPECT
531 void ShaderStorageBufferObjRefChunkBase::execSyncV( FieldContainer
&oFrom
,
532 ConstFieldMaskArg whichField
,
533 AspectOffsetStore
&oOffsets
,
534 ConstFieldMaskArg syncMode
,
535 const UInt32 uiSyncInfo
)
537 ShaderStorageBufferObjRefChunk
*pThis
= static_cast<ShaderStorageBufferObjRefChunk
*>(this);
539 pThis
->execSync(static_cast<ShaderStorageBufferObjRefChunk
*>(&oFrom
),
548 #ifdef OSG_MT_CPTR_ASPECT
549 FieldContainer
*ShaderStorageBufferObjRefChunkBase::createAspectCopy(
550 const FieldContainer
*pRefAspect
) const
552 ShaderStorageBufferObjRefChunk
*returnValue
;
554 newAspectCopy(returnValue
,
555 dynamic_cast<const ShaderStorageBufferObjRefChunk
*>(pRefAspect
),
556 dynamic_cast<const ShaderStorageBufferObjRefChunk
*>(this));
562 void ShaderStorageBufferObjRefChunkBase::resolveLinks(void)
564 Inherited::resolveLinks();