Skip to content

Yield to the defer agent per mesh assignment during instantiation - #55

Open
nickdnk wants to merge 2 commits into
Unity-Technologies:mainfrom
nickdnk:yield_to_defer_agent
Open

Yield to the defer agent per mesh assignment during instantiation#55
nickdnk wants to merge 2 commits into
Unity-Technologies:mainfrom
nickdnk:yield_to_defer_agent

Conversation

@nickdnk

@nickdnk nickdnk commented Jul 16, 2026

Copy link
Copy Markdown

Also a moved PR, like the JSON decode one. See atteneder#823 for details.

nickdnk added 2 commits July 16, 2026 21:55
Hierarchy population honored the frame budget only between nodes; a node carrying many mesh assignments (multi-material meshes) populated them all in one un-yielding callback.
@atteneder

Copy link
Copy Markdown
Collaborator

Hi,

Thanks for the contribution.

Currently the breakpoint fires between every node. With your change, it would also fire after every mesh assignment. That would start to make sense when the cost per mesh assignment multiplied by the number of per-node meshes exceeds a certain threshold.

Assuming that assigning a mesh is a cheap operation I'm questioning whether that's a realistic scenario? Would you mind sharing your observations and ideally a test glTF asset that lets me re-produce those?

Granted, the overhead for some additional breakpoints isn't neck-breaking, but still.

Thanks

@nickdnk

nickdnk commented Aug 21, 2026

Copy link
Copy Markdown
Author

Hello

I believe the numbers in the other thread kind of speak for themselves. I was loading large gLTFs into a game and this was a significant performance increase.

Specifically, I was building a game using assets from World of Warcraft, as an educational project. Some of them, like cities, are very large, so streaming them in as you run around the world would hitch quite badly without this change. Apparently, they consist of big nodes with a lot of individual meshes.

I'm not home at the moment, but I can provide a reproduction repo for you to test when I am back.

Edit: This also means I cannot legally share the city asset with you as it's Blizzard's IP, so I'm not sure how to do this, quite honestly. I may be able to make Claude generate a sample object of similar size that isn't copyrighted.

@atteneder

Copy link
Copy Markdown
Collaborator

Thanks for getting back.

Not to bother you more than necessary, but I want to make sure we're solving the actual problem. In order to hit the case you are describing, two things have to be true:

  1. A mesh with multiple primitives (presumably dozens or even more)
  2. The primitives' structure is incompatible, so that they cannot be merged into one Unity mesh with many sub-meshes.

Questions I'd answer if I had the asset. Pick out one mesh (ideally a worst-case):

  1. Primitive count?
  2. Number of resulting MeshAssignment/MeshResults (which indicates whether glTFast had do split the mesh).
  3. Profile the inner part of the for-loop over m_MeshAssignments in PopulateHierarchy to get a min/max/median duration.
  4. What's the glTF generator ( Root.Asset.Generator )?

If the nr. of MeshResults is closer to the nr. of primitives than 1 I'd also like to investigate why they don't get merged. It requires analyzing the JSON primitive, accessors, bufferViews and buffer. I'd assume sharing just that part of the glTF JSON (or let AI synthesizing it) is safe since nobody won't be able to reconstruct it without the binary data.

Also, feel free to send sensitive information to andreas dot atteneder at unity3d dot com.

Thanks.

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.

2 participants