The video card is my bottleneck - how to speed it up?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
fargoth
Posts: 22
Joined: Fri May 01, 2015 7:43 pm

The video card is my bottleneck - how to speed it up?

Post by fargoth »

I've used the CBatchingMesh to hold my whole maze - since I thought it's not that big and demanding - it's just 250 planes + 500 boxes - all boxes with same texture of about 100kb and all planes with the same texture of about the same size...

I only see about 10th of these planes and boxes at a given time, so I can split them up into 25 planes + 50 boxes and dynamically turn them on or off as I move about (Is setVisible(false) enough - or do I have to drop the sceneNodes and re-create them?)

Here's my current code:

Code: Select all

 
                //get vector of horizontal or vertical walls with x1,y1 and x2,y2 (where x1<=x2, and y1<=y2, and if x2-x1 is none-zero than y2==y1 and vice versa)
        auto walls = _worldModel.getMaze().getMazeWalls();
 
        irr::extra::irr_ptr<irr::scene::CBatchingMesh *> batchingMesh(new irr::scene::CBatchingMesh());
        
        irr::scene::IGeometryCreator const * geometryCreator(_sceneManager->getGeometryCreator());
        irr::extra::irr_ptr<irr::scene::IMesh *> floorTile(geometryCreator->createPlaneMesh(irr::core::dimension2d<irr::f32>(1, 1)));
        floorTile->getMeshBuffer(0)->getMaterial().setTexture(0, _videoDriver->getTexture("..\\media\\floor.jpg"));
        for (unsigned int y = 0; y < _length; ++y)
        {
            for (unsigned int x = 0; x < _width; ++x)
            {
                batchingMesh->addMesh(floorTile.get(),
                    irr::core::vector3df(x - 0.5, 0,
                    y - 0.5));
            }
        }
        irr::extra::irr_ptr<irr::scene::IMesh *> horizontalBoundingWall(geometryCreator->createCubeMesh(irr::core::vector3df(0.9f, 1.5f, 0.1f)));
        irr::extra::irr_ptr<irr::scene::IMesh *> verticalBoundingWall(geometryCreator->createCubeMesh(irr::core::vector3df(0.1f, 1.5f, 0.9f)));
        auto wallTexture = _videoDriver->getTexture("../media/t351sml.jpg");
        horizontalBoundingWall->getMeshBuffer(0)->getMaterial().setTexture(0, wallTexture);
        verticalBoundingWall->getMeshBuffer(0)->getMaterial().setTexture(0, wallTexture);
        float horizontalWallOffsetX = -0.45f;
        float horizontalWallOffsetY = -0.95f;
        float verticalWallOffsetX = -0.95f;
        float verticalWallOffsetY = -0.45f;
        //add maze bounding walls
        for (unsigned int x = 0; x < _width; ++x)
        {
            batchingMesh->addMesh(horizontalBoundingWall.get(), irr::core::vector3df(x + horizontalWallOffsetX, 0, horizontalWallOffsetY));
            batchingMesh->addMesh(horizontalBoundingWall.get(), irr::core::vector3df(x + horizontalWallOffsetX, 0, horizontalWallOffsetY + _length));
        }
        for (unsigned int y = 0; y < _length; ++y)
        {
            batchingMesh->addMesh(verticalBoundingWall.get(), irr::core::vector3df(verticalWallOffsetX, 0, y + verticalWallOffsetY));
            batchingMesh->addMesh(verticalBoundingWall.get(), irr::core::vector3df(verticalWallOffsetX + _width, 0, y + verticalWallOffsetY));
        }
 
        //add all other maze walls
        for (const auto & wall : walls)
        {
            int dx = wall.x2 - wall.x1;
            int dy = wall.y2 - wall.y1;
            if (dx) //check if horizontal wall
            {
                for (auto x = 0; x < dx; ++x)
                    batchingMesh->addMesh(horizontalBoundingWall.get(), irr::core::vector3df(x + wall.x1 + horizontalWallOffsetX, 0,
                    wall.y1 + horizontalWallOffsetY));
            }
            else //or vertical wall
            {
                for (auto y = 0; y < dy; ++y)
                    batchingMesh->addMesh(verticalBoundingWall.get(), irr::core::vector3df(wall.x1 + verticalWallOffsetX, 0,
                    y + wall.y1 + verticalWallOffsetY));
            }
        }
        batchingMesh->update();
        auto floorNode = _sceneManager->addMeshSceneNode(batchingMesh.get(), _sceneManager->getRootSceneNode(), 0);
 
And my profiler's conclusions:
Image
Post Reply