Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL framerate: connection with the size of the window

I was in the process of tracking down and eliminating those parts of my C++/OpenGL/GLUT code that were inefficient and slow, and in doing so, I watched my frames per second counter to know if I was actually making progress. I noticed that my frame rate dropped from about 120 to 60 if I maximized the window.

Further experimentation revealed that this was a linear thing, I could change the frame rate by changing the size of the window.

Does this mean that my bottleneck in in the GPU rendering? Surely GPUs these days are more than powerful enough not to notice the difference between a 300x300 and 1920x1080? Or am I asking too much from my graphics card?

The alternative is that there is some bug in my code that is causing the system to slow down on larger renders.

What I am asking is this: is it reasonable to expect a halving of framerate when changing the window size, or is there something very wrong?

like image 253
rspencer Avatar asked Dec 12 '22 10:12

rspencer


1 Answers

Further experimentation revealed that this was a linear thing, I could change the frame rate by changing the size of the window.

Congratulations: You discovered fill rate

Does this mean that my bottleneck in in the GPU rendering?

Yes, pretty much. To be specific the bottleneck is either the bandwidth from/to the graphics memory, or the complexity of the fragment shader, or a combination of both.

Surely GPUs these days are more than powerful enough not to notice the difference between a 300x300 and 1920x1080?

300×300   =   90000
1920×1080 = 2073600

Or in other words: You ask the GPU to fill about 20 times as many pixels. Which means 20 times as much data must be flung around and also be processed.

That drop from 120Hz to 60Hz comes from V-Sync. If you disabled V-Sync you'd find, that your program would probably reach way higher rates than 60Hz for 1920×1080, but for 300×300 it will be something below 180Hz.

The reason for that is simple: When synched to the display vertical retrace, your GPU can "put out" the next frame only at the moment the display is v-syncing. If your display can do 120Hz (like yours as it's obvious) and your rendering takes less time than 1/120s to complete it will make the deadline and your framerate synchronizes to the display. If however drawing a frame takes more then 1/120s, then it will sync with every 2nd frame displayed. If rendering takes more than 1/60s second every 3rd, 1/30s every 4th and so on.

like image 126
datenwolf Avatar answered Dec 23 '22 19:12

datenwolf