SwapBuffers slow

Started by
5 comments, last by b2b3 18 years, 1 month ago
Hi all, I'm using Win32/opengl under c++. When I call "SwapBuffers()", that call takes longer or shorter depending on how many triangles I've rendered. But my actual "glBegin" and "glEnd" calls aren't taking nearly as much time. I'm assuming this means OGL is doing stuff in the background and has to finish that before it can swap buffers? Does anyone know what that means, in terms of optimization? Am I cpu-bound, or vertex bound, or what? -Thomas
Advertisement
try turning of V-sinc
that could help
Someone who uses a, euhm..., delta!?
Quote:Original post by delta user
try turning of V-sinc
that could help..


...you to to see if your scene is getting rendered "in time" between refreshes.
[size="2"]I like the Walrus best.
SwapBuffers() waits for your monitor to refresh if V-sinc is enabled
Someone who uses a, euhm..., delta!?
Yeah, I checked v-sync, doesn't change much.

The time to run SwapBuffers actually increases if I'm rendering more triangles. So I suspect that its actually working and doing things.

So... any optimization suggestions?

-Thomas
I think I might explain that, someone correctly if I am wrong.

Generally, you use GL commands to pass the data to GPU, passing takes allot less time , then rendering it. So the CPU passed the whole data, but GPU didn't finish rendering all the primitives. The swap buffer actually waits for GPU to render all the data, so that there won't be any artefact's, thats why the delay is present.

About any optimizations, well use the faster methods to draw primitives, Vertex Buffers/Arrays, Lists and so on, and try to send all the drawing first, then physics or other CPU dependent calculations, so the GPU and CPU would be both busy at the same time.
When you use immediate mode in OpenGL you are not sending triangles directly to the GPU. You are just sending them to the some buffer allocated for your context by the driver. When this buffer is full or when you call method which forces synchronization data is sent to the GPU and then rasterized. SwapBuffers is one of these commands because it has to assure everything is drawn before you start working on the next frame. So if you are rendering only few triangles they are all being rendered when you call SwapBuffers. It's basically what DMINATOR said.

And to speed up your rendering process you can use display lists, vertex arrays or vbos (I think they are preferred method nowadays).

This topic is closed to new replies.

Advertisement