Jump to content
  • Advertisement
Sign in to follow this  
thomahawk

OpenGL SwapBuffers slow

This topic is 4548 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!