How to get Bevy to run longer than 5 seconds on Windows 11 with Geforce RTX 2060

844 views Asked by At

I'm trying to go through the Bevy docs and have noticed that I absoilutely cannot run a single example or basic app for longer than about 5 seconds without getting errors breaking execution. Is there something special outside of the doc's setup needed to get things to run or is Bevy just broken for an up-to-date Windows 11 + Geforce RTX 2060 machine?

Doesn't matter which example I run or try to follow along with the docs, this always happens:

PS C:\Development\GameDev\my_bevy_game> cargo run
warning: unused manifest key: target.aarch64-apple-darwin.rustflags
warning: unused manifest key: target.x86_64-apple-darwin.rustflags
warning: unused manifest key: target.x86_64-pc-windows-msvc.linker
warning: unused manifest key: target.x86_64-pc-windows-msvc.rustflags
warning: unused manifest key: target.x86_64-unknown-linux-gnu.linker
warning: unused manifest key: target.x86_64-unknown-linux-gnu.rustflags
   Compiling my_bevy_game v0.1.0 (C:\Development\GameDev\my_bevy_game)
    Finished dev [unoptimized + debuginfo] target(s) in 4.01s
     Running `target\debug\my_bevy_game.exe`
2022-04-18T15:56:45.590239Z ERROR wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
        setupLoaderTrampPhysDevs:  Failed during dispatch call of 'vkEnumeratePhysicalDevices' to lower layers or loader to get count.
2022-04-18T15:56:45.591644Z ERROR wgpu_hal::vulkan::instance:   objects: (type: INSTANCE, hndl: 0x207c17a7b00, name: ?)
2022-04-18T15:56:45.592432Z ERROR wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
        setupLoaderTrampPhysDevs:  Failed during dispatch call of 'vkEnumeratePhysicalDevices' to lower layers or loader to get count.
2022-04-18T15:56:45.592561Z ERROR wgpu_hal::vulkan::instance:   objects: (type: INSTANCE, hndl: 0x207c17a7b00, name: ?)
2022-04-18T15:56:45.901926Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 2060", vendor: 4318, device: 7957, device_type: DiscreteGpu, backend: Dx12 }
hello Elaina Proctor!
hello Renzo Hume!
hello Zayna Nieves!
2022-04-18T15:56:48.506223Z ERROR present_frames: wgpu_hal::dx12::instance: ID3D12CommandQueue::Present: Resource state (0x800: D3D12_RESOURCE_STATE_COPY_SOURCE) (promoted from COMMON state) of resource (0x00000207DD7D0A70:'Unnamed ID3D12Resource Object') (subresource: 0) must be in COMMON state when transitioning to use in a different Command List type, because resource state on previous Command List type : D3D12_COMMAND_LIST_TYPE_COPY, is actually incompatible and different from that on the next Command List type : D3D12_COMMAND_LIST_TYPE_DIRECT. [ RESOURCE_MANIPULATION ERROR #990: RESOURCE_BARRIER_MISMATCHING_COMMAND_LIST_TYPE]
error: process didn't exit successfully: `target\debug\my_bevy_game.exe` (exit code: 1)
PS C:\Development\GameDev\my_bevy_game>

The Rust code I made from the book (please note this happens with the bevy repo's untouched example code as well):

use bevy::prelude::*;

pub struct HelloPlugin;

struct GreetTimer(Timer);

#[derive(Component)]
struct Person;

#[derive(Component)]
struct Name(String);

impl Plugin for HelloPlugin {
    fn build(&self, app: &mut App) {
        // the reason we call from_seconds with the true flag is to make the timer repeat itself
        app.insert_resource(GreetTimer(Timer::from_seconds(2.0, true)))
            .add_startup_system(add_people)
            .add_system(greet_people);
    }
}

fn greet_people(time: Res<Time>, mut timer: ResMut<GreetTimer>, query: Query<&Name, With<Person>>) {
    // update our timer with the time elapsed since the last update
    // if that caused the timer to finish, we say hello to everyone
    if timer.0.tick(time.delta()).just_finished() {
        for name in query.iter() {
            println!("hello {}!", name.0);
        }
    }
}

fn add_people(mut commands: Commands) {
    commands
        .spawn()
        .insert(Person)
        .insert(Name("Elaina Proctor".to_string()));
    commands
        .spawn()
        .insert(Person)
        .insert(Name("Renzo Hume".to_string()));
    commands
        .spawn()
        .insert(Person)
        .insert(Name("Zayna Nieves".to_string()));
}

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

You can see from the output that I'm trying to run the my_bevy_game example from the book, but this exact same issue with wgpu occurs on all the examples I've run thus far. What does one need to do to run anything with Bevy?

-- edit --

It would appear that this is a dx12 issue that WGPU needs to address. The proposed workarounds in the Bevy issue don't work for my, and other's, machine. It would appear that Bevy is "broken" irreparably for the time being, due to depending on WGPU.

1

There are 1 answers

5
Stargateur On BEST ANSWER

It look like a bug see issues #4461 of bevy the bug was inside wgpu:

You can try to temporary use the last wgpu version:

[patch.crates-io]
wgpu = { git = "https://github.com/gfx-rs/wgpu" }

# or

wgpu = { git = "https://github.com/gfx-rs/wgpu" , rev = "3d10678a91b78557b0dea537407eb4a4ff754872" }