bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.03k stars 3.56k forks source link

Rendering resource cache improvements #9706

Closed JMS55 closed 6 months ago

JMS55 commented 1 year ago

What problem does this solve or what need does it fill?

Currently we have only a TextureCache and PipelineCache. We'd additionally want at least BufferCache. Maybe a SamplerCache and BindGroupCache.

It would also be great to have a generic cache type. Something that acts like a HashMap and evicts no longer used resources, which we can reuse for other rendering tasks instead of implementing it from scratch every time. I've found use cases for BLAS storage, FSR/DLSS contexts, and other times I want to cache custom render resources.

What solution would you like?

Adopt moka, or a similar crate.

What alternative(s) have you considered?

Write a generic caching API ourselves.

superdump commented 1 year ago

I am going to experiment with making a dumb bind group cache at some point fairly soon to support some of the rendering optimisation, but I am intending to use generational indices, free lists, atomics, etc. I’m also not yet concerned about LRU/LFU, and I’m not sure how we want to manage assets. I think the texture cache has a simple ‘if not used for N frames then drop’ policy.

msvbg commented 2 months ago

A quick search shows that there's still no BufferCache in Bevy, but this issue was marked as completed. What did we implement?

JMS55 commented 2 months ago

We didn't end up implementing anything. Caching is done ad-hoc for each rendering feature.