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

Autodesk: Fix vtarray unecessary or hidden copies #3549

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

erikaharrison-adsk
Copy link
Contributor

Description of Change(s)

The changes contained in this PR were done after checking VtArrays unintended copies with the environment variable VT_LOG_STACK_ON_ARRAY_DETACH_COPY on several scene including Caldera from Activision and the Pixar usdskel examples.
It also introduces a new function GetJointInverseWorldBindTransforms to benefit from the caching done in the skel definition.

This should reduce the number of allocations with scenes leveraging usdskel and instances.

Link to proposal (if applicable)

  • N/A

Fixes Issue(s)

  • N/A

Checklist

remove change of skeleton API
@@ -2577,7 +2577,7 @@ HdSceneIndexAdapterSceneDelegate::GetInstancerId(SdfPath const &id)
}

if (instancerIds.size() > 0) {
instancerId = instancerIds[0];
instancerId = instancerIds.AsConst()[0];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -2665,7 +2668,7 @@ UsdSkelImagingSkeletonAdapter::_SkelData::ComputePoints(

if(TF_VERIFY(_boneMeshPoints.size() == _boneMeshJointIndices.size())) {

VtVec3fArray skinnedPoints(_boneMeshPoints);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this is triggering a detach. The copy constructor should be using a const VtArray&.

VtArray(VtArray const &other) : Vt_ArrayBase(other)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's triggered later when skinnedPoints is used, not when it's constructed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you're effectively moving the detach that would've happened here?

GfVec3f* points = skinnedPoints.data();

for (VtTokenArray::reverse_iterator it = opOrderVec.rbegin() ;
it != opOrderVec.rend(); ++it) {
const VtTokenArray opOrderVecConst = opOrderVec.AsConst();
for (VtTokenArray::const_reverse_iterator it = opOrderVecConst.rbegin() ;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're open to the suggestion, crbegin and crend would be less invasive changes.

@@ -1155,7 +1155,7 @@ UsdGeomPointInstancer::_ComputeExtentAtTimePreamble(
}

// verify that all the protoIndices are in bounds.
TF_FOR_ALL(iter, *protoIndices) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good opportunity to transition to a ranged base for loop.

for (const int protoIndex : protoIndices->AsConst()){ ... }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is TF_FOR_ALL going away ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's going away, but there are several open issues / pull requests that are focused on replacing it.

#80

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10707

(This is an automated message. See here for more information.)

@jesschimein
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants