Conversation
|
Advantages of using bytes::Bytes:
|
Since we don't need to mutate images once loaded, we avoid unnecessary extra allocations.
hecrj
left a comment
There was a problem hiding this comment.
Looks great!
I made some further changes to use Bytes for the ImageBuffer data containers as well. This way, we avoid reallocating completely when Handle::from_pixels is used!
I have also removed the eager Data hashing and instead decided to use the Bytes pointer as the identifier of a Handle.
Hashing pointers is a terrible idea.
Terrible idea. It's common for allocators to reuse memory causing false cache hits in some edge cases. Changed it to use an auto-incremented unique |
|
New changes look fantastic! I think this work will tie in really nicely into a generalized asset loading solution whereby a generation arena stores load state, updates create new requests by initializing a loading state and getting an index, views read the current load state using the index, and the arena updates load state with bytes when processing responses. This will be super efficient both for loading images and for deserialization with borrows |
This PR is to replace image::Bytes with bytes::Bytes as it's more optimized/feature rich and is basically a drop in replacement.