Use vertex input mask for creating vertex arrays #85092
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #85053
The issue is that the calculation of skeletons became super slow after #81138. The root cause was how we cache and retrieve vertex array objects. Prior to #81138 we created a special vertex array object for skeletons which only ever contained vertices, normals, and tangents. After #81138 we used the regular mesh caching approach so we could automatically get the correct vertex array object.
However, the caching approach was subtly broken. It always returned a vertex array object with all available attributes enabled. That means, if the mesh has colors, UVs, etc. The VAO would also contain them. For skeletons, this created a huge amount of unnecessary overhead as only positions, normals, and tangents (at most) are needed.
Once I added the code to take the vertex input mask into account. I noticed it was broken as the indices were off by one.
This PR fixes the performance regression in #85053 and might also increase performance in other cases as well.
This PR is slightly too risky for RCs, so let's plan on merging for 4.3 and cherry picking to 4.2.1