Neil Roberts wrote:
The problem with this workaround is that you do glGet* upon every
frame, which is flushing/finishing the GL pipeline, causing
performance issues.
    

I would be very surprised if that is how glGet is implemented. It would
expect it to just read from some internal struct attached to the context
and it wouldn't matter whether the actual hardware has caught up to that
state or not.
  
  
I guess (and I hope) you're right, actually because of the internal state cache that the OpenGL driver has to manage.

I now understand that it is indeed necessary for a scene graph engine to push and pop (save and restore in your terms) the GL state in order to paint-traverse the tree correctly, exactly as you do in your example. So regardless of Cogl's caching, we have to restore the original GL state before moving to the sibling actor. I think that was my mistake which caused the corruption.
When Cogl was rewritten, there was a point where we weren't using the
cache for some part of the Pango rendering and we had a definite
measurable performance impact compared to the old Cogl from calling
glEnable/Disable excessively. Even if the OpenGL driver internally
caches the state as well, I believe there is still some expense for any
GL call to lookup the current context from thread-local storage and do
an indirect function call.
  
I haven't looked at an actual GL driver though so I'm not an expert, but
this is just my experience.

  
I have seen some actual GL driver and they were indeed looking up from the TLS, which was not costful as they are using very optimized assembly code.
But this is just one driver, and maybe others are not that performant.
For example, in the mobile world, a leader like imgtec's  PowerVR is known for its poor state changing performance, which could indeed motivate toolkits like clutter to take over this task.

So I now understand a little more the Cogl choices.
Thanks

Michael

-- 
Michael Boccara
Graphtech
Herzliya, Israel

-- To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to