Skip to content

Conversation

KirmesBude
Copy link
Contributor

@KirmesBude KirmesBude commented Aug 30, 2025

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

  • Did you test these changes? If so, how?
    • CI + changed examples
  • Are there any parts that need more testing?
    • My hardware seems to support only the png skybox. So someone might want to run the example.
  • How can other people (reviewers) test your changes? Is there anything specific they need to know?
    • Run the examples. No.
  • If relevant, what platforms did you test these changes on, and are there any important ones you can't test?
    • linux, amd cpu, amd gpu

Showcase

Check out the changes examples.


depends on #20797
alternative to #20536

@KirmesBude KirmesBude marked this pull request as draft August 30, 2025 09:37
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,
}
Copy link
Contributor Author

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.

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,
)?;
Copy link
Contributor Author

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.

@KirmesBude
Copy link
Contributor Author

Some of the changes are from #20797 (most of image and some in image_loader). Consider that for the review.

@KirmesBude KirmesBude changed the title Feature/image loader setting view dim Image load_with_settings with TextureViewDimension Aug 30, 2025
@KirmesBude KirmesBude marked this pull request as ready for review August 30, 2025 10:07
@IQuick143 IQuick143 added A-Rendering Drawing game state to the screen A-Assets Load files from disk to use for things like images, models, and sounds M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. labels Aug 30, 2025
Copy link
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.

@IQuick143 IQuick143 removed the C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. label Aug 30, 2025
@KirmesBude KirmesBude marked this pull request as draft August 30, 2025 18:09
@IQuick143 IQuick143 added S-Blocked This cannot move forward until something else changes and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Rendering Drawing game state to the screen D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Blocked This cannot move forward until something else changes
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Allow users to provide image dimensions type/layers count in ImageLoaderSettings
2 participants