Open hajimehoshi opened 2 months ago
Q. What if we want to use CDN as a backend?
A. You can implement a fs.FS with the CDN backed, but in this case, an asset manager have to consider asynchronous loading. Hmm. For example, Image
can return a channel instead of an image object directly.
The backend doesn't have to be a fs.FS
. What about this?
type Backend interface {
Open(path string) (io.ReadSeekCloser, error)
}
func NewBackendFromFS(fs fs.FS) Backend
func New(backend Backend) *AssetManager
I realized there are two memory regions: CPU and GPU. The aim is to minimize GPU memory usages compared to CPU memory usages. For Audio, only CPU memory matters. Thus, the APIs to set lifetime should be like this:
SetImageCPUCacheLifetime
// e.g. a decoded RGBA binary data. The default is like 1 minutes?SetImageGPUCacheLifetime
// e.g. *ebiten.Image's internal texture data. The default is like 1 seconds?SetAudioCPUCacheLifetime
// e.g. a decoded audio PCM data. The default is like 1 minutes?To note, merged filesystems can be good/important for modding. e.g., you load your base assets, then load other implementations on top of the base to override. See https://github.com/kettek/go-multipath -- it's basically just a virtualized FS that aggregates multiple FS sources based upon a hierarchy.
To note, merged filesystems can be good/important for modding
I think having Backend
interface (https://github.com/hajimehoshi/ebiten/issues/3100#issuecomment-2351080032) is enough since you can implement Backend
as you like. Is my understanding correct?
Yes, that should actually be sufficient.
Operating System
What feature would you like to be added?
Overview
From our experiment in our games (Odencat Inc.) and other games, we found we often had to implement an asset manager for memory efficiency. Memory efficiency is important for some low-end platforms like mobiles, browsers, and consoles. However, it is annoying to implement such a manager for each game.
I propose to have an official asset manager for such use cases.
API
Rationale
Why not an independent module?
AssetManager has to know the last usage of an image, thus AssetManager has to access the internal of Ebitengine.