Skip to content

Commit

Permalink
Merge pull request #436 from Autodesk/chenh/MAYA-104316/want-consolid…
Browse files Browse the repository at this point in the history
…ation-for-instanced-items

Enable consolidation for instanced render items
  • Loading branch information
Krystian Ligenza authored May 27, 2020
2 parents 37042fd + 9de8352 commit 6f0c244
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
18 changes: 11 additions & 7 deletions lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,10 +1360,19 @@ HdVP2BasisCurves::_UpdateDrawItem(
kSolidColorStr, stateToCommit._instanceColors);
}
}
#if MAYA_API_VERSION >= 20210000
else if (newInstanceCount >= 1) {
#else
// In Maya 2020 and before, GPU instancing and consolidation are two separate systems that
// cannot be used by a render item at the same time. In case of single instance, we keep
// the original render item to allow consolidation with other prims. In case of multiple
// instances, we need to disable consolidation to allow GPU instancing to be used.
else if (newInstanceCount == 1) {
renderItem->setMatrix(&stateToCommit._instanceTransforms[0]);
}
else if (newInstanceCount > 1) {
// Turn off consolidation to allow GPU instancing to be used for
// multiple instances.
setWantConsolidation(*renderItem, false);
#endif
drawScene.setInstanceTransformArray(*renderItem,
stateToCommit._instanceTransforms);

Expand All @@ -1375,11 +1384,6 @@ HdVP2BasisCurves::_UpdateDrawItem(

stateToCommit._drawItemData._usingInstancedDraw = true;
}
else if (newInstanceCount == 1) {
// Special case for single instance prims. We will keep the original
// render item to allow consolidation.
renderItem->setMatrix(&stateToCommit._instanceTransforms[0]);
}
else if (stateToCommit._worldMatrix != nullptr) {
// Regular non-instanced prims. Consolidation has been turned on by
// default and will be kept enabled on this case.
Expand Down
18 changes: 11 additions & 7 deletions lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,10 +1463,19 @@ void HdVP2Mesh::_UpdateDrawItem(
kSolidColorStr, stateToCommit._instanceColors);
}
}
#if MAYA_API_VERSION >= 20210000
else if (newInstanceCount >= 1) {
#else
// In Maya 2020 and before, GPU instancing and consolidation are two separate systems that
// cannot be used by a render item at the same time. In case of single instance, we keep
// the original render item to allow consolidation with other prims. In case of multiple
// instances, we need to disable consolidation to allow GPU instancing to be used.
else if (newInstanceCount == 1) {
renderItem->setMatrix(&stateToCommit._instanceTransforms[0]);
}
else if (newInstanceCount > 1) {
// Turn off consolidation to allow GPU instancing to be used for
// multiple instances.
setWantConsolidation(*renderItem, false);
#endif
drawScene.setInstanceTransformArray(*renderItem,
stateToCommit._instanceTransforms);

Expand All @@ -1478,11 +1487,6 @@ void HdVP2Mesh::_UpdateDrawItem(

stateToCommit._drawItemData._usingInstancedDraw = true;
}
else if (newInstanceCount == 1) {
// Special case for single instance prims. We will keep the original
// render item to allow consolidation.
renderItem->setMatrix(&stateToCommit._instanceTransforms[0]);
}
else if (stateToCommit._worldMatrix != nullptr) {
// Regular non-instanced prims. Consolidation has been turned on by
// default and will be kept enabled on this case.
Expand Down

0 comments on commit 6f0c244

Please sign in to comment.