Hello Michael,
while debugging the last days I stumbled over the fact that OpenSG does
lots of redundant function calls. I'm attaching some screenshots of a
gDebugger session for a simple scene (simple geometry, 4 lights).
After rendering 81 frames I have amongst others 1312 calls to glLightf
which are ALL redundant.
are these redundant within a single frame or only if considering state
across frames? OpenSG does not track state between frames and looking at
System/State/Base/OSGLightChunk.cpp:LightChunk::activate() specifying
state for a light requires 8-10 calls to glLightf. In that sense the
number of redundant state changes is not surprising.
I'm not sure how much these things affect the
overall performance of the rendering system.
I think that mostly "global" things like lights, fog, and perhaps a few
others show that much redundancy between frames.
My (perhaps optimistic?) hope would be that since the drivers can detect
and report the redundant state change that they also avoid any
reprogramming of the GPU and so the overhead is mostly on the CPU side
for making an unneeded GL call.
I think for more complex scenes (with multiple materials in particular)
the ratio of such redundant calls vs. needed ones goes down sharply.
Would something like a state cache help to minimize such redundancies,
or do you think the cache look ups are equal or more expansive than the
redundant calls?
Without data that shows this slows things down quite a bit, I'm not sure
if that is something worth worrying about too much.
All that is assuming that the majority of redundant calls is between
frames, a high number of redundant calls _within_ a single frame would
be more important to look at IMHO.
Cheers,
Carsten