PDA

View Full Version : Why is glViewport slow?



jonask
10-06-2002, 04:59 AM
For reasons I'm not very proud of, I called glViewport three times per frame. That was obviously not necessary, but what surprised me was that my profiler indicated glViewport consumed 5% of the elapsed time. Why is glViewport that expensive? It seems a bit out of proportion for just setting the device-to-window transformation...

Thanks,

/Jonas

PS. I use a GeForce3 with Nvidia's 30.82 drivers.

jwatte
10-06-2002, 09:43 AM
Just a guess: It probably has to go asking GDI about other child windows in the main window, and possibly even sycnrhonize up with a GDI flush.

*shudder*

cass
10-06-2002, 05:20 PM
Jonas,

That doesn't make any sense to me either. Do you have a simple example I could pass along to the driver folks to take a look at?

Thanks -
Cass

MichaelK
10-07-2002, 01:04 AM
Maybe You should use glScissor instead of glViewport?

Asgard
10-07-2002, 02:35 AM
Cass,

Talking about the drivers guys. Passing in NULL as 'attributes' parameter to wglCreatePbuffer (which is fine according to the spec) still gives an access violation in NVOGLNT.dll in the 40.72 drivers.
I've already reported this here http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/007527.html
but apparently nobody of you guys read it http://www.opengl.org/discussion_boards/ubb/smile.gif

Cheers.

V-man
10-07-2002, 11:17 AM
Maybe glViewport is making up 5% of the calls (more or less).


V-man

pbrown
10-07-2002, 06:45 PM
Originally posted by Asgard:
Cass,

Talking about the drivers guys. Passing in NULL as 'attributes' parameter to wglCreatePbuffer (which is fine according to the spec) still gives an access violation in NVOGLNT.dll in the 40.72 drivers.
I've already reported this here http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/007527.html
but apparently nobody of you guys read it http://www.opengl.org/discussion_boards/ubb/smile.gif

Cheers.

Asgard,

Sorry I didn't notice your earlier post.

Looking at the extension spec in the registry, I'm not sure how you came to the conclusion that passing in a NULL pointer for the <piAttribList> argument of wglCreatePbufferARB is valid.



<piAttribList> is a list of attributes {type, value} pairs
containing integer attribute values. All of the attributes in the
<piAttribList> are followed by the corresponding required value.
The list is terminated with a value of 0.


My reading of this is that you keep reading the contents of <piAttribList> until you find a zero. That's exactly what the driver does.

It's utterly trivial to "fix" this behavior by checking for NULL, but that doesn't seem to be what the spec says. Is there something I'm missing?

[This message has been edited by pbrown (edited 10-07-2002).]

Humus
10-07-2002, 07:09 PM
From WGL_ARB_render_texture:



Modify wglCreatePbufferARB:

HPBUFFERARB wglCreatePbufferARB (HDC hDC, int iPixelFormat,
int iWidth, int iHeight, const int *piAttribList);

<snip>

<piAttribList> may be NULL or empty in which case all attributes assume
their default values as described below.

pbrown
10-07-2002, 07:49 PM
Dueling specs. How nice. :-)

I will update our driver tomorrow to implement the behavior specified in ARB_render_texture, since it's obviously the less restrictive behavior.

To be on the safe side for "old" drivers, I'd recommend passing in a list of zeroes instead of using a NULL pointer.

Thanks for the heads-up.

jonask
10-08-2002, 05:21 AM
You're right, V-man. 5% doesn't say very much.

In my test-run, glViewport takes two times longer to execute than a standard 4x4 matrix transpose. That's maybe not too bad, after all.

/Jonas