Bevy 测试用例
在笔记本环境下,默认启动intel的集成显卡,cargo run 执行bevy的测试例子,会发现窗口图形无法正常启动,报错信息如下:
thread 'main' panicked at /home/chen/.cargo/registry/src/mirrors.ustc.edu.cn-4affec411d11e50f/wgpu-0.17.2/src/backend/direct.rs:771:18:
Error in Surface::configure: Validation Error
Caused by:
Not enough memory left
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::view::window::prepare_windows`!
thread 'Compute Task Pool (3)' panicked at /home/chen/.cargo/registry/src/mirrors.ustc.edu.cn-4affec411d11e50f/bevy_render-0.12.1/src/pipelined_rendering.rs:145:45:
called `Result::unwrap()` on an `Err` value: RecvError
原因是,wgpu默认使用了GPU卡,而笔记本上需要用optimus-manager设置高性能模式启动gpu卡
如果不希望用gpu卡,使用Intel集成显卡,需要设置代码配置wgpu,参考代码:
App.new()
.add_plugins((
DefaultPlugins.set(RenderPlugin {
render_creation: RenderCreation::Automatic(WgpuSettings {
power_preference: PowerPreference::LowPower,
..default()
}),
}),
HelloPlugin,
)).run();
可以正常启动示例。
RenderPlugin的结构体可能还会变更,需要参考最新的api调整代码
https://docs.rs/bevy/latest/bevy/render/struct.RenderPlugin.html
标签:Bevy,bevy,render,src,cargo,rs,集成显卡,设置 From: https://www.cnblogs.com/tmacy/p/17998568