bevy_ecs_tilemap icon indicating copy to clipboard operation
bevy_ecs_tilemap copied to clipboard

Obscure error in 'basic' example with slight modifications.

Open 0awful opened this issue 1 year ago • 3 comments

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.

0awful avatar Feb 17 '24 21:02 0awful

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.

StarArawn avatar Feb 17 '24 21:02 StarArawn

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.

0awful avatar Feb 23 '24 01:02 0awful

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.

StarArawn avatar Mar 30 '24 15:03 StarArawn