![]() |
VR-Forces 5.0.2 Developer's Guide
|
A generic OpenGL buffer. This can be: -> a vertex buffer -> an index buffer -> a shader storage buffer (SSBO), etc.

Public Member Functions | |
| DtGlBuffer (const char *name, DtBufferType type, DtUsage usage, DtCpuAccess accessType, bool hasStagingBuffer) | |
| virtual | ~DtGlBuffer () |
| virtual void | tearDown (void) |
| virtual unsigned int | releaseHandle (void) |
| virtual bool | updateBuffer (const int sizeToTransferInBytes, const void *data) |
| virtual bool | updateBuffer (const int offsetInBytes, const int sizeToTransferInBytes, const void *data) |
| virtual void | clearBuffer (unsigned int clearValue) |
| virtual bool | bufferSubData (unsigned int offset, unsigned int sizeInBytes, const void *data) |
| virtual void | resetStagingBuffer () |
| virtual int | sizeInBytes (void) const |
| virtual int | sizeInBytesFromGl (void) const |
| virtual const unsigned int | handle (void) const |
| virtual void | setResizeMultiplier (float rmul) |
| virtual void | setUseIncrementalUpdate (bool incrementalUpdate) |
| virtual bool | useIncrementalUpdate () |
| virtual float | resizeMultiplier () |
| unsigned int | type (void) const |
| virtual uint64_t | gpuResidentAddress () |
| virtual const void * | mapForReading (void) const |
| virtual void | unMap (void) const |
| template<class T > | |
| void | printContents (std::ostream &outputStream, const std::string &strNumPrefix, const std::string &strValPrefix) const |
| virtual const DtGlBufferListener * | listener (void) const |
| virtual DtGlBufferListener * | listener (void) |
| virtual void | setListener (DtGlBufferListener *listener) |
| virtual const std::string & | name () const |
| virtual bool | gpuResidentAddressWasCalledAtleastOnce (void) const |
| virtual void | bind () const |
| virtual void | unbind () const |
| virtual unsigned char * | stagingBuffer (void) const |
| virtual unsigned char * | stagingBufferWithSize (unsigned int requestedSizeInBytes) |
| virtual void | syncStagingBufferToGpu (unsigned int offset, unsigned int sizeInBytes) |
| virtual void | syncStagingBufferToGpu () |
Protected Member Functions | |
| virtual bool | createAndBindBuffer () |
| virtual int | calculateNewSize (int requestedNewSizeInBytes) |
Protected Attributes | |
| std::string | myName |
| unsigned int | myHandle |
| unsigned int | myType |
| int | mySizeInBytes |
| float | myResizeMultiplier |
| unsigned char * | myStagingBuffer |
| bool | myHasStagingBuffer |
| DtUsage | myUsage |
| DtCpuAccess | myAccessType |
| bool | myUseIncrementalUpdate |
| int | myLastBufferTransferOffset |
| uint64_t | myResidentAddress |
| bool | myIsResident |
| bool | myMutableIsMapped |
| DtGlBufferListener * | myListener |
Private Member Functions | |
| DtGlBuffer ()=delete | |
| DtGlBuffer (const DtGlBuffer &other)=delete | |
| DtGlBuffer & | operator= (const DtGlBuffer &other)=delete |
| makVrv::DtGlBuffer::DtGlBuffer | ( | const char * | name, |
| DtBufferType | type, | ||
| DtUsage | usage, | ||
| DtCpuAccess | accessType, | ||
| bool | hasStagingBuffer | ||
| ) |
CTOR.
| name | Name of buffer for debugging and nsight. |
| type | Indicates the type of the buffer this will be (vertex buffer, index buffer, etc) |
| usage | Indicates what the intended usage of this buffer will be (dynamic, const, etc) |
| accessType | Indicates what level of CPU access is needed (will CPU only ever write, etc) |
| hasStagingBuffer | indicates whether this buffer will have an internal staging buffer |
|
virtual |
DTOR.
|
privatedelete |
not allowed
|
privatedelete |
Copy Constructor not implemented – Copy Not Allowed.
|
privatedelete |
Assignment Operator Not implemented – Assignment Not Allowed.
|
virtual |
releases GL objects and delete GL buffer
releases GL handle but does not delete GL buffer
|
virtual |
update the buffer, this can resize it if needed or create it from scratch
| sizeInBytes | size in bytes of the incoming data |
| data | is the data to copy from. |
|
virtual |
update the buffer, this can resize it if needed or create it from scratch
| offsetInBytes | offset into the buffer from where to update |
| sizeInBytes | size in bytes of the incoming data |
| data | is the data to copy from. |
clear the buffer to the value specified. clears both the GPU data and the staging buffer if there is a staging buffer. requires valid graphics context
|
virtual |
bind/unbind the buffer bind will not create the buffer if it is not yet created. it will also spew a warning so it is easy to know when it is used incorrectly.
|
virtual |
bind/unbind the buffer bind will not create the buffer if it is not yet created. it will also spew a warning so it is easy to know when it is used incorrectly.
Internally GLBuffer uses a 'staging buffer' This is because map/unmap and directly uploading to the buffer is horribly slow in OpenGL. The usage therefore is to get the staging buffer, modify it and then call syncStagingBufferToGpu.
|
virtual |
gets the staging buffer can resize the opengl data.. FIXME seperate sb size from ogl
|
virtual |
Use when you modified (and hence need to update) only part of the buffer [offset, offset+sizeInBytes].
|
virtual |
Use when you modified (and hence need to update) the whole buffer [0, sizeInBytes()].
|
virtual |
Optional API to upload data directly to the buffer, side stepping the staging buffer. You can use one or the other. That is to say you cannot use this API if you specified that this buffer has a staging buffer, which means you'll use that API (getStagingBuffer, syncToGPU)
|
virtual |
set the whole staging buffer to 0
|
virtual |
The size in bytes of the buffer.
|
virtual |
The size in bytes of the buffer from OpenGL.
The internal GL handle of the buffer.
|
virtual |
multiplier on how much extra memory should get allocated at gl buffer creation time.
|
virtual |
enable or disable incremental update for this buffer this means that only new data is sent down instead of resending the whole buffer every time. On resize all the data is sent down again. use this if the data is static
|
virtual |
get the current state of incremental update for this buffer.
|
virtual |
returns multiplier on how much extra memory should get allocated at gl buffer creation time.
The internal OpenGL type of the buffer of the gl buffer.
|
virtual |
Get the bindless gpu address for this buffer. It makes it resident if it is not already Bindless accessed buffers are read only since only GL_READ_ONLY is supported according to the spec.
|
virtual |
map the buffer for reading on the CPU side
Should only be used for debugging purposes. In the past we determined that mapping buffers is very slow
|
virtual |
unmap a previously mapped buffer
Should only be used for debugging purposes. In the past we determined that mapping buffers is very slow
|
inline |
Template function to print the contents of the buffer. The contents are interpreted as items of type T. Requires that operator << will be defined for the type T. cannot be a virtual since its a template function.
|
virtual |
Each DtGlBuffer can have a listener set on it. When the buffer is deleted/becomes resident/non-resident, the buffer will call the 3 signals/functions here from within its internal functions. **Note* for speed reasons, a buffer can have only one listener set on it Right now, the listener class does memory tracking for all buffers get the listener.
|
virtual |
get the listener (non-const)
|
virtual |
set the listener
|
virtual |
The name. This is the same as the given gl object name If the object handle gets released externally, attempt to get that name from the id does not succeed, so this can be used instead.
|
virtual |
was called atleast once (hence the buffer was tried to be made resident)
|
protectedvirtual |
creates buffer, must be called in main render thread. returns true if the buffer was created
helper function to calculate the new size a buffer should be based on it's current size and the requested size.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |