Buffer rendering slow on start

So I’m rendering my game with OpenGL using several types of buffers:

  • A huge buffer containing the map (50,000 - 100,000 vertices). It is only filled once and used many times (so flagged as GL_STATIC_DRAW).
  • Some very small individual buffers containing things that can change often (actually so far only one containing the player’s character).

The whole thing is rendered using very simple shaders I’ve written.

When the whole thing starts, the buffers are filled with no problem, then the scene is rendered at a very stable but low 8-10 FPS per second for about 5 seconds, which is very uncomfortable. Then, the scene simply renders at a glorious 60+ FPS for as long as I run the game. It’s simply a kickstart problem.

I’m starting to have a lot of experience with OpenGL 3.3+ but have no idea why the first frames are so slow. I tried to put some glFinish() commands a bit everywhere but it doesn’t change anything.

Actually I have a glFinish() (right after the buffer swap) between frames that prevents some consistent lag spikes from happening. When I remove it, the “starting lag” is gone but I have a slight permanent lag because I don’t tell OpenGL to finish its commands.

So my conclusion is, when during the first frames, because I ask OpenGL to glFinish(), it’s taking a lot of time. Does anybody know why and has experience with fixing this? Or should I put some sort of “fake loading screen” that would give the starting lag enough time to go away?

Sorry, with additionnal tests the problem turns out entirely different.

It turns out that the lag wasn’t due to low FPS. The rendering was choppy but the FPS was still 60.

I disabled v-sync and now it is rendering smoothly all the time at 1400 FPS.

Now the question is why vsync, supposed to enhance performances, is making it choppy during the first 5 seconds… I’m using glew + SDL2.

I suspect SDL2 has something to do with this.