OGRE-Next  4.0.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::VertexArrayObject Struct Reference

Vertex array objects (Vaos) are immutable objects that describe a combination of vertex buffers and index buffer with a given operation type. More...

#include <OgreVertexArrayObject.h>

+ Inheritance diagram for Ogre::VertexArrayObject:

Classes

struct  ReadRequests
 

Public Types

typedef vector< ReadRequests >::type ReadRequestsVec
 

Public Member Functions

 VertexArrayObject (uint32 vaoName, uint32 renderQueueId, uint16 inputLayoutId, const VertexBufferPackedVec &vertexBuffers, IndexBufferPacked *indexBuffer, OperationType operationType)
 
VertexArrayObjectclone (VaoManager *vaoManager, SharedVertexBufferMap *sharedBuffers, int vertexBufferType=-1, int indexBufferType=-1) const
 Clones the vertex & index buffers and creates a new VertexArrayObject. More...
 
const VertexElement2findBySemantic (VertexElementSemantic semantic, size_t &outIndex, size_t &outOffset, size_t repeat=0) const
 Returns the entire VertexElement2 descriptor in the vertex buffers. More...
 
VertexBufferPackedgetBaseVertexBuffer () const
 
IndexBufferPackedgetIndexBuffer () const
 
uint16 getInputLayoutId () const
 
OperationType getOperationType () const
 
uint32 getPrimitiveCount () const
 
uint32 getPrimitiveStart () const
 
uint32 getRenderQueueId () const
 
uint32 getVaoName () const
 
const VertexBufferPackedVecgetVertexBuffers () const
 
VertexElement2VecVec getVertexDeclaration () const
 Gets the combined vertex declaration of all the vertex buffers. More...
 
void readRequests (ReadRequestsVec &requests, size_t elementStart=0, size_t elementCount=0, bool skipRequestIfBufferHasShadowCopy=false)
 Utility to get multiple pointers & read specific elements of the vertex, even if they're in separate buffers. More...
 
void setPrimitiveRange (uint32 primStart, uint32 primCount)
 Limits the range of triangle primitives that is rendered. More...
 

Static Public Member Functions

static VertexElement2VecVec getVertexDeclaration (const VertexBufferPackedVec &vertexBuffers)
 
static void mapAsyncTickets (ReadRequestsVec &tickets)
 Maps the buffers requested via. More...
 
static void unmapAsyncTickets (ReadRequestsVec &tickets)
 Unmaps the buffers mapped via. More...
 

Static Public Attributes

static VertexBufferPacked msDummyVertexBuffer
 When a Vao doesn't have a vertex buffer, a dummy one is assigned for performance reasons (avoid checking if pointer is null, avoid crashing inside Ogre) More...
 

Detailed Description

Vertex array objects (Vaos) are immutable objects that describe a combination of vertex buffers and index buffer with a given operation type.

Once created, they can't be modified. You have to destroy them and create a new one.

Remarks
If the VertexArrayObject contains one BT_IMMUTABLE buffer (i.e. one of the vertex buffers or the index buffer) then despite the immutability of this class, the internal values of mVaoName & mRenderQueueId may be changed automatically by the VaoManager as it performs maintenance and cleanups of these type of buffers (in practice only affects D3D11). Don't rely on the contents of these two variables if the Vao contains

Member Typedef Documentation

◆ ReadRequestsVec

Constructor & Destructor Documentation

◆ VertexArrayObject()

Ogre::VertexArrayObject::VertexArrayObject ( uint32  vaoName,
uint32  renderQueueId,
uint16  inputLayoutId,
const VertexBufferPackedVec vertexBuffers,
IndexBufferPacked indexBuffer,
OperationType  operationType 
)

Member Function Documentation

◆ clone()

VertexArrayObject* Ogre::VertexArrayObject::clone ( VaoManager vaoManager,
SharedVertexBufferMap sharedBuffers,
int  vertexBufferType = -1,
int  indexBufferType = -1 
) const

Clones the vertex & index buffers and creates a new VertexArrayObject.

The only exception is when one of the vertex buffers is already in sharedBuffers, in which case the buffer in sharedBuffers.find(vertexBuffer)->second will be used without cloning (useful for cloning LODs).

Parameters
vaoManagerThe VaoManager needed to create the structures
sharedBuffers[in/out] Maps old vertex buffers to new vertex buffers so that we can reuse them. Optional. Use a null pointer to disable this feature.
vertexBufferTypeSee BufferType. Must be set to a valid BufferType. Pass a negative value to keep the same type of the original buffer being cloned.
indexBufferTypeSee BufferType. Must be set to a valid BufferType. Pass a negative value to keep the same type of the original buffer being cloned.
Returns
New cloned Vao.

◆ findBySemantic()

const VertexElement2* Ogre::VertexArrayObject::findBySemantic ( VertexElementSemantic  semantic,
size_t &  outIndex,
size_t &  outOffset,
size_t  repeat = 0 
) const

Returns the entire VertexElement2 descriptor in the vertex buffers.

Parameters
semanticSemantic to look for.
outIndexThe index to mVertexBuffers[index] if it's found. Otherwise the value is left untouched.
outIndexThe offset in bytes to retrieve the element in the vertex data. If the semantic isn't found, the value is left untouched.
repeatThe number of times to skip a semantic before returning the hit. Useful when you have more than one VES_TEXTURE_COORDINATES for example. Set repeat = 0 to retrieve the first set of VES_TEXTURE_COORDINATES Set repeat = 1 to retrieve the second set of VES_TEXTURE_COORDINATES etc.
Returns
Null if not found. The returned pointer might be invalidated by future calls (e.g. something happens to the vertex buffer or the Vao) although this is strange since in general these objects are immutable once they've been constructed.

◆ getBaseVertexBuffer()

VertexBufferPacked* Ogre::VertexArrayObject::getBaseVertexBuffer ( ) const
inline

◆ getIndexBuffer()

IndexBufferPacked* Ogre::VertexArrayObject::getIndexBuffer ( ) const
inline

◆ getInputLayoutId()

uint16 Ogre::VertexArrayObject::getInputLayoutId ( ) const
inline

◆ getOperationType()

OperationType Ogre::VertexArrayObject::getOperationType ( ) const
inline

◆ getPrimitiveCount()

uint32 Ogre::VertexArrayObject::getPrimitiveCount ( ) const
inline

◆ getPrimitiveStart()

uint32 Ogre::VertexArrayObject::getPrimitiveStart ( ) const
inline

◆ getRenderQueueId()

uint32 Ogre::VertexArrayObject::getRenderQueueId ( ) const
inline

◆ getVaoName()

uint32 Ogre::VertexArrayObject::getVaoName ( ) const
inline

◆ getVertexBuffers()

const VertexBufferPackedVec& Ogre::VertexArrayObject::getVertexBuffers ( ) const
inline

◆ getVertexDeclaration() [1/2]

VertexElement2VecVec Ogre::VertexArrayObject::getVertexDeclaration ( ) const

Gets the combined vertex declaration of all the vertex buffers.

Note that we iterate through all of them and allocate the vector. You should cache the result rather than calling this function frequently.

◆ getVertexDeclaration() [2/2]

static VertexElement2VecVec Ogre::VertexArrayObject::getVertexDeclaration ( const VertexBufferPackedVec vertexBuffers)
static

◆ mapAsyncTickets()

static void Ogre::VertexArrayObject::mapAsyncTickets ( ReadRequestsVec tickets)
static

Maps the buffers requested via.

See also
readRequests

◆ readRequests()

void Ogre::VertexArrayObject::readRequests ( ReadRequestsVec requests,
size_t  elementStart = 0,
size_t  elementCount = 0,
bool  skipRequestIfBufferHasShadowCopy = false 
)

Utility to get multiple pointers & read specific elements of the vertex, even if they're in separate buffers.

When two elements share the same buffer, only one ticket is created.

Example usage: VertexArrayObject::ReadRequestsVec requests; requests.push_back( VertexArrayObject::ReadRequests( VES_POSITION ) ); requests.push_back( VertexArrayObject::ReadRequests( VES_NORMALS ) ); vao->readRequests( requests ); vao->mapAsyncTickets( requests );

for( size_t i=0; i<numVertices; ++i ) { float const position = reinterpret_cast<const float>( requests[0].data ); float const normals = reinterpret_cast<const float>( requests[1].data );

requests[0].data += requests[0].vertexBuffer->getBytesPerElement(); requests[1].data += requests[1].vertexBuffer->getBytesPerElement(); }

vao->unmapAsyncTickets( requests );

Remarks
Throws if an element couldn't be found.
Parameters
requests[in/out] Array filled with the semantic.
skipRequestIfBufferHasShadowCopyAvoid generating the AsyncTicket if the buffer has a shadow copy. Useful if you want to read directly from the shadow copy instead of downloading from the GPU. The 'data' variable will be filled immediately if there's a shadow copy available, and mapAsyncTickets can be safely called even if skipRequestIfBufferHasShadowCopy=true

◆ setPrimitiveRange()

void Ogre::VertexArrayObject::setPrimitiveRange ( uint32  primStart,
uint32  primCount 
)

Limits the range of triangle primitives that is rendered.

For VAOs with index buffers, this controls the index start & count, akin to indexStart & indexCount from the v1 objects.

For VAOs with no index buffers, this controls the vertex start & count, akin to vertexStart & vertexCount from the v1 objects.
Remarks
An exception is thrown if primStart, or primStart + primCount are out of the half open range: [0; mIndexBuffer->getNumElements()) or [0; mVertexBuffers[0]->getNumElements())
Parameters are always in elements (indices or vertices)

◆ unmapAsyncTickets()

static void Ogre::VertexArrayObject::unmapAsyncTickets ( ReadRequestsVec tickets)
static

Unmaps the buffers mapped via.

See also
mapAsyncTickets

Member Data Documentation

◆ msDummyVertexBuffer

VertexBufferPacked Ogre::VertexArrayObject::msDummyVertexBuffer
static

When a Vao doesn't have a vertex buffer, a dummy one is assigned for performance reasons (avoid checking if pointer is null, avoid crashing inside Ogre)


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