-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Add new ImageLoaderSettings member for loading as stacked 2d array #20536
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
base: main
Are you sure you want to change the base?
Add new ImageLoaderSettings member for loading as stacked 2d array #20536
Conversation
Very nice! |
abe31c6
to
13a4d42
Compare
I also changed the tilemap example. I see one use of |
})?; | ||
|
||
if let Some(layers) = settings.layers { | ||
image.reinterpret_stacked_2d_as_array(layers.into()); |
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.
I just realized this actually panics. So I want to change this so it returns a Result, but I am not sure if I should keep the panicing version? Is there any benefit to it?
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.
Please swap it to return a Result. Panicking APIs are only worth it when the operation is extremely common and the panics are extremely rare. Neither is the case here :)
Objective
Loading images for use as texture 2d array is tedious and should be supported in the context of loading the asset.
Partially fixes #17145
Solution
Add a new
layers
member toImageLoaderSettings
which determines if and how we callreinterpret_stacked_2d_as_array
during asset loading.Testing
array_texture
exampleShowcase
I believe the changes in
examples/shader/array_texture.rs
show quite well how this is nicer to work with.