Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
om::graphics::buffers::DeviceBuffer Class Referenceabstract

A class that represents a buffer of shader attributes stored in GPU memory. More...

#include <omGraphicsDeviceBuffer.h>

Inheritance diagram for om::graphics::buffers::DeviceBuffer:
om::graphics::devices::DeviceResource om::graphics::devices::opengl::OpenGLBuffer

Public Member Functions

const BufferTypegetType () const
 Return the type of attribute buffer that this device buffer represents. More...
 
virtual BufferUsage getUsage () const =0
 Return the current expected usage pattern for this hardware attribute buffer. More...
 
virtual Size getCapacity () const =0
 Return the number of bytes that this buffer is able to hold. More...
 
virtual Bool setCapacity (Size newCapacityInBytes)=0
 Set the number of bytes that this buffer is able to hold. More...
 
virtual Bool setCapacity (Size newCapacityInBytes, BufferUsage newUsage)=0
 Set the number of bytes that this buffer is able to hold. More...
 
virtual Bool reallocate ()=0
 Reallocate this buffer's data store using its current capacity. More...
 
virtual Bool reallocate (BufferUsage newUsage)=0
 Reallocate this buffer's data store using its current capacity, changing its usage type. More...
 
virtual Bool getData (void *data, Size &numBytes) const =0
 Read the specified number of bytes from the attribute buffer into the output data pointer. More...
 
virtual Bool setData (const void *data, Size numBytes, BufferUsage newUsage=BufferUsage::STATIC)=0
 Replace the contents of this attribute buffer with the specified data. More...
 
virtual Bool updateData (const void *data, Size numBytes, Index startIndex=0)=0
 Update a region of this attribute buffer with the specified data. More...
 
virtual void * map (BufferAccessType accessType)=0
 Map this buffer's data store to the main memory address space and return a pointer to it. More...
 
virtual void * mapRange (BufferAccessType accessType, Index byteOffset, Size numBytes)=0
 Map this buffer's data store to the main memory address space and return a pointer to it. More...
 
virtual void unmap () const =0
 Unmap this buffer's data store from the main memory address space. More...
 
virtual Bool isMapped () const =0
 Return whether or not this attribute buffer is currently mapped to main memory. More...
 
- Public Member Functions inherited from om::graphics::devices::DeviceResource
virtual ~DeviceResource ()
 Destroy a device object, releasing all internal state. More...
 
GraphicsContextgetContext () const
 Return a pointer to the graphics context associated with this DeviceResource. More...
 
virtual Bool isValid () const =0
 Return whether or not the state of this device resource is valid and able to be used for rendering. More...
 

Protected Member Functions

 DeviceBuffer (devices::GraphicsContext *newContext, BufferType newBufferType)
 Create a device attribute buffer for the specified context with the given buffer type. More...
 
- Protected Member Functions inherited from om::graphics::devices::DeviceResource
 DeviceResource (GraphicsContext *newContext)
 Create a new device object that is associated with the specified graphics context. More...
 

Protected Attributes

BufferType bufferType
 An enum value that is set by subclasses that specifies the kind of attribute buffer this is. More...
 

Detailed Description

A class that represents a buffer of shader attributes stored in GPU memory.

This class allows attribute data to be stored in the graphics card's RAM for faster access. It is analogous to the Texture class that performs the same function but for pixel data.

Constructor & Destructor Documentation

om::graphics::buffers::DeviceBuffer::DeviceBuffer ( devices::GraphicsContext newContext,
BufferType  newBufferType 
)
inlineprotected

Create a device attribute buffer for the specified context with the given buffer type.

Member Function Documentation

const BufferType& om::graphics::buffers::DeviceBuffer::getType ( ) const
inline

Return the type of attribute buffer that this device buffer represents.

virtual BufferUsage om::graphics::buffers::DeviceBuffer::getUsage ( ) const
pure virtual

Return the current expected usage pattern for this hardware attribute buffer.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual Size om::graphics::buffers::DeviceBuffer::getCapacity ( ) const
pure virtual

Return the number of bytes that this buffer is able to hold.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual Bool om::graphics::buffers::DeviceBuffer::setCapacity ( Size  newCapacityInBytes)
pure virtual

Set the number of bytes that this buffer is able to hold.

Calling this method reallocates the buffer with the new capacity. The method returns whether or not the capacity change was successful.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual Bool om::graphics::buffers::DeviceBuffer::setCapacity ( Size  newCapacityInBytes,
BufferUsage  newUsage 
)
pure virtual

Set the number of bytes that this buffer is able to hold.

Calling this method reallocates the buffer with the new capacity and changes the usage type of this buffer. The method returns whether or not the capacity change was successful.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual Bool om::graphics::buffers::DeviceBuffer::reallocate ( )
pure virtual

Reallocate this buffer's data store using its current capacity.

This method allows the user to get a new data store for the buffer, releasing the previous data store. This is useful if you are using a memory-mapped buffer to transfer vertices to the GPU. By releasing the buffer before mapping it, you signal that you don't need the old buffer anymore, avoiding synchronization stalls.

The resulting contents of the buffer are undefined.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual Bool om::graphics::buffers::DeviceBuffer::reallocate ( BufferUsage  newUsage)
pure virtual

Reallocate this buffer's data store using its current capacity, changing its usage type.

This method allows the user to get a new data store for the buffer, releasing the previous data store. This is useful if you are using a memory-mapped buffer to transfer vertices to the GPU. By releasing the buffer before mapping it, you signal that you don't need the old buffer anymore, avoiding synchronization stalls.

The resulting contents of the buffer are undefined.

This variant allows the user to change the usage of the buffer when it is reallocated.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual Bool om::graphics::buffers::DeviceBuffer::getData ( void *  data,
Size numBytes 
) const
pure virtual

Read the specified number of bytes from the attribute buffer into the output data pointer.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual Bool om::graphics::buffers::DeviceBuffer::setData ( const void *  data,
Size  numBytes,
BufferUsage  newUsage = BufferUsage::STATIC 
)
pure virtual

Replace the contents of this attribute buffer with the specified data.

The usage of the buffer is set to the specified usage type and will have a capacity equal to the input data. The method returns whether or not the buffer set operation was successful.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual Bool om::graphics::buffers::DeviceBuffer::updateData ( const void *  data,
Size  numBytes,
Index  startIndex = 0 
)
pure virtual

Update a region of this attribute buffer with the specified data.

The specified nubmer of bytes are copied from the data pointer to the given start offset in bytes in the attribute buffer. The method returns whether or not the update operation was successful.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual void* om::graphics::buffers::DeviceBuffer::map ( BufferAccessType  accessType)
pure virtual

Map this buffer's data store to the main memory address space and return a pointer to it.

The method returns NULL if the buffer is unable to be mapped with the given access type.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual void* om::graphics::buffers::DeviceBuffer::mapRange ( BufferAccessType  accessType,
Index  byteOffset,
Size  numBytes 
)
pure virtual

Map this buffer's data store to the main memory address space and return a pointer to it.

The method returns NULL if the buffer is unable to be mapped with the given access type. The method allows the user to specify a range of bytes within the buffer that is mapped. Mapping smaller ranges of a buffer can be faster than mapping the whole buffer since less data must be copied.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual void om::graphics::buffers::DeviceBuffer::unmap ( ) const
pure virtual

Unmap this buffer's data store from the main memory address space.

This starts a transfer of the mapped data to GPU memory if the access type was WRITE or READ_WRITE.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

virtual Bool om::graphics::buffers::DeviceBuffer::isMapped ( ) const
pure virtual

Return whether or not this attribute buffer is currently mapped to main memory.

If this method returns TRUE, it means that the buffer is currently mapped. The buffer cannot be used for any drawing until the buffer is unmapped.

Implemented in om::graphics::devices::opengl::OpenGLBuffer.

Member Data Documentation

BufferType om::graphics::buffers::DeviceBuffer::bufferType
protected

An enum value that is set by subclasses that specifies the kind of attribute buffer this is.

This can be used to specify that a buffer is a vertex buffer or an index buffer or some other kind of buffer. These buffers types allow different kinds of attributes to be stored in them.


The documentation for this class was generated from the following file: