Helco / zzio

Zanzarah - WIP modding tools and engine remake
MIT License
14 stars 3 forks source link

zzre: Rework asset loading #311

Closed Helco closed 8 months ago

Helco commented 9 months ago

There is a new implementation of an AssetRegistry, but before merging I want to extensively test this. Therefore we have:

Old comment Another somewhat large rework, this time the way assets are loaded and kept alive, as the current way with mostly using `ManagedResource` except when not bothers me immensely. Other issues briefly written down in the issue were: - No deferred application of assets (meaning definitely no asynchronous loading) - No asynchronous or parallel loading - No model of asset dependencies - No checking that `TAsset` and `TInfo` (now `TQuery`) actually have a loader registered - No deferred unloading of assets - No statistics However I found that the general ECS memory model works well enough for my design, so it is used internally. This should also allow us to add it to `ECSExplorer` for further debugging purposes. However² the implementation sketches show a deeper problem which is OneToMany / ManyToMany relationships which are badly supported by DefaultEcs at this time. I might invest into a "RefittedEcs" to correct this and other shortcomings A quick alternative thought: Creating and disposing resources will inevitably allocate and deallocate memory, additional (relatively tiny) allocations regarding dependency management or even resource state management should be negligible. This is strengthen by the fact that this dynamic memory is probably not often accessed. Meaning: maybe we can use a more naive approach and concentrate on getting the API right.

Fixes #180

Helco commented 8 months ago

Okay, third (or fourth?) design:

Constraints:

Helco commented 8 months ago

First measurable results: With only backdrops, models and FOModels migrated we have gone from loading 156 textures for sc_2411 to just 11. When transitioning to sc_2421 we only load 2 textures. Currently however none of this is async as seemingly textures are loaded too fast relative to the other stuff.