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

Enable consolidation for instanced render items #436

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 11 additions & 7 deletions lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,10 +1355,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 @@ -1370,11 +1379,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 @@ -1442,10 +1442,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 @@ -1457,11 +1466,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