-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Utilize bytes::Bytes for images #2356
Conversation
Advantages of using bytes::Bytes:
|
Since we don't need to mutate images once loaded, we avoid unnecessary extra allocations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.