Siamak M. Mirzaie
Siamak M. Mirzaie

Reputation: 234

Opengl increase in speed after few seconds

I am developing a rendering engine with OpenGL as base renderer. The renderer start with 150 fps in beginning and after 30 seconds or so the fps increases to 500. I have timed each part of the engine separately and the only part that increase in speed is the drawMesh function which binds the [static]VBOs and calls the glDrawArrays.

I have also commented the glPush and glGet functions with the same behavior as result.

This happens every time i run the engine, even when the camera is not moved and remains rendering the exact same scene.

Does anyone has any idea how this can be happening?

Upvotes: 0

Views: 189

Answers (2)

Siamak M. Mirzaie
Siamak M. Mirzaie

Reputation: 234

The problem

The problem arises from the VBO being mapped to a buffer after being created. The model class does this once to update its boundaries; and in case of particles to update the buffer with required data.

As it seems the video-card (or at least in my case having a Geforce GTS 450) does not copy the data back into the video-card directly after unmapping the VBO, specially when using the GL_READ_WRITE_ARB flag for mapping the buffer. it will keep the data in external RAM for few seconds before copying the data back into the VRAM.

The solution

By using the GL_READ_ONLY_ARB flag to map the data which are supposed to only read the data, the buffer will get copied back into the VRAM almost directly. However in my case it would be much more efficient to calculate the boundaries during the mesh conversation and not accessing the data at all once the VBO is created for such purposes.

Upvotes: 1

MrLeap
MrLeap

Reputation: 506

Maybe it's because shaders are compiled just-in-time before first usage.

Take a look at GL_ARB_get_program_binary

Also, try rendering a triangle ( can probably do this off screen) with your shaders as you load them during the initialization phase.

Upvotes: 0

Related Questions