Maximum size of a VertexArrayObject? Topic is solved

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
Posts: 7
Joined: Tue Aug 24, 2021 7:52 am

Maximum size of a VertexArrayObject?

Post by maz_1 »

I'm trying to render a point cloud with Ogre::Renderable with code like this:

Code: Select all

    // definition of PointCloudObject::Point
    struct Point {
        float px, py, pz;   //Position
        Ogre::ARGB c;   //Color
        Point() {}
        Point( float _px, float _py, float _pz, uint32_t _c ) : px( _px ), py( _py ), pz( _pz ), c( _c ){}
        void setColor(Ogre::ColourValue color) {c = color.getAsABGR();}
        void setColor(float r, float g, float b, float a) {c = Ogre::ColourValue(r, g, b, a).getAsABGR();}

    Ogre::uint16 *vertexIndices = reinterpret_cast<Ogre::uint16*>( OGRE_MALLOC_SIMD( sizeof(Ogre::uint16) * bufferSize, Ogre::MEMCATEGORY_GEOMETRY ) );
    #pragma omp parallel for
    for (int i = 0; i < bufferSize; i++) {
        vertexIndices[i] = i;
    Ogre::IndexBufferPacked *indexBuffer = vaoManager->createIndexBuffer( Ogre::IndexBufferPacked::IT_16BIT, bufferSize, Ogre::BT_IMMUTABLE, vertexIndices, true );
    //Vertex declaration
    Ogre::VertexElement2Vec vertexElements;
    vertexElements.push_back( Ogre::VertexElement2( Ogre::VET_FLOAT3, Ogre::VES_POSITION ) );
    vertexElements.push_back( Ogre::VertexElement2( Ogre::VET_COLOUR, Ogre::VES_DIFFUSE ) );
    PointCloudObject::Point *cloudVertices = reinterpret_cast<PointCloudObject::Point*>( OGRE_MALLOC_SIMD(
                sizeof(PointCloudObject::Point) * bufferSize,
                Ogre::MEMCATEGORY_GEOMETRY ) );
    memcpy( cloudVertices, pointBuffer, sizeof(PointCloudObject::Point) * bufferSize );
    Ogre::VertexBufferPacked *vertexBuffer = vaoManager->createVertexBuffer( vertexElements, bufferSize, Ogre::BT_IMMUTABLE, cloudVertices, true );
    Ogre::VertexBufferPackedVec vertexBuffers;
    vertexBuffers.push_back( vertexBuffer );
    Ogre::VertexArrayObject *vao = vaoManager->createVertexArrayObject( vertexBuffers, indexBuffer, Ogre::OT_POINT_LIST );
    mVaoPerLod[0].push_back( vao );
I refered the point cloud rendering implement with ogre 1.x by ROS Rviz( ... _cloud.cpp), They limited maximum vertices per renderable to (36 * 1024 * 10), however with above codeI can only render points equal or less than (1024 * 64), is there a hard-coded limitation of vertices per VertexArrayObject? If so, could I change it?
User avatar
OGRE Team Member
OGRE Team Member
Posts: 4740
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1035

Re: Maximum size of a VertexArrayObject?

Post by dark_sylinc »


You're using 16-bit indices which has an obvious limit of 65535.

If you want more, switch to 32-bit indices i.e. IndexBufferPacked::IT_32BIT and use an uint32 ptr.

Other than that, the only limits are imposed by HW and tend to be quite large (at least 16 million which is 2^24 but it can be a lot more) assuming you don't run out of memory first

Btw an index buffer for a point cloud is unnecessary. You can get rid of it to save ram and performance (just pass a nullptr)

Post Reply