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

Obscure error in 'basic' example with slight modifications. #515

Open
0awful opened this issue Feb 17, 2024 · 3 comments
Open

Obscure error in 'basic' example with slight modifications. #515

0awful opened this issue Feb 17, 2024 · 3 comments

Comments

@0awful
Copy link

0awful commented Feb 17, 2024

If you take the basic example and make a few modifications you can induce a panic.

on this line here if you set the value to 32.0, 31.0, 17.0 and likely many other numbers, it errors with:

2024-02-17T21:38:03.853803Z ERROR log: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (0)' panicked at /home/guest/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/backend/direct.rs:3056:5:
wgpu error: Validation Error

Caused by:
    In Device::create_texture
      note: label = `texture_array`
    Dimension Z is zero


note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_ecs_tilemap::render::prepare_textures`!
thread 'Compute Task Pool (0)' panicked at /home/guest/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_render-0.12.1/src/pipelined_rendering.rs:145:45:
called `Result::unwrap()` on an `Err` value: RecvError

Notably it doesn't error with 8.0 and 9.0.

@StarArawn
Copy link
Owner

We could do a better job of handling these errors, but the reasoning behind the error is sound. You have to be able to transfer the atlas texture to an array texture which is all based on sprite and atlas sizes.

@0awful
Copy link
Author

0awful commented Feb 23, 2024

At the time of the error it was unclear what caused it and how to resolve it. Could you elaborate further on the underlying cause? I'd love to contribute better error messaging once I understand the error.

@StarArawn
Copy link
Owner

StarArawn commented Mar 30, 2024

At the time of the error it was unclear what caused it and how to resolve it. Could you elaborate further on the underlying cause? I'd love to contribute better error messaging once I understand the error.

Sure, when you change the values of those numbers the atlas to array texture code can no longer split the atlas texture up correctly because you are attempting to access texture memory that doesn't exist. When that happens it creates a texture with no z layers(an empty array texture) and wgpu catches that as an error. We can do some validation that the inputs given make some sense and warn the user if its not the case. In previous versions we did not use array textures and the GPU was using the atlas directly. The GPU wraps/clamps the texture and allows any UV coords so it wont error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants