开发者

OpenGL drawing time

开发者 https://www.devze.com 2023-04-03 17:55 出处:网络
When does OpenGL actually draw things I instruct it to? is it on the call to the specific drawing function or on the buffer swap?

When does OpenGL actually draw things I instruct it to? is it on the call to the specific drawing function or on the buffer swap?

I want to know this to see if I can do something li开发者_如何学JAVAke this:

SomeTimer Timer;

Timer.Start();
glDrawArrays(...);
long time = Timer.Stop();

To see what drawing takes the most time and optimize based on that.

If it matters: I'm drawing only in 2d, no stencil/depth or any other buffer tests.


That code will not work. OpenGL commands are by definition assumed to be asynchronous in behavior. GL commands are required to have fully written to or read from any parameters before they complete. But outside of that, all bets are off.

Timing any individual glDraw* call will tell you only how much time it takes that function call to complete. It says nothing about how long the rendering takes to finish.

A more thorough discussion of this subject is available.

The upside is that you can time rendering, but you have to do it OpenGL's way. ARB_timer_query allows you to do exactly that: time how long it takes for OpenGL commands to complete, not merely be given to OpenGL. This extension is core in OpenGL 3.3, and it is pretty widely available for various levels of hardware. Pretty much any GPU still being supported by its owner implements this.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号