OGRE 2.1
Object-Oriented Graphics Rendering Engine
Loading...
Searching...
No Matches
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 FastArray< ReadRequestsReadRequestsArray
 

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.
 
const VertexElement2findBySemantic (VertexElementSemantic semantic, size_t &outIndex, size_t &outOffset, size_t repeat=0) const
 Returns the entire VertexElement2 descriptor in the vertex buffers.
 
VertexBufferPackedgetBaseVertexBuffer (void) const
 
IndexBufferPackedgetIndexBuffer (void) const
 
uint16 getInputLayoutId (void) const
 
OperationType getOperationType (void) const
 
uint32 getPrimitiveCount (void) const
 
uint32 getPrimitiveStart (void) const
 
uint32 getRenderQueueId (void) const
 
uint32 getVaoName (void) const
 
const VertexBufferPackedVecgetVertexBuffers (void) const
 
VertexElement2VecVec getVertexDeclaration (void) const
 Gets the combined vertex declaration of all the vertex buffers.
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete (void *ptr, void *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info
 
voidoperator new (size_t sz, void *ptr)
 placement operator new
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info
 
void readRequests (ReadRequestsArray &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.
 
void setPrimitiveRange (uint32 primStart, uint32 primCount)
 Limits the range of triangle primitives that is rendered.
 

Static Public Member Functions

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

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)
 

Friends

class D3D11RenderSystem
 
class GL3PlusRenderSystem
 
class GLES2RenderSystem
 
class MetalRenderSystem
 
class RenderQueue
 
class RenderSystem
 

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

◆ ReadRequestsArray

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 ( void  ) const
inline

◆ getIndexBuffer()

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

◆ getInputLayoutId()

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

◆ getOperationType()

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

◆ getPrimitiveCount()

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

◆ getPrimitiveStart()

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

◆ getRenderQueueId()

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

◆ getVaoName()

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

◆ getVertexBuffers()

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

◆ getVertexDeclaration() [1/2]

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

◆ getVertexDeclaration() [2/2]

VertexElement2VecVec Ogre::VertexArrayObject::getVertexDeclaration ( void  ) 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.

◆ mapAsyncTickets()

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

Maps the buffers requested via.

See also
readRequests

◆ operator delete() [1/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void ptr)
inlineinherited

◆ operator delete() [2/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void ptr,
const char ,
int  ,
const char  
)
inlineinherited

◆ operator delete() [3/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void ptr,
void  
)
inlineinherited

◆ operator delete[]() [1/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void ptr)
inlineinherited

◆ operator delete[]() [2/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void ptr,
const char ,
int  ,
const char  
)
inlineinherited

◆ operator new() [1/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

◆ operator new() [2/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char file,
int  line,
const char func 
)
inlineinherited

operator new, with debug line info

◆ operator new() [3/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void ptr 
)
inlineinherited

placement operator new

◆ operator new[]() [1/2]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inlineinherited

◆ operator new[]() [2/2]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char file,
int  line,
const char func 
)
inlineinherited

array operator new, with debug line info

◆ readRequests()

void Ogre::VertexArrayObject::readRequests ( ReadRequestsArray 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::ReadRequestsArray 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 ( ReadRequestsArray tickets)
static

Unmaps the buffers mapped via.

See also
mapAsyncTickets

Friends And Related Symbol Documentation

◆ D3D11RenderSystem

◆ GL3PlusRenderSystem

◆ GLES2RenderSystem

◆ MetalRenderSystem

◆ RenderQueue

◆ RenderSystem

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: