bevyengine / bevyengine/bevy

`ImageSampler::get_or_init_descriptor()` changes the sampler.

Open
#19,149 1 comment 0 reactions 0 assignees View on GitHub
A-Rendering C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.16

## What went wrong

`ImageSampler::get_or_init_descriptor()` is changing descriptor from the ImagePlugin's default to `ImageSamplerDescriptor::default()`.

The current method looks like this:
```rust
/// Initialize the descriptor if it is not already initialized.
///
/// Descriptor is typically initialized by Bevy when the image is loaded,
/// so this is convenient shortcut for updating the descriptor.
pub fn get_or_init_descriptor(&mut self) -> &mut ImageSamplerDescriptor {
match self {
ImageSampler::Default => {
*self = ImageSampler::Descriptor(ImageSamplerDescriptor::default());
match self {
ImageSampler::Descriptor(descriptor) => descriptor,
_ => unreachable!(),
}
}
Self::Descriptor(descriptor) => descriptor,
}
}
```
ImageSampler::Default variant is meant to represent that an image uses sampler stored in `DefaultImageSampler` in `RenderApp`, which is in turn inserted by ImagePlugin and can contain user input. This code, however, changes sampler to `ImageSamplerDescriptor::default()`.

Came from #11113.

## Additional information

Caught that one while checking what uses `ImageSamplerDescriptor::default()` because I'm redefining it in #19127.
I did not try to reproduce this yet.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.