Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset locking #15359

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Asset locking #15359

wants to merge 16 commits into from

Commits on Sep 27, 2024

  1. Create AssetPresence as a replacement to Option.

    This currently buys us nothing, but it's a nice stepping stone to making `AssetPresence` have a locked variant.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    17d84eb View commit details
    Browse the repository at this point in the history
  2. Add a Locked variant to AssetPresence.

    This variant is still unused.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    d030b11 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c56b6e2 View commit details
    Browse the repository at this point in the history
  4. Allow locking and unlocking assets.

    Now assets can be "locked" into an `Arc`.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    cf8024c View commit details
    Browse the repository at this point in the history
  5. Keep track of the set of currently locked assets.

    This will make it more performant to try unlocking all the locked assets in the "happy case" that few assets are locked.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    67a60c8 View commit details
    Browse the repository at this point in the history
  6. Create a system to automatically unlock assets every frame.

    This way, if you lock an asset, you just have to drop its `Arc` and wait a frame for the asset to become mutable again (as opposed to requiring a system to figure out which assets can be unlocked and trying to unlock just those).
    
    The price is constant polling whenever an asset is locked. We have to repeatedly try unlocking an asset until it is actually ready to be unlocked.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    7450ba5 View commit details
    Browse the repository at this point in the history
  7. Add some convenience functions to AssetPresenceMut.

    This makes it easier to just unwrap a mutable borrow by just doing `.as_mut().unwrap()`.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    209465d View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    e654299 View commit details
    Browse the repository at this point in the history
  9. Handle locked assets when moving assets from the render world to the …

    …main world.
    
    For simplicity, we just clone the assets. In theory, we could have an enum to store the RenderAssets as either a locked Arc or an Unlocked asset, but I'd rather just avoid that branch.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    ed80653 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    2574e62 View commit details
    Browse the repository at this point in the history
  11. Handle meshlets possibly being locked.

    This is actually a totally fine case, we just need a borrow to be able to clone the internal Arc's.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    13019fe View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    c8ffbf1 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    a8f4663 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    167aad4 View commit details
    Browse the repository at this point in the history
  15. Implement get_mut_or_clone.

    This makes working with asset locking much more palatable, as users don't need to explicitly handle the locking case in most situations.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    816fb29 View commit details
    Browse the repository at this point in the history
  16. Use get_mut_or_clone in all the examples.

    This is likely the common case for users, so we should have our examples use this function.
    andriyDev committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    2c87377 View commit details
    Browse the repository at this point in the history