dtcristo / bevy_pixels

Bevy plugin that uses Pixels (a tiny pixel buffer) for rendering
https://docs.rs/bevy_pixels
Apache License 2.0
84 stars 12 forks source link

Basic rendering gives an error #8

Closed mathijs28498 closed 2 years ago

mathijs28498 commented 2 years ago

Whenever I try to run the most basic code with bevy_pixels the app crashes.

This is the most basic code that gives this error:

use bevy::prelude::*;
use bevy_pixels::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(PixelsPlugin)
        .run();
}

What happens is that the application will open and it will show a screen with a white background, but then it will panic. This happens as soon as I add the PixelsPlugin in the main function. Without it there are no problems.

error message: 2022-02-20T17:41:26.114561Z INFO bevy_render::renderer: AdapterInfo { name: "Quadro M1200", vendor: 4318, device: 5046, device_type: DiscreteGpu, backend: Vulkan } 2022-02-20T17:41:26.553636Z ERROR wgpu_hal::vulkan::instance: VALIDATION [NVIDIA (0x0)] vkCreateSwapchainKHR: internal drawable creation failed 2022-02-20T17:41:26.554363Z ERROR wgpu_hal::vulkan::instance: objects: (type: SWAPCHAIN_KHR, hndl: 0x25e79a54f88, name: ?)
thread 'main' panicked at 'Error in Surface::configure: parent device is lost', C:\Users\mathi.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.12.0\src\backend\direct.rs:214:9 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace error: process didn't exit successfully: target\debug\raytrace_test.exe (exit code: 101)

dtcristo commented 2 years ago

Hmm, very interesting. I'm on macOS and I have occasionally noticed issues where when the window is created it doesn't render correctly and runs at a very fast framerate. But it doesn't crash.

I think my issue and yours are related. I think it has something to do with the way bevy interacts with the winit event loop (how systems are run and thus pixels rendering is triggered). Given how bevy currently works there is no way for this to be fixed right now. I've attempted a fix here, but it was not really sufficient.

Bevy 0.6 separated rendering from the app systems, but this has not been exposed for plugins yet. This would hopefully allow my to fix the issues that might be caused by the winit event loop.

All this being said, I've noticed there is this issue on bevy that looks similar to your issue. Could be your Nvidia drivers?

mathijs28498 commented 2 years ago

Thanks for the reply! I see that forgot to mention that I am using windows.

But more importantly I forgot to read your readme properly.. I didn't add the "default_features = false" in the toml file. I can run your minimal.rs, so all is good now. Excuse my incompetence.

dtcristo commented 2 years ago

No worries. Glad you could get it working.