PDA

View Full Version : glPopAttrib() throws GL_INVALID_OPERATION ?!



Simon Eves
05-01-2008, 03:19 PM
Forgive my newbie posting in the Advanced Forum, but it could be an advanced question...

I am writing a GPU-accelerated renderer inside Softimage XSI, and have a repeatable but inexplicable problem. The renderer does multiple passes (depth, screen-space ambient occlusion, environment maps, shadow maps, off-screen beauty pass to FBO with CSAA, final quad render to screen with gamma and motion blur).

Everything works fine when rendering directly to the screen. When batch rendering, there is an additional FBO wrapped around the whole process, and in that case the first render from cold, or from any interactive work inside the application, always throws an error and renders black.

The error is a GL_INVALID_OPERATION thrown by the very final glPopAttrib() call in the rendering sequence. I am checking this with a macro which loops while glError() != GL_ERROR_NONE which is placed after every single GL or GL-related call in the code, so it's definitely this function and this function alone.

If I immediately hit the RENDER button again without having done any interactive manipulation in the app to cause other GL stuff to happen, it renders fine. Similarly an off-screen batch render results in one black frame (and error) and the rest just fine.

The docs, of course, say that the only way that glPopAttrib() can throw a GL_INVALID_OPERATION is if called between glBegin/End, which is certainly not the case (I have traced the code paths in great detail).

If anyone has any idea why this is happening, or suggest any tools which might allow me to work it out myself, please advise.

The system is as follows:

Dell Precision M6300 laptop with Quadro FX1600M
Windows Vista Ultimate (32-bit)
nVidia ForceWare 156.20 drivers
Cg 2.0.0.12 for shading
Softimage XSI 6.5
Visual Studio 2005 SP1

Many thanks in advance.

Lord crc
05-01-2008, 04:11 PM
Are you absolutely certain that you're not popping more than you've pushed? I'd update a counter for each push/pop just to make sure (the ideal way to do this is to replace the function pointer, so you don't miss any spots).

Simon Eves
05-01-2008, 08:10 PM
Good idea. I'll try that tomorrow, although according to the docs that would produce a different error (GL_STACK_UNDERFLOW)...

Jackis
05-05-2008, 11:43 AM
May be, you have glBegin() somewhere you've been forgotten about?
It's a rather common thing with invalid operation error message.