ggez / ggez

Rust library to create a Good Game Easily
http://ggez.rs
MIT License
4.27k stars 420 forks source link

Error: RequestDeviceError(RequestDeviceError) #1074

Open xiaoshihou514 opened 2 years ago

xiaoshihou514 commented 2 years ago

Describe the bug Hey guys sorry to bother, the issue is a duplicate of #1070. Error: RequestDeviceError(RequestDeviceError)

To Reproduce

git clone https://github.com/ggez/ggez.git
cd ggez
git switch devel
cargo run --example 01_super_simple

Expected behavior Example codes compiles.

Screenshots or pasted code Before switching to devel branch:

Liebknecht@arch ~/P/r/E/ggez (master) [1]> cargo run --example 01_super_simple
    Finished dev [unoptimized + debuginfo] target(s) in 0.66s
     Running `target/debug/examples/01_super_simple`
Error: RenderError("failed to find suitable graphics adapter")

After switching to devel branch:

    Finished dev [unoptimized + debuginfo] target(s) in 1m 53s
    Running `target/debug/examples/01_super_simple`
Failed to initialize graphics, trying secondary backends.. Please mention this if you encounter any bugs!
Error: RequestDeviceError(RequestDeviceError)

Hardware and Software:

Sorry if I'm dumb about anything. I'm probably switching to a windows environment to explore this engine before I know how to fix that :) Great work done by the dev team.

nobbele commented 2 years ago

Edited to make it a bit easier to read. Thanks for reporting! I'll take a look at it when I have time

nobbele commented 2 years ago

It's likely not using your dedicated GPU but for some reason it crashes with intel graphics too

nobbele commented 2 years ago

Our limits might be set higher than needed. https://github.com/ggez/ggez/blob/d787f7f2a0ee8d8bdae6ec487261451220af64c5/src/graphics/context.rs#L191 could you go to line 191 in src/graphics/context.rs and replace Default::default() with wgpu::Limits::downlevel_defaults() or wgpu::Limits::downlevel_webgl2_defaults()?

xiaoshihou514 commented 2 years ago

Our limits might be set higher than needed. https://github.com/ggez/ggez/blob/d787f7f2a0ee8d8bdae6ec487261451220af64c5/src/graphics/context.rs#L191 could you go to line 191 in src/graphics/context.rs and replace Default::default() with wgpu::Limits::downlevel_defaults() or wgpu::Limits::downlevel_webgl2_defaults()?

Changing that as follows:

limits: wgpu::Limits {
                    max_bind_groups: 5,
                    //..Default::default()
            ..wgpu::Limits::downlevel_defaults()
                },

Output from using <cargo run --example 01_super_simple>:

    Finished dev [unoptimized + debuginfo] target(s) in 21.87s
     Running `target/debug/examples/01_super_simple`
Failed to initialize graphics, trying secondary backends.. Please mention this if you encounter any bugs!
Error: RequestDeviceError(RequestDeviceError)

Output from using <wgpu::Limits::downlevel_webgl2_defaults()>:

    Finished dev [unoptimized + debuginfo] target(s) in 29.32s
     Running `target/debug/examples/01_super_simple`
Failed to initialize graphics, trying secondary backends.. Please mention this if you encounter any bugs!
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_bind_group_layout
    binding 0 entry is invalid
    Downlevel flags VERTEX_STORAGE are required but not supported on the device.
This is not an invalid use of WebGPU: the underlying API or device does not support enough features to be a fully compliant implementation. A subset of the features can still be used. If you are running this program on native and not in a browser and wish to work around this issue, call Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current platform supports.

', /home/Liebknecht/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:2273:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I guess that's a rendering API issue? Nevertheless I'm going to post the output with the retracing flag to produce more debug info.

$ export RUST_BACKTRACE=1
$ cargo run --example 01_super_simple

Additinal output as follows:

stack backtrace:
   0: rust_begin_unwind
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library/core/src/panicking.rs:142:14
   2: wgpu::backend::direct::default_error_handler
             at /home/Liebknecht/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:2273:5
   3: core::ops::function::Fn::call
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library/core/src/ops/function.rs:77:5
   4: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library/alloc/src/boxed.rs:1886:9
   5: wgpu::backend::direct::ErrorSinkRaw::handle_error
             at /home/Liebknecht/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:2259:17
   6: wgpu::backend::direct::Context::handle_error
             at /home/Liebknecht/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:194:9
   7: <wgpu::backend::direct::Context as wgpu::Context>::device_create_bind_group_layout
             at /home/Liebknecht/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:1099:13
   8: wgpu::Device::create_bind_group_layout
             at /home/Liebknecht/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/lib.rs:1794:17
   9: ggez::graphics::gpu::bind_group::BindGroupLayoutBuilder::create_uncached
             at ./src/graphics/gpu/bind_group.rs:67:13
  10: ggez::graphics::gpu::bind_group::BindGroupLayoutBuilder::create::{{closure}}
             at ./src/graphics/gpu/bind_group.rs:61:32
  11: std::collections::hash::map::Entry<K,V>::or_insert_with
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library/std/src/collections/hash/map.rs:2386:43
  12: ggez::graphics::gpu::bind_group::BindGroupLayoutBuilder::create
             at ./src/graphics/gpu/bind_group.rs:58:9
  13: ggez::graphics::context::GraphicsContext::new_from_instance
             at ./src/graphics/context.rs:310:36
  14: ggez::graphics::context::GraphicsContext::new
             at ./src/graphics/context.rs:121:21
  15: ggez::context::Context::from_conf
             at ./src/context.rs:178:32
  16: ggez::context::ContextBuilder::build
             at ./src/context.rs:343:9
  17: _01_super_simple::main
             at ./examples/01_super_simple.rs:53:33
  18: core::ops::function::FnOnce::call_once
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

All that done using the devel branch ofc. Again, thank you guys for your work and your time to maintain this project! That's why I love open source communities :P Also, I ran the example on my other windows laptop and it's fine, probably hardware issues (the arch laptop is pretty old as you can see).

nobbele commented 2 years ago

downlevel_defaults might still be too high but downlevel_webgl2_defaults is too low. Gonna have to check more specific limits. Thanks for testing!

xiaoshihou514 commented 2 years ago

downlevel_defaults might still be too high but downlevel_webgl2_defaults is too low. Gonna have to check more specific limits. Thanks for testing!

Glad to help!