Skip to content

Add a setting to ImageLoader that calls Image::reinterpret_stacked_2d_as_array#21628

Merged
alice-i-cecile merged 10 commits into
bevyengine:mainfrom
grind086:image_loader_arrays
Oct 29, 2025
Merged

Add a setting to ImageLoader that calls Image::reinterpret_stacked_2d_as_array#21628
alice-i-cecile merged 10 commits into
bevyengine:mainfrom
grind086:image_loader_arrays

Conversation

@grind086

@grind086 grind086 commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

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

let array_texture = asset_server.load_with_settings(
    "textures/array_texture.png",
    |settings: &mut ImageLoaderSettings| {
        settings.array_layout = Some(ImageArrayLayout::RowCount(4));
    },
);

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 27, 2025
Comment thread crates/bevy_image/src/image_loader.rs Outdated

@alice-i-cecile alice-i-cecile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change! A few things:

  • I think we can make the enum clearer
  • this is a neat change, but not splashy enough for a release note
  • this needs a short migration guide for the new field on ImageLoaderSettings

@alice-i-cecile alice-i-cecile added the M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Oct 27, 2025
@github-actions

Copy link
Copy Markdown
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.

@KirmesBude

Copy link
Copy Markdown
Contributor

This tries to do something similar. At least the motivation is the same #20799

@grind086

Copy link
Copy Markdown
Contributor Author

I went ahead and applied the suggested changes, but I would be fine closing in favor of #20799 if you'd prefer that one.

@alice-i-cecile alice-i-cecile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this now, but I'll defer to you and @KirmesBude on which solution you prefer.

@KirmesBude

Copy link
Copy Markdown
Contributor

@alice-i-cecile @grind086 My PR does more (cubemap), but that does not mean it does it better. I only really care about 2darray anyways and this PR does exactly that, so we can go ahead with this one. Thanks for creating the PR :).

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 29, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 29, 2025
Merged via the queue into bevyengine:main with commit 0451082 Oct 29, 2025
38 checks passed
@grind086 grind086 deleted the image_loader_arrays branch October 29, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants