Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upRework assets crate #416
Conversation
torkleyy
added
project: assets
status: working
type: RFC
labels
Oct 14, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 14, 2017
Member
This file pretty much shows the new design: https://github.com/amethyst/amethyst/pull/416/files#diff-1d28361fa1117c22df23aaee9e82da0a
|
This file pretty much shows the new design: https://github.com/amethyst/amethyst/pull/416/files#diff-1d28361fa1117c22df23aaee9e82da0a |
Rhuagh
reviewed
Oct 14, 2017
FWIW I like it! Gonna hold off until the PR is done to do a full review, but do far it looks good.
torkleyy
and others
added some commits
Oct 14, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Should return mat also |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Yeah, did locally already ;) |
| - /// Request for clearing the whole cache. | ||
| - fn clear_all(&self) {} | ||
| -} | ||
| - | ||
| /// A format, providing a conversion from bytes to asset data, which is then | ||
| /// in turn accepted by `Asset::from_data`. Examples for formats are |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 15, 2017
Member
The advantage is that now systems can do that. So the problem you complained about (meshes taking two frames to be displayed) is fixed now.
torkleyy
Oct 15, 2017
Member
The advantage is that now systems can do that. So the problem you complained about (meshes taking two frames to be displayed) is fixed now.
| camera: Option<Fetch<'a, Camera>>, | ||
| - mesh: ReadStorage<'a, M>, | ||
| - material: ReadStorage<'a, N>, | ||
| + mesh_storage: Fetch<'a, AssetStorage<Mesh>>, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 15, 2017
Member
@omni-viral Now passes should be fixed. Code is not very organized, but logically it should be all there now.
|
@omni-viral Now passes should be fixed. Code is not very organized, but logically it should be all there now. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@torkleyy so new system doesn't require any notification mechanism? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Oct 15, 2017
Member
It's pull based, the asset loading systems will call process and be handed the data that has finished loading, and process them, turning them into assets
|
It's pull based, the asset loading systems will call process and be handed the data that has finished loading, and process them, turning them into assets |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Oct 15, 2017
Member
There's a simple implementation of a loading system that can be used for simple assets, check Processor
|
There's a simple implementation of a loading system that can be used for simple assets, check |
torkleyy
added some commits
Oct 15, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
A benchmark would be great. ;) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 15, 2017
Member
@jojolepro I'm pretty sure it's faster than before, but yes, we could really use some benchmarks. That said, I don't think I'll include them in this PR. It's already big enough.
|
@jojolepro I'm pretty sure it's faster than before, but yes, we could really use some benchmarks. That said, I don't think I'll include them in this PR. It's already big enough. |
| @@ -21,14 +21,15 @@ use shred::ResourceId; | ||
| /// | ||
| /// Panics during `DjSystem` registration if the bundle is applied twice. | ||
| /// | ||
| -pub struct DjBundle<'a> { | ||
| +pub struct DjBundle<'a, F> { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
added some commits
Oct 15, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 15, 2017
Member
Right now things are still verbose, but it's getting better. I really hope that I can increase the expressibility in future PRs, not limited to the assets crate.
|
Right now things are still verbose, but it's getting better. I really hope that I can increase the expressibility in future PRs, not limited to the assets crate. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Yeah, we could have all asset resources in |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jojolepro
Oct 16, 2017
Collaborator
I'll hold on reviewing, as I don't have anywhere enough time to check that much code. Following the discussions on gitter, conceptually this PR is good.
|
I'll hold on reviewing, as I don't have anywhere enough time to check that much code. Following the discussions on gitter, conceptually this PR is good. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
Thanks @jojolepro . I'm not sure I understood you correctly, are you self-requesting a review but saying you can't do the review now, or are you saying you can't do a full review because you don't have enough time?
|
Thanks @jojolepro . I'm not sure I understood you correctly, are you self-requesting a review but saying you can't do the review now, or are you saying you can't do a full review because you don't have enough time? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Can't fully review. |
| log = "0.3.8" | ||
| parking_lot = "0.4.4" | ||
| rayon = "0.8" | ||
| specs = { version = "0.10", features = ["common"] } | ||
| + | ||
| +[dev-dependencies] | ||
| +ron = "0.1.4" |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
That's because 0.1.3 had a a bug which has been fixed in 0.1.4, so I thought it would be important to require that version.
torkleyy
Oct 16, 2017
Member
That's because 0.1.3 had a a bug which has been fixed in 0.1.4, so I thought it would be important to require that version.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
omni-viral
reviewed
Oct 16, 2017
I have a little concern in mind.
If an error occur in Source::load, Format::import and ends Errors passed in AssetStorage::process how user would know what Handle will never give him loaded asset?
| + errors.execute::<AssetError, _>(|| { | ||
| + println!("Got asset with name {}", &name); | ||
| + | ||
| + let asset = data.and_then(|d| f(d)) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
how user would know what Handle will never give him loaded asset
This actually is a problem, I know. You'd basically check the errors. So it's not the most ergonomic thing, but before the error was also just added to Errors.
This actually is a problem, I know. You'd basically check the errors. So it's not the most ergonomic thing, but before the error was also just added to |
| + let bitset = &mut self.bitset; | ||
| + let handles = &mut self.handles; | ||
| + errors.execute::<AssetError, _>(|| { | ||
| + let asset = data.and_then(|d| f(d)) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
omni-viral
Oct 16, 2017
Member
Ah. It's in loop.
and_then(&mut f) in this case.
Shows borrowing more explicitly.
omni-viral
Oct 16, 2017
•
Member
Ah. It's in loop.
and_then(&mut f) in this case.
Shows borrowing more explicitly.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
Is FnMut implemented for &mut T where T: FnMut? I think not, will try later.
torkleyy
Oct 16, 2017
•
Member
Is FnMut implemented for &mut T where T: FnMut? I think not, will try later.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
omni-viral
Oct 16, 2017
Member
You'd basically check the errors.
How you can find connection between error in Errors (BoxedErr) and Handles?
How you can find connection between error in |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
As I said, this is not fully resolved yet. To be honest, I don't know a very good solution right now; as I said, this problem existed before, so this is neither making the problem worse nor solves it.
|
As I said, this is not fully resolved yet. To be honest, I don't know a very good solution right now; as I said, this problem existed before, so this is neither making the problem worse nor solves it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Oct 16, 2017
Member
Couldn't we use Progress for this? Push Handle<..> and the Error and have a separate function for it ?
|
Couldn't we use Progress for this? Push Handle<..> and the Error and have a separate function for it ? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@Rhuagh This is a very, very, very good idea! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
I actually thought about adding such a method, but I didn't realize it would solve this problem
|
I actually thought about adding such a method, but I didn't realize it would solve this problem |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Again, this is great! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
The only question that is left is should
- the progress tracker get the full
BoxedError should we - give it to
Errorsand giveProgressonly a description of the error?
|
The only question that is left is should
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Oct 16, 2017
Member
I'm not sure. Whichever way is easiest for now, we can improve on it later.
|
I'm not sure. Whichever way is easiest for now, we can improve on it later. |
Aceeri
self-requested a review
Oct 16, 2017
torkleyy
added some commits
Oct 16, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
I've addressed all review comments, so please give it a final review. @Aceeri self-requested, so we need to wait for their review before merging.
|
I've addressed all review comments, so please give it a final review. @Aceeri self-requested, so we need to wait for their review before merging. |
torkleyy
requested a review
from
Rhuagh
Oct 16, 2017
| + fn create_tracker(self) -> Self::Tracker; | ||
| +} | ||
| + | ||
| +impl Progress for () { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
So basically now you can also pass () if you don't care and just want the assets to pop in once they're there.
torkleyy
Oct 16, 2017
Member
So basically now you can also pass () if you don't care and just want the assets to pop in once they're there.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
Error handling needs improvements, but I think one can see that this design at least allows them, thus we should do that in a future PR.
torkleyy
Oct 16, 2017
Member
Error handling needs improvements, but I think one can see that this design at least allows them, thus we should do that in a future PR.
Rhuagh
approved these changes
Oct 16, 2017
Like you said, error handling needs improvement but let's do that in a separate PR.
Xaeroxe
requested changes
Oct 16, 2017
I would prefer that we fix music in pong prior to merging, otherwise looks great!
| +} | ||
| + | ||
| +impl State { | ||
| + /// Returns `true` if the app should quit. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| + self.bitset.remove(id); | ||
| + self.unused_handles.push(old); | ||
| + | ||
| + println!("Removed value!"); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
added some commits
Oct 16, 2017
torkleyy
assigned
Rhuagh
Oct 16, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Oct 16, 2017
Member
So I assigned @Rhuagh for merging this when it's ready, and I assigned myself for
|
So I assigned @Rhuagh for merging this when it's ready, and I assigned myself for |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
bors r+ |
torkleyy commentedOct 14, 2017
•
edited
Edited 1 time
-
torkleyy
edited Oct 14, 2017 (most recent)
Changes
FormatHandle)Progressstruct to allow loading screens and similar stuffStoretoSourceTODO