You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that drawing could be greatly improved by doing lazy computation on the conversion of IECore Primitives to IECoreGL primitives or to gl buffers, not to mention reduce memory consumption.
Ideally it should be driven by the primVars that the GL shaders see.
Hi Lucio,
It's been a while since I looked at this code, but I'm pretty sure the conversion of primvars to GL buffers is lazy, and already driven by the GL shader's requirements as you suggest.
In Shader::Setup::addVertexAttribute you'll see an early-out at the top if the shader doesn't have a matching parameter, and then the conversion to a buffer doesn't occur till the end of that method :
It would be nice to remove primvars that won't be needed even before this, so we can drop the DataPtr storage too, but since a Primitive can be instanced multiple times with multiple shaders, and have the shader applied to it multiple times at runtime, I don't think there's a good automatic way of doing that - for now I think it needs to be the responsibility of the creator of the scene to remove things if its known they are never needed.
Do you have some specific figures on this that could drive our decision making, or are you seeing the lazy conversion not working for some reason?
Cheers…
John
Hi John, to be frank, me too. I haven't seen this for a while but wanted to leave as something to check when looking at Cortex 9 improvements.
I believe I saw the TriangulateOp in the profile back then. So I figured that we are triangulating all the primVars before knowing which ones are actually necessary for GL view. I guess our readers could remove primVars as you suggested... for now it would work. But if we start supporting shaders in the SceneReaders than they won't necessarily know which primVars are important.
So when I said lazy conversion, it was more referring to the translation IECore.Primitive to IECoreGL.Primitive. Either make it lazy or drop this intermediate representation and do straight conversions to GL buffers. I agree that all that should only take place if improves performance...
Activity
johnhaddon commentedon Mar 7, 2014
Hi Lucio,
It's been a while since I looked at this code, but I'm pretty sure the conversion of primvars to GL buffers is lazy, and already driven by the GL shader's requirements as you suggest.
In Shader::Setup::addVertexAttribute you'll see an early-out at the top if the shader doesn't have a matching parameter, and then the conversion to a buffer doesn't occur till the end of that method :
https://github.com/ImageEngine/cortex/blob/master/src/IECoreGL/Shader.cpp#L819
It would be nice to remove primvars that won't be needed even before this, so we can drop the DataPtr storage too, but since a Primitive can be instanced multiple times with multiple shaders, and have the shader applied to it multiple times at runtime, I don't think there's a good automatic way of doing that - for now I think it needs to be the responsibility of the creator of the scene to remove things if its known they are never needed.
Do you have some specific figures on this that could drive our decision making, or are you seeing the lazy conversion not working for some reason?
Cheers…
John
ldmoser commentedon Mar 7, 2014
Hi John, to be frank, me too. I haven't seen this for a while but wanted to leave as something to check when looking at Cortex 9 improvements.
I believe I saw the TriangulateOp in the profile back then. So I figured that we are triangulating all the primVars before knowing which ones are actually necessary for GL view. I guess our readers could remove primVars as you suggested... for now it would work. But if we start supporting shaders in the SceneReaders than they won't necessarily know which primVars are important.
So when I said lazy conversion, it was more referring to the translation IECore.Primitive to IECoreGL.Primitive. Either make it lazy or drop this intermediate representation and do straight conversions to GL buffers. I agree that all that should only take place if improves performance...