Image load_with_settings with TextureViewDimension#20799
Closed
KirmesBude wants to merge 14 commits into
Closed
Conversation
…o feature/image-loader-setting-view-dim
KirmesBude
commented
Aug 30, 2025
Comment on lines
+720
to
+737
| /// 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, | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This way we get serde support and can encode the layers in the type.
KirmesBude
commented
Aug 30, 2025
Comment on lines
+201
to
+207
| 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, | ||
| )?; |
Contributor
Author
There was a problem hiding this comment.
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.
Contributor
Author
|
Some of the changes are from #20797 (most of image and some in image_loader). Consider that for the review. |
Contributor
|
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. |
…r-setting-view-dim
…r-setting-view-dim
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Oct 29, 2025
…_2d_as_array` (#21628) # Objective If you want to use a `TilemapChunk` (or more generally use a `texture2DArray` in a shader), you have to implement a mechanism that waits for your texture to load, then calls `Image::reinterpret_stacked_2d_as_array`. ## Solution Have the loader do it instead. Closes #20799, which does very similar things and should be remade if more functionality is needed. ## Testing - Ran the updated examples --- ## Showcase ```rs let array_texture = asset_server.load_with_settings( "textures/array_texture.png", |settings: &mut ImageLoaderSettings| { settings.array_layout = Some(ImageArrayLayout::RowCount(4)); }, ); ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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