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

Model Resource Caching #2177

Closed
wants to merge 19 commits into from
Closed

Conversation

Relfos
Copy link
Contributor

@Relfos Relfos commented Oct 4, 2014

This branch provides a modification the internals of the Model class.
Now there is a clear separation between a model and its resources used by the GPU (shaders, textures, vertex arrays, etc).
This means that it is now possible to load multiple instances of the same model without requiring reloading the whole model again, and without wasting gpu resources having multiple copies of the same things.

In order to preserve backwards compatitibility, the previous system will still work as usual. In order to make use of the new caching system, the programmer will have to create a ModelResourceCache and pass it inside the options when creating a new Model.
Currently models resources are cached by URLs (meaning Models loaded from the same URL will reuse the same assets if they are sharing a cache instance).

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 4, 2014

Thanks for this @Relfos! Can you please merge cesium's master branch into your branch so we'll be able to merge when this is ready:

image

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 4, 2014

In order to preserve backwards compatitibility, the previous system will still work as usual. In order to make use of the new caching system, the programmer will have to create a ModelResourceCache and pass it inside the options when creating a new Model.

Do you think we need this? I envisioned this working without any changes to the user's code.

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 4, 2014

Actually, I'm going to wait until you merge in master so I can look at a clean diff.

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 6, 2014

@Relfos please add a comment to this pull request when it is ready since github does not automatically send an email when new commits are added to a branch. Thanks!

@Relfos
Copy link
Contributor Author

Relfos commented Dec 3, 2014

Hi Patrick, can you check this pull request soon?
I updated it to Cesium 1.4, if we can finally integrate with it the master would help a lot!

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 8, 2014

I'll try to look at this on Saturday. Please keep it up-to-date with master.

@Relfos
Copy link
Contributor Author

Relfos commented Dec 8, 2014

Ok, I'll keep it updated until then!

On Mon, Dec 8, 2014 at 3:08 PM, Patrick Cozzi notifications@github.com
wrote:

I'll try to look at this on Saturday. Please keep it up-to-date with
master.


Reply to this email directly or view it on GitHub
#2177 (comment)
.

@pjcozzi pjcozzi mentioned this pull request Dec 14, 2014
@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 15, 2014

Thanks again for the pull request @Relfos. I think this needs a few changes for robustness. Renderer resources should be cached per context to support the same model in two different Cesium viewers (which can't share resources), and cached items should automatically be deleted from the cache when they are not in use. We would also like to be able to cache using a user-defined key for the cases when the glTF was created procedurally and a URL is not available.

I tried to support all of this in the model-cache branch. Try it and let me know if it works for you. The only other changes I would consider for this branch are:

  • Reference counting the animation cache so it is also automatically deleted.
  • Ability to invalidate the whole cache or the cache for one url/cache-key
  • Avoid potential ping-ponging by delaying actually removing from the cache when the count reaches zero for several frames/seconds. This may also move all the GL delete functions into the render loop, which would be better for requestAnimationFrame timing (however, perhaps not noticeable).

Let me know if you need any of these changes or anything else in that branch.

CC #927

@pjcozzi pjcozzi mentioned this pull request Dec 21, 2014
@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 24, 2014

Closing via #2340.

@pjcozzi pjcozzi closed this Dec 24, 2014
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.

3 participants