Skip to content
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

Pipelined texture atlas crashing with wrong texture view format #2929

Open
Hoidigan opened this issue Oct 7, 2021 · 3 comments
Open

Pipelined texture atlas crashing with wrong texture view format #2929

Hoidigan opened this issue Oct 7, 2021 · 3 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@Hoidigan
Copy link
Contributor

Hoidigan commented Oct 7, 2021

Bevy version

Pipelined-rendering branch, commit bf19ddf

Operating system & version

Windows 10

What you did

Using the pipelined_texture_example as an example, load a single image as a texture atlas from a grid.
Attempt to both draw the whole sheet, and a single item from the sheet, in following with the example.

What you expected to happen

Like the example, it should have drawn and not crashed.

What actually happened

The program crashed

Caused by:
    In Device::create_bind_group
      note: label = `sprite_material_bind_group`
    texture binding 0 expects sample type = Float { filterable: false }, but given a view with format = Rg16Uint

Additional information

It looks like when loading an Image they're automatically assigned a TextureFormat from the image format. But as far as I could tell, the sprite shader can only use a Texture in the right format.
(The example works because the image is the correct format.)
I was able to get it to run successfully by modifying image_to_texture in image_texture_conversion.rs to convert all loaded images to rgba8.

Edit: I checked, and the image from the example is loaded as Rgba8UnormSrgb.
When converting the image to get it to work, I used this (copied from the original code, but converting the image first instead of matching) instead:

let i = dyn_img.into_rgba8();
width = i.width();
height = i.height();
format = TextureFormat::Rgba8UnormSrgb;
data = i.into_raw();
@Hoidigan Hoidigan added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 7, 2021
@NiklasEi NiklasEi added A-Rendering Drawing game state to the screen P-Crash A sudden unexpected crash S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Triage This issue needs to be labelled labels Oct 8, 2021
@Hoidigan
Copy link
Contributor Author

It looks like there is a convert function to switch texture formats, but "Only a few formats are supported as input and output" and at least in my case, this means I'm not able to convert it. (My image is Rg16Uint, according to debug printing.)

@nicopap
Copy link
Contributor

nicopap commented Jul 31, 2023

@nicopap
Copy link
Contributor

nicopap commented Sep 9, 2023

Could you test on latest main? It has probably been fixed by #9611 but I'm not confident enough to close this issue.

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-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests

3 participants