My understanding of the RenderAsset trait is that it owns GPU resources. However multiple implimentations... mainly MeshAllocator use a interesting system of indirection. Instead of MeshAllocator giving handles that can be used to access the buffer they internally map AssetIds to resources. If we give out handles instead of mapping on the key of the associated resource a two things will happen
- It will probably be faster because the handles can point into a generationed vector instead of a hashmap with hashing and collision overhead.
- Ownership of resources will be clearer. EX. Inside the RenderMesh there will clearly exist ownership of a handle to the MeshAllocator VS the only proof that RenderMesh owns vertex data being in mesh_allocator.rs
Also currently the RenderAsset::unload_asset, which I would use to manually free claimed resources, would need to change from being called "whenever SourceAsset is removed from the MainWorld" => "Whenever this Asset is Dropped" (Aka Source Removed OR Changed/Reprepared). This would allow us to reclaim resources in that step. Also we would need to pass self or &self into the function so it can use the handles to reclaim resources.
My understanding of the RenderAsset trait is that it owns GPU resources. However multiple implimentations... mainly
MeshAllocatoruse a interesting system of indirection. Instead of MeshAllocator giving handles that can be used to access the buffer they internally map AssetIds to resources. If we give out handles instead of mapping on the key of the associated resource a two things will happenAlso currently the
RenderAsset::unload_asset, which I would use to manually free claimed resources, would need to change from being called "whenever SourceAsset is removed from the MainWorld" => "Whenever this Asset is Dropped" (Aka Source Removed OR Changed/Reprepared). This would allow us to reclaim resources in that step. Also we would need to pass self or &self into the function so it can use the handles to reclaim resources.