i’ve been timing functions looking for bottlenecks in my code and found that the call to SwapBuffers was taking on average 15ms… i find this high but is it normal?
the pixel format is 32bit color / 24bit depth / 8bit alpha / 8bit stencil
Yes it’s normal, SwapBuffers makes sure everything is finished before it swaps the buffers, and if you have vsync on then it waits even longer until the next frame starts to redraw.
SwapBuffers does not really do anything in this time. So if you use more CPU time outside SwapBuffers, the wait time decreases and the whole frame time should stay (roughly) the same.
Say your monitor has an update rate of 60Hz (60-100Hz is common)
Say your application can run at 120 FPS.
With vsync disabled, the user sees half of one frame and half of another frame. (Commonly called tearing)
With VSync enabled you will get exactly 60 FPS.
The catch is, if you app can only run at 45 FPS, the user sees 30FPS with Vsync enabled. (or even worse if your app runs at 29FPS, it will clamp to 15FPS)