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

Proper dependency management for asset loading #10586

Open
nicopap opened this issue Nov 16, 2023 · 0 comments
Open

Proper dependency management for asset loading #10586

nicopap opened this issue Nov 16, 2023 · 0 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Feature A new feature, making something new possible

Comments

@nicopap
Copy link
Contributor

nicopap commented Nov 16, 2023

Problem

I have a scene definition language (cuicui_chirp) that may depend on the content of other files.

I call "dependent" the file that depends on another one, while "dependency" is the file a dependent file depends on.

I need the actual content of the dependency file in order to interpret dependent files.

The current LoadContext interface let me access the content of a different asset through the LoadContext::load_direct API. However, in my situation, I will have many dependent that depend on a single dependency. load_direct does not cache/re-use loaded assets. Which is problematic, I want to load and parse each file once, then re-use the AST.

Shaders has a similar issue. The implementation of loading and re-using shader dependency in bevy is very complex, and could benefit from re-using a holistic bevy_asset solution.

Potential solutions

In my case, I could implement a complex solution similar to bevy's shader system. But that's (1) reinventing the wheel (2) a large burden (3) doesn't solve the problem for other users and use cases.

What I would like to see:

  • An alternative to load_direct that returns a Cow<A> (or a clone of A), providing a reference to the asset from the Assets store if it is already loaded.
@nicopap nicopap added C-Feature A new feature, making something new possible A-Assets Load files from disk to use for things like images, models, and sounds labels Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Feature A new feature, making something new possible
Projects
None yet
Development

No branches or pull requests

1 participant