bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.23k stars 3.57k forks source link

Error when trying to create render 3d shapes in version 11.0 and 12.0-dev #9405

Open paul-james-charles opened 1 year ago

paul-james-charles commented 1 year ago

Bevy version

I have the same issue on both version 11.0 and 12-dev...This is an issue that did not appear on version 8.0 or 9.0

Relevant system information

See below

2023-08-10T09:30:00.576695Z INFO bevy_render::renderer: AdapterInfo { name: "NVE4", vendor: 65541, device: 0, device_type: Other, driver: "", driver_info: "", backend: Gl }

What you did

You can easily recreate the issue by running: -

cargo run --example "3d_shapes" --features wayland

What went wrong

Panic with the following error message

This is from build

commit e87d3cccbe329783572ecb0d4e3d130a99694508

Error message

2023-08-10T09:30:00.786651Z ERROR wgpu_hal::gles::egl: GLES: [API/Error] ID 2 : GL_INVALID_ENUM in glTexStorage2DMultisample(target=GL_TEXTURE_2D)
2023-08-10T09:30:00.786835Z ERROR wgpu_hal::gles::egl: GLES: [API/Error] ID 2 : GL_INVALID_ENUM in glTexStorage2DMultisample(target=GL_TEXTURE_2D)
2023-08-10T09:30:01.048552Z ERROR wgpu::backend::direct: Shader translation error for stage ShaderStages(FRAGMENT): gsamplerCubeArrayShadow isn't supported in textureGrad, textureLod or texture with bias
2023-08-10T09:30:01.048598Z ERROR wgpu::backend::direct: Please report it to https://github.com/gfx-rs/naga
2023-08-10T09:30:01.048636Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (1)' panicked at 'wgpu error: Validation Error

Caused by: In Device::create_render_pipeline note: label = pbr_opaque_mesh_pipeline Internal error in ShaderStages(FRAGMENT) shader: gsamplerCubeArrayShadow isn't supported in textureGrad, textureLod or texture with bias

', /home/paul/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.16.3/src/backend/direct.rs:3019:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Encountered a panic in system bevy_render::render_resource::pipeline_cache::PipelineCache::process_pipeline_queue_system! thread 'Compute Task Pool (1)' panicked at 'called Result::unwrap() on an Err value: RecvError', crates/bevy_render/src/pipelined_rendering.rs:143:45

paul-james-charles commented 1 year ago

Note that this appears to break between 0.9.1 and 0.10.0

nicopap commented 1 year ago

NVE4 is the "Kepler" series of NVIDIA GPUs. The Archlinux wiki has some interesting info: https://wiki.archlinux.org/title/NVIDIA (search for "kepler" keyword)

Kepler should support Vulkan, I'm not sure why wgpu is defaulting to GL. Can you run WGPU_BACKEND=vulkan cargo run to see if it changes anything?

Independently I'm fairly certain we have a GL issue. I can reproduce the error with WGPU_BACKEND=gl on my end. Edit: #7320 tells the fix is to use the --features webgl2 with the gl backend (open gl), it does work. But regardless, you should prefer the vulkan backend as it has more features.

paul-james-charles commented 1 year ago

I will admit this is my first time giving something back to Open Source...But I have identified that the issue appeared on commit 5ee57ff4ba13925963a423770564647c61b3c709.

It appears they changed the default backend for WgpuSettings from Backends::all() to Backends::PRIMARY.

The fix for 3d_shapes example is to add the following

    .add_plugins(DefaultPlugins
        .set(RenderPlugin { 
            wgpu_settings: WgpuSettings {
                backends: Some(Backends::PRIMARY),
                ..Default::default()
            } 
        })

However it may be worth looking if this default value should be changed back in the future...or technote added about the issue

paul-james-charles commented 1 year ago

Also I agree that using WGPU_BACKEND=vulkan cargo run appears to fix the issue

nicopap commented 1 year ago

More links:

nicopap commented 1 year ago

This needs to be escalated to wgpu https://github.com/gfx-rs/wgpu. As far as I can tell, this is an issue with wgpu's feature detection and heuristic for choosing the backend. Do you see any supsicious warnings when running with WGPU_BACKEND=vulkan? Since you seem to be able to run vulkan, wgpu should have chosen it over open gl.

paul-james-charles commented 1 year ago

No warnings when running with WGPU_BACKEND=vulkan. Just one note I am running the Ubuntu driver for the Nvidia card, as the nvidia native drivers do not work since upgrading Ubuntu to the latest does not work

nicopap commented 1 year ago

The open source reverse-engineered NVIDIA nouveau drivers are notoriously broken. To the point people will tell you to use the proprietary nvidia drivers rather than try to fix your issue (because if you can't reproduce the bug with proprietary nvidia drivers, it means the bug is in the nouveau drivers). This may explain things. I'm surprised it's even capable of running a bevy app. It's actually impressive.