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

Bevy can't render default shapes if bevy_render has shader_format_glsl enabled. #13232

Open
jimvdl opened this issue May 4, 2024 · 5 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@jimvdl
Copy link

jimvdl commented May 4, 2024

Bevy version

0.13

Relevant system information

Operating system: Windows 10.
Rust version: 1.76.0

AdapterInfo { name: "NVIDIA GeForce RTX 3080", vendor: 4318, device: 8726, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "551.52", backend: Vulkan }

What you did

Minimal reproducible example:
Cargo.toml

# package omitted

[profile.dev]
opt-level = 1

[profile.dev.package."*"]
opt-level = 3

[dependencies]
bevy = "0.13"
bevy_render = { version = "0.13", features = ["shader_format_glsl"] }

main.rs

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    commands.spawn(MaterialMeshBundle {
        mesh: meshes.add(Cuboid::default()),
        transform: Transform::from_xyz(0.0, 0.5, 0.0),
        material: materials.add(Color::rgb(0., 0.5, 0.7)),
        ..default()
    });

    commands.spawn(Camera3dBundle {
        transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
        ..default()
    });
}

What went wrong

I can render GLTF models fine but once I replace that with a Cuboid::default I get the following panic:

thread 'Async Compute Task Pool (2)' panicked at C:\Users\Jim\.cargo\registry\src\index.crates.io-6f17d22bba15001f\naga-0.19.2\src\back\glsl\mod.rs:1183:44:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'Async Compute Task Pool (2)' panicked at C:\Users\Jim\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_render-0.13.2\src\render_resource\pipeline_cache.rs:702:60:
called `Result::unwrap()` on an `Err` value: PoisonError { .. }
thread 'Async Compute Task Pool (1)' panicked at C:\Users\Jim\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_render-0.13.2\src\render_resource\pipeline_cache.rs:801:60:
called `Result::unwrap()` on an `Err` value: PoisonError { .. }
Encountered a panic in system `bevy_render::render_resource::pipeline_cache::PipelineCache::process_pipeline_queue_system`!
thread 'Compute Task Pool (3)' panicked at C:\Users\Jim\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_render-0.13.2\src\pipelined_rendering.rs:49:67:
called `Result::unwrap()` on an `Err` value: RecvError

In my bigger project I'm using GLSL to shade models that I've imported with GLTF, those work perfectly, the shader works and the models are correctly imported and displayed. The only thing that goes wrong is if you use either MaterialMeshBundle or PbrBundle with a basic shape mesh, then the above panic occurs.

I can't use bevy_render without shader_format_glsl because it's a required feature if you want to shade GLTF meshes with GLSL.

Additional information

I'm very new to all this, I've worked with Bevy before without needing any models or meshes (it was basically only a ECS backend) so it might be that I'm just doing something wrong.

if you disable the shader_format_glsl feature the above example compiles and runs fine.

@jimvdl jimvdl added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels May 4, 2024
@rornic
Copy link

rornic commented May 4, 2024

I'm seeing the same error message using a PbrBundle with and without the extra bevy_render dependency.

Bevy 0.13.2

System info:

2024-05-04T18:11:11.728782Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 2060", vendor: 4318, de
vice: 7944, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "552.12", backend: Vulkan }
2024-05-04T18:11:13.088476Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Wi
ndows 10 Home", kernel: "19045", cpu: "AMD Ryzen 7 1700 Eight-Core Processor", core_count: "8", memory: "15.9 GiB" }

@rornic
Copy link

rornic commented May 5, 2024

I played around with this a bit more and got it to start up by explicitly setting my rendering backend to OpenGL - it renders fine but with a bunch of errors.

2024-05-05T09:40:20.754652Z ERROR log: wgpu-hal heuristics assumed that the view dimension will be equal to `D2` rather than `D2Array`.
`D2` textures with `depth_or_array_layers == 1` are assumed to have view dimension `D2`
`D2` textures with `depth_or_array_layers > 1` are assumed to have view dimension `D2Array`
`D2` textures with `depth_or_array_layers == 6` are assumed to have view dimension `Cube`
`D2` textures with `depth_or_array_layers > 6 && depth_or_array_layers % 6 == 0` are assumed to have view dimension `CubeArray`

Powershell:

$Env:WGPU_BACKEND="opengl"

It continues to fail as before if I explicitly set the backend to vulkan and dx12.

@jimvdl can you see if that makes any difference for you?

@jimvdl
Copy link
Author

jimvdl commented May 5, 2024

For me no rendering happens, I have roughly the same errors but my GPU doesn't have full OpenGL support (it seems)

@rornic
Copy link

rornic commented May 5, 2024

I got to the bottom of the error on my end. I was working on migrating an old project over to bevy -- I hadn't realised it was on 2018 Rust edition.

Upgrading to 2021 fixed it for me.

@ozer
Copy link

ozer commented May 9, 2024

I'm also having the same problem on my Apple machine, it panics as shared above. The issue does not occur if I spawn only the camera or the ground but occurs when I spawn both of them. I'm also new to Bevy and the game development so, got no clues here.

Rust version: 1.78.0

2024-05-09T09:59:35.817984Z  INFO bevy_render::renderer: AdapterInfo { name: "Apple M2 Pro", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
2024-05-09T09:59:36.299343Z  INFO bevy_winit::system: Creating new window "App" (0v1)
2024-05-09T09:59:36.335828Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "MacOS 14.4.1 ", kernel: "23.4.0", cpu: "Apple M2 Pro", core_count: "12", memory: "32.0 GiB" }

Cargo.toml

[package]
name = "agustos"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = { version = "0.13.2", features = ["default"] }

main.rs

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, (spawn_camera, create_ground))
        .run();
}

pub fn spawn_camera(mut commands: Commands) {
    commands.spawn((
        Camera3dBundle {
            transform: Transform::from_xyz(-2., 2.5, 5.0)
                .looking_at(Vec3::ZERO, Vec3::Y),
            ..default()
        }
    ));
}


pub fn create_ground(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    let floor = PbrBundle {
        mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)),
        material: materials.add(Color::DARK_GREEN),
        ..default()
    };
    commands.spawn(floor);
}

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen 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 May 13, 2024
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 S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests

4 participants