OGRE 2.1
Object-Oriented Graphics Rendering Engine
Loading...
Searching...
No Matches
Ogre::MultiSourceVertexBufferPool Class Referenceabstract

Vertex Array Objects do not need to change when: The same (internal) vertex buffer is still bound. More...

#include <OgreMultiSourceVertexBufferPool.h>

+ Inheritance diagram for Ogre::MultiSourceVertexBufferPool:

Public Member Functions

 MultiSourceVertexBufferPool (const VertexElement2VecVec &vertexElementsBySource, size_t maxVertices, BufferType bufferType, size_t internalBufferStart, VaoManager *vaoManager)
 
virtual ~MultiSourceVertexBufferPool ()
 
virtual void createVertexBuffers (VertexBufferPackedVec &outVertexBuffers, size_t numVertices, void *const *initialData, bool keepAsShadow)=0
 Creates a vertex buffer based on the given parameters.
 
void destroyVertexBuffers (VertexBufferPackedVec &inOutVertexBuffers)
 Destroys all the buffers returned from a call to createVertexBuffers.
 
size_t getBytesOffsetToSource (uint8 sourceIdx) const
 
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
 

Detailed Description

Vertex Array Objects do not need to change when: The same (internal) vertex buffer is still bound.

The same vertex format is still used. The same (internal) index buffer is still bound. This also allows for MultDrawIndirect to render multiple meshes in just one call. Ogre takes care of pretending that multiple different vertex buffers are indepedent when internally we keep everything within the same buffers.

However multisource buffers (i.e. having position in one buffer, UVs in another) pose a problem: In order to keep using the same VAO, the internal distance between the start (offset) of the position and the start of the UVs in the buffer must remain the same for all the meshes using the same multisource vertex declaration.
Here's where MultiSourceVertexBufferPool comes into play: We need an extra layer on top of the VaoManager to manage multisource vertex buffers, in addition to the regular memory management the VaoManager already performs.
First create a MultiSourceVertexBufferPool from the VaoManager, then request the group of vertex buffers to this class.
Remarks
Only the combination of buffers returned by createVertexBuffers can be bound together. Trying to bind a buffer from two different createVertexBuffers calls is not allowed.

Constructor & Destructor Documentation

◆ MultiSourceVertexBufferPool()

Ogre::MultiSourceVertexBufferPool::MultiSourceVertexBufferPool ( const VertexElement2VecVec vertexElementsBySource,
size_t  maxVertices,
BufferType  bufferType,
size_t  internalBufferStart,
VaoManager vaoManager 
)

◆ ~MultiSourceVertexBufferPool()

virtual Ogre::MultiSourceVertexBufferPool::~MultiSourceVertexBufferPool ( )
inlinevirtual

Member Function Documentation

◆ createVertexBuffers()

virtual void Ogre::MultiSourceVertexBufferPool::createVertexBuffers ( VertexBufferPackedVec outVertexBuffers,
size_t  numVertices,
void *const initialData,
bool  keepAsShadow 
)
pure virtual

Creates a vertex buffer based on the given parameters.

Behind the scenes, the vertex buffer is part of much larger vertex buffer, in order to reduce bindings at runtime.

Parameters
outVertexBuffers[out] A list of the generated vertex buffers, one per buffer source in mVertexElementsPerSource. WARNING: Can be empty if the pool is out of memory or too fragmented to honour this request, in which case you need to use another pool (or free some memory from this pool).
numVerticesThe number of vertices for these vertex buffer.
initialDataInitial data the buffer will hold upon creation. Can be null (i.e. you plan to upload later). Cannot be null when bufferType is BT_IMMUTABLE. Must have enough room to prevent an overflow. If non-null, the buffer must hold enough data for each vertex buffers. E.g. If mVertexElementsPerSource.size() == 3 then this is valid: initialData = 0; This is also valid: initialData[0] = buffer[numVertices * sumOfBytes(mVertexElementsPerSource[0])]; initialData[1] = 0; //Unless bufferType == BT_IMMUTABLE initialData[2] = buffer[numVertices * sumOfBytes(mVertexElementsPerSource[2])];

This is invalid: initialData[0] = whatever; initialData[1] = out of bounds;

Parameters
keepAsShadowWhether to keep the pointer "initialData" as a shadow copy of the contents. @See BufferPacked::BufferPacked regarding on who is responsible for freeing this pointer and what happens if an exception was raised.
Returns
The desired vertex buffer pointer

Implemented in Ogre::GL3PlusMultiSourceVertexBufferPool, Ogre::GLES2MultiSourceVertexBufferPool, Ogre::MetalMultiSourceVertexBufferPool, and Ogre::NULLMultiSourceVertexBufferPool.

◆ destroyVertexBuffers()

void Ogre::MultiSourceVertexBufferPool::destroyVertexBuffers ( VertexBufferPackedVec inOutVertexBuffers)

Destroys all the buffers returned from a call to createVertexBuffers.

All the returned buffers from that call must be supplied. Not one more, not one less. They can be in any order, though.

Parameters
inOutVertexBuffers[in] [out] In: The list of buffers that was returned by createVertexBuffers. Can be sorted in any order Out: Cleared list.

◆ getBytesOffsetToSource()

size_t Ogre::MultiSourceVertexBufferPool::getBytesOffsetToSource ( uint8  sourceIdx) const

◆ 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


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