@@ -412,6 +412,7 @@ HnRenderPass::EXECUTE_RESULT HnRenderPass::Execute(HnRenderPassState& RPState, c
412412 Uint32 JointsBufferOffset = 0 ;
413413 Uint32 CurrJointsDataSize = 0 ;
414414 size_t XformsHash = 0 ;
415+ size_t GeomBindXformHash = 0 ;
415416 Uint32 JointCount = 0 ;
416417
417418 if (AttribsBuffDesc.Usage != USAGE_DYNAMIC)
@@ -460,7 +461,8 @@ HnRenderPass::EXECUTE_RESULT HnRenderPass::Execute(HnRenderPassState& RPState, c
460461 // Reset the hash to force updating the joint transforms for the next draw item.
461462 // NB: we can't reuse the transforms at the existing offset because they may be
462463 // overwritten by the next draw item.
463- XformsHash = 0 ;
464+ XformsHash = 0 ;
465+ GeomBindXformHash = 0 ;
464466
465467 RenderPendingDrawItems (State);
466468 VERIFY_EXPR (m_PendingDrawItems.empty ());
@@ -518,7 +520,7 @@ HnRenderPass::EXECUTE_RESULT HnRenderPass::Execute(HnRenderPassState& RPState, c
518520 if (MultiDrawCount == PrimitiveArraySize)
519521 MultiDrawCount = 0 ;
520522
521- if (pSkinningData && pSkinningData->XformsHash != XformsHash)
523+ if (pSkinningData && ( pSkinningData->XformsHash != XformsHash || pSkinningData-> GeomBindXformHash != GeomBindXformHash) )
522524 {
523525 // Restart batch when the joint transforms change
524526 MultiDrawCount = 0 ;
@@ -598,7 +600,9 @@ HnRenderPass::EXECUTE_RESULT HnRenderPass::Execute(HnRenderPassState& RPState, c
598600
599601 if (pSkinningData)
600602 {
601- if (pSkinningData->XformsHash != XformsHash)
603+ // NOTE: we currently reupload all joint transforms if geometry bind matrix changes, which is not optimal.
604+ // A better approach would be to move the matrix to PBRPrimitiveAttribs.
605+ if (pSkinningData->XformsHash != XformsHash || pSkinningData->GeomBindXformHash != GeomBindXformHash)
602606 {
603607 VERIFY (CurrJointsDataSize + JointsDataRange <= JointsBuffDesc.Size ,
604608 " There must be enough space for the new joint transforms as we flush the pending draw if there is not enough space." );
@@ -623,7 +627,8 @@ HnRenderPass::EXECUTE_RESULT HnRenderPass::Execute(HnRenderPassState& RPState, c
623627 VERIFY_EXPR (JointsDataSize == State.USDRenderer .GetJointsDataSize (JointCount, ListItem.PSOFlags ));
624628 CurrJointsDataSize = AlignUp (JointsBufferOffset + JointsDataSize, JointsBufferOffsetAlignment);
625629
626- XformsHash = pSkinningData->XformsHash ;
630+ XformsHash = pSkinningData->XformsHash ;
631+ GeomBindXformHash = pSkinningData->GeomBindXformHash ;
627632
628633 VERIFY (MultiDrawCount == 0 , " The batch must be reset when the joint transforms change." );
629634 }
0 commit comments