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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8ac460e
[px_vp20] add GetMFrameContextDisplayStyle() utility function for the…
mattyjams Jun 4, 2020
4970573
[pxrUsdMayaGL] use new utility function to convert legacy display sta…
mattyjams Jun 4, 2020
4f41065
[px_vp20] add functions for testing whether the display style indicat…
mattyjams Jun 4, 2020
2db526e
[pxrUsdMayaGL] add batch renderer methods for drawing bounding boxes …
mattyjams Jun 4, 2020
a549120
[pxrUsdMayaGL] always query the shape's bounding box when preparing f…
mattyjams Jun 4, 2020
1d2ad70
[pxrUsdMayaGL] remove early out in GetMayaUserData()
mattyjams Jun 5, 2020
1cecda7
[pxrUsdMayaGL] add private helper function for determining active sta…
mattyjams Jun 4, 2020
e4a7ace
[pxrUsdMayaGL] add useWireframe field to the render params
mattyjams Jun 4, 2020
93a82ce
[pxrUsdMayaGL] store whether or not to use the wireframe into the ren…
mattyjams Jun 4, 2020
7746547
[pxrUsdMayaGL] use render params useWireframe and query displayStatus…
mattyjams Jun 4, 2020
ba208df
[pxrUsdMayaGL] remove drawShape and drawBoundingBox params from GetRe…
mattyjams Jun 5, 2020
6ba5129
[pxrUsdMayaGL] remove now unused _drawBoundingBox field on shape adap…
mattyjams Jun 5, 2020
90aeee4
[pxrUsdMayaGL] call batch renderer DrawBoundingBox() from USD proxy s…
mattyjams Jun 5, 2020
5fff187
[pxrUsdMayaGL] make batch renderer Draw() only handle Hydra drawing
mattyjams Jun 5, 2020
7aa7034
[pxrUsdMayaGL] remove now unused drawShape field on PxrMayaHdUserData
mattyjams Jun 5, 2020
4189220
[pxrUsdMayaGL] always store the wireframe color in the render params
mattyjams Jun 5, 2020
4fdc11c
[pxrUsdMayaGL] remove virtual dispatch for shape adapter methods and/…
mattyjams Jun 5, 2020
7846579
[pxrUsdMayaGL] remove virtual dispatch of shape adapter Sync()
mattyjams Jun 5, 2020
d62fb64
[pxrUsdMayaGL] make shape adapter base class responsible for identifiers
mattyjams Jun 5, 2020
d3bbd46
[pxrUsdMayaGL] update doc strings on shape adapter _Init() functions
mattyjams Jun 8, 2020
aa65162
[pxrUsdMayaGL] make shape adapter's _shapeDagPath a private field
mattyjams Jun 5, 2020
5f0d234
[pxrUsdMayaGL] use renderTags token from HdTokens instead of private …
mattyjams Jun 5, 2020
2d0b160
[pxrUsdMayaGL] move GetPickingTasks() after GetRenderTasks()
mattyjams Jun 5, 2020
04ab04b
[pxrUsdMayaGL] reuse already fetched renderIndex in scene delegate Ge…
mattyjams Jun 5, 2020
d4fdf26
[pxrUsdMayaGL] get viewport displayStyle in _RenderBatches() and plum…
mattyjams Jun 5, 2020
fd0860c
[pxrUsdMayaGL] remove old, and now inaccurate, refactoring comments i…
mattyjams Jun 5, 2020
d1232ad
[pxrUsdMayaGL] use a single selection task instead of one per render …
mattyjams Jun 5, 2020
d7926c4
[pxrUsdMayaGL] map collection names to render tasks and render params…
mattyjams Jun 6, 2020
b59b187
[pxrUsdMayaGL] add a way to plumb shape adapters into GetRenderTasks(…
mattyjams Jun 6, 2020
9d27bf8
[pxrUsdMayaGL] make shape adapters manage a collection and a render t…
mattyjams Jun 6, 2020
ece9429
[pxrUsdMayaGL] push "drawShape" out of shape adapter Sync() and into …
mattyjams Jun 6, 2020
7acc081
[pxrUsdMayaGL] add a shape adapter function for dirtying its render t…
mattyjams Jun 6, 2020
f3f0405
[pxrUsdMayaGL] add missing header includes in batch renderer .h and .…
mattyjams Jun 4, 2020
4fbe00e
[pxrUsdMayaGL] add missing include of hd/changeTracker.h in sceneDele…
mattyjams Jun 6, 2020
24031f0
[px_vp20, pxrUsdMayaGL] whitespace clean-up
mattyjams Jun 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/mayaUsd/render/px_vp20/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,8 @@ px_vp20Utils::RenderBoundingBox(
bboxTransformMatrix.setScale(scales, MSpace::kTransform);
return RenderWireCubes(
{ GfMatrix4f(bboxTransformMatrix.asMatrix().matrix) },
color,
GfMatrix4d(worldViewMat.matrix),
color,
GfMatrix4d(worldViewMat.matrix),
GfMatrix4d(projectionMat.matrix));
}

Expand Down Expand Up @@ -875,7 +875,7 @@ void main()
// Populate the shader variables.
GfMatrix4f vpMatrix(worldViewMat * projectionMat);
GLuint vpMatrixLoc = glGetUniformLocation(renderBoundsProgramId, "vpMatrix");
glUniformMatrix4fv(vpMatrixLoc, 1,
glUniformMatrix4fv(vpMatrixLoc, 1,
GL_TRUE, // transpose
vpMatrix.data());

Expand All @@ -891,12 +891,12 @@ void main()
// since we're copying these directly from GfMatrix4f, we need to
// transpose() them in the shader.
const GLuint cubeXformLoc = glGetAttribLocation(renderBoundsProgramId, "cubeXformT");
glBufferData(GL_ARRAY_BUFFER,
glBufferData(GL_ARRAY_BUFFER,
sizeof(GfMatrix4f) * numCubes, cubeXforms.data(), GL_DYNAMIC_DRAW);
for (size_t r = 0; r < 4; r++) {
GLuint loc = cubeXformLoc + r;
glEnableVertexAttribArray(loc);
glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, sizeof(GfMatrix4f),
glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, sizeof(GfMatrix4f),
(char*)(sizeof(float)*4*r));
glVertexAttribDivisor(loc, 1);
}
Expand Down
11 changes: 10 additions & 1 deletion lib/mayaUsd/render/px_vp20/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <maya/MBoundingBox.h>
#include <maya/MDrawContext.h>
#include <maya/MHWGeometryUtilities.h>
#include <maya/MFrameContext.h>
#include <maya/MMatrix.h>
#include <maya/MSelectionContext.h>

Expand Down Expand Up @@ -64,6 +65,14 @@ class px_vp20Utils
const MHWRender::MDrawContext& context,
M3dView& view);

/// Returns true if the given Maya display style indicates that a
/// bounding box should be rendered.
static bool ShouldRenderBoundingBox(unsigned int displayStyle) {
const bool boundingBoxStyle =
displayStyle & MHWRender::MFrameContext::DisplayStyle::kBoundingBox;
return boundingBoxStyle;
}

/// Renders the given bounding box in the given \p color via OpenGL.
MAYAUSD_CORE_PUBLIC
static bool RenderBoundingBox(
Expand All @@ -74,7 +83,7 @@ class px_vp20Utils

/// Helper to draw multiple wireframe boxes, where \p cubeXforms is a
/// list of transforms to apply to the unit cube centered around the
/// origin. Those transforms will all be concatenated with the
/// origin. Those transforms will all be concatenated with the
/// \p worldViewMat and \p projectionMat.
MAYAUSD_CORE_PUBLIC
static bool RenderWireCubes(
Expand Down
56 changes: 56 additions & 0 deletions lib/mayaUsd/render/px_vp20/utils_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,24 @@

/// \file px_vp20/utils_legacy.h

// XXX: With Maya versions up through 2019 on Linux, M3dView.h ends up
// indirectly including an X11 header that #define's "Bool" as int:
// - <maya/M3dView.h> includes <maya/MNativeWindowHdl.h>
// - <maya/MNativeWindowHdl.h> includes <X11/Intrinsic.h>
// - <X11/Intrinsic.h> includes <X11/Xlib.h>
// - <X11/Xlib.h> does: "#define Bool int"
// This can cause compilation issues if <pxr/usd/sdf/types.h> is included
// afterwards, so to fix this, we ensure that it gets included first.
//
// The X11 include appears to have been removed in Maya 2020+, so this should
// no longer be an issue with later versions.
#include <pxr/usd/sdf/types.h>

#include <pxr/pxr.h>
#include <pxr/base/gf/matrix4d.h>

#include <maya/M3dView.h>
#include <maya/MFrameContext.h>
#include <maya/MSelectInfo.h>

#include <mayaUsd/base/api.h>
Expand All @@ -40,6 +55,47 @@ class px_LegacyViewportUtils
GfMatrix4d& viewMatrix,
GfMatrix4d& projectionMatrix);

/// Helper function that converts M3dView::DisplayStyle from the legacy
/// viewport into MHWRender::MFrameContext::DisplayStyle for Viewport
/// 2.0.
///
/// In the legacy viewport, the M3dView can be in exactly one
/// displayStyle whereas Viewport 2.0's displayStyle is a bitmask of
/// potentially multiple styles. To translate from the legacy viewport
/// to Viewport 2.0, we simply bitwise-OR the single legacy viewport
/// displayStyle into an empty mask.
static unsigned int GetMFrameContextDisplayStyle(
M3dView::DisplayStyle legacyDisplayStyle) {
unsigned int displayStyle = 0u;

switch (legacyDisplayStyle) {
case M3dView::kBoundingBox:
displayStyle |= MHWRender::MFrameContext::DisplayStyle::kBoundingBox;
break;
case M3dView::kFlatShaded:
displayStyle |= MHWRender::MFrameContext::DisplayStyle::kFlatShaded;
break;
case M3dView::kGouraudShaded:
displayStyle |= MHWRender::MFrameContext::DisplayStyle::kGouraudShaded;
break;
case M3dView::kWireFrame:
displayStyle |= MHWRender::MFrameContext::DisplayStyle::kWireFrame;
break;
case M3dView::kPoints:
// Not supported.
break;
}

return displayStyle;
}

/// Returns true if the given Maya display style indicates that a
/// bounding box should be rendered.
static bool ShouldRenderBoundingBox(
M3dView::DisplayStyle legacyDisplayStyle) {
return (legacyDisplayStyle == M3dView::kBoundingBox);
}

private:
px_LegacyViewportUtils() = delete;
~px_LegacyViewportUtils() = delete;
Expand Down
Loading