OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BufferObject.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  * Copyright (C) 2012 David Callu
3  *
4  * This library is open source and may be redistributed and/or modified under
5  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6  * (at your option) any later version. The full license is in LICENSE file
7  * included with this distribution, and on the openscenegraph.org website.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * OpenSceneGraph Public License for more details.
13 */
14 
15 #ifndef OSG_BUFFEROBJECT
16 #define OSG_BUFFEROBJECT 1
17 
18 #include <osg/GL>
19 #include <osg/GLExtensions>
20 #include <osg/Object>
21 #include <osg/buffered_value>
22 #include <osg/FrameStamp>
23 
24 #include <iosfwd>
25 #include <list>
26 #include <map>
27 
28 #ifndef GL_ARB_vertex_buffer_object
29  #define GL_ARRAY_BUFFER_ARB 0x8892
30  #define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
31  #define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
32  #define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
33  #define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
34  #define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
35  #define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
36  #define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
37  #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
38  #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
39  #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
40  #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
41  #define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
42  #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
43  #define GL_STREAM_DRAW_ARB 0x88E0
44  #define GL_STREAM_READ_ARB 0x88E1
45  #define GL_STREAM_COPY_ARB 0x88E2
46  #define GL_STATIC_DRAW_ARB 0x88E4
47  #define GL_STATIC_READ_ARB 0x88E5
48  #define GL_STATIC_COPY_ARB 0x88E6
49  #define GL_DYNAMIC_DRAW_ARB 0x88E8
50  #define GL_DYNAMIC_READ_ARB 0x88E9
51  #define GL_DYNAMIC_COPY_ARB 0x88EA
52  #define GL_READ_ONLY_ARB 0x88B8
53  #define GL_WRITE_ONLY_ARB 0x88B9
54  #define GL_READ_WRITE_ARB 0x88BA
55  #define GL_BUFFER_SIZE_ARB 0x8764
56  #define GL_BUFFER_USAGE_ARB 0x8765
57  #define GL_BUFFER_ACCESS_ARB 0x88BB
58  #define GL_BUFFER_MAPPED_ARB 0x88BC
59  #define GL_BUFFER_MAP_POINTER_ARB 0x88BD
60 #endif
61 
62 #ifndef GL_VERSION_1_5
63  #define GL_STREAM_DRAW 0x88E0
64  #define GL_STREAM_READ 0x88E1
65  #define GL_STREAM_COPY 0x88E2
66  #define GL_STATIC_DRAW 0x88E4
67  #define GL_STATIC_READ 0x88E5
68  #define GL_STATIC_COPY 0x88E6
69  #define GL_DYNAMIC_DRAW 0x88E8
70  #define GL_DYNAMIC_READ 0x88E9
71  #define GL_DYNAMIC_COPY 0x88EA
72 #endif
73 
74 #ifndef GL_VERSION_2_1
75  #define GL_PIXEL_PACK_BUFFER 0x88EB
76  #define GL_PIXEL_UNPACK_BUFFER 0x88EC
77  #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
78  #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
79 #endif
80 
81 
82 #ifndef GL_ARB_pixel_buffer_object
83  #define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
84  #define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
85  #define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
86  #define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
87 #endif
88 
89 namespace osg
90 {
91 
92 class State;
93 class BufferData;
94 class BufferObject;
95 
97 {
98  public:
100  _target(0),
101  _usage(0),
102  _size(0) {}
103 
104  BufferObjectProfile(GLenum target, GLenum usage, unsigned int size):
105  _target(target),
106  _usage(usage),
107  _size(size) {}
108 
110  _target(bpo._target),
111  _usage(bpo._usage),
112  _size(bpo._size) {}
113 
114  bool operator < (const BufferObjectProfile& rhs) const
115  {
116  if (_target < rhs._target) return true;
117  else if (_target > rhs._target) return false;
118  if (_usage < rhs._usage) return true;
119  else if (_usage > rhs._usage) return false;
120  return _size < rhs._size;
121  }
122 
123  bool operator == (const BufferObjectProfile& rhs) const
124  {
125  return (_target == rhs._target) &&
126  (_usage == rhs._usage) &&
127  (_size == rhs._size);
128  }
129 
130  void setProfile(GLenum target, GLenum usage, unsigned int size)
131  {
132  _target = target;
133  _usage = usage;
134  _size = size;
135  }
136 
138  {
139  _target = rhs._target;
140  _usage = rhs._usage;
141  _size = rhs._size;
142  return *this;
143  }
144 
145  GLenum _target;
146  GLenum _usage;
147  GLenum _size;
148 };
149 
150 // forward declare
151 class GLBufferObjectSet;
153 
155 {
156  public:
157 
158  GLBufferObject(unsigned int contextID, BufferObject* bufferObject, unsigned int glObjectID=0);
159 
160  void setProfile(const BufferObjectProfile& profile) { _profile = profile; }
161  const BufferObjectProfile& getProfile() const { return _profile; }
162 
163  void setBufferObject(BufferObject* bufferObject);
164  BufferObject* getBufferObject() { return _bufferObject; }
165 
166  struct BufferEntry
167  {
168  BufferEntry(): numRead(0), modifiedCount(0),dataSize(0),offset(0),dataSource(0) {}
169 
171  numRead(rhs.numRead),
172  modifiedCount(rhs.modifiedCount),
173  dataSize(rhs.dataSize),
174  offset(rhs.offset),
175  dataSource(rhs.dataSource) {}
176 
177  BufferEntry& operator = (const BufferEntry& rhs)
178  {
179  if (&rhs==this) return *this;
180  numRead = rhs.numRead;
181  modifiedCount = rhs.modifiedCount;
182  dataSize = rhs.dataSize;
183  offset = rhs.offset;
184  dataSource = rhs.dataSource;
185  return *this;
186  }
187 
188  unsigned int getNumClients() const;
189 
190  unsigned int numRead;
191  unsigned int modifiedCount;
192  unsigned int dataSize;
193  unsigned int offset;
195  };
196 
197  inline unsigned int getContextID() const { return _contextID; }
198 
199  inline GLuint& getGLObjectID() { return _glObjectID; }
200  inline GLuint getGLObjectID() const { return _glObjectID; }
201  inline GLsizeiptr getOffset(unsigned int i) const { return _bufferEntries[i].offset; }
202 
203  inline void bindBuffer();
204 
205  inline void unbindBuffer()
206  {
207  _extensions->glBindBuffer(_profile._target,0);
208  }
209 
210  inline bool isDirty() const { return _dirty; }
211 
212  void dirty() { _dirty = true; }
213 
214  void clear();
215 
216  void compileBuffer();
217 
218  void deleteGLObject();
219 
220  void assign(BufferObject* bufferObject);
221 
222  bool isPBOSupported() const { return _extensions->isPBOSupported; }
223 
224  static osg::ref_ptr<GLBufferObject> createGLBufferObject(unsigned int contextID, const BufferObject* bufferObject);
225 
226  static void deleteAllBufferObjects(unsigned int contextID);
227  static void discardAllBufferObjects(unsigned int contextID);
228  static void flushAllDeletedBufferObjects(unsigned int contextID);
229  static void discardAllDeletedBufferObjects(unsigned int contextID);
230  static void flushDeletedBufferObjects(unsigned int contextID,double currentTime, double& availbleTime);
231  static void releaseGLBufferObject(unsigned int contextID, GLBufferObject* to);
232 
233  bool hasAllBufferDataBeenRead() const;
234 
235  void setBufferDataHasBeenRead(const osg::BufferData* bd);
236 
237  protected:
238 
239  virtual ~GLBufferObject();
240 
241  unsigned int computeBufferAlignment(unsigned int pos, unsigned int bufferAlignment) const
242  {
243  if (bufferAlignment<2) return pos;
244  if ((pos%bufferAlignment)==0) return pos;
245  return ((pos/bufferAlignment)+1)*bufferAlignment;
246  }
247 
248  unsigned int _contextID;
249  GLuint _glObjectID;
250 
252  unsigned int _allocatedSize;
253 
254  bool _dirty;
255 
256  typedef std::vector<BufferEntry> BufferEntries;
257  BufferEntries _bufferEntries;
258 
260 
261  public:
262 
266  unsigned int _frameLastUsed;
267 
268  public:
270 
271 };
272 
273 typedef std::list< ref_ptr<GLBufferObject> > GLBufferObjectList;
274 
276 {
277  public:
279 
280  const BufferObjectProfile& getProfile() const { return _profile; }
281 
282  void handlePendingOrphandedGLBufferObjects();
283 
284  void deleteAllGLBufferObjects();
285  void discardAllGLBufferObjects();
286  void flushAllDeletedGLBufferObjects();
287  void discardAllDeletedGLBufferObjects();
288  void flushDeletedGLBufferObjects(double currentTime, double& availableTime);
289 
290  osg::ref_ptr<GLBufferObject> takeFromOrphans(BufferObject* bufferObject);
291  osg::ref_ptr<GLBufferObject> takeOrGenerate(BufferObject* bufferObject);
292 
293  void moveToBack(GLBufferObject* to);
294  void addToBack(GLBufferObject* to);
295  void orphan(GLBufferObject* to);
296  void remove(GLBufferObject* to);
297  void moveToSet(GLBufferObject* to, GLBufferObjectSet* set);
298 
299  unsigned int size() const { return _profile._size * _numOfGLBufferObjects; }
300 
301  bool makeSpace(unsigned int& size);
302 
303  bool checkConsistency() const;
304 
305  GLBufferObjectManager* getParent() { return _parent; }
306 
307  unsigned int computeNumGLBufferObjectsInList() const;
308  unsigned int getNumOfGLBufferObjects() const { return _numOfGLBufferObjects; }
309  unsigned int getNumOrphans() const { return static_cast<unsigned int>(_orphanedGLBufferObjects.size()); }
310  unsigned int getNumPendingOrphans() const { return static_cast<unsigned int>(_pendingOrphanedGLBufferObjects.size()); }
311 
312 
313  protected:
314 
315  virtual ~GLBufferObjectSet();
316 
318 
320  unsigned int _contextID;
322  unsigned int _numOfGLBufferObjects;
323  GLBufferObjectList _orphanedGLBufferObjects;
325 
328 };
329 
331 {
332  public:
333  GLBufferObjectManager(unsigned int contextID);
334 
335  unsigned int getContextID() const { return _contextID; }
336 
337 
338  void setNumberActiveGLBufferObjects(unsigned int size) { _numActiveGLBufferObjects = size; }
339  unsigned int& getNumberActiveGLBufferObjects() { return _numActiveGLBufferObjects; }
340  unsigned int getNumberActiveGLBufferObjects() const { return _numActiveGLBufferObjects; }
341 
342  void setNumberOrphanedGLBufferObjects(unsigned int size) { _numOrphanedGLBufferObjects = size; }
343  unsigned int& getNumberOrphanedGLBufferObjects() { return _numOrphanedGLBufferObjects; }
344  unsigned int getNumberOrphanedGLBufferObjects() const { return _numOrphanedGLBufferObjects; }
345 
346  void setCurrGLBufferObjectPoolSize(unsigned int size) { _currGLBufferObjectPoolSize = size; }
347  unsigned int& getCurrGLBufferObjectPoolSize() { return _currGLBufferObjectPoolSize; }
348  unsigned int getCurrGLBufferObjectPoolSize() const { return _currGLBufferObjectPoolSize; }
349 
350  void setMaxGLBufferObjectPoolSize(unsigned int size);
351  unsigned int getMaxGLBufferObjectPoolSize() const { return _maxGLBufferObjectPoolSize; }
352 
353  bool hasSpace(unsigned int size) const { return (_currGLBufferObjectPoolSize+size)<=_maxGLBufferObjectPoolSize; }
354  bool makeSpace(unsigned int size);
355 
356  osg::ref_ptr<GLBufferObject> generateGLBufferObject(const osg::BufferObject* bufferObject);
357 
358  void handlePendingOrphandedGLBufferObjects();
359 
360  void deleteAllGLBufferObjects();
361  void discardAllGLBufferObjects();
362  void flushAllDeletedGLBufferObjects();
363  void discardAllDeletedGLBufferObjects();
364  void flushDeletedGLBufferObjects(double currentTime, double& availableTime);
365  void releaseGLBufferObject(GLBufferObject* to);
366 
367  GLBufferObjectSet* getGLBufferObjectSet(const BufferObjectProfile& profile);
368 
369  void newFrame(osg::FrameStamp* fs);
370  void resetStats();
371  void reportStats(std::ostream& out);
372  void recomputeStats(std::ostream& out);
373 
374  unsigned int& getFrameNumber() { return _frameNumber; }
375  unsigned int& getNumberFrames() { return _numFrames; }
376 
377  unsigned int& getNumberDeleted() { return _numDeleted; }
378  double& getDeleteTime() { return _deleteTime; }
379 
380  unsigned int& getNumberGenerated() { return _numGenerated; }
381  double& getGenerateTime() { return _generateTime; }
382 
383  unsigned int& getNumberApplied() { return _numApplied; }
384  double& getApplyTime() { return _applyTime; }
385 
386  static osg::ref_ptr<GLBufferObjectManager>& getGLBufferObjectManager(unsigned int contextID);
387 
388  protected:
389 
390  typedef std::map< BufferObjectProfile, osg::ref_ptr<GLBufferObjectSet> > GLBufferObjectSetMap;
391  unsigned int _contextID;
396  GLBufferObjectSetMap _glBufferObjectSetMap;
397 
398  unsigned int _frameNumber;
399 
400  unsigned int _numFrames;
401  unsigned int _numDeleted;
402  double _deleteTime;
403 
404  unsigned int _numGenerated;
406 
407  unsigned int _numApplied;
408  double _applyTime;
409 
410 };
411 
412 
414 {
415  public:
416 
417  BufferObject();
418 
420  BufferObject(const BufferObject& bo,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
421 
422  virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const BufferObject*>(obj)!=NULL; }
423  virtual const char* libraryName() const { return "osg"; }
424  virtual const char* className() const { return "BufferObject"; }
425 
426  void setTarget(GLenum target) { _profile._target = target; }
427  GLenum getTarget() const { return _profile._target; }
428 
434  void setUsage(GLenum usage) { _profile._usage = usage; }
435 
437  GLenum getUsage() const { return _profile._usage; }
438 
439  BufferObjectProfile& getProfile() { return _profile; }
440  const BufferObjectProfile& getProfile() const { return _profile; }
441 
442 
444  void setCopyDataAndReleaseGLBufferObject(bool copyAndRelease) { _copyDataAndReleaseGLBufferObject = copyAndRelease; }
445 
447  bool getCopyDataAndReleaseGLBufferObject() const { return _copyDataAndReleaseGLBufferObject; }
448 
449 
450  void dirty();
451 
453  virtual void resizeGLObjectBuffers(unsigned int maxSize);
454 
458  void releaseGLObjects(State* state=0) const;
459 
460  unsigned int addBufferData(BufferData* bd);
461  void removeBufferData(unsigned int index);
462  void removeBufferData(BufferData* bd);
463 
464  void setBufferData(unsigned int index, BufferData* bd);
465  BufferData* getBufferData(unsigned int index) { return _bufferDataList[index]; }
466  const BufferData* getBufferData(unsigned int index) const { return _bufferDataList[index]; }
467 
468  unsigned int getNumBufferData() const { return static_cast<unsigned int>(_bufferDataList.size()); }
469 
470  void setGLBufferObject(unsigned int contextID, GLBufferObject* glbo) { _glBufferObjects[contextID] = glbo; }
471 
472  GLBufferObject* getGLBufferObject(unsigned int contextID) const { return _glBufferObjects[contextID].get(); }
473 
474  GLBufferObject* getOrCreateGLBufferObject(unsigned int contextID) const
475  {
476  if (!_glBufferObjects[contextID]) _glBufferObjects[contextID] = GLBufferObject::createGLBufferObject(contextID, this);
477  return _glBufferObjects[contextID].get();
478  }
479 
480  unsigned int computeRequiredBufferSize() const;
481 
483  static void deleteBufferObject(unsigned int contextID,GLuint globj);
484 
485  protected:
486 
487  ~BufferObject();
488 
489  typedef std::vector< BufferData* > BufferDataList;
491 
493 
495 
496  BufferDataList _bufferDataList;
497 
498  mutable GLBufferObjects _glBufferObjects;
499 };
500 
502 {
503  public:
504 
506  Object(true),
507  _modifiedCount(0),
508  _bufferIndex(0),
509  _numClients(0) {}
510 
513  osg::Object(bd,copyop),
514  _modifiedCount(0),
515  _bufferIndex(0),
516  _modifiedCallback(bd._modifiedCallback),
517  _numClients(0) {}
518 
519  virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const BufferData*>(obj)!=NULL; }
520  virtual const char* libraryName() const { return "osg"; }
521  virtual const char* className() const { return "BufferData"; }
522 
523  virtual const GLvoid* getDataPointer() const = 0;
524  virtual unsigned int getTotalDataSize() const = 0;
525 
526  virtual osg::Array* asArray() { return 0; }
527  virtual const osg::Array* asArray() const { return 0; }
528 
529  virtual osg::PrimitiveSet* asPrimitiveSet() { return 0; }
530  virtual const osg::PrimitiveSet* asPrimitiveSet() const { return 0; }
531 
532  virtual osg::Image* asImage() { return 0; }
533  virtual const osg::Image* asImage() const { return 0; }
534 
535  void setBufferObject(BufferObject* bufferObject);
536  BufferObject* getBufferObject() { return _bufferObject.get(); }
537  const BufferObject* getBufferObject() const { return _bufferObject.get(); }
538 
539  void setBufferIndex(unsigned int index) { _bufferIndex = index; }
540  unsigned int getBufferIndex() const { return _bufferIndex; }
541 
542  GLBufferObject* getGLBufferObject(unsigned int contextID) const { return _bufferObject.valid() ? _bufferObject->getGLBufferObject(contextID) : 0; }
543  GLBufferObject* getOrCreateGLBufferObject(unsigned int contextID) const { return _bufferObject.valid() ? _bufferObject->getOrCreateGLBufferObject(contextID) : 0; }
544 
545  struct ModifiedCallback : public virtual osg::Object
546  {
548 
550 
552 
553  virtual void modified(BufferData* /*bufferData*/) const {}
554  };
555 
556  void setModifiedCallback(ModifiedCallback* md) { _modifiedCallback = md; }
557  ModifiedCallback* getModifiedCallback() { return _modifiedCallback.get(); }
558  const ModifiedCallback* getModifiedCallback() const { return _modifiedCallback.get(); }
559 
562  inline void dirty()
563  {
564  ++_modifiedCount;
565  if (_modifiedCallback.valid()) _modifiedCallback->modified(this);
566  if (_bufferObject.valid()) _bufferObject->dirty();
567  }
568 
570  inline void setModifiedCount(unsigned int value) { _modifiedCount=value; }
571 
573  inline unsigned int getModifiedCount() const { return _modifiedCount; }
574 
576  virtual void resizeGLObjectBuffers(unsigned int maxSize);
577 
581  void releaseGLObjects(State* state=0) const;
582 
583  unsigned int getNumClients() const { return _numClients; }
584 
585  void addClient(osg::Object * /*client*/) { ++_numClients; }
586 
587  void removeClient(osg::Object * /*client*/) { --_numClients; }
588 
589 protected:
590 
591  virtual ~BufferData();
592 
593  unsigned int _modifiedCount;
594 
595  unsigned int _bufferIndex;
598 
599  unsigned int _numClients;
600 };
601 
602 
603 class Array;
605 {
606  public:
607 
609 
612 
614 
615  unsigned int addArray(osg::Array* array);
616  void removeArray(osg::Array* array);
617 
618  void setArray(unsigned int i, Array* array);
619  Array* getArray(unsigned int i);
620  const Array* getArray(unsigned int i) const;
621 
622  protected:
623  virtual ~VertexBufferObject();
624 };
625 
626 class DrawElements;
628 {
629  public:
630 
632 
635 
637 
638  unsigned int addDrawElements(osg::DrawElements* PrimitiveSet);
639  void removeDrawElements(osg::DrawElements* PrimitiveSet);
640 
641  void setDrawElements(unsigned int i, DrawElements* PrimitiveSet);
642  DrawElements* getDrawElements(unsigned int i);
643  const DrawElements* getDrawElements(unsigned int i) const;
644 
645  protected:
646 
647  virtual ~ElementBufferObject();
648 };
649 
650 class Image;
652 {
653  public:
654 
655  PixelBufferObject(osg::Image* image=0);
656 
659 
661 
662  void setImage(osg::Image* image);
663 
664  Image* getImage();
665  const Image* getImage() const;
666 
667  bool isPBOSupported(unsigned int contextID) const { return _glBufferObjects[contextID]->isPBOSupported(); }
668 
669  protected:
670 
671  virtual ~PixelBufferObject();
672 };
673 
681 {
682  public:
685 
687 
689  inline void setDataSize(unsigned int size) { _profile._size = size; dirty(); }
690 
692  inline unsigned int getDataSize() const { return _profile._size; }
693 
695  virtual void compileBuffer(State& state) const;
696 
698  virtual void bindBufferInReadMode(State& state);
699 
701  virtual void bindBufferInWriteMode(State& state);
702 
704  virtual void unbindBuffer(unsigned int contextID) const;
705 
707  virtual void resizeGLObjectBuffers(unsigned int maxSize);
708 
709  enum Mode
710  {
712  NONE = 0,
713 
715  READ = 1,
716 
718  WRITE = 2
719  };
720 
721  Mode getMode(unsigned int contextID) const { return (Mode)_mode[contextID]; }
722 
723  protected:
724 
725  virtual ~PixelDataBufferObject();
726 
728 
729  mutable ModeList _mode;
730 
731 };
732 
733 
735 {
736  public:
740  protected:
741  virtual ~UniformBufferObject();
742 };
743 
745 {
746  public:
750 
751  protected:
752  virtual ~AtomicCounterBufferObject();
753 };
754 
756 {
757  _extensions->glBindBuffer(_profile._target,_glObjectID);
758  if (_set) _set->moveToBack(this);
759 }
760 
761 
763 {
764  public:
765 
769  protected:
770  virtual ~ShaderStorageBufferObject();
771 };
772 
773 
774 
775 }
776 
777 #endif
unsigned int _contextID
Definition: BufferObject.h:320
#define OSG_EXPORT
Definition: Export.h:43
void setCurrGLBufferObjectPoolSize(unsigned int size)
Definition: BufferObject.h:346
unsigned int _allocatedSize
Definition: BufferObject.h:252
virtual const osg::Array * asArray() const
Definition: BufferObject.h:527
void setDataSize(unsigned int size)
Set new size of the buffer object. This will reallocate the memory on the next compile.
Definition: BufferObject.h:689
GLBufferObject * getGLBufferObject(unsigned int contextID) const
Definition: BufferObject.h:542
void setProfile(const BufferObjectProfile &profile)
Definition: BufferObject.h:160
BufferEntry(const BufferEntry &rhs)
Definition: BufferObject.h:170
unsigned int & getNumberFrames()
Definition: BufferObject.h:375
virtual const char * className() const
Definition: BufferObject.h:521
#define NULL
Definition: Export.h:59
This class provides an object-oriented thread mutex interface.
Definition: Mutex.h:31
BufferDataList _bufferDataList
Definition: BufferObject.h:496
unsigned int & getNumberDeleted()
Definition: BufferObject.h:377
virtual void modified(BufferData *) const
Definition: BufferObject.h:553
unsigned int getNumOrphans() const
Definition: BufferObject.h:309
std::vector< BufferData * > BufferDataList
Definition: BufferObject.h:489
unsigned int _numActiveGLBufferObjects
Definition: BufferObject.h:392
Mode getMode(unsigned int contextID) const
Definition: BufferObject.h:721
BufferData * getBufferData(unsigned int index)
Definition: BufferObject.h:465
void setNumberOrphanedGLBufferObjects(unsigned int size)
Definition: BufferObject.h:342
unsigned int _currGLBufferObjectPoolSize
Definition: BufferObject.h:394
unsigned int & getCurrGLBufferObjectPoolSize()
Definition: BufferObject.h:347
BufferData * dataSource
Definition: BufferObject.h:194
GLenum getTarget() const
Definition: BufferObject.h:427
GLBufferObject * _next
Definition: BufferObject.h:265
unsigned int getNumClients() const
Definition: BufferObject.h:583
ptrdiff_t GLsizeiptr
Definition: GLDefines.h:621
BufferObjectProfile _profile
Definition: BufferObject.h:321
unsigned int _contextID
Definition: BufferObject.h:248
const BufferData * getBufferData(unsigned int index) const
Definition: BufferObject.h:466
unsigned int getNumberOrphanedGLBufferObjects() const
Definition: BufferObject.h:344
unsigned int _numClients
Definition: BufferObject.h:599
unsigned int numRead
Definition: BufferObject.h:190
unsigned int modifiedCount
Definition: BufferObject.h:191
void setGLBufferObject(unsigned int contextID, GLBufferObject *glbo)
Definition: BufferObject.h:470
unsigned int getNumBufferData() const
Definition: BufferObject.h:468
unsigned int getNumOfGLBufferObjects() const
Definition: BufferObject.h:308
void setProfile(GLenum target, GLenum usage, unsigned int size)
Definition: BufferObject.h:130
bool isPBOSupported(unsigned int contextID) const
Definition: BufferObject.h:667
bool operator<(const BufferObjectProfile &rhs) const
Definition: BufferObject.h:114
GLBufferObject * getOrCreateGLBufferObject(unsigned int contextID) const
Definition: BufferObject.h:474
unsigned int getCurrGLBufferObjectPoolSize() const
Definition: BufferObject.h:348
GLBufferObjectSet * _set
Definition: BufferObject.h:263
unsigned int offset
Definition: BufferObject.h:193
void setCopyDataAndReleaseGLBufferObject(bool copyAndRelease)
Definition: BufferObject.h:444
unsigned int & getFrameNumber()
Definition: BufferObject.h:374
bool _copyDataAndReleaseGLBufferObject
Definition: BufferObject.h:494
bool getCopyDataAndReleaseGLBufferObject() const
Definition: BufferObject.h:447
virtual const osg::Image * asImage() const
Definition: BufferObject.h:533
virtual osg::Array * asArray()
Definition: BufferObject.h:526
unsigned int _modifiedCount
Definition: BufferObject.h:593
unsigned int getNumberActiveGLBufferObjects() const
Definition: BufferObject.h:340
unsigned int _frameLastUsed
Definition: BufferObject.h:266
GLuint & getGLObjectID()
Definition: BufferObject.h:199
const BufferObjectProfile & getProfile() const
Definition: BufferObject.h:440
unsigned int _numOrphanedGLBufferObjects
Definition: BufferObject.h:393
std::vector< BufferEntry > BufferEntries
Definition: BufferObject.h:256
BufferObject * _bufferObject
Definition: BufferObject.h:259
OpenThreads::Mutex _mutex
Definition: BufferObject.h:317
unsigned int computeBufferAlignment(unsigned int pos, unsigned int bufferAlignment) const
Definition: BufferObject.h:241
GLExtensions * _extensions
Definition: BufferObject.h:269
osg::buffered_object< osg::ref_ptr< GLBufferObject > > GLBufferObjects
Definition: BufferObject.h:490
GLBufferObjectList _pendingOrphanedGLBufferObjects
Definition: BufferObject.h:324
bool hasSpace(unsigned int size) const
Definition: BufferObject.h:353
osg::ref_ptr< ModifiedCallback > _modifiedCallback
Definition: BufferObject.h:597
#define META_Object(library, name)
Definition: Object.h:42
BufferObject * getBufferObject()
Definition: BufferObject.h:536
unsigned int & getNumberApplied()
Definition: BufferObject.h:383
void moveToBack(GLBufferObject *to)
unsigned int getMaxGLBufferObjectPoolSize() const
Definition: BufferObject.h:351
unsigned int getContextID() const
Definition: BufferObject.h:197
unsigned int _bufferIndex
Definition: BufferObject.h:595
Definition: BufferObject.h:166
GLuint getGLObjectID() const
Definition: BufferObject.h:200
GLsizeiptr getOffset(unsigned int i) const
Definition: BufferObject.h:201
virtual const char * libraryName() const
Definition: BufferObject.h:520
GLBufferObject * getGLBufferObject(unsigned int contextID) const
Definition: BufferObject.h:472
unsigned int getBufferIndex() const
Definition: BufferObject.h:540
GLBufferObjectList _orphanedGLBufferObjects
Definition: BufferObject.h:323
osg::buffered_value< unsigned int > ModeList
Definition: BufferObject.h:727
GLBufferObjects _glBufferObjects
Definition: BufferObject.h:498
BufferObjectProfile _profile
Definition: BufferObject.h:492
GLBufferObject * _previous
Definition: BufferObject.h:264
BufferData(const BufferData &bd, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition: BufferObject.h:512
void setNumberActiveGLBufferObjects(unsigned int size)
Definition: BufferObject.h:338
unsigned int size() const
Definition: BufferObject.h:299
unsigned int getDataSize() const
Get data size of the used buffer.
Definition: BufferObject.h:692
GLBufferObject * _head
Definition: BufferObject.h:326
void setBufferIndex(unsigned int index)
Definition: BufferObject.h:539
BufferObjectProfile(const BufferObjectProfile &bpo)
Definition: BufferObject.h:109
void setModifiedCallback(ModifiedCallback *md)
Definition: BufferObject.h:556
GLenum getUsage() const
Definition: BufferObject.h:437
bool isPBOSupported() const
Definition: BufferObject.h:222
unsigned int getNumPendingOrphans() const
Definition: BufferObject.h:310
virtual const char * libraryName() const
Definition: BufferObject.h:423
unsigned int dataSize
Definition: BufferObject.h:192
GLBufferObject * getOrCreateGLBufferObject(unsigned int contextID) const
Definition: BufferObject.h:543
void setUsage(GLenum usage)
Definition: BufferObject.h:434
void addClient(osg::Object *)
Definition: BufferObject.h:585
GLBufferObjectSetMap _glBufferObjectSetMap
Definition: BufferObject.h:396
unsigned int _maxGLBufferObjectPoolSize
Definition: BufferObject.h:395
ModifiedCallback(const ModifiedCallback &, const CopyOp &)
Definition: BufferObject.h:549
BufferObjectProfile & getProfile()
Definition: BufferObject.h:439
unsigned int & getNumberActiveGLBufferObjects()
Definition: BufferObject.h:339
unsigned int getContextID() const
Definition: BufferObject.h:335
Definition: AlphaFunc.h:19
BufferEntry()
Definition: BufferObject.h:168
unsigned int getModifiedCount() const
Definition: BufferObject.h:573
const BufferObject * getBufferObject() const
Definition: BufferObject.h:537
virtual const osg::PrimitiveSet * asPrimitiveSet() const
Definition: BufferObject.h:530
static osg::ref_ptr< GLBufferObject > createGLBufferObject(unsigned int contextID, const BufferObject *bufferObject)
BufferObjectProfile & operator=(const BufferObjectProfile &rhs)
Definition: BufferObject.h:137
BufferObjectProfile(GLenum target, GLenum usage, unsigned int size)
Definition: BufferObject.h:104
void setTarget(GLenum target)
Definition: BufferObject.h:426
GLBufferObjectManager * _parent
Definition: BufferObject.h:319
BufferEntries _bufferEntries
Definition: BufferObject.h:257
bool isDirty() const
Definition: BufferObject.h:210
const ModifiedCallback * getModifiedCallback() const
Definition: BufferObject.h:558
virtual bool isSameKindAs(const Object *obj) const
Definition: BufferObject.h:422
const BufferObjectProfile & getProfile() const
Definition: BufferObject.h:280
ModifiedCallback * getModifiedCallback()
Definition: BufferObject.h:557
bool operator==(const BufferObjectProfile &rhs) const
Definition: BufferObject.h:123
virtual const char * className() const
Definition: BufferObject.h:424
GLBufferObject * _tail
Definition: BufferObject.h:327
osg::ref_ptr< BufferObject > _bufferObject
Definition: BufferObject.h:596
void setModifiedCount(unsigned int value)
Definition: BufferObject.h:570
void removeClient(osg::Object *)
Definition: BufferObject.h:587
GLBufferObjectManager * getParent()
Definition: BufferObject.h:305
std::list< ref_ptr< GLBufferObject > > GLBufferObjectList
Definition: BufferObject.h:273
virtual bool isSameKindAs(const Object *obj) const
Definition: BufferObject.h:519
virtual osg::PrimitiveSet * asPrimitiveSet()
Definition: BufferObject.h:529
virtual osg::Image * asImage()
Definition: BufferObject.h:532
std::map< BufferObjectProfile, osg::ref_ptr< GLBufferObjectSet > > GLBufferObjectSetMap
Definition: BufferObject.h:390
unsigned int _numOfGLBufferObjects
Definition: BufferObject.h:322
unsigned int & getNumberGenerated()
Definition: BufferObject.h:380
const BufferObjectProfile & getProfile() const
Definition: BufferObject.h:161
BufferObjectProfile _profile
Definition: BufferObject.h:251
unsigned int & getNumberOrphanedGLBufferObjects()
Definition: BufferObject.h:343
BufferObject * getBufferObject()
Definition: BufferObject.h:164