#include <OgreHardwareBuffer.h>
Inheritance diagram for Ogre::HardwareBuffer:
Public Types | |
enum | Usage { HBU_STATIC = 1, HBU_DYNAMIC = 2, HBU_WRITE_ONLY = 4, HBU_DISCARDABLE = 8, HBU_STATIC_WRITE_ONLY = 5, HBU_DYNAMIC_WRITE_ONLY = 6, HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE = 14 } |
Enums describing buffer usage; not mutually exclusive. More... | |
enum | LockOptions { HBL_NORMAL, HBL_DISCARD, HBL_READ_ONLY, HBL_NO_OVERWRITE } |
Locking options. More... | |
Public Methods | |
HardwareBuffer (Usage usage, bool systemMemory, bool useShadowBuffer) | |
Constructor, to be called by HardwareBufferManager only. | |
virtual | ~HardwareBuffer () |
virtual void * | lock (size_t offset, size_t length, LockOptions options) |
Lock the buffer for (potentially) reading / writing. | |
void * | lock (LockOptions options) |
Lock the entire buffer for (potentially) reading / writing. | |
virtual void | unlock (void) |
Releases the lock on this buffer. | |
virtual void | readData (size_t offset, size_t length, void *pDest)=0 |
Reads data from the buffer and places it in the memory pointed to by pDest. | |
virtual void | writeData (size_t offset, size_t length, const void *pSource, bool discardWholeBuffer=false)=0 |
Writes data to the buffer from an area of system memory; note that you must ensure that your buffer is big enough. | |
virtual void | copyData (HardwareBuffer &srcBuffer, size_t srcOffset, size_t dstOffset, size_t length, bool discardWholeBuffer=false) |
Copy data from another buffer into this one. | |
virtual void | _updateFromShadow (void) |
Updates the real buffer from the shadow buffer, if required. | |
size_t | getSizeInBytes (void) const |
Returns the size of this buffer in bytes. | |
Usage | getUsage (void) const |
Returns the Usage flags with which this buffer was created. | |
bool | isSystemMemory (void) const |
Returns whether this buffer is held in system memory. | |
bool | hasShadowBuffer (void) const |
Returns whether this buffer has a system memory shadow for quicker reading. | |
bool | isLocked (void) const |
Returns whether or not this buffer is currently locked. | |
void | suppressHardwareUpdate (bool suppress) |
Pass true to suppress hardware upload of shadow buffer changes. | |
Protected Methods | |
virtual void * | lockImpl (size_t offset, size_t length, LockOptions options)=0 |
Internal implementation of lock(). | |
virtual void | unlockImpl (void)=0 |
Internal implementation of unlock(). | |
Protected Attributes | |
size_t | mSizeInBytes |
Usage | mUsage |
bool | mIsLocked |
size_t | mLockStart |
size_t | mLockSize |
bool | mSystemMemory |
bool | mUseShadowBuffer |
HardwareBuffer * | mpShadowBuffer |
bool | mShadowUpdated |
bool | mSuppressHardwareUpdate |
This reflects the fact that memory held outside of main system RAM must be interacted with in a more formal fashion in order to promote cooperative and optimal usage of the buffers between the various processing units which manipulate them.
This abstract class defines the core interface which is common to all buffers, whether it be vertex buffers, index buffers, texture memory or framebuffer memory etc.
Buffers have the ability to be 'shadowed' in system memory, this is because the kinds of access allowed on hardware buffers is not always as flexible as that allowed for areas of system memory - for example it is often either impossible, or extremely undesirable from a performance standpoint to read from a hardware buffer; when writing to hardware buffers, you should also write every byte and do it sequentially. In situations where this is too restrictive, it is possible to create a hardware, write-only buffer (the most efficient kind) and to back it with a system memory 'shadow' copy which can be read and updated arbitrarily. Ogre handles synchronising this buffer with the real hardware buffer (which should still be created with the HBU_DYNAMIC flag if you intend to update it very frequently). Whilst this approach does have it's own costs, such as increased memory overhead, these costs can often be outweighed by the performance benefits of using a more hardware efficient buffer. You should look for the 'useShadowBuffer' parameter on the creation methods used to create the buffer of the type you require (see HardwareBufferManager) to enable this feature.
Definition at line 64 of file OgreHardwareBuffer.h.
|
Locking options.
Definition at line 111 of file OgreHardwareBuffer.h. |
|
Enums describing buffer usage; not mutually exclusive.
Definition at line 69 of file OgreHardwareBuffer.h. |
|
Constructor, to be called by HardwareBufferManager only.
Definition at line 149 of file OgreHardwareBuffer.h. |
|
Definition at line 164 of file OgreHardwareBuffer.h. |
|
Updates the real buffer from the shadow buffer, if required.
Definition at line 275 of file OgreHardwareBuffer.h. References lockImpl(), and unlockImpl(). |
|
Copy data from another buffer into this one.
Definition at line 265 of file OgreHardwareBuffer.h. |
|
Returns the size of this buffer in bytes.
Definition at line 300 of file OgreHardwareBuffer.h. |
|
Returns the Usage flags with which this buffer was created.
Definition at line 302 of file OgreHardwareBuffer.h. |
|
Returns whether this buffer has a system memory shadow for quicker reading.
Definition at line 306 of file OgreHardwareBuffer.h. |
|
Returns whether or not this buffer is currently locked.
Definition at line 308 of file OgreHardwareBuffer.h. Referenced by unlock(). |
|
Returns whether this buffer is held in system memory.
Definition at line 304 of file OgreHardwareBuffer.h. |
|
Lock the entire buffer for (potentially) reading / writing.
Definition at line 201 of file OgreHardwareBuffer.h. |
|
Lock the buffer for (potentially) reading / writing.
Reimplemented in Ogre::DefaultHardwareVertexBuffer, Ogre::DefaultHardwareIndexBuffer, Ogre::GLDefaultHardwareVertexBuffer, and Ogre::GLDefaultHardwareIndexBuffer. Definition at line 171 of file OgreHardwareBuffer.h. Referenced by copyData(), Ogre::GLHardwareVertexBuffer::readData(), Ogre::GLHardwareIndexBuffer::readData(), Ogre::D3D9HardwareVertexBuffer::readData(), Ogre::D3D9HardwareIndexBuffer::readData(), Ogre::GLHardwareVertexBuffer::writeData(), Ogre::GLHardwareIndexBuffer::writeData(), Ogre::D3D9HardwareVertexBuffer::writeData(), and Ogre::D3D9HardwareIndexBuffer::writeData(). |
|
Internal implementation of lock().
Implemented in Ogre::DefaultHardwareVertexBuffer, Ogre::DefaultHardwareIndexBuffer, Ogre::D3D9HardwareIndexBuffer, Ogre::D3D9HardwareVertexBuffer, Ogre::GLDefaultHardwareVertexBuffer, Ogre::GLDefaultHardwareIndexBuffer, Ogre::GLHardwareIndexBuffer, and Ogre::GLHardwareVertexBuffer. Referenced by _updateFromShadow(). |
|
Reads data from the buffer and places it in the memory pointed to by pDest.
Implemented in Ogre::DefaultHardwareVertexBuffer, Ogre::DefaultHardwareIndexBuffer, Ogre::D3D9HardwareIndexBuffer, Ogre::D3D9HardwareVertexBuffer, Ogre::GLDefaultHardwareVertexBuffer, Ogre::GLDefaultHardwareIndexBuffer, Ogre::GLHardwareIndexBuffer, and Ogre::GLHardwareVertexBuffer. |
|
Pass true to suppress hardware upload of shadow buffer changes.
Definition at line 312 of file OgreHardwareBuffer.h. |
|
Releases the lock on this buffer.
Reimplemented in Ogre::DefaultHardwareVertexBuffer, Ogre::DefaultHardwareIndexBuffer, Ogre::GLDefaultHardwareVertexBuffer, and Ogre::GLDefaultHardwareIndexBuffer. Definition at line 217 of file OgreHardwareBuffer.h. References isLocked(). Referenced by copyData(), Ogre::GLHardwareVertexBuffer::readData(), Ogre::GLHardwareIndexBuffer::readData(), Ogre::D3D9HardwareVertexBuffer::readData(), Ogre::D3D9HardwareIndexBuffer::readData(), Ogre::GLHardwareVertexBuffer::writeData(), Ogre::GLHardwareIndexBuffer::writeData(), Ogre::D3D9HardwareVertexBuffer::writeData(), and Ogre::D3D9HardwareIndexBuffer::writeData(). |
|
Internal implementation of unlock().
Implemented in Ogre::DefaultHardwareVertexBuffer, Ogre::DefaultHardwareIndexBuffer, Ogre::D3D9HardwareIndexBuffer, Ogre::D3D9HardwareVertexBuffer, Ogre::GLDefaultHardwareVertexBuffer, Ogre::GLDefaultHardwareIndexBuffer, Ogre::GLHardwareIndexBuffer, and Ogre::GLHardwareVertexBuffer. Referenced by _updateFromShadow(). |
|
Writes data to the buffer from an area of system memory; note that you must ensure that your buffer is big enough.
Implemented in Ogre::DefaultHardwareVertexBuffer, Ogre::DefaultHardwareIndexBuffer, Ogre::D3D9HardwareIndexBuffer, Ogre::D3D9HardwareVertexBuffer, Ogre::GLDefaultHardwareVertexBuffer, Ogre::GLDefaultHardwareIndexBuffer, Ogre::GLHardwareIndexBuffer, and Ogre::GLHardwareVertexBuffer. |
|
|
Definition at line 135 of file OgreHardwareBuffer.h. |
|
Definition at line 134 of file OgreHardwareBuffer.h. |
|
|
Definition at line 139 of file OgreHardwareBuffer.h. |
|
|
Definition at line 140 of file OgreHardwareBuffer.h. |
|
Definition at line 136 of file OgreHardwareBuffer.h. |
|
Definition at line 132 of file OgreHardwareBuffer.h. Referenced by Ogre::GLHardwareVertexBuffer::lockImpl(), Ogre::GLHardwareIndexBuffer::lockImpl(), Ogre::D3D9HardwareVertexBuffer::lockImpl(), Ogre::D3D9HardwareIndexBuffer::lockImpl(), Ogre::GLHardwareVertexBuffer::writeData(), and Ogre::GLHardwareIndexBuffer::writeData(). |
|
Definition at line 137 of file OgreHardwareBuffer.h. |
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:51:03 2004