如何让Bevy在使用Geforce RTX 2060的Windows 11上运行超过5秒



我试图通过Bevy文档,并注意到我绝对不能运行一个例子或基本的应用程序超过5秒没有得到错误打破执行。文档的设置之外是否有什么特殊的东西需要运行,或者Bevy只是为最新的Windows 11 + Geforce RTX 2060机器而坏了?

无论我运行哪个示例或尝试遵循文档,这种情况总是发生:

PS C:DevelopmentGameDevmy_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:DevelopmentGameDevmy_bevy_game)
Finished dev [unoptimized + debuginfo] target(s) in 4.01s
Running `targetdebugmy_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: `targetdebugmy_bevy_game.exe` (exit code: 1)
PS C:DevelopmentGameDevmy_bevy_game>

我从书中编写的Rust代码(请注意,这也发生在大量repo未触碰的示例代码中):

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();
}

您可以从输出中看到,我试图从书中运行my_bevy_game示例,但是wgpu的这个完全相同的问题发生在我迄今为止运行的所有示例上。你要怎么做才能跟贝弗合作?

—edit—

看来这是一个dx12问题,WGPU需要解决。Bevy问题中提出的解决方案不适用于我和其他人的机器。看来贝弗"坏了"。不可挽回的暂时,由于依赖于WGPU。

这看起来像是一个bug,请参阅问题#4461 of bevy, bug位于wgpu:

你可以尝试临时使用最新的wgpu版本:

[patch.crates-io]
wgpu = { git = "https://github.com/gfx-rs/wgpu" }
# or
wgpu = { git = "https://github.com/gfx-rs/wgpu" , rev = "3d10678a91b78557b0dea537407eb4a4ff754872" }

最新更新