changed: gcc8 base update
[opensg.git] / Source / System / State / Base / OSGShaderStorageBufferObjChunk.cpp
blobda18797b92ed3185062d3fbf9265b4f13fffba8d
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 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include <boost/bind.hpp>
47 #include <boost/algorithm/string.hpp>
48 #include <boost/range/iterator_range_core.hpp>
49 #include <boost/unordered_map.hpp>
51 #include "OSGConfig.h"
53 #include "OSGGL.h"
54 #include "OSGGLU.h"
55 #include "OSGGLEXT.h"
56 #include "OSGWindow.h"
58 #include "OSGGLFuncProtos.h"
60 #include "OSGDrawEnv.h"
62 #include "OSGShaderStorageBufferObjChunk.h"
64 OSG_BEGIN_NAMESPACE
67 struct bracket_expr_finder
69 bracket_expr_finder(int& index) : idx(index) {}
71 template<typename ForwardIteratorT>
72 boost::iterator_range<ForwardIteratorT> operator()(
73 ForwardIteratorT iter,
74 ForwardIteratorT end )
76 ForwardIteratorT Begin = iter;
77 ForwardIteratorT End = iter;
79 for (; iter != end; ++iter)
81 if (*iter == '[')
82 Begin = iter;
83 else if (*iter == ']')
85 End = ++iter;
86 break;
90 if (Begin != End)
92 ForwardIteratorT r1 = Begin;
93 ForwardIteratorT r2 = End;
94 std::string str(++r1, --r2);
95 idx = atoi(str.c_str());
98 return boost::make_iterator_range(Begin, End);
101 int& idx;
104 // Documentation for this class is emitted in the
105 // OSGShaderStorageBufferObjChunkBase.cpp file.
106 // To modify it, please change the .fcd file (OSGShaderStorageBufferObjChunk.fcd) and
107 // regenerate the base file.
109 /***************************************************************************\
110 * Class variables *
111 \***************************************************************************/
113 typedef OSG::Window Win;
115 UInt32 ShaderStorageBufferObjChunk::_extVertexBufferObject = Win::invalidExtensionID;
116 UInt32 ShaderStorageBufferObjChunk::_extUniformBufferObject = Win::invalidExtensionID;
117 UInt32 ShaderStorageBufferObjChunk::_extProgramInterfaceQuery = Win::invalidExtensionID;
118 UInt32 ShaderStorageBufferObjChunk::_extShaderStorageBufferObject = Win::invalidExtensionID;
120 UInt32 ShaderStorageBufferObjChunk::_funcBindBuffer = Win::invalidFunctionID;
121 UInt32 ShaderStorageBufferObjChunk::_funcMapBuffer = Win::invalidFunctionID;
122 UInt32 ShaderStorageBufferObjChunk::_funcUnmapBuffer = Win::invalidFunctionID;
123 UInt32 ShaderStorageBufferObjChunk::_funcBufferData = Win::invalidFunctionID;
124 UInt32 ShaderStorageBufferObjChunk::_funcBufferSubData = Win::invalidFunctionID;
125 UInt32 ShaderStorageBufferObjChunk::_funcGenBuffers = Win::invalidFunctionID;
126 UInt32 ShaderStorageBufferObjChunk::_funcDeleteBuffers = Win::invalidFunctionID;
127 UInt32 ShaderStorageBufferObjChunk::_funcGetBufferParameteriv = Win::invalidFunctionID;
129 UInt32 ShaderStorageBufferObjChunk::_funcBindBufferBase = Win::invalidFunctionID;
131 UInt32 ShaderStorageBufferObjChunk::_funcGetProgramResourceIndex = Win::invalidFunctionID;
132 UInt32 ShaderStorageBufferObjChunk::_funcGetProgramResourceiv = Win::invalidFunctionID;
133 UInt32 ShaderStorageBufferObjChunk::_funcGetProgramResourceName = Win::invalidFunctionID;
135 /***************************************************************************\
136 * Class methods *
137 \***************************************************************************/
139 void ShaderStorageBufferObjChunk::initMethod(InitPhase ePhase)
141 Inherited::initMethod(ePhase);
143 if(ePhase == TypeObject::SystemPost)
145 _extVertexBufferObject=
146 Window::registerExtension("GL_ARB_vertex_buffer_object");
148 _funcBindBuffer = Window::registerFunction(
149 OSG_DLSYM_UNDERSCORE"glBindBufferARB",
150 _extVertexBufferObject);
152 _funcMapBuffer = Window::registerFunction(
153 OSG_DLSYM_UNDERSCORE"glMapBufferARB",
154 _extVertexBufferObject);
156 _funcUnmapBuffer = Window::registerFunction(
157 OSG_DLSYM_UNDERSCORE"glUnmapBufferARB",
158 _extVertexBufferObject);
160 _funcBufferData = Window::registerFunction(
161 OSG_DLSYM_UNDERSCORE"glBufferDataARB",
162 _extVertexBufferObject);
164 _funcBufferSubData = Window::registerFunction(
165 OSG_DLSYM_UNDERSCORE"glBufferSubDataARB",
166 _extVertexBufferObject);
168 _funcGenBuffers = Window::registerFunction(
169 OSG_DLSYM_UNDERSCORE"glGenBuffersARB",
170 _extVertexBufferObject);
172 _funcDeleteBuffers = Window::registerFunction(
173 OSG_DLSYM_UNDERSCORE"glDeleteBuffersARB",
174 _extVertexBufferObject);
176 _funcGetBufferParameteriv = Window::registerFunction(
177 OSG_DLSYM_UNDERSCORE"glGetBufferParameterivARB",
178 _extVertexBufferObject);
181 _extShaderStorageBufferObject =
182 Window::registerExtension("GL_ARB_shader_storage_buffer_object" );
184 _funcBindBufferBase = Window::registerFunction(
185 OSG_DLSYM_UNDERSCORE"glBindBufferBase",
186 _extShaderStorageBufferObject);
189 _extProgramInterfaceQuery =
190 Window::registerExtension("GL_ARB_program_interface_query" );
192 _funcGetProgramResourceIndex = Window::registerFunction(
193 OSG_DLSYM_UNDERSCORE"glGetProgramResourceIndex",
194 _extProgramInterfaceQuery);
196 _funcGetProgramResourceiv = Window::registerFunction(
197 OSG_DLSYM_UNDERSCORE"glGetProgramResourceiv",
198 _extProgramInterfaceQuery);
200 _funcGetProgramResourceName = Window::registerFunction(
201 OSG_DLSYM_UNDERSCORE"glGetProgramResourceName",
202 _extProgramInterfaceQuery);
205 _extShaderStorageBufferObject =
206 Window::registerExtension("GL_ARB_shader_storage_buffer_object" );
211 /***************************************************************************\
212 * Instance methods *
213 \***************************************************************************/
215 /*-------------------------------------------------------------------------*\
216 - private -
217 \*-------------------------------------------------------------------------*/
219 /*----------------------- constructors & destructors ----------------------*/
221 ShaderStorageBufferObjChunk::ShaderStorageBufferObjChunk(void) :
222 Inherited()
226 ShaderStorageBufferObjChunk::ShaderStorageBufferObjChunk(const ShaderStorageBufferObjChunk &source) :
227 Inherited(source)
231 ShaderStorageBufferObjChunk::~ShaderStorageBufferObjChunk(void)
235 /*----------------------------- class specific ----------------------------*/
237 void ShaderStorageBufferObjChunk::changed(ConstFieldMaskArg whichField,
238 UInt32 origin,
239 BitVector details)
241 GLenum id = _sfGLId.getValue();
243 if((whichField & ( UsageFieldMask |
244 BlockNameFieldMask |
245 FundamentalTypesFieldMask |
246 MainTypesFieldMask |
247 CardinalityFieldMask |
248 IndexFieldMask |
249 NamesFieldMask |
250 NameToIndexFieldMask |
251 FloatValuesFieldMask |
252 DoubleValuesFieldMask |
253 IntValuesFieldMask |
254 UIntValuesFieldMask |
255 BoolValuesFieldMask )) != 0)
257 Window::refreshGLObject(id);
260 Inherited::changed(whichField, origin, details);
263 /*----------------------------- onCreate --------------------------------*/
265 void ShaderStorageBufferObjChunk::onCreate(const ShaderStorageBufferObjChunk *source)
267 Inherited::onCreate(source);
269 if(GlobalSystemState == Startup)
270 return;
272 setGLId(Window::registerGLObject(
273 boost::bind(&ShaderStorageBufferObjChunk::handleGL,
274 ShaderStorageBufferObjChunkMTUncountedPtr(this),
275 _1, _2, _3, _4),
276 &ShaderStorageBufferObjChunk::handleDestroyGL));
279 void ShaderStorageBufferObjChunk::onCreateAspect(
280 const ShaderStorageBufferObjChunk *createAspect,
281 const ShaderStorageBufferObjChunk *source )
283 Inherited::onCreateAspect(createAspect, source);
286 void ShaderStorageBufferObjChunk::onDestroy(UInt32 uiContainerId)
288 if(getGLId() > 0)
289 Window::destroyGLObject(getGLId(), 1);
291 Inherited::onDestroy(uiContainerId);
294 /*------------------------------ Output ----------------------------------*/
296 void ShaderStorageBufferObjChunk::dump( UInt32 uiIndent,
297 const BitVector bvFlags) const
299 Inherited::dump(uiIndent, bvFlags);
301 if((bvFlags & UsageFieldMask) != 0)
303 indentLog(uiIndent, PLOG);
304 PLOG << "usage " << _sfUsage.getValue() << "\n";
306 if((bvFlags & BlockNameFieldMask) != 0)
308 indentLog(uiIndent, PLOG);
309 PLOG << "block name " << _sfBlockName.getValue() << "\n";
313 /*------------------------------ GL -----------------------------------------*/
315 /*! GL object handler */
316 UInt32 ShaderStorageBufferObjChunk::handleGL(DrawEnv *pEnv,
317 UInt32 osgid,
318 Window::GLObjectStatusE mode,
319 UInt64 uiOptions)
321 Window *pWin = pEnv->getWindow();
322 GLuint id = pWin->getGLObjectId(osgid);
324 bool hasVBO = pWin->hasExtOrVersion(_extVertexBufferObject, 0x0105, 0x0200);
325 if(!hasVBO)
327 FWARNING(
328 ("ShaderStorageBufferObjStdLayoutChunk::handleGL: vertex buffer objects not "
329 "supported for this window!\n"));
330 return 0;
333 bool hasUBO = pWin->hasExtOrVersion(_extUniformBufferObject, 0x0301);
334 if(!hasUBO)
336 FWARNING(
337 ("ShaderStorageBufferObjStdLayoutChunk::handleGL: uniform buffer objects not "
338 "supported for this window!\n"));
339 return 0;
342 bool hasSSBO = pWin->hasExtOrVersion(_extShaderStorageBufferObject, 0x0403);
343 if(!hasSSBO)
345 FWARNING(
346 ("ShaderStorageBufferObjStdLayoutChunk::handleGL: GL_ARB_uniform_buffer_object not "
347 "supported for this window!\n"));
348 return 0;
351 bool hasPIQ = pWin->hasExtOrVersion(_extProgramInterfaceQuery, 0x0402);
352 if(!hasPIQ)
354 FWARNING(
355 ("ShaderStorageBufferObjStdLayoutChunk::handleGL: GL_ARB_program_interface_query not "
356 "supported for this window!\n"));
357 return 0;
360 switch (mode)
362 case Window::initialize:
364 OSGGETGLFUNCBYID_GL3_ES( glGenBuffers,
365 osgGlGenBuffers,
366 _funcGenBuffers,
367 pWin);
369 OSGGETGLFUNCBYID_GL3_ES( glBindBuffer,
370 osgGlBindBuffer,
371 _funcBindBuffer,
372 pWin);
374 OSGGETGLFUNCBYID_GL3_ES( glBufferData,
375 osgGlBufferData,
376 _funcBufferData,
377 pWin);
379 OSGGETGLFUNCBYID_GL3_ES( glBindBufferBase,
380 osgGlBindBufferBase,
381 _funcBindBufferBase,
382 pWin);
384 osgGlGenBuffers(1, &id);
385 pWin->setGLObjectId(osgid, id);
387 std::vector<GLubyte> buffer = createBuffer(pEnv);
389 std::size_t sz = buffer.size();
390 if (sz > 0)
392 osgGlBindBuffer (GL_SHADER_STORAGE_BUFFER, id);
393 osgGlBufferData (GL_SHADER_STORAGE_BUFFER, sz, &buffer[0], _sfUsage.getValue());
394 osgGlBindBuffer (GL_SHADER_STORAGE_BUFFER, 0);
397 glErr("ShaderStorageBufferObjChunk::handleGL initialize");
399 break;
401 case Window::needrefresh:
403 OSGGETGLFUNCBYID_GL3_ES( glBindBuffer,
404 osgGlBindBuffer,
405 _funcBindBuffer,
406 pWin);
408 OSGGETGLFUNCBYID_GL3_ES( glMapBuffer,
409 osgGlMapBuffer,
410 _funcMapBuffer,
411 pWin);
413 OSGGETGLFUNCBYID_GL3_ES( glUnmapBuffer,
414 osgGlUnmapBuffer,
415 _funcUnmapBuffer,
416 pWin);
418 osgGlBindBuffer(GL_SHADER_STORAGE_BUFFER, id);
419 GLubyte* pBuffer = static_cast<GLubyte*>(
420 osgGlMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY_ARB));
422 std::vector<GLubyte> buffer = createBuffer(pEnv);
423 if (!buffer.empty())
424 memcpy(pBuffer, &buffer[0], sizeof(GLubyte) * buffer.size());
426 osgGlUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
427 osgGlBindBuffer (GL_SHADER_STORAGE_BUFFER, 0);
429 glErr("ShaderStorageBufferObjChunk::handleGL needrefresh");
431 break;
432 default:
434 SWARNING << "ShaderStorageBufferObjChunk(" << this << "::handleGL: Illegal mode: "
435 << mode << " for id " << id << std::endl;
439 return 0;
442 /*! GL object handler
443 destroy it
445 void ShaderStorageBufferObjChunk::handleDestroyGL(DrawEnv *pEnv,
446 UInt32 osgid,
447 Window::GLObjectStatusE mode)
449 Window *pWin = pEnv->getWindow();
450 GLuint id = pWin->getGLObjectId(osgid);
452 if(mode == Window::destroy)
454 OSGGETGLFUNCBYID_GL3_ES( glDeleteBuffers,
455 osgGlDeleteBuffers,
456 _funcDeleteBuffers,
457 pWin);
459 osgGlDeleteBuffers(1, &id);
460 pWin->setGLObjectId(osgid, 0);
462 glErr("ShaderStorageBufferObjChunk::handleDestroyGL");
464 else if(mode == Window::finaldestroy)
466 //SWARNING << "Last buffer user destroyed" << std::endl;
468 else
470 SWARNING << "ShaderStorageBufferObjChunk::handleDestroyGL: Illegal mode: "
471 << mode << " for id " << id << std::endl;
476 /*------------------------------ tools --------------------------------------*/
478 void ShaderStorageBufferObjChunk::validate(DrawEnv *pEnv)
480 pEnv->getWindow()->validateGLObject(this->getGLId(),
481 pEnv );
484 Int32 ShaderStorageBufferObjChunk::getOpenGLId(DrawEnv *pEnv)
486 return pEnv->getWindow()->getGLObjectId(this->getGLId());
489 /*------------------------------ activate -----------------------------------*/
491 void ShaderStorageBufferObjChunk::activate(DrawEnv *pEnv, UInt32 idx)
493 Window *pWin = pEnv->getWindow();
495 pWin->validateGLObject(getGLId(), pEnv);
497 GLuint id = pWin->getGLObjectId(getGLId());
499 OSGGETGLFUNCBYID_GL3_ES( glBindBuffer,
500 osgGlBindBuffer,
501 _funcBindBuffer,
502 pWin);
504 OSGGETGLFUNCBYID_GL3_ES( glBindBufferBase,
505 osgGlBindBufferBase,
506 _funcBindBufferBase,
507 pWin);
509 osgGlBindBuffer (GL_SHADER_STORAGE_BUFFER, id);
510 osgGlBindBufferBase(GL_SHADER_STORAGE_BUFFER, idx, id);
512 glErr("ShaderStorageBufferObjChunk::activate");
515 /*------------------------------ deactivate ---------------------------------*/
517 void ShaderStorageBufferObjChunk::deactivate(DrawEnv *pEnv, UInt32 idx)
519 Window *pWin = pEnv->getWindow();
521 OSGGETGLFUNCBYID_GL3_ES( glBindBuffer,
522 osgGlBindBuffer,
523 _funcBindBuffer,
524 pWin);
526 OSGGETGLFUNCBYID_GL3_ES( glBindBufferBase,
527 osgGlBindBufferBase,
528 _funcBindBufferBase,
529 pWin);
531 osgGlBindBufferBase(GL_SHADER_STORAGE_BUFFER, idx, 0);
532 osgGlBindBuffer (GL_SHADER_STORAGE_BUFFER, 0);
534 glErr("ShaderStorageBufferObjChunk::deactivate");
537 /*------------------------------ changeFrom ---------------------------------*/
539 void ShaderStorageBufferObjChunk::changeFrom(DrawEnv *pEnv,
540 StateChunk *old,
541 UInt32 idx )
543 // change from me to me?
544 // this assumes I haven't changed in the meantime.
545 // is that a valid assumption?
546 if (old == this)
547 return;
549 old->deactivate(pEnv, idx);
550 this->activate(pEnv, idx);
553 /*------------------------------ buffer -------------------------------------*/
555 std::vector<GLubyte> ShaderStorageBufferObjChunk::createBuffer(DrawEnv *pEnv)
557 Window *pWin = pEnv->getWindow();
559 OSGGETGLFUNCBYID_GL3_ES( glGetProgramResourceIndex,
560 osgGlGetProgramResourceIndex,
561 _funcGetProgramResourceIndex,
562 pWin);
564 OSGGETGLFUNCBYID_GL3_ES( glGetProgramResourceiv,
565 osgGlGetProgramResourceiv,
566 _funcGetProgramResourceiv,
567 pWin);
569 OSGGETGLFUNCBYID_GL3_ES( glGetProgramResourceName,
570 osgGlGetProgramResourceName,
571 _funcGetProgramResourceName,
572 pWin);
574 std::vector<GLubyte> buffer;
576 GLuint index = osgGlGetProgramResourceIndex(pEnv->getActiveShader(), GL_SHADER_STORAGE_BLOCK, _sfBlockName.getValue().c_str());
577 if (index == GL_INVALID_INDEX) {
578 SWARNING << "ShaderStorageBufferObjChunk::createBuffer: Invalid block index" << std::endl;
579 return buffer;
582 const GLenum block_prop_query[2] = { GL_BUFFER_DATA_SIZE, GL_NUM_ACTIVE_VARIABLES };
583 std::vector<GLint> block_prop_query_result(2);
585 osgGlGetProgramResourceiv(pEnv->getActiveShader(), GL_SHADER_STORAGE_BLOCK, index, 2, block_prop_query, 2, NULL, &block_prop_query_result[0]);
587 GLint size = block_prop_query_result[0];
588 GLint num = block_prop_query_result[1];
590 std::vector<GLuint> indices(num);
591 const GLenum indices_query[1] = { GL_ACTIVE_VARIABLES };
593 osgGlGetProgramResourceiv(pEnv->getActiveShader(), GL_SHADER_STORAGE_BLOCK, index, 1, indices_query, num, NULL, reinterpret_cast<GLint*>(&indices[0]));
595 for (std::size_t i = 0; i < indices.size(); ++i)
597 if (indices[i] == GL_INVALID_INDEX)
599 SWARNING << "ShaderStorageBufferObjChunk::createBuffer: Invalid index of active variables in block" << std::endl;
600 return buffer;
604 std::vector<GLint> offsets(num),
605 array_sizes(num),
606 array_strides(num),
607 matrix_strides(num),
608 top_level_array_sizes(num),
609 top_level_array_strides(num),
610 name_lengths(num)
613 std::vector<std::string> names(num);
614 std::vector<GLchar> nameData(1024);
616 typedef boost::unordered_map<std::string, std::size_t> MapNameToIdxT;
617 MapNameToIdxT mapNameToIdx;
619 for(int idx = 0; idx < num; ++idx)
621 const GLint num_queries = 7;
622 const GLenum query[num_queries] = {
623 //GL_TYPE,
624 GL_OFFSET,
625 GL_ARRAY_SIZE,
626 GL_ARRAY_STRIDE,
627 GL_MATRIX_STRIDE,
628 //GL_IS_ROW_MAJOR,
629 GL_TOP_LEVEL_ARRAY_SIZE,
630 GL_TOP_LEVEL_ARRAY_STRIDE,
631 GL_NAME_LENGTH
633 GLint query_result[num_queries];
634 osgGlGetProgramResourceiv(pEnv->getActiveShader(), GL_BUFFER_VARIABLE, indices[idx], num_queries, query, num_queries, NULL, query_result);
636 offsets[idx] = query_result[0];
637 array_sizes[idx] = query_result[1];
638 array_strides[idx] = query_result[2];
639 matrix_strides[idx] = query_result[3];
640 top_level_array_sizes[idx] = query_result[4];
641 top_level_array_strides[idx] = query_result[5];
642 name_lengths[idx] = query_result[6];
644 nameData.resize(name_lengths[idx]);
646 osgGlGetProgramResourceName(pEnv->getActiveShader(), GL_BUFFER_VARIABLE, indices[idx], GLsizei(nameData.size()), NULL, &nameData[0]);
648 names[idx] = std::string(&nameData[0], nameData.size()-1);
650 mapNameToIdx.insert(MapNameToIdxT::value_type(names[idx], idx));
653 buffer.resize(size);
655 for (GLint i = 0; i < GLint(_mfIndex.size()); ++i)
657 UInt32 idx = _mfIndex [i];
658 FundamentalTypes fType = static_cast<FundamentalTypes>(_mfFundamentalTypes[i]);
659 MainType mType = static_cast<MainType> (_mfMainTypes [i]);
660 UInt32 card = _mfCardinality [i];
661 std::string name = _mfNames [i];
663 UInt8 columns = 0;
664 UInt8 rows = 0;
666 switch (mType) {
667 case SIMPLE_T:
668 columns = 1;
669 rows = 1;
670 break;
671 case VEC2_T:
672 columns = 1;
673 rows = 2;
674 break;
675 case VEC3_T:
676 columns = 1;
677 rows = 3;
678 break;
679 case VEC4_T:
680 columns = 1;
681 rows = 4;
682 break;
683 case MAT2_T:
684 columns = 2;
685 rows = 2;
686 break;
687 case MAT3_T:
688 columns = 3;
689 rows = 3;
690 break;
691 case MAT4_T:
692 columns = 4;
693 rows = 4;
694 break;
695 case MAT2X3_T:
696 columns = 2;
697 rows = 3;
698 break;
699 case MAT2X4_T:
700 columns = 2;
701 rows = 4;
702 break;
703 case MAT3X4_T:
704 columns = 3;
705 rows = 4;
706 break;
707 case MAT3X2_T:
708 columns = 3;
709 rows = 2;
710 break;
711 case MAT4X2_T:
712 columns = 4;
713 rows = 2;
714 break;
715 case MAT4X3_T:
716 columns = 4;
717 rows = 3;
718 break;
721 std::size_t resource_idx = 0;
723 int top_level_idx = 0;
726 // Resource name lookup
728 MapNameToIdxT::const_iterator iter = mapNameToIdx.find(name);
729 if (iter == mapNameToIdx.end())
731 if (card > 1)
733 iter = mapNameToIdx.find(name += "[0]");
737 if (iter == mapNameToIdx.end())
739 bracket_expr_finder finder(top_level_idx);
740 boost::algorithm::find_format(name, finder, boost::algorithm::const_formatter("[0]"));
742 iter = mapNameToIdx.find(name);
744 if (iter == mapNameToIdx.end())
746 if (card > 1)
748 iter = mapNameToIdx.find(name += "[0]");
753 if (iter != mapNameToIdx.end())
755 resource_idx = iter->second;
757 else
759 SWARNING << "ShaderStorageBufferObjChunk::createBuffer: Invalid resource name found" << std::endl;
762 GLint top_level_array_size = top_level_array_sizes[resource_idx];
763 GLint top_level_array_stride = top_level_array_strides[resource_idx];
765 OSG_ASSERT(top_level_idx < top_level_array_size);
767 GLint top_level_array_offset = top_level_idx * top_level_array_stride;
769 GLint offset = top_level_array_offset + offsets[resource_idx];
770 // GLint array_size = array_sizes[resource_idx];
771 GLint array_stride = array_strides[resource_idx];
772 GLint matrix_stride = matrix_strides[resource_idx];
774 for (UInt32 j = 0; j < card; ++j)
776 GLint offset_ = offset;
777 for (UInt8 k = 0; k < columns; ++k)
779 for (UInt8 l = 0; l < rows; ++l)
781 UInt32 idx_ = idx + j * rows * columns + k * rows + l;
782 switch (fType) {
783 case FLOAT_T:
784 reinterpret_cast<Real32*>(&buffer[0] + offset)[l] = _mfFloatValues[idx_];
785 break;
786 case DOUBLE_T:
787 reinterpret_cast<Real64*>(&buffer[0] + offset)[l] = _mfDoubleValues[idx_];
788 break;
789 case INT_T:
790 reinterpret_cast<Int32*>(&buffer[0] + offset)[l] = _mfIntValues[idx_];
791 break;
792 case UINT_T:
793 reinterpret_cast<UInt32*>(&buffer[0] + offset)[l] = _mfUIntValues[idx_];
794 break;
795 case BOOL_T:
796 reinterpret_cast<Int32*>(&buffer[0] + offset)[l] = _mfBoolValues[idx_];
797 break;
800 offset += matrix_stride;
802 offset = offset_ + array_stride;
806 return buffer;
809 /*------------------------------ add-interface ------------------------------*/
811 UInt32 ShaderStorageBufferObjChunk::addFloat(const std::string& name, UInt32 cardinality)
813 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
814 editMField(MainTypesFieldMask, _mfMainTypes);
815 editMField(CardinalityFieldMask, _mfCardinality);
816 editMField(IndexFieldMask, _mfIndex);
817 editMField(NamesFieldMask, _mfNames);
818 editMField(FloatValuesFieldMask, _mfFloatValues);
819 editSField(NameToIndexFieldMask);
821 _mfFundamentalTypes.push_back(FLOAT_T);
822 _mfMainTypes .push_back(SIMPLE_T);
823 _mfCardinality .push_back(cardinality);
824 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
825 _mfNames .push_back(name);
827 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
829 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
831 for (UInt32 i = 0; i < cardinality; ++i)
832 _mfFloatValues.push_back(0.f);
834 OSG_ASSERT(invariantOnStorageSize());
836 return index;
839 UInt32 ShaderStorageBufferObjChunk::addDouble(const std::string& name, UInt32 cardinality)
841 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
842 editMField(MainTypesFieldMask, _mfMainTypes);
843 editMField(CardinalityFieldMask, _mfCardinality);
844 editMField(IndexFieldMask, _mfIndex);
845 editMField(NamesFieldMask, _mfNames);
846 editMField(DoubleValuesFieldMask, _mfDoubleValues);
847 editSField(NameToIndexFieldMask);
849 _mfFundamentalTypes.push_back(DOUBLE_T);
850 _mfMainTypes .push_back(SIMPLE_T);
851 _mfCardinality .push_back(cardinality);
852 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
853 _mfNames .push_back(name);
855 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
857 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
859 for (UInt32 i = 0; i < cardinality; ++i)
860 _mfDoubleValues.push_back(0.);
862 OSG_ASSERT(invariantOnStorageSize());
864 return index;
867 UInt32 ShaderStorageBufferObjChunk::addInt(const std::string& name, UInt32 cardinality)
869 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
870 editMField(MainTypesFieldMask, _mfMainTypes);
871 editMField(CardinalityFieldMask, _mfCardinality);
872 editMField(IndexFieldMask, _mfIndex);
873 editMField(NamesFieldMask, _mfNames);
874 editMField(IntValuesFieldMask, _mfIntValues);
875 editSField(NameToIndexFieldMask);
877 _mfFundamentalTypes.push_back(INT_T);
878 _mfMainTypes .push_back(SIMPLE_T);
879 _mfCardinality .push_back(cardinality);
880 _mfIndex .push_back(static_cast<UInt32>(_mfIntValues.size()));
881 _mfNames .push_back(name);
883 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
885 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
887 for (UInt32 i = 0; i < cardinality; ++i)
888 _mfIntValues.push_back(0);
890 OSG_ASSERT(invariantOnStorageSize());
892 return index;
895 UInt32 ShaderStorageBufferObjChunk::addUInt(const std::string& name, UInt32 cardinality)
897 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
898 editMField(MainTypesFieldMask, _mfMainTypes);
899 editMField(CardinalityFieldMask, _mfCardinality);
900 editMField(IndexFieldMask, _mfIndex);
901 editMField(NamesFieldMask, _mfNames);
902 editMField(UIntValuesFieldMask, _mfUIntValues);
903 editSField(NameToIndexFieldMask);
905 _mfFundamentalTypes.push_back(UINT_T);
906 _mfMainTypes .push_back(SIMPLE_T);
907 _mfCardinality .push_back(cardinality);
908 _mfIndex .push_back(static_cast<UInt32>(_mfUIntValues.size()));
909 _mfNames .push_back(name);
911 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
913 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
915 for (UInt32 i = 0; i < cardinality; ++i)
916 _mfUIntValues.push_back(0);
918 OSG_ASSERT(invariantOnStorageSize());
920 return index;
923 UInt32 ShaderStorageBufferObjChunk::addBool(const std::string& name, UInt32 cardinality)
925 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
926 editMField(MainTypesFieldMask, _mfMainTypes);
927 editMField(CardinalityFieldMask, _mfCardinality);
928 editMField(IndexFieldMask, _mfIndex);
929 editMField(NamesFieldMask, _mfNames);
930 editMField(BoolValuesFieldMask, _mfBoolValues);
931 editSField(NameToIndexFieldMask);
933 _mfFundamentalTypes.push_back(BOOL_T);
934 _mfMainTypes .push_back(SIMPLE_T);
935 _mfCardinality .push_back(cardinality);
936 _mfIndex .push_back(static_cast<UInt32>(_mfBoolValues.size()));
937 _mfNames .push_back(name);
939 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
941 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
943 for (UInt32 i = 0; i < cardinality; ++i)
944 _mfBoolValues.push_back(static_cast<UInt8>(false));
946 OSG_ASSERT(invariantOnStorageSize());
948 return index;
951 UInt32 ShaderStorageBufferObjChunk::addVec2(const std::string& name, UInt32 cardinality)
953 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
954 editMField(MainTypesFieldMask, _mfMainTypes);
955 editMField(CardinalityFieldMask, _mfCardinality);
956 editMField(IndexFieldMask, _mfIndex);
957 editMField(NamesFieldMask, _mfNames);
958 editMField(FloatValuesFieldMask, _mfFloatValues);
959 editSField(NameToIndexFieldMask);
961 _mfFundamentalTypes.push_back(FLOAT_T);
962 _mfMainTypes .push_back(VEC2_T);
963 _mfCardinality .push_back(cardinality);
964 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
965 _mfNames .push_back(name);
967 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
969 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
971 UInt8 rows = 2;
973 for (UInt32 i = 0; i < cardinality; ++i)
974 for (UInt8 j = 0; j < rows; ++j)
975 _mfFloatValues.push_back(0.f);
977 OSG_ASSERT(invariantOnStorageSize());
979 return index;
982 UInt32 ShaderStorageBufferObjChunk::addVec3(const std::string& name, UInt32 cardinality)
984 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
985 editMField(MainTypesFieldMask, _mfMainTypes);
986 editMField(CardinalityFieldMask, _mfCardinality);
987 editMField(IndexFieldMask, _mfIndex);
988 editMField(NamesFieldMask, _mfNames);
989 editMField(FloatValuesFieldMask, _mfFloatValues);
990 editSField(NameToIndexFieldMask);
992 _mfFundamentalTypes.push_back(FLOAT_T);
993 _mfMainTypes .push_back(VEC3_T);
994 _mfCardinality .push_back(cardinality);
995 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
996 _mfNames .push_back(name);
998 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1000 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1002 UInt8 rows = 3;
1004 for (UInt32 i = 0; i < cardinality; ++i)
1005 for (UInt8 j = 0; j < rows; ++j)
1006 _mfFloatValues.push_back(0.f);
1008 OSG_ASSERT(invariantOnStorageSize());
1010 return index;
1013 UInt32 ShaderStorageBufferObjChunk::addVec4(const std::string& name, UInt32 cardinality)
1015 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1016 editMField(MainTypesFieldMask, _mfMainTypes);
1017 editMField(CardinalityFieldMask, _mfCardinality);
1018 editMField(IndexFieldMask, _mfIndex);
1019 editMField(NamesFieldMask, _mfNames);
1020 editMField(FloatValuesFieldMask, _mfFloatValues);
1021 editSField(NameToIndexFieldMask);
1023 _mfFundamentalTypes.push_back(FLOAT_T);
1024 _mfMainTypes .push_back(VEC4_T);
1025 _mfCardinality .push_back(cardinality);
1026 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1027 _mfNames .push_back(name);
1029 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1031 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1033 UInt8 rows = 4;
1035 for (UInt32 i = 0; i < cardinality; ++i)
1036 for (UInt8 j = 0; j < rows; ++j)
1037 _mfFloatValues.push_back(0.f);
1039 OSG_ASSERT(invariantOnStorageSize());
1041 return index;
1044 UInt32 ShaderStorageBufferObjChunk::addDVec2(const std::string& name, UInt32 cardinality)
1046 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1047 editMField(MainTypesFieldMask, _mfMainTypes);
1048 editMField(CardinalityFieldMask, _mfCardinality);
1049 editMField(IndexFieldMask, _mfIndex);
1050 editMField(NamesFieldMask, _mfNames);
1051 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1052 editSField(NameToIndexFieldMask);
1054 _mfFundamentalTypes.push_back(DOUBLE_T);
1055 _mfMainTypes .push_back(VEC2_T);
1056 _mfCardinality .push_back(cardinality);
1057 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1058 _mfNames .push_back(name);
1060 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1062 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1064 UInt8 rows = 2;
1066 for (UInt32 i = 0; i < cardinality; ++i)
1067 for (UInt8 j = 0; j < rows; ++j)
1068 _mfDoubleValues.push_back(0.);
1070 OSG_ASSERT(invariantOnStorageSize());
1072 return index;
1075 UInt32 ShaderStorageBufferObjChunk::addDVec3(const std::string& name, UInt32 cardinality)
1077 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1078 editMField(MainTypesFieldMask, _mfMainTypes);
1079 editMField(CardinalityFieldMask, _mfCardinality);
1080 editMField(IndexFieldMask, _mfIndex);
1081 editMField(NamesFieldMask, _mfNames);
1082 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1083 editSField(NameToIndexFieldMask);
1085 _mfFundamentalTypes.push_back(DOUBLE_T);
1086 _mfMainTypes .push_back(VEC3_T);
1087 _mfCardinality .push_back(cardinality);
1088 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1089 _mfNames .push_back(name);
1091 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1093 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1095 UInt8 rows = 3;
1097 for (UInt32 i = 0; i < cardinality; ++i)
1098 for (UInt8 j = 0; j < rows; ++j)
1099 _mfDoubleValues.push_back(0.);
1101 OSG_ASSERT(invariantOnStorageSize());
1103 return index;
1106 UInt32 ShaderStorageBufferObjChunk::addDVec4(const std::string& name, UInt32 cardinality)
1108 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1109 editMField(MainTypesFieldMask, _mfMainTypes);
1110 editMField(CardinalityFieldMask, _mfCardinality);
1111 editMField(IndexFieldMask, _mfIndex);
1112 editMField(NamesFieldMask, _mfNames);
1113 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1114 editSField(NameToIndexFieldMask);
1116 _mfFundamentalTypes.push_back(DOUBLE_T);
1117 _mfMainTypes .push_back(VEC4_T);
1118 _mfCardinality .push_back(cardinality);
1119 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1120 _mfNames .push_back(name);
1122 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1124 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1126 UInt8 rows = 4;
1128 for (UInt32 i = 0; i < cardinality; ++i)
1129 for (UInt8 j = 0; j < rows; ++j)
1130 _mfDoubleValues.push_back(0.);
1132 OSG_ASSERT(invariantOnStorageSize());
1134 return index;
1137 UInt32 ShaderStorageBufferObjChunk::addIVec2(const std::string& name, UInt32 cardinality)
1139 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1140 editMField(MainTypesFieldMask, _mfMainTypes);
1141 editMField(CardinalityFieldMask, _mfCardinality);
1142 editMField(IndexFieldMask, _mfIndex);
1143 editMField(NamesFieldMask, _mfNames);
1144 editMField(IntValuesFieldMask, _mfIntValues);
1145 editSField(NameToIndexFieldMask);
1147 _mfFundamentalTypes.push_back(INT_T);
1148 _mfMainTypes .push_back(VEC2_T);
1149 _mfCardinality .push_back(cardinality);
1150 _mfIndex .push_back(static_cast<UInt32>(_mfIntValues.size()));
1151 _mfNames .push_back(name);
1153 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1155 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1157 UInt8 rows = 2;
1159 for (UInt32 i = 0; i < cardinality; ++i)
1160 for (UInt8 j = 0; j < rows; ++j)
1161 _mfIntValues.push_back(0);
1163 OSG_ASSERT(invariantOnStorageSize());
1165 return index;
1168 UInt32 ShaderStorageBufferObjChunk::addIVec3(const std::string& name, UInt32 cardinality)
1170 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1171 editMField(MainTypesFieldMask, _mfMainTypes);
1172 editMField(CardinalityFieldMask, _mfCardinality);
1173 editMField(IndexFieldMask, _mfIndex);
1174 editMField(NamesFieldMask, _mfNames);
1175 editMField(IntValuesFieldMask, _mfIntValues);
1176 editSField(NameToIndexFieldMask);
1178 _mfFundamentalTypes.push_back(INT_T);
1179 _mfMainTypes .push_back(VEC3_T);
1180 _mfCardinality .push_back(cardinality);
1181 _mfIndex .push_back(static_cast<UInt32>(_mfIntValues.size()));
1182 _mfNames .push_back(name);
1184 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1186 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1188 UInt8 rows = 3;
1190 for (UInt32 i = 0; i < cardinality; ++i)
1191 for (UInt8 j = 0; j < rows; ++j)
1192 _mfIntValues.push_back(0);
1194 OSG_ASSERT(invariantOnStorageSize());
1196 return index;
1199 UInt32 ShaderStorageBufferObjChunk::addIVec4(const std::string& name, UInt32 cardinality)
1201 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1202 editMField(MainTypesFieldMask, _mfMainTypes);
1203 editMField(CardinalityFieldMask, _mfCardinality);
1204 editMField(IndexFieldMask, _mfIndex);
1205 editMField(NamesFieldMask, _mfNames);
1206 editMField(IntValuesFieldMask, _mfIntValues);
1207 editSField(NameToIndexFieldMask);
1209 _mfFundamentalTypes.push_back(INT_T);
1210 _mfMainTypes .push_back(VEC4_T);
1211 _mfCardinality .push_back(cardinality);
1212 _mfIndex .push_back(static_cast<UInt32>(_mfIntValues.size()));
1213 _mfNames .push_back(name);
1215 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1217 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1219 UInt8 rows = 4;
1221 for (UInt32 i = 0; i < cardinality; ++i)
1222 for (UInt8 j = 0; j < rows; ++j)
1223 _mfIntValues.push_back(0);
1225 OSG_ASSERT(invariantOnStorageSize());
1227 return index;
1230 UInt32 ShaderStorageBufferObjChunk::addUVec2(const std::string& name, UInt32 cardinality)
1232 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1233 editMField(MainTypesFieldMask, _mfMainTypes);
1234 editMField(CardinalityFieldMask, _mfCardinality);
1235 editMField(IndexFieldMask, _mfIndex);
1236 editMField(NamesFieldMask, _mfNames);
1237 editMField(UIntValuesFieldMask, _mfUIntValues);
1238 editSField(NameToIndexFieldMask);
1240 _mfFundamentalTypes.push_back(UINT_T);
1241 _mfMainTypes .push_back(VEC2_T);
1242 _mfCardinality .push_back(cardinality);
1243 _mfIndex .push_back(static_cast<UInt32>(_mfUIntValues.size()));
1244 _mfNames .push_back(name);
1246 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1248 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1250 UInt8 rows = 2;
1252 for (UInt32 i = 0; i < cardinality; ++i)
1253 for (UInt8 j = 0; j < rows; ++j)
1254 _mfUIntValues.push_back(0);
1256 OSG_ASSERT(invariantOnStorageSize());
1258 return index;
1261 UInt32 ShaderStorageBufferObjChunk::addUVec3(const std::string& name, UInt32 cardinality)
1263 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1264 editMField(MainTypesFieldMask, _mfMainTypes);
1265 editMField(CardinalityFieldMask, _mfCardinality);
1266 editMField(IndexFieldMask, _mfIndex);
1267 editMField(NamesFieldMask, _mfNames);
1268 editMField(UIntValuesFieldMask, _mfUIntValues);
1269 editSField(NameToIndexFieldMask);
1271 _mfFundamentalTypes.push_back(UINT_T);
1272 _mfMainTypes .push_back(VEC3_T);
1273 _mfCardinality .push_back(cardinality);
1274 _mfIndex .push_back(static_cast<UInt32>(_mfUIntValues.size()));
1275 _mfNames .push_back(name);
1277 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1279 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1281 UInt8 rows = 3;
1283 for (UInt32 i = 0; i < cardinality; ++i)
1284 for (UInt8 j = 0; j < rows; ++j)
1285 _mfUIntValues.push_back(0);
1287 OSG_ASSERT(invariantOnStorageSize());
1289 return index;
1292 UInt32 ShaderStorageBufferObjChunk::addUVec4(const std::string& name, UInt32 cardinality)
1294 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1295 editMField(MainTypesFieldMask, _mfMainTypes);
1296 editMField(CardinalityFieldMask, _mfCardinality);
1297 editMField(IndexFieldMask, _mfIndex);
1298 editMField(NamesFieldMask, _mfNames);
1299 editMField(UIntValuesFieldMask, _mfUIntValues);
1300 editSField(NameToIndexFieldMask);
1302 _mfFundamentalTypes.push_back(UINT_T);
1303 _mfMainTypes .push_back(VEC4_T);
1304 _mfCardinality .push_back(cardinality);
1305 _mfIndex .push_back(static_cast<UInt32>(_mfUIntValues.size()));
1306 _mfNames .push_back(name);
1308 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1310 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1312 UInt8 rows = 4;
1314 for (UInt32 i = 0; i < cardinality; ++i)
1315 for (UInt8 j = 0; j < rows; ++j)
1316 _mfUIntValues.push_back(0);
1318 OSG_ASSERT(invariantOnStorageSize());
1320 return index;
1323 UInt32 ShaderStorageBufferObjChunk::addBVec2(const std::string& name, UInt32 cardinality)
1325 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1326 editMField(MainTypesFieldMask, _mfMainTypes);
1327 editMField(CardinalityFieldMask, _mfCardinality);
1328 editMField(IndexFieldMask, _mfIndex);
1329 editMField(NamesFieldMask, _mfNames);
1330 editMField(BoolValuesFieldMask, _mfBoolValues);
1331 editSField(NameToIndexFieldMask);
1333 _mfFundamentalTypes.push_back(BOOL_T);
1334 _mfMainTypes .push_back(VEC2_T);
1335 _mfCardinality .push_back(cardinality);
1336 _mfIndex .push_back(static_cast<UInt32>(_mfBoolValues.size()));
1337 _mfNames .push_back(name);
1339 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1341 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1343 UInt8 rows = 2;
1345 for (UInt32 i = 0; i < cardinality; ++i)
1346 for (UInt8 j = 0; j < rows; ++j)
1347 _mfBoolValues.push_back(static_cast<UInt8>(false));
1349 OSG_ASSERT(invariantOnStorageSize());
1351 return index;
1354 UInt32 ShaderStorageBufferObjChunk::addBVec3(const std::string& name, UInt32 cardinality)
1356 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1357 editMField(MainTypesFieldMask, _mfMainTypes);
1358 editMField(CardinalityFieldMask, _mfCardinality);
1359 editMField(IndexFieldMask, _mfIndex);
1360 editMField(NamesFieldMask, _mfNames);
1361 editMField(BoolValuesFieldMask, _mfBoolValues);
1362 editSField(NameToIndexFieldMask);
1364 _mfFundamentalTypes.push_back(BOOL_T);
1365 _mfMainTypes .push_back(VEC3_T);
1366 _mfCardinality .push_back(cardinality);
1367 _mfIndex .push_back(static_cast<UInt32>(_mfBoolValues.size()));
1368 _mfNames .push_back(name);
1370 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1372 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1374 UInt8 rows = 3;
1376 for (UInt32 i = 0; i < cardinality; ++i)
1377 for (UInt8 j = 0; j < rows; ++j)
1378 _mfBoolValues.push_back(static_cast<UInt8>(false));
1380 OSG_ASSERT(invariantOnStorageSize());
1382 return index;
1385 UInt32 ShaderStorageBufferObjChunk::addBVec4(const std::string& name, UInt32 cardinality)
1387 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1388 editMField(MainTypesFieldMask, _mfMainTypes);
1389 editMField(CardinalityFieldMask, _mfCardinality);
1390 editMField(IndexFieldMask, _mfIndex);
1391 editMField(NamesFieldMask, _mfNames);
1392 editMField(BoolValuesFieldMask, _mfBoolValues);
1393 editSField(NameToIndexFieldMask);
1395 _mfFundamentalTypes.push_back(BOOL_T);
1396 _mfMainTypes .push_back(VEC4_T);
1397 _mfCardinality .push_back(cardinality);
1398 _mfIndex .push_back(static_cast<UInt32>(_mfBoolValues.size()));
1399 _mfNames .push_back(name);
1401 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1403 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1405 UInt8 rows = 4;
1407 for (UInt32 i = 0; i < cardinality; ++i)
1408 for (UInt8 j = 0; j < rows; ++j)
1409 _mfBoolValues.push_back(static_cast<UInt8>(false));
1411 OSG_ASSERT(invariantOnStorageSize());
1413 return index;
1416 UInt32 ShaderStorageBufferObjChunk::addMat2(const std::string& name, UInt32 cardinality)
1418 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1419 editMField(MainTypesFieldMask, _mfMainTypes);
1420 editMField(CardinalityFieldMask, _mfCardinality);
1421 editMField(IndexFieldMask, _mfIndex);
1422 editMField(NamesFieldMask, _mfNames);
1423 editMField(FloatValuesFieldMask, _mfFloatValues);
1424 editSField(NameToIndexFieldMask);
1426 _mfFundamentalTypes.push_back(FLOAT_T);
1427 _mfMainTypes .push_back(MAT2_T);
1428 _mfCardinality .push_back(cardinality);
1429 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1430 _mfNames .push_back(name);
1432 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1434 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1436 UInt8 columns = 2;
1437 UInt8 rows = 2;
1439 for (UInt32 i = 0; i < cardinality; ++i)
1440 for (UInt8 j = 0; j < columns; ++j)
1441 for (UInt8 k = 0; k < rows; ++k)
1442 _mfFloatValues.push_back(0.f);
1444 OSG_ASSERT(invariantOnStorageSize());
1446 return index;
1449 UInt32 ShaderStorageBufferObjChunk::addMat3(const std::string& name, UInt32 cardinality)
1451 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1452 editMField(MainTypesFieldMask, _mfMainTypes);
1453 editMField(CardinalityFieldMask, _mfCardinality);
1454 editMField(IndexFieldMask, _mfIndex);
1455 editMField(NamesFieldMask, _mfNames);
1456 editMField(FloatValuesFieldMask, _mfFloatValues);
1457 editSField(NameToIndexFieldMask);
1459 _mfFundamentalTypes.push_back(FLOAT_T);
1460 _mfMainTypes .push_back(MAT3_T);
1461 _mfCardinality .push_back(cardinality);
1462 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1463 _mfNames .push_back(name);
1465 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1467 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1469 UInt8 columns = 3;
1470 UInt8 rows = 3;
1472 for (UInt32 i = 0; i < cardinality; ++i)
1473 for (UInt8 j = 0; j < columns; ++j)
1474 for (UInt8 k = 0; k < rows; ++k)
1475 _mfFloatValues.push_back(0.f);
1477 OSG_ASSERT(invariantOnStorageSize());
1479 return index;
1482 UInt32 ShaderStorageBufferObjChunk::addMat4(const std::string& name, UInt32 cardinality)
1484 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1485 editMField(MainTypesFieldMask, _mfMainTypes);
1486 editMField(CardinalityFieldMask, _mfCardinality);
1487 editMField(IndexFieldMask, _mfIndex);
1488 editMField(NamesFieldMask, _mfNames);
1489 editMField(FloatValuesFieldMask, _mfFloatValues);
1490 editSField(NameToIndexFieldMask);
1492 _mfFundamentalTypes.push_back(FLOAT_T);
1493 _mfMainTypes .push_back(MAT4_T);
1494 _mfCardinality .push_back(cardinality);
1495 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1496 _mfNames .push_back(name);
1498 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1500 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1502 UInt8 columns = 4;
1503 UInt8 rows = 4;
1505 for (UInt32 i = 0; i < cardinality; ++i)
1506 for (UInt8 j = 0; j < columns; ++j)
1507 for (UInt8 k = 0; k < rows; ++k)
1508 _mfFloatValues.push_back(0.f);
1510 OSG_ASSERT(invariantOnStorageSize());
1512 return index;
1515 UInt32 ShaderStorageBufferObjChunk::addDMat2(const std::string& name, UInt32 cardinality)
1517 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1518 editMField(MainTypesFieldMask, _mfMainTypes);
1519 editMField(CardinalityFieldMask, _mfCardinality);
1520 editMField(IndexFieldMask, _mfIndex);
1521 editMField(NamesFieldMask, _mfNames);
1522 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1523 editSField(NameToIndexFieldMask);
1525 _mfFundamentalTypes.push_back(DOUBLE_T);
1526 _mfMainTypes .push_back(MAT2_T);
1527 _mfCardinality .push_back(cardinality);
1528 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1529 _mfNames .push_back(name);
1531 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1533 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1535 UInt8 columns = 2;
1536 UInt8 rows = 2;
1538 for (UInt32 i = 0; i < cardinality; ++i)
1539 for (UInt8 j = 0; j < columns; ++j)
1540 for (UInt8 k = 0; k < rows; ++k)
1541 _mfDoubleValues.push_back(0.f);
1543 OSG_ASSERT(invariantOnStorageSize());
1545 return index;
1548 UInt32 ShaderStorageBufferObjChunk::addDMat3(const std::string& name, UInt32 cardinality)
1550 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1551 editMField(MainTypesFieldMask, _mfMainTypes);
1552 editMField(CardinalityFieldMask, _mfCardinality);
1553 editMField(IndexFieldMask, _mfIndex);
1554 editMField(NamesFieldMask, _mfNames);
1555 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1556 editSField(NameToIndexFieldMask);
1558 _mfFundamentalTypes.push_back(DOUBLE_T);
1559 _mfMainTypes .push_back(MAT3_T);
1560 _mfCardinality .push_back(cardinality);
1561 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1562 _mfNames .push_back(name);
1564 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1566 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1568 UInt8 columns = 3;
1569 UInt8 rows = 3;
1571 for (UInt32 i = 0; i < cardinality; ++i)
1572 for (UInt8 j = 0; j < columns; ++j)
1573 for (UInt8 k = 0; k < rows; ++k)
1574 _mfDoubleValues.push_back(0.f);
1576 OSG_ASSERT(invariantOnStorageSize());
1578 return index;
1581 UInt32 ShaderStorageBufferObjChunk::addDMat4(const std::string& name, UInt32 cardinality)
1583 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1584 editMField(MainTypesFieldMask, _mfMainTypes);
1585 editMField(CardinalityFieldMask, _mfCardinality);
1586 editMField(IndexFieldMask, _mfIndex);
1587 editMField(NamesFieldMask, _mfNames);
1588 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1589 editSField(NameToIndexFieldMask);
1591 _mfFundamentalTypes.push_back(DOUBLE_T);
1592 _mfMainTypes .push_back(MAT4_T);
1593 _mfCardinality .push_back(cardinality);
1594 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1595 _mfNames .push_back(name);
1597 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1599 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1601 UInt8 columns = 4;
1602 UInt8 rows = 4;
1604 for (UInt32 i = 0; i < cardinality; ++i)
1605 for (UInt8 j = 0; j < columns; ++j)
1606 for (UInt8 k = 0; k < rows; ++k)
1607 _mfDoubleValues.push_back(0.f);
1609 OSG_ASSERT(invariantOnStorageSize());
1611 return index;
1614 UInt32 ShaderStorageBufferObjChunk::addMat2x3(const std::string& name, UInt32 cardinality)
1616 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1617 editMField(MainTypesFieldMask, _mfMainTypes);
1618 editMField(CardinalityFieldMask, _mfCardinality);
1619 editMField(IndexFieldMask, _mfIndex);
1620 editMField(NamesFieldMask, _mfNames);
1621 editMField(FloatValuesFieldMask, _mfFloatValues);
1622 editSField(NameToIndexFieldMask);
1624 _mfFundamentalTypes.push_back(FLOAT_T);
1625 _mfMainTypes .push_back(MAT2X3_T);
1626 _mfCardinality .push_back(cardinality);
1627 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1628 _mfNames .push_back(name);
1630 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1632 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1634 UInt8 columns = 2;
1635 UInt8 rows = 3;
1637 for (UInt32 i = 0; i < cardinality; ++i)
1638 for (UInt8 j = 0; j < columns; ++j)
1639 for (UInt8 k = 0; k < rows; ++k)
1640 _mfFloatValues.push_back(0.f);
1642 OSG_ASSERT(invariantOnStorageSize());
1644 return index;
1647 UInt32 ShaderStorageBufferObjChunk::addMat3x2(const std::string& name, UInt32 cardinality)
1649 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1650 editMField(MainTypesFieldMask, _mfMainTypes);
1651 editMField(CardinalityFieldMask, _mfCardinality);
1652 editMField(IndexFieldMask, _mfIndex);
1653 editMField(NamesFieldMask, _mfNames);
1654 editMField(FloatValuesFieldMask, _mfFloatValues);
1655 editSField(NameToIndexFieldMask);
1657 _mfFundamentalTypes.push_back(FLOAT_T);
1658 _mfMainTypes .push_back(MAT3X2_T);
1659 _mfCardinality .push_back(cardinality);
1660 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1661 _mfNames .push_back(name);
1663 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1665 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1667 UInt8 columns = 3;
1668 UInt8 rows = 2;
1670 for (UInt32 i = 0; i < cardinality; ++i)
1671 for (UInt8 j = 0; j < columns; ++j)
1672 for (UInt8 k = 0; k < rows; ++k)
1673 _mfFloatValues.push_back(0.f);
1674 OSG_ASSERT(invariantOnStorageSize());
1676 return index;
1679 UInt32 ShaderStorageBufferObjChunk::addMat2x4(const std::string& name, UInt32 cardinality)
1681 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1682 editMField(MainTypesFieldMask, _mfMainTypes);
1683 editMField(CardinalityFieldMask, _mfCardinality);
1684 editMField(IndexFieldMask, _mfIndex);
1685 editMField(NamesFieldMask, _mfNames);
1686 editMField(FloatValuesFieldMask, _mfFloatValues);
1687 editSField(NameToIndexFieldMask);
1689 _mfFundamentalTypes.push_back(FLOAT_T);
1690 _mfMainTypes .push_back(MAT2X4_T);
1691 _mfCardinality .push_back(cardinality);
1692 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1693 _mfNames .push_back(name);
1695 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1697 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1699 UInt8 columns = 2;
1700 UInt8 rows = 4;
1702 for (UInt32 i = 0; i < cardinality; ++i)
1703 for (UInt8 j = 0; j < columns; ++j)
1704 for (UInt8 k = 0; k < rows; ++k)
1705 _mfFloatValues.push_back(0.f);
1707 OSG_ASSERT(invariantOnStorageSize());
1709 return index;
1712 UInt32 ShaderStorageBufferObjChunk::addMat4x2(const std::string& name, UInt32 cardinality)
1714 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1715 editMField(MainTypesFieldMask, _mfMainTypes);
1716 editMField(CardinalityFieldMask, _mfCardinality);
1717 editMField(IndexFieldMask, _mfIndex);
1718 editMField(NamesFieldMask, _mfNames);
1719 editMField(FloatValuesFieldMask, _mfFloatValues);
1720 editSField(NameToIndexFieldMask);
1722 _mfFundamentalTypes.push_back(FLOAT_T);
1723 _mfMainTypes .push_back(MAT4X2_T);
1724 _mfCardinality .push_back(cardinality);
1725 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1726 _mfNames .push_back(name);
1728 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1730 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1732 UInt8 columns = 4;
1733 UInt8 rows = 2;
1735 for (UInt32 i = 0; i < cardinality; ++i)
1736 for (UInt8 j = 0; j < columns; ++j)
1737 for (UInt8 k = 0; k < rows; ++k)
1738 _mfFloatValues.push_back(0.f);
1740 OSG_ASSERT(invariantOnStorageSize());
1742 return index;
1745 UInt32 ShaderStorageBufferObjChunk::addMat3x4(const std::string& name, UInt32 cardinality)
1747 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1748 editMField(MainTypesFieldMask, _mfMainTypes);
1749 editMField(CardinalityFieldMask, _mfCardinality);
1750 editMField(IndexFieldMask, _mfIndex);
1751 editMField(NamesFieldMask, _mfNames);
1752 editMField(FloatValuesFieldMask, _mfFloatValues);
1753 editSField(NameToIndexFieldMask);
1755 _mfFundamentalTypes.push_back(FLOAT_T);
1756 _mfMainTypes .push_back(MAT3X4_T);
1757 _mfCardinality .push_back(cardinality);
1758 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1759 _mfNames .push_back(name);
1761 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1763 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1765 UInt8 columns = 3;
1766 UInt8 rows = 4;
1768 for (UInt32 i = 0; i < cardinality; ++i)
1769 for (UInt8 j = 0; j < columns; ++j)
1770 for (UInt8 k = 0; k < rows; ++k)
1771 _mfFloatValues.push_back(0.f);
1773 OSG_ASSERT(invariantOnStorageSize());
1775 return index;
1778 UInt32 ShaderStorageBufferObjChunk::addMat4x3(const std::string& name, UInt32 cardinality)
1780 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1781 editMField(MainTypesFieldMask, _mfMainTypes);
1782 editMField(CardinalityFieldMask, _mfCardinality);
1783 editMField(IndexFieldMask, _mfIndex);
1784 editMField(NamesFieldMask, _mfNames);
1785 editMField(FloatValuesFieldMask, _mfFloatValues);
1786 editSField(NameToIndexFieldMask);
1788 _mfFundamentalTypes.push_back(FLOAT_T);
1789 _mfMainTypes .push_back(MAT4X3_T);
1790 _mfCardinality .push_back(cardinality);
1791 _mfIndex .push_back(static_cast<UInt32>(_mfFloatValues.size()));
1792 _mfNames .push_back(name);
1794 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1796 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1798 UInt8 columns = 4;
1799 UInt8 rows = 3;
1801 for (UInt32 i = 0; i < cardinality; ++i)
1802 for (UInt8 j = 0; j < columns; ++j)
1803 for (UInt8 k = 0; k < rows; ++k)
1804 _mfFloatValues.push_back(0.f);
1806 OSG_ASSERT(invariantOnStorageSize());
1808 return index;
1811 UInt32 ShaderStorageBufferObjChunk::addDMat2x3(const std::string& name, UInt32 cardinality)
1813 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1814 editMField(MainTypesFieldMask, _mfMainTypes);
1815 editMField(CardinalityFieldMask, _mfCardinality);
1816 editMField(IndexFieldMask, _mfIndex);
1817 editMField(NamesFieldMask, _mfNames);
1818 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1819 editSField(NameToIndexFieldMask);
1821 _mfFundamentalTypes.push_back(DOUBLE_T);
1822 _mfMainTypes .push_back(MAT2X3_T);
1823 _mfCardinality .push_back(cardinality);
1824 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1825 _mfNames .push_back(name);
1827 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1829 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1831 UInt8 columns = 2;
1832 UInt8 rows = 3;
1834 for (UInt32 i = 0; i < cardinality; ++i)
1835 for (UInt8 j = 0; j < columns; ++j)
1836 for (UInt8 k = 0; k < rows; ++k)
1837 _mfDoubleValues.push_back(0.f);
1839 OSG_ASSERT(invariantOnStorageSize());
1841 return index;
1844 UInt32 ShaderStorageBufferObjChunk::addDMat3x2(const std::string& name, UInt32 cardinality)
1846 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1847 editMField(MainTypesFieldMask, _mfMainTypes);
1848 editMField(CardinalityFieldMask, _mfCardinality);
1849 editMField(IndexFieldMask, _mfIndex);
1850 editMField(NamesFieldMask, _mfNames);
1851 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1852 editSField(NameToIndexFieldMask);
1854 _mfFundamentalTypes.push_back(DOUBLE_T);
1855 _mfMainTypes .push_back(MAT3X2_T);
1856 _mfCardinality .push_back(cardinality);
1857 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1858 _mfNames .push_back(name);
1860 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1862 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1864 UInt8 columns = 3;
1865 UInt8 rows = 2;
1867 for (UInt32 i = 0; i < cardinality; ++i)
1868 for (UInt8 j = 0; j < columns; ++j)
1869 for (UInt8 k = 0; k < rows; ++k)
1870 _mfDoubleValues.push_back(0.f);
1872 OSG_ASSERT(invariantOnStorageSize());
1874 return index;
1877 UInt32 ShaderStorageBufferObjChunk::addDMat2x4(const std::string& name, UInt32 cardinality)
1879 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1880 editMField(MainTypesFieldMask, _mfMainTypes);
1881 editMField(CardinalityFieldMask, _mfCardinality);
1882 editMField(IndexFieldMask, _mfIndex);
1883 editMField(NamesFieldMask, _mfNames);
1884 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1885 editSField(NameToIndexFieldMask);
1887 _mfFundamentalTypes.push_back(DOUBLE_T);
1888 _mfMainTypes .push_back(MAT2X4_T);
1889 _mfCardinality .push_back(cardinality);
1890 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1891 _mfNames .push_back(name);
1893 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1895 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1897 UInt8 columns = 2;
1898 UInt8 rows = 4;
1900 for (UInt32 i = 0; i < cardinality; ++i)
1901 for (UInt8 j = 0; j < columns; ++j)
1902 for (UInt8 k = 0; k < rows; ++k)
1903 _mfDoubleValues.push_back(0.f);
1905 OSG_ASSERT(invariantOnStorageSize());
1907 return index;
1910 UInt32 ShaderStorageBufferObjChunk::addDMat4x2(const std::string& name, UInt32 cardinality)
1912 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1913 editMField(MainTypesFieldMask, _mfMainTypes);
1914 editMField(CardinalityFieldMask, _mfCardinality);
1915 editMField(IndexFieldMask, _mfIndex);
1916 editMField(NamesFieldMask, _mfNames);
1917 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1918 editSField(NameToIndexFieldMask);
1920 _mfFundamentalTypes.push_back(DOUBLE_T);
1921 _mfMainTypes .push_back(MAT4X2_T);
1922 _mfCardinality .push_back(cardinality);
1923 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1924 _mfNames .push_back(name);
1926 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1928 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1930 UInt8 columns = 4;
1931 UInt8 rows = 2;
1933 for (UInt32 i = 0; i < cardinality; ++i)
1934 for (UInt8 j = 0; j < columns; ++j)
1935 for (UInt8 k = 0; k < rows; ++k)
1936 _mfDoubleValues.push_back(0.f);
1938 OSG_ASSERT(invariantOnStorageSize());
1940 return index;
1943 UInt32 ShaderStorageBufferObjChunk::addDMat3x4(const std::string& name, UInt32 cardinality)
1945 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1946 editMField(MainTypesFieldMask, _mfMainTypes);
1947 editMField(CardinalityFieldMask, _mfCardinality);
1948 editMField(IndexFieldMask, _mfIndex);
1949 editMField(NamesFieldMask, _mfNames);
1950 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1951 editSField(NameToIndexFieldMask);
1953 _mfFundamentalTypes.push_back(DOUBLE_T);
1954 _mfMainTypes .push_back(MAT3X4_T);
1955 _mfCardinality .push_back(cardinality);
1956 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1957 _mfNames .push_back(name);
1959 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1961 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1963 UInt8 columns = 3;
1964 UInt8 rows = 4;
1966 for (UInt32 i = 0; i < cardinality; ++i)
1967 for (UInt8 j = 0; j < columns; ++j)
1968 for (UInt8 k = 0; k < rows; ++k)
1969 _mfDoubleValues.push_back(0.f);
1971 OSG_ASSERT(invariantOnStorageSize());
1973 return index;
1976 UInt32 ShaderStorageBufferObjChunk::addDMat4x3(const std::string& name, UInt32 cardinality)
1978 editMField(FundamentalTypesFieldMask, _mfFundamentalTypes);
1979 editMField(MainTypesFieldMask, _mfMainTypes);
1980 editMField(CardinalityFieldMask, _mfCardinality);
1981 editMField(IndexFieldMask, _mfIndex);
1982 editMField(NamesFieldMask, _mfNames);
1983 editMField(DoubleValuesFieldMask, _mfDoubleValues);
1984 editSField(NameToIndexFieldMask);
1986 _mfFundamentalTypes.push_back(DOUBLE_T);
1987 _mfMainTypes .push_back(MAT4X3_T);
1988 _mfCardinality .push_back(cardinality);
1989 _mfIndex .push_back(static_cast<UInt32>(_mfDoubleValues.size()));
1990 _mfNames .push_back(name);
1992 UInt32 index = static_cast<UInt32>(_mfIndex.size()) - 1;
1994 _sfNameToIndex.getValue().insert(StringToUInt32Map::value_type(name, index));
1996 UInt8 columns = 4;
1997 UInt8 rows = 3;
1999 for (UInt32 i = 0; i < cardinality; ++i)
2000 for (UInt8 j = 0; j < columns; ++j)
2001 for (UInt8 k = 0; k < rows; ++k)
2002 _mfDoubleValues.push_back(0.f);
2004 OSG_ASSERT(invariantOnStorageSize());
2006 return index;
2009 /*------------------------------ set-interface I ----------------------------*/
2011 void ShaderStorageBufferObjChunk::setFloat(UInt32 handle, Real32 value, UInt32 array_idx)
2013 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2015 editMField(FloatValuesFieldMask, _mfFloatValues);
2016 _mfFloatValues[_mfIndex[handle] + array_idx] = value;
2019 void ShaderStorageBufferObjChunk::setDouble(UInt32 handle, Real64 value, UInt32 array_idx)
2021 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2023 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2024 _mfDoubleValues[_mfIndex[handle] + array_idx] = value;
2027 void ShaderStorageBufferObjChunk::setInt(UInt32 handle, Int32 value, UInt32 array_idx)
2029 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2031 editMField(IntValuesFieldMask, _mfIntValues);
2032 _mfIntValues[_mfIndex[handle] + array_idx] = value;
2035 void ShaderStorageBufferObjChunk::setUInt(UInt32 handle, UInt32 value, UInt32 array_idx)
2037 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2039 editMField(UIntValuesFieldMask, _mfUIntValues);
2040 _mfUIntValues[_mfIndex[handle] + array_idx] = value;
2043 void ShaderStorageBufferObjChunk::setBool(UInt32 handle, bool value, UInt32 array_idx)
2045 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2047 editMField(BoolValuesFieldMask, _mfBoolValues);
2048 _mfBoolValues[_mfIndex[handle] + array_idx] = static_cast<UInt8>(value);
2051 void ShaderStorageBufferObjChunk::setVec2(UInt32 handle, const Vec2f& value, UInt32 array_idx)
2053 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2055 editMField(FloatValuesFieldMask, _mfFloatValues);
2057 int size = 2;
2058 for (int i = 0; i < size; ++i)
2059 _mfFloatValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2062 void ShaderStorageBufferObjChunk::setVec2(UInt32 handle, const Pnt2f& value, UInt32 array_idx)
2064 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2066 editMField(FloatValuesFieldMask, _mfFloatValues);
2068 int size = 2;
2069 for (int i = 0; i < size; ++i)
2070 _mfFloatValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2073 void ShaderStorageBufferObjChunk::setVec3(UInt32 handle, const Vec3f& value, UInt32 array_idx)
2075 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2077 editMField(FloatValuesFieldMask, _mfFloatValues);
2079 int size = 3;
2080 for (int i = 0; i < size; ++i)
2081 _mfFloatValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2084 void ShaderStorageBufferObjChunk::setVec3(UInt32 handle, const Pnt3f& value, UInt32 array_idx)
2086 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2088 editMField(FloatValuesFieldMask, _mfFloatValues);
2090 int size = 3;
2091 for (int i = 0; i < size; ++i)
2092 _mfFloatValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2095 void ShaderStorageBufferObjChunk::setVec3(UInt32 handle, const Color3f& value, UInt32 array_idx)
2097 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2099 editMField(FloatValuesFieldMask, _mfFloatValues);
2101 int size = 3;
2102 for (int i = 0; i < size; ++i)
2103 _mfFloatValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2106 void ShaderStorageBufferObjChunk::setVec4(UInt32 handle, const Vec4f& value, UInt32 array_idx)
2108 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2110 editMField(FloatValuesFieldMask, _mfFloatValues);
2112 int size = 4;
2113 for (int i = 0; i < size; ++i)
2114 _mfFloatValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2117 void ShaderStorageBufferObjChunk::setVec4(UInt32 handle, const Pnt4f& value, UInt32 array_idx)
2119 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2121 editMField(FloatValuesFieldMask, _mfFloatValues);
2123 int size = 4;
2124 for (int i = 0; i < size; ++i)
2125 _mfFloatValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2128 void ShaderStorageBufferObjChunk::setVec4(UInt32 handle, const Color4f& value, UInt32 array_idx)
2130 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2132 editMField(FloatValuesFieldMask, _mfFloatValues);
2134 int size = 4;
2135 for (int i = 0; i < size; ++i)
2136 _mfFloatValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2139 void ShaderStorageBufferObjChunk::setDVec2(UInt32 handle, const Vec2d& value, UInt32 array_idx)
2141 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2143 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2145 int size = 2;
2146 for (int i = 0; i < size; ++i)
2147 _mfDoubleValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2150 void ShaderStorageBufferObjChunk::setDVec2(UInt32 handle, const Pnt2d& value, UInt32 array_idx)
2152 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2154 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2156 int size = 2;
2157 for (int i = 0; i < size; ++i)
2158 _mfDoubleValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2161 void ShaderStorageBufferObjChunk::setDVec3(UInt32 handle, const Vec3d& value, UInt32 array_idx)
2163 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2165 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2167 int size = 3;
2168 for (int i = 0; i < size; ++i)
2169 _mfDoubleValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2172 void ShaderStorageBufferObjChunk::setDVec3(UInt32 handle, const Pnt3d& value, UInt32 array_idx)
2174 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2176 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2178 int size = 3;
2179 for (int i = 0; i < size; ++i)
2180 _mfDoubleValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2183 void ShaderStorageBufferObjChunk::setDVec4(UInt32 handle, const Vec4d& value, UInt32 array_idx)
2185 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2187 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2189 int size = 4;
2190 for (int i = 0; i < size; ++i)
2191 _mfDoubleValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2194 void ShaderStorageBufferObjChunk::setDVec4(UInt32 handle, const Pnt4d& value, UInt32 array_idx)
2196 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2198 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2200 int size = 4;
2201 for (int i = 0; i < size; ++i)
2202 _mfDoubleValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2205 void ShaderStorageBufferObjChunk::setIVec2(UInt32 handle, const Vec2i& value, UInt32 array_idx)
2207 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2209 editMField(IntValuesFieldMask, _mfIntValues);
2211 int size = 2;
2212 for (int i = 0; i < size; ++i)
2213 _mfIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2216 void ShaderStorageBufferObjChunk::setIVec2(UInt32 handle, const Pnt2i& value, UInt32 array_idx)
2218 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2220 editMField(IntValuesFieldMask, _mfIntValues);
2222 int size = 2;
2223 for (int i = 0; i < size; ++i)
2224 _mfIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2227 void ShaderStorageBufferObjChunk::setIVec3(UInt32 handle, const Vec3i& value, UInt32 array_idx)
2229 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2231 editMField(IntValuesFieldMask, _mfIntValues);
2233 int size = 3;
2234 for (int i = 0; i < size; ++i)
2235 _mfIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2238 void ShaderStorageBufferObjChunk::setIVec3(UInt32 handle, const Pnt3i& value, UInt32 array_idx)
2240 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2242 editMField(IntValuesFieldMask, _mfIntValues);
2244 int size = 3;
2245 for (int i = 0; i < size; ++i)
2246 _mfIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2249 void ShaderStorageBufferObjChunk::setIVec4(UInt32 handle, const Vec4i& value, UInt32 array_idx)
2251 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2253 editMField(IntValuesFieldMask, _mfIntValues);
2255 int size = 4;
2256 for (int i = 0; i < size; ++i)
2257 _mfIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2260 void ShaderStorageBufferObjChunk::setIVec4(UInt32 handle, const Pnt4i& value, UInt32 array_idx)
2262 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2264 editMField(IntValuesFieldMask, _mfIntValues);
2266 int size = 4;
2267 for (int i = 0; i < size; ++i)
2268 _mfIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2271 void ShaderStorageBufferObjChunk::setUVec2(UInt32 handle, const Vec2u& value, UInt32 array_idx)
2273 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2275 editMField(UIntValuesFieldMask, _mfUIntValues);
2277 int size = 2;
2278 for (int i = 0; i < size; ++i)
2279 _mfUIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2282 void ShaderStorageBufferObjChunk::setUVec2(UInt32 handle, const Pnt2u& value, UInt32 array_idx)
2284 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2286 editMField(UIntValuesFieldMask, _mfUIntValues);
2288 int size = 2;
2289 for (int i = 0; i < size; ++i)
2290 _mfUIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2293 void ShaderStorageBufferObjChunk::setUVec3(UInt32 handle, const Vec3u& value, UInt32 array_idx)
2295 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2297 editMField(UIntValuesFieldMask, _mfUIntValues);
2299 int size = 3;
2300 for (int i = 0; i < size; ++i)
2301 _mfUIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2304 void ShaderStorageBufferObjChunk::setUVec3(UInt32 handle, const Pnt3u& value, UInt32 array_idx)
2306 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2308 editMField(UIntValuesFieldMask, _mfUIntValues);
2310 int size = 3;
2311 for (int i = 0; i < size; ++i)
2312 _mfUIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2315 void ShaderStorageBufferObjChunk::setUVec4(UInt32 handle, const Vec4u& value, UInt32 array_idx)
2317 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2319 editMField(UIntValuesFieldMask, _mfUIntValues);
2321 int size = 4;
2322 for (int i = 0; i < size; ++i)
2323 _mfUIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2326 void ShaderStorageBufferObjChunk::setUVec4(UInt32 handle, const Pnt4u& value, UInt32 array_idx)
2328 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2330 editMField(UIntValuesFieldMask, _mfUIntValues);
2332 int size = 4;
2333 for (int i = 0; i < size; ++i)
2334 _mfUIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2337 void ShaderStorageBufferObjChunk::setBVec2(UInt32 handle, const Vec2b& value, UInt32 array_idx)
2339 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2341 editMField(BoolValuesFieldMask, _mfBoolValues);
2343 int size = 2;
2344 for (int i = 0; i < size; ++i)
2345 _mfBoolValues[_mfIndex[handle] + (array_idx * size) + i] = static_cast<UInt8>(value[i]);
2348 void ShaderStorageBufferObjChunk::setBVec2(UInt32 handle, const Pnt2b& value, UInt32 array_idx)
2350 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2352 editMField(BoolValuesFieldMask, _mfBoolValues);
2354 int size = 2;
2355 for (int i = 0; i < size; ++i)
2356 _mfBoolValues[_mfIndex[handle] + (array_idx * size) + i] = static_cast<UInt8>(value[i]);
2359 void ShaderStorageBufferObjChunk::setBVec3(UInt32 handle, const Vec3b& value, UInt32 array_idx)
2361 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2363 editMField(BoolValuesFieldMask, _mfBoolValues);
2365 int size = 3;
2366 for (int i = 0; i < size; ++i)
2367 _mfBoolValues[_mfIndex[handle] + (array_idx * size) + i] = static_cast<UInt8>(value[i]);
2370 void ShaderStorageBufferObjChunk::setBVec3(UInt32 handle, const Pnt3b& value, UInt32 array_idx)
2372 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2374 editMField(BoolValuesFieldMask, _mfBoolValues);
2376 int size = 3;
2377 for (int i = 0; i < size; ++i)
2378 _mfBoolValues[_mfIndex[handle] + (array_idx * size) + i] = static_cast<UInt8>(value[i]);
2381 void ShaderStorageBufferObjChunk::setBVec4(UInt32 handle, const Vec4b& value, UInt32 array_idx)
2383 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2385 editMField(BoolValuesFieldMask, _mfBoolValues);
2387 int size = 4;
2388 for (int i = 0; i < size; ++i)
2389 _mfBoolValues[_mfIndex[handle] + (array_idx * size) + i] = static_cast<UInt8>(value[i]);
2392 void ShaderStorageBufferObjChunk::setBVec4(UInt32 handle, const Pnt4b& value, UInt32 array_idx)
2394 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2396 editMField(BoolValuesFieldMask, _mfBoolValues);
2398 int size = 4;
2399 for (int i = 0; i < size; ++i)
2400 _mfBoolValues[_mfIndex[handle] + (array_idx * size) + i] = static_cast<UInt8>(value[i]);
2403 void ShaderStorageBufferObjChunk::setMat2(UInt32 handle, const Matrix4f& value, UInt32 array_idx)
2405 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2407 editMField(FloatValuesFieldMask, _mfFloatValues);
2409 UInt8 columns = 2;
2410 UInt8 rows = 2;
2412 for (int i = 0; i < columns; ++i) {
2413 const Vec4f& v = value[i];
2414 for (int j = 0; j < rows; ++j) {
2415 _mfFloatValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2420 void ShaderStorageBufferObjChunk::setMat3(UInt32 handle, const Matrix4f& value, UInt32 array_idx)
2422 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2424 editMField(FloatValuesFieldMask, _mfFloatValues);
2426 UInt8 columns = 3;
2427 UInt8 rows = 3;
2429 for (int i = 0; i < columns; ++i) {
2430 const Vec4f& v = value[i];
2431 for (int j = 0; j < rows; ++j) {
2432 _mfFloatValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2437 void ShaderStorageBufferObjChunk::setMat4(UInt32 handle, const Matrix4f& value, UInt32 array_idx)
2439 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2441 editMField(FloatValuesFieldMask, _mfFloatValues);
2443 UInt8 columns = 4;
2444 UInt8 rows = 4;
2446 for (int i = 0; i < columns; ++i) {
2447 const Vec4f& v = value[i];
2448 for (int j = 0; j < rows; ++j) {
2449 _mfFloatValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2454 void ShaderStorageBufferObjChunk::setDMat2(UInt32 handle, const Matrix4d& value, UInt32 array_idx)
2456 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2458 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2460 UInt8 columns = 2;
2461 UInt8 rows = 2;
2463 for (int i = 0; i < columns; ++i) {
2464 const Vec4d& v = value[i];
2465 for (int j = 0; j < rows; ++j) {
2466 _mfDoubleValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2471 void ShaderStorageBufferObjChunk::setDMat3(UInt32 handle, const Matrix4d& value, UInt32 array_idx)
2473 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2475 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2477 UInt8 columns = 3;
2478 UInt8 rows = 3;
2480 for (int i = 0; i < columns; ++i) {
2481 const Vec4d& v = value[i];
2482 for (int j = 0; j < rows; ++j) {
2483 _mfDoubleValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2488 void ShaderStorageBufferObjChunk::setDMat4(UInt32 handle, const Matrix4d& value, UInt32 array_idx)
2490 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2492 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2494 UInt8 columns = 4;
2495 UInt8 rows = 4;
2497 for (int i = 0; i < columns; ++i) {
2498 const Vec4d& v = value[i];
2499 for (int j = 0; j < rows; ++j) {
2500 _mfDoubleValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2505 void ShaderStorageBufferObjChunk::setMat2x3(UInt32 handle, const Matrix4f& value, UInt32 array_idx)
2507 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2509 editMField(FloatValuesFieldMask, _mfFloatValues);
2511 UInt8 columns = 2;
2512 UInt8 rows = 3;
2514 for (int i = 0; i < columns; ++i) {
2515 const Vec4f& v = value[i];
2516 for (int j = 0; j < rows; ++j) {
2517 _mfFloatValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2522 void ShaderStorageBufferObjChunk::setMat3x2(UInt32 handle, const Matrix4f& value, UInt32 array_idx)
2524 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2526 editMField(FloatValuesFieldMask, _mfFloatValues);
2528 UInt8 columns = 3;
2529 UInt8 rows = 2;
2531 for (int i = 0; i < columns; ++i) {
2532 const Vec4f& v = value[i];
2533 for (int j = 0; j < rows; ++j) {
2534 _mfFloatValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2539 void ShaderStorageBufferObjChunk::setMat2x4(UInt32 handle, const Matrix4f& value, UInt32 array_idx)
2541 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2543 editMField(FloatValuesFieldMask, _mfFloatValues);
2545 UInt8 columns = 2;
2546 UInt8 rows = 4;
2548 for (int i = 0; i < columns; ++i) {
2549 const Vec4f& v = value[i];
2550 for (int j = 0; j < rows; ++j) {
2551 _mfFloatValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2556 void ShaderStorageBufferObjChunk::setMat4x2(UInt32 handle, const Matrix4f& value, UInt32 array_idx)
2558 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2560 editMField(FloatValuesFieldMask, _mfFloatValues);
2562 UInt8 columns = 4;
2563 UInt8 rows = 2;
2565 for (int i = 0; i < columns; ++i) {
2566 const Vec4f& v = value[i];
2567 for (int j = 0; j < rows; ++j) {
2568 _mfFloatValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2573 void ShaderStorageBufferObjChunk::setMat3x4(UInt32 handle, const Matrix4f& value, UInt32 array_idx)
2575 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2577 editMField(FloatValuesFieldMask, _mfFloatValues);
2579 UInt8 columns = 3;
2580 UInt8 rows = 4;
2582 for (int i = 0; i < columns; ++i) {
2583 const Vec4f& v = value[i];
2584 for (int j = 0; j < rows; ++j) {
2585 _mfFloatValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2590 void ShaderStorageBufferObjChunk::setMat4x3(UInt32 handle, const Matrix4f& value, UInt32 array_idx)
2592 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2594 editMField(FloatValuesFieldMask, _mfFloatValues);
2596 UInt8 columns = 4;
2597 UInt8 rows = 3;
2599 for (int i = 0; i < columns; ++i) {
2600 const Vec4f& v = value[i];
2601 for (int j = 0; j < rows; ++j) {
2602 _mfFloatValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2607 void ShaderStorageBufferObjChunk::setDMat2x3(UInt32 handle, const Matrix4d& value, UInt32 array_idx)
2609 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2611 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2613 UInt8 columns = 2;
2614 UInt8 rows = 3;
2616 for (int i = 0; i < columns; ++i) {
2617 const Vec4d& v = value[i];
2618 for (int j = 0; j < rows; ++j) {
2619 _mfDoubleValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2624 void ShaderStorageBufferObjChunk::setDMat3x2(UInt32 handle, const Matrix4d& value, UInt32 array_idx)
2626 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2628 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2630 UInt8 columns = 3;
2631 UInt8 rows = 2;
2633 for (int i = 0; i < columns; ++i) {
2634 const Vec4d& v = value[i];
2635 for (int j = 0; j < rows; ++j) {
2636 _mfDoubleValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2641 void ShaderStorageBufferObjChunk::setDMat2x4(UInt32 handle, const Matrix4d& value, UInt32 array_idx)
2643 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2645 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2647 UInt8 columns = 2;
2648 UInt8 rows = 4;
2650 for (int i = 0; i < columns; ++i) {
2651 const Vec4d& v = value[i];
2652 for (int j = 0; j < rows; ++j) {
2653 _mfDoubleValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2658 void ShaderStorageBufferObjChunk::setDMat4x2(UInt32 handle, const Matrix4d& value, UInt32 array_idx)
2660 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2662 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2664 UInt8 columns = 4;
2665 UInt8 rows = 2;
2667 for (int i = 0; i < columns; ++i) {
2668 const Vec4d& v = value[i];
2669 for (int j = 0; j < rows; ++j) {
2670 _mfDoubleValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2675 void ShaderStorageBufferObjChunk::setDMat3x4(UInt32 handle, const Matrix4d& value, UInt32 array_idx)
2677 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2679 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2681 UInt8 columns = 3;
2682 UInt8 rows = 4;
2684 for (int i = 0; i < columns; ++i) {
2685 const Vec4d& v = value[i];
2686 for (int j = 0; j < rows; ++j) {
2687 _mfDoubleValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2692 void ShaderStorageBufferObjChunk::setDMat4x3(UInt32 handle, const Matrix4d& value, UInt32 array_idx)
2694 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2696 editMField(DoubleValuesFieldMask, _mfDoubleValues);
2698 UInt8 columns = 4;
2699 UInt8 rows = 3;
2701 for (int i = 0; i < columns; ++i) {
2702 const Vec4d& v = value[i];
2703 for (int j = 0; j < rows; ++j) {
2704 _mfDoubleValues[_mfIndex[handle] + (array_idx * rows * columns) + (j + rows * i)] = v[j];
2709 /*------------------------------ set-interface II ---------------------------*/
2711 void ShaderStorageBufferObjChunk::setFloat(const std::string& name, Real32 value, UInt32 array_idx)
2713 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2714 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2715 setFloat(iter->second, value, array_idx);
2718 void ShaderStorageBufferObjChunk::setDouble(const std::string& name, Real64 value, UInt32 array_idx)
2720 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2721 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2722 setDouble(iter->second, value, array_idx);
2725 void ShaderStorageBufferObjChunk::setInt(const std::string& name, Int32 value, UInt32 array_idx)
2727 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2728 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2729 setInt(iter->second, value, array_idx);
2732 void ShaderStorageBufferObjChunk::setUInt(const std::string& name, UInt32 value, UInt32 array_idx)
2734 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2735 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2736 setUInt(iter->second, value, array_idx);
2739 void ShaderStorageBufferObjChunk::setBool(const std::string& name, bool value, UInt32 array_idx)
2741 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2742 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2743 setBool(iter->second, value, array_idx);
2746 void ShaderStorageBufferObjChunk::setVec2(const std::string& name, const Vec2f& value, UInt32 array_idx)
2748 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2749 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2750 setVec2(iter->second, value, array_idx);
2753 void ShaderStorageBufferObjChunk::setVec2(const std::string& name, const Pnt2f& value, UInt32 array_idx)
2755 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2756 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2757 setVec2(iter->second, value, array_idx);
2760 void ShaderStorageBufferObjChunk::setVec3(const std::string& name, const Vec3f& value, UInt32 array_idx)
2762 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2763 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2764 setVec3(iter->second, value, array_idx);
2767 void ShaderStorageBufferObjChunk::setVec3(const std::string& name, const Pnt3f& value, UInt32 array_idx)
2769 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2770 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2771 setVec3(iter->second, value, array_idx);
2774 void ShaderStorageBufferObjChunk::setVec3(const std::string& name, const Color3f& value, UInt32 array_idx)
2776 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2777 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2778 setVec3(iter->second, value, array_idx);
2781 void ShaderStorageBufferObjChunk::setVec4(const std::string& name, const Vec4f& value, UInt32 array_idx)
2783 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2784 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2785 setVec4(iter->second, value, array_idx);
2788 void ShaderStorageBufferObjChunk::setVec4(const std::string& name, const Pnt4f& value, UInt32 array_idx)
2790 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2791 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2792 setVec4(iter->second, value, array_idx);
2795 void ShaderStorageBufferObjChunk::setVec4(const std::string& name, const Color4f& value, UInt32 array_idx)
2797 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2798 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2799 setVec4(iter->second, value, array_idx);
2802 void ShaderStorageBufferObjChunk::setDVec2(const std::string& name, const Vec2d& value, UInt32 array_idx)
2804 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2805 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2806 setDVec2(iter->second, value, array_idx);
2809 void ShaderStorageBufferObjChunk::setDVec2(const std::string& name, const Pnt2d& value, UInt32 array_idx)
2811 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2812 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2813 setDVec2(iter->second, value, array_idx);
2816 void ShaderStorageBufferObjChunk::setDVec3(const std::string& name, const Vec3d& value, UInt32 array_idx)
2818 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2819 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2820 setDVec3(iter->second, value, array_idx);
2823 void ShaderStorageBufferObjChunk::setDVec3(const std::string& name, const Pnt3d& value, UInt32 array_idx)
2825 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2826 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2827 setDVec3(iter->second, value, array_idx);
2830 void ShaderStorageBufferObjChunk::setDVec4(const std::string& name, const Vec4d& value, UInt32 array_idx)
2832 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2833 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2834 setDVec4(iter->second, value, array_idx);
2837 void ShaderStorageBufferObjChunk::setDVec4(const std::string& name, const Pnt4d& value, UInt32 array_idx)
2839 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2840 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2841 setDVec4(iter->second, value, array_idx);
2844 void ShaderStorageBufferObjChunk::setIVec2(const std::string& name, const Vec2i& value, UInt32 array_idx)
2846 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2847 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2848 setIVec2(iter->second, value, array_idx);
2851 void ShaderStorageBufferObjChunk::setIVec2(const std::string& name, const Pnt2i& value, UInt32 array_idx)
2853 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2854 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2855 setIVec2(iter->second, value, array_idx);
2858 void ShaderStorageBufferObjChunk::setIVec3(const std::string& name, const Vec3i& value, UInt32 array_idx)
2860 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2861 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2862 setIVec3(iter->second, value, array_idx);
2865 void ShaderStorageBufferObjChunk::setIVec3(const std::string& name, const Pnt3i& value, UInt32 array_idx)
2867 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2868 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2869 setIVec3(iter->second, value, array_idx);
2872 void ShaderStorageBufferObjChunk::setIVec4(const std::string& name, const Vec4i& value, UInt32 array_idx)
2874 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2875 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2876 setIVec4(iter->second, value, array_idx);
2879 void ShaderStorageBufferObjChunk::setIVec4(const std::string& name, const Pnt4i& value, UInt32 array_idx)
2881 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2882 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2883 setIVec4(iter->second, value, array_idx);
2886 void ShaderStorageBufferObjChunk::setUVec2(const std::string& name, const Vec2u& value, UInt32 array_idx)
2888 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2889 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2890 setUVec2(iter->second, value, array_idx);
2893 void ShaderStorageBufferObjChunk::setUVec2(const std::string& name, const Pnt2u& value, UInt32 array_idx)
2895 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2896 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2897 setUVec2(iter->second, value, array_idx);
2900 void ShaderStorageBufferObjChunk::setUVec3(const std::string& name, const Vec3u& value, UInt32 array_idx)
2902 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2903 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2904 setUVec3(iter->second, value, array_idx);
2907 void ShaderStorageBufferObjChunk::setUVec3(const std::string& name, const Pnt3u& value, UInt32 array_idx)
2909 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2910 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2911 setUVec3(iter->second, value, array_idx);
2914 void ShaderStorageBufferObjChunk::setUVec4(const std::string& name, const Vec4u& value, UInt32 array_idx)
2916 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2917 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2918 setUVec4(iter->second, value, array_idx);
2921 void ShaderStorageBufferObjChunk::setUVec4(const std::string& name, const Pnt4u& value, UInt32 array_idx)
2923 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2924 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2925 setUVec4(iter->second, value, array_idx);
2928 void ShaderStorageBufferObjChunk::setBVec2(const std::string& name, const Vec2b& value, UInt32 array_idx)
2930 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2931 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2932 setBVec2(iter->second, value, array_idx);
2935 void ShaderStorageBufferObjChunk::setBVec2(const std::string& name, const Pnt2b& value, UInt32 array_idx)
2937 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2938 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2939 setBVec2(iter->second, value, array_idx);
2942 void ShaderStorageBufferObjChunk::setBVec3(const std::string& name, const Vec3b& value, UInt32 array_idx)
2944 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2945 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2946 setBVec3(iter->second, value, array_idx);
2949 void ShaderStorageBufferObjChunk::setBVec3(const std::string& name, const Pnt3b& value, UInt32 array_idx)
2951 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2952 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2953 setBVec3(iter->second, value, array_idx);
2956 void ShaderStorageBufferObjChunk::setBVec4(const std::string& name, const Vec4b& value, UInt32 array_idx)
2958 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2959 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2960 setBVec4(iter->second, value, array_idx);
2963 void ShaderStorageBufferObjChunk::setBVec4(const std::string& name, const Pnt4b& value, UInt32 array_idx)
2965 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2966 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2967 setBVec4(iter->second, value, array_idx);
2970 void ShaderStorageBufferObjChunk::setMat2(const std::string& name, const Matrix4f& value, UInt32 array_idx)
2972 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2973 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2974 setMat2(iter->second, value, array_idx);
2977 void ShaderStorageBufferObjChunk::setMat3(const std::string& name, const Matrix4f& value, UInt32 array_idx)
2979 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2980 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2981 setMat3(iter->second, value, array_idx);
2984 void ShaderStorageBufferObjChunk::setMat4(const std::string& name, const Matrix4f& value, UInt32 array_idx)
2986 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2987 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2988 setMat4(iter->second, value, array_idx);
2991 void ShaderStorageBufferObjChunk::setDMat2(const std::string& name, const Matrix4d& value, UInt32 array_idx)
2993 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2994 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2995 setDMat2(iter->second, value, array_idx);
2998 void ShaderStorageBufferObjChunk::setDMat3(const std::string& name, const Matrix4d& value, UInt32 array_idx)
3000 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3001 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3002 setDMat3(iter->second, value, array_idx);
3005 void ShaderStorageBufferObjChunk::setDMat4(const std::string& name, const Matrix4d& value, UInt32 array_idx)
3007 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3008 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3009 setDMat4(iter->second, value, array_idx);
3012 void ShaderStorageBufferObjChunk::setMat2x3(const std::string& name, const Matrix4f& value, UInt32 array_idx)
3014 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3015 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3016 setMat2x3(iter->second, value, array_idx);
3019 void ShaderStorageBufferObjChunk::setMat3x2(const std::string& name, const Matrix4f& value, UInt32 array_idx)
3021 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3022 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3023 setMat3x2(iter->second, value, array_idx);
3026 void ShaderStorageBufferObjChunk::setMat2x4(const std::string& name, const Matrix4f& value, UInt32 array_idx)
3028 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3029 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3030 setMat2x4(iter->second, value, array_idx);
3033 void ShaderStorageBufferObjChunk::setMat4x2(const std::string& name, const Matrix4f& value, UInt32 array_idx)
3035 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3036 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3037 setMat4x2(iter->second, value, array_idx);
3040 void ShaderStorageBufferObjChunk::setMat3x4(const std::string& name, const Matrix4f& value, UInt32 array_idx)
3042 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3043 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3044 setMat3x4(iter->second, value, array_idx);
3047 void ShaderStorageBufferObjChunk::setMat4x3(const std::string& name, const Matrix4f& value, UInt32 array_idx)
3049 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3050 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3051 setMat4x3(iter->second, value, array_idx);
3054 void ShaderStorageBufferObjChunk::setDMat2x3(const std::string& name, const Matrix4d& value, UInt32 array_idx)
3056 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3057 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3058 setDMat2x3(iter->second, value, array_idx);
3061 void ShaderStorageBufferObjChunk::setDMat3x2(const std::string& name, const Matrix4d& value, UInt32 array_idx)
3063 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3064 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3065 setDMat3x2(iter->second, value, array_idx);
3068 void ShaderStorageBufferObjChunk::setDMat2x4(const std::string& name, const Matrix4d& value, UInt32 array_idx)
3070 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3071 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3072 setDMat2x4(iter->second, value, array_idx);
3075 void ShaderStorageBufferObjChunk::setDMat4x2(const std::string& name, const Matrix4d& value, UInt32 array_idx)
3077 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3078 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3079 setDMat4x2(iter->second, value, array_idx);
3082 void ShaderStorageBufferObjChunk::setDMat3x4(const std::string& name, const Matrix4d& value, UInt32 array_idx)
3084 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3085 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3086 setDMat3x4(iter->second, value, array_idx);
3089 void ShaderStorageBufferObjChunk::setDMat4x3(const std::string& name, const Matrix4d& value, UInt32 array_idx)
3091 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
3092 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
3093 setDMat4x3(iter->second, value, array_idx);
3096 /*------------------------------ Invariants ---------------------------------*/
3098 bool ShaderStorageBufferObjChunk::invariantOnStorageSize()
3100 std::size_t sz = _mfFundamentalTypes.size();
3101 if (sz != _mfMainTypes .size() ||
3102 sz != _mfCardinality.size() ||
3103 sz != _mfIndex .size() ||
3104 sz != _mfNames .size() ||
3105 sz != _sfNameToIndex.getValue().size()
3106 ) return false;
3107 return true;
3110 OSG_END_NAMESPACE