X Tutup
Skip to content

GLTF: Use const Vector internally instead of TypedArray copies#113172

Merged
akien-mga merged 1 commit intogodotengine:masterfrom
aaronfranke:gltf-state-vector
Dec 1, 2025
Merged

GLTF: Use const Vector internally instead of TypedArray copies#113172
akien-mga merged 1 commit intogodotengine:masterfrom
aaronfranke:gltf-state-vector

Conversation

@aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Nov 26, 2025

This PR fixes a performance regression introduced in PR #109103. As part of moving the accessor code from GLTFDocument to GLTFAccessor, I replaced the internal Vector uses with calls to the exposed TypedArray versions. This seemed harmless, but in fact, an astonishing 98% of CPU time in the array decode functions is spent converting between Vector and TypedArray. It seems that it is absolutely performance critical for us to use Vector internally.

The fix in this PR is simple: Add new functions that let us use Vector internally. We still need to keep the TypedArray versions around, but discourage their use, therefore I have their internal names suffixed with _bind. At the same time, since this PR changes this code, I figured I may as well make all the getters const, which also requires binding compatibility functions. As such, this PR does involve a lot of boilerplate changes, but there isn't much functionally different in here.

I have tested this on the TPS demo, which is where @akien-mga noticed the performance regression. I can reproduce the atrocious import times in master after PR #109103, nearly 10 minutes for me to import the TPS demo from scratch, and this PR restores the speed found in 4.5, a bit over 2 minutes of total time, with most of the time no longer spent importing the glTF files.

Copy link
Member

@fire fire left a comment

Choose a reason for hiding this comment

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

@dsnopek is that how we use the api overrides?

Copy link
Member

@fire fire left a comment

Choose a reason for hiding this comment

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

I think we should fast track this.

Not sure if the const change should be in this pull request. The changes to api validation is suspect and probably break users like rust and gdextension.

Copy link
Member

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

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

Just putting my two cents here since the docs have been marked as changed.
... still fine. I do like the parameters getting renamed.

@akien-mga akien-mga merged commit f0f30fe into godotengine:master Dec 1, 2025
20 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Done in Asset Pipeline Issue Triage Dec 1, 2025
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup