AryanpurTech / BlueEngine

Blue Engine is a general-purpose and easy-to-use graphics engine written in rust.
Apache License 2.0
315 stars 14 forks source link

Surface configuration failed #59

Open smu-sc-gj opened 2 months ago

smu-sc-gj commented 2 months ago

Describe the bug

The sample code provided and examples fail with:

[2024-04-18T08:41:47Z ERROR wgpu_core::device::global] surface configuration failed: Native window is in use thread 'main' panicked at C:\Users\xxxxx.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.19.4\src\backend\wgpu_core.rs:724:18: Error in Surface::configure: Validation Error

Caused by: Invalid surface

To Reproduce Steps to reproduce the behavior:

  1. Open example (https://docs.rs/blue_engine/latest/blue_engine/) or demos.
  2. Cargo build
  3. Cargo run
  4. Error as above, a window is briefly shown on screen.

Expected behavior

Should show a window on screen.

Screenshots

N/A

Desktop (please complete the following information):

ElhamAryanpur commented 2 months ago

could be driver issue such as https://github.com/gfx-rs/wgpu/issues/1492. Try running with a different backend through selecting it from Engine::new_config(WindowDescriptor {backend: ..., ..Default::default()})

related docs for backends available: https://docs.rs/blue_engine/latest/blue_engine/struct.WindowDescriptor.html#structfield.backends

smu-sc-gj commented 2 months ago

Tried GL, VULKAN, BROWSER_WEBGPU and DX12 (currently on a Windows 10 machine). I'm getting slightly different errors for each, can I check I've done this right before reporting the errors?

use blue_engine::{
    header::{ Engine, ObjectSettings, WindowDescriptor, Backends},
    primitive_shapes::triangle
};

fn main() {
    let window_descriptor = WindowDescriptor {
        width: 1280,
        height: 720,
        title: "My Awesome Render",
        backends: Backends::GL,
        ..Default::default() // To keep other details to default values
    };

    // set config
    let _ = Engine::new_config(window_descriptor);

    // initialize the engine
    let mut engine = Engine::new().expect("engine couldn't be initialized");

    // create a triangle
    triangle("my triangle", ObjectSettings::default(), &mut engine.renderer, &mut engine.objects).unwrap();

    // run the engine
    engine
        .update_loop(move |_, _, _, _, _, _| {})
        .expect("Error during update loop");
}
ElhamAryanpur commented 2 months ago

I see, this is quite unique error and its a wgpu error too. Some of the reasons that might cause it:

1) bugs in the wgpu after migration 2) bugs in winit windowing due to eventloop v3 3) driver issue 4) engine's issue

Try using an older version of the engine and see if same issue exist, otherwise it's probably driver issue