PDA

View Full Version : Waiting for sync when flushing with glut. CPU overload.



Drakkhen
10-19-2004, 03:43 PM
Hi,

I have an empty view (background color) with a mouse cursor I display and bitmap text coordinates in a corner, CPU load is ~15% up to ~20% when moving it. But when I simply added the display of a (250x261x24) bitmap previously stored in memory (once), CPU load jumped to 100% and sticked to it.

I thought the glDrawPixels function with the later glFlush would wait for buffer swapping to be finished and thus wouldn't run faster than the frame refreshes. So I suspected another func to make his own stuff meanwhile (dumb idea since it would have done it with the empty menu too).
To be sure, I added counters in glutDisplayFunc, glutIdleFunc and the rest of them that proove there's no function running more times than others.
Then I looked for a command that would allow me to "wait" for buffer swap in case I would have to add it in adequate funcs when flushing but didn't found one.

Is it normal the CPU load is at max as soon as ONE single bitmap is send to card?
Does glFlush "wait" for display refresh (I assumed it did since I set the flag for sync.)?
If it does, could there be any conflict between gl functions and glut ones?

Did someone see some similar CPU load variations? And why as we display something else than simple text or lines?

P.S.With another small graphic engine without glut libs (only gl ones), I experienced the same problem. It allows the engine to run (up to 900 objects (cubic visuals) sliding on a 3Dworld "ground" at 50fps) but CPU load sticks to 100% even with no object as soon as I display a triangle.

Maybe is it something (a flag) to set on Funcs?

Thanx for any clue.

yooyo
10-21-2004, 12:03 AM
The problem is that you SENDING image data from system memory to GPU memory EVERY FRAME. To avoid this, upload image as texture once and render textured quad every frame.

yooyo

Drakkhen
10-21-2004, 12:09 AM
Ah, you're right.
But do I need to keep one in RAM also or is graphic memory enough? (in a general way)

ZbuffeR
10-21-2004, 02:25 AM
If you don't need to modify the texture after binding, you can free your RAM array, it will stay on the card (or in AGP memory if needed). No need to keep it.

Drakkhen
10-21-2004, 02:55 AM
Got the picture.
Thanx both.