-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Image load_with_settings with TextureViewDimension #20799
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?
Image load_with_settings with TextureViewDimension #20799
Conversation
…o feature/image-loader-setting-view-dim
/// Dimensions of a particular texture view. | ||
/// | ||
/// This type mirrors [`TextureViewDimension`]. | ||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
pub enum ImageTextureViewDimension { | ||
/// A one dimensional texture. `texture_1d` in WGSL and `texture1D` in GLSL. | ||
D1, | ||
/// A two dimensional texture. `texture_2d` in WGSL and `texture2D` in GLSL. | ||
D2, | ||
/// A two dimensional array texture. `texture_2d_array` in WGSL and `texture2DArray` in GLSL. | ||
D2Array(u32), | ||
/// A cubemap texture. `texture_cube` in WGSL and `textureCube` in GLSL. | ||
Cube, | ||
/// A cubemap array texture. `texture_cube_array` in WGSL and `textureCubeArray` in GLSL. | ||
CubeArray(u32), | ||
/// A three dimensional texture. `texture_3d` in WGSL and `texture3D` in GLSL. | ||
D3, | ||
} |
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.
This way we get serde support and can encode the layers in the type.
ImageTextureViewDimension::Cube => { | ||
image.reinterpret_stacked_2d_as_array(image.height() / image.width())?; | ||
} | ||
ImageTextureViewDimension::CubeArray(layers) => { | ||
image.reinterpret_stacked_2d_as_array( | ||
image.height() / image.width() * *layers, | ||
)?; |
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 have no idea about Cube or CubeArray textures. Not sure if this was something specific to the skybox example or if Cube will always be height/width.
Some of the changes are from #20797 (most of image and some in image_loader). Consider that for the review. |
It looks like your PR is a breaking change, but you didn't provide a migration guide. Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes. |
Objective
Make loading images with specific TextureViewDimension easier where the image does not contain the meta data.
e.g. loading a png as a texture_2d_array
Fixes #17145
Solution
Add new optional TextureViewDimension member to ImageLoaderSettings.
If Some will override the TextureViewDescriptor with the provided TextureViewDimension.
Testing
Showcase
Check out the changes examples.
depends on #20797
alternative to #20536