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

More imagery refactoring #389

Merged
merged 14 commits into from
Jul 12, 2023
Merged

More imagery refactoring #389

merged 14 commits into from
Jul 12, 2023

Conversation

lilleyse
Copy link
Contributor

@lilleyse lilleyse commented Jul 7, 2023

Continuation of the work started in #384.

Added a texture pool that holds onto DynamicTextureProvider objects. Textures are now a distinct resource type that can be assigned to multiple materials. This allows multiple tiles to reference the same imagery, which happens when child tiles use their parent's imagery while waiting for higher res imagery. Previously we were copying the imagery due to limitations in Kit 104.

On the performance side, imagery preparation has been offloaded to a worker thread. I think we can do the same for glTF base color textures, I just haven't done it in this PR.

Aside from new files, the main changes are in FabricPrepareRenderResources and FabricMaterial. GltfUtil was refactored heavily to consolidate a bunch of the getters. I'll wait for #387 to be merged first.

As a bonus, this PR adds support for KHR_texture_transform because it just neatly fit into the refactoring.

What's next

This PR is a stepping stone towards a bigger performance fix. One of the biggest bottlenecks is material compilation, and I think instead of creating a material for each cached tile we can create a material for each selected tile. This will cut the number of materials down from 2000-50000 (depending on your cache size) to around 200-500 (depending on the tileset and your SSE). Any time we allocate lots of materials we get a 10+ second main thread stall, which in my opinion is the most glaring usability issue with the extension right now.

With Kit 105 and the refactoring in this PR we should be able to make a material pool for selected tiles only and update texture paths dynamically.

@lilleyse
Copy link
Contributor Author

I added a few more commits to this PR:

  • 52b0760: some cleanup that will be helpful for the next PR
  • 34e6e3f: I realized that we no longer use the tileId attribute in Fabric so I removed it
  • d2c2a9b: moved base color texture loading to the worker thread

@lilleyse
Copy link
Contributor Author

This is ready for review now. I fixed the merge conflict with #308.

Copy link
Contributor

@weegeekps weegeekps left a comment

Choose a reason for hiding this comment

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

Approved. There's one documentation related nitpick. If you fix it, don't worry about re-approval. I still approve.

src/core/src/FabricGeometry.cpp Outdated Show resolved Hide resolved
@lilleyse lilleyse merged commit c92c435 into main Jul 12, 2023
3 checks passed
@lilleyse lilleyse deleted the imagery-refactor-part-2 branch July 12, 2023 22:25
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