Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixar batch renderer refactoring and performance improvements #577

Merged
merged 35 commits into from
Jun 11, 2020

Commits on Jun 9, 2020

  1. [px_vp20] add GetMFrameContextDisplayStyle() utility function for the…

    … legacy viewport
    
    This creates a public utility function out of the _ToMFrameContextDisplayStyle()
    private, static function in PxrMayaHdShapeAdapter. A subsequent commit will
    remove the old function and replace its usage with the new public function.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    8ac460e View commit details
    Browse the repository at this point in the history
  2. [pxrUsdMayaGL] use new utility function to convert legacy display sta…

    …tus for VP 2.0
    
    This change removes the private, static _ToMFrameContextDisplayStyle for
    PxrMayaHdShapeAdapter in favor of the newly added
    px_LegacyViewportUtils::GetMFrameContextDisplayStyle().
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    4970573 View commit details
    Browse the repository at this point in the history
  3. [px_vp20] add functions for testing whether the display style indicat…

    …es bounding box rendering
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    4f41065 View commit details
    Browse the repository at this point in the history
  4. [pxrUsdMayaGL] add batch renderer methods for drawing bounding boxes …

    …only
    
    The current batch renderer API offers Draw() functions that draw shapes,
    bounding boxes, or both depending on the user data. The usage, however, is that
    only the PxrHdImagingShape invokes a draw for all of the shapes, and then
    individual shapes only need to draw their bounding boxes.
    
    This change adds independent bounding box-only methods that the shapes can use
    when they need to draw their bounding boxes. Subsequent commits will update
    MPxDrawOverrides and MPxSurfaceShapeUIs to use the appropriate draw method.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    2db526e View commit details
    Browse the repository at this point in the history
  5. [pxrUsdMayaGL] always query the shape's bounding box when preparing f…

    …or viewport draw
    
    This ensures that the bounding box is always available in case the viewport
    display style is changed and we don't end up executing another shape adapter
    Sync().
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    a549120 View commit details
    Browse the repository at this point in the history
  6. [pxrUsdMayaGL] remove early out in GetMayaUserData()

    Since practically we will now always have a bounding box in GetMayaUserData(),
    we remove the early return that used to check for it.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    1d2ad70 View commit details
    Browse the repository at this point in the history
  7. [pxrUsdMayaGL] add private helper function for determining active sta…

    …tus from displayStatus
    
    There are a handful of Maya displayStatus values that we consider "active",
    which means that Hydra should draw them including their wireframe. This reduces
    some duplicated code for determining whether the shape is active.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    1cecda7 View commit details
    Browse the repository at this point in the history
  8. [pxrUsdMayaGL] add useWireframe field to the render params

    This field will provide an easy way to re-use the state determined during
    Sync(). Subsequent changes will make it so that only the displayStatus (and
    not the viewport-specific displayStyle) determine whether or not to use the
    wireframe.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    e4a7ace View commit details
    Browse the repository at this point in the history
  9. [pxrUsdMayaGL] store whether or not to use the wireframe into the ren…

    …der params
    
    This boolean will soon be based on only the shape's display status and not any
    viewport's display style, so it can accurately be cached during calls to Sync()
    and re-used in between.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    93a82ce View commit details
    Browse the repository at this point in the history
  10. [pxrUsdMayaGL] use render params useWireframe and query displayStatus…

    … when computing repr
    
    This change renames the shape adapter GetReprSelectorForDisplayState() function
    to GetReprSelectorForDisplayStyle(), makes it non-virtual, and only requires
    that the displayStyle be provided. It will query Maya for the shape's
    displayStatus itself.
    
    We also use the render params' useWireframe field to determine whether or not
    to use a repr that includes the wireframe, in addition to the displayStyle.
    
    Note that we are still erroneously using the displayStyle at Sync() time to
    decide whether or not to enable lighting. This can be addressed later but for
    now it only causes subtly incorrect visual results for wireframe display
    styles in certain cases.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    7746547 View commit details
    Browse the repository at this point in the history
  11. [pxrUsdMayaGL] remove drawShape and drawBoundingBox params from GetRe…

    …nderParams()
    
    Draw overrides for individual shapes will call the batch renderer's
    DrawBoundingBox() and pxrHdImagingShape's draw override will call Draw(), so we
    don't need the shape adapters to track (unreliably) whether to draw its shape
    and/or bounding box, especially since those can also vary depending on each
    viewport's displayStyle.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    ba208df View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    6ba5129 View commit details
    Browse the repository at this point in the history
  13. [pxrUsdMayaGL] call batch renderer DrawBoundingBox() from USD proxy s…

    …hape draw callbacks
    
    Only the pxrHdImagingShape will actually invoke a Hydra draw to render shapes,
    so the only reason that individual shape draw callbacks will do any drawing is
    if they need to draw the bounding box for their shape.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    90aeee4 View commit details
    Browse the repository at this point in the history
  14. [pxrUsdMayaGL] make batch renderer Draw() only handle Hydra drawing

    With the pxrHdImagingShape draw override now the only one that calls Draw(), we
    don't need any bounding-box related drawing code in those methods anymore,
    since individual shape draw overrides are instead expected to call
    DrawBoundingBox() as necessary from their own draw callbacks.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    5fff187 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    7aa7034 View commit details
    Browse the repository at this point in the history
  16. [pxrUsdMayaGL] always store the wireframe color in the render params

    Since we may not get another Sync() callback if the viewport display style is
    changed, we need to make sure that the wireframe color is always available from
    the render params.
    
    This may lead to slightly different shape adapter bucketing behavior, since the
    render params for shapes will pretty much always have a non-zero wireframe
    color now, but it shouldn't practically impact performance significantly.
    
    This also modifies the _GetWireframeColor() function to handle the MColor to
    GfVec4f conversion so that clients don't have to, and so that they can pass a
    pointer to the render params' wireframeColor directly.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    4189220 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    4fdc11c View commit details
    Browse the repository at this point in the history
  18. [pxrUsdMayaGL] remove virtual dispatch of shape adapter Sync()

    Derived classes can control their own behaviors in the protected _Sync().
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    7846579 View commit details
    Browse the repository at this point in the history
  19. [pxrUsdMayaGL] make shape adapter base class responsible for identifiers

    This moves all computation of a unique identifier for the shape into the shape
    adapter base class and removes it from derived classes. Instead of a fixed
    string and a hash of the Maya object, we instead query Maya for the node's UUID
    and use that directly as the shape's "identifier", which we also use both as
    the name of its rprim collection, and to construct the delegate ID.
    
    We use the node's UUID since MPxDrawOverrides may be constructed and destructed
    over the course of a node's lifetime (e.g. by doing 'ogs -reset'). Since the
    draw override owns the shape adapter, we therefore need an identifier tied to
    the node's lifetime rather than to the shape adapter's lifetime.
    
    With the delegate ID now stored in the base class, its accessor no longer needs
    to be virtual, and also gets defined inline.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    d62fb64 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    d3bbd46 View commit details
    Browse the repository at this point in the history
  21. [pxrUsdMayaGL] make shape adapter's _shapeDagPath a private field

    Now that a bunch of other shape adapter data is recomputed whenever
    _SetDagPath() is called, we want to make sure that _shapeDagPath is not changed
    any other way, so this change makes it private instead of protected. Existing
    usage of the field now uses the public accessor instead.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    aa65162 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    5f0d234 View commit details
    Browse the repository at this point in the history
  23. [pxrUsdMayaGL] move GetPickingTasks() after GetRenderTasks()

    This makes the ordering in the cpp file consistent with the declaration order
    in the header.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    2d0b160 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    04ab04b View commit details
    Browse the repository at this point in the history
  25. [pxrUsdMayaGL] get viewport displayStyle in _RenderBatches() and plum…

    …b it down to GetRenderTasks()
    
    displayStatus may vary per viewport, so we need to select the repr for each
    shape at draw time rather than at Sync() time.
    
    Subsequent commits will make use of the displayStyle by querying each shape
    adapter for the repr that should be used.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    d4fdf26 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    fd0860c View commit details
    Browse the repository at this point in the history
  27. [pxrUsdMayaGL] use a single selection task instead of one per render …

    …params hash
    
    Since the parameters to the selection task do not vary based on anything shape
    related and in fact never change at all, there's no reason that we need one per
    set of unique render params. We can just always use the same one for all shapes.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    d1232ad View commit details
    Browse the repository at this point in the history
  28. [pxrUsdMayaGL] map collection names to render tasks and render params…

    … hashes to render setup tasks
    
    This change simplifies the mapping of HdRprimCollection names to render task
    IDs and hashes of render params to render setup task IDs, respectively. Since
    the batch renderer now never changes the collection of a render task itself,
    it no longer needs to mark them dirty on every draw.
    
    Note that this commit would actually cause somewhat of a performance regression
    on its own, since the single render task per collection would get thrashed a
    bit more as its repr is changed. Subsequent commits will make the shape
    adapters manage a collection and a render task ID *per* repr. This also allows
    the shape adapter to notify the change tracker when its collections or tasks
    need to be dirtied.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    d7926c4 View commit details
    Browse the repository at this point in the history
  29. [pxrUsdMayaGL] add a way to plumb shape adapters into GetRenderTasks(…

    …) using prim filters
    
    This will allow us to delay computing which repr to use until draw time and to
    query the necessary data from the shape adapters directly. The original
    mechanism will be supported by specifying the shape adapter as nullptr in the
    prim filter.
    
    This commit adds the plumbing and a subsequent commit will take advantage of it
    when the shape adapters manage a collection per repr.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    b59b187 View commit details
    Browse the repository at this point in the history
  30. [pxrUsdMayaGL] make shape adapters manage a collection and a render t…

    …ask ID per repr
    
    This change provides a consistent one-to-one mapping between reprs, collections,
    and render tasks in the shape adapter. This results in minimal draw batch
    thrashing within hydra when the repr changes due to a change in Maya viewport
    displayStyle, since the repr on the collection never needs to change and the
    collection on the render task never needs to change.
    
    The shape adapter must be queried for which collection and render task ID to
    use based on a particular repr, so that handling has been added where necessary
    in the batch renderer and scene/task delegate. When rendering, the shape
    adapters are plumbed through to GetRenderTasks() where we determine what repr
    to use based on the displayStyle, and then use that repr to get the appropriate
    collection and render task ID for each shape we're drawing.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    9d27bf8 View commit details
    Browse the repository at this point in the history
  31. [pxrUsdMayaGL] push "drawShape" out of shape adapter Sync() and into …

    …GetRenderTasks()
    
    Storing whether or not to draw the shape during Sync() is not correct since we
    may be drawing for multiple viewports with differing displayStyles, or we may
    change displayStyles on a particular viewport and not get another
    prepareForDraw() callback.
    
    To fix this, instead of setting the delegate's root visibility during sync, we
    check during GetRenderTasks() to see whether there's an active render for the
    given displayStatus, and simply skip adding the render task if there isn't one.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    ece9429 View commit details
    Browse the repository at this point in the history
  32. [pxrUsdMayaGL] add a shape adapter function for dirtying its render t…

    …asks
    
    Though this is not yet being used, this function can be used to notify the
    change tracker when the shape adapter detects a change in the shape that
    requires regenerating draw batches.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    7acc081 View commit details
    Browse the repository at this point in the history
  33. [pxrUsdMayaGL] add missing header includes in batch renderer .h and .…

    …cpp files
    
    Symbols from these headers are used, but the headers were not being included.
    mattyjams committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    f3f0405 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    4fbe00e View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    24031f0 View commit details
    Browse the repository at this point in the history