Skip to content

RenderAssets indirectly owning GPU Resources. #24204

@larsraph

Description

@larsraph

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

  1. It will probably be faster because the handles can point into a generationed vector instead of a hashmap with hashing and collision overhead.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions