Skip to content

Lazy computation of prim vars in IECoreGL #238

Open

Description

@ldmoser

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.

Activity

  1. added this to the Cortex 9 milestone on Mar 7, 2014
  2. johnhaddon commented on Mar 7, 2014

    @johnhaddon
    Member

    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

  3. ldmoser commented on Mar 7, 2014

    @ldmoser
    Author

    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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions