-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Bevy version 89e19aa
The many_cubes example with cargo run --example many_cubes --release -- --vary-material-data-per-instance hangs indefinitely (Update: Tried just letting this run and after a little over 2 minutes the example started working).
This regression also affects modifying materials at run time. See example: #15893 (comment)
Windows 10 / RTX3060 / Vulkan
The issue was introduced at 7b81ae7 with Update WGPU to version 22
Apple M1 / Metal: Hangs for 4 minutes
Win10 / GTX1060 / Vulkan / i7 6700k: Hangs for 12 minutes
Win10 / RTX3060 / Vulkan / 7950x: Hangs for 2 minutes
Win10 / RTX3060 / Dx12 / 7950x: Crashes (Note Dx12 also crashes in 0.14)
2024-10-14T19:44:43.028155Z ERROR wgpu_hal::dx12::descriptor: Unable to allocate descriptors: RangeAllocationError { fragmented_free_length: 1 }
2024-10-14T19:44:43.028302Z ERROR wgpu::backend::wgpu_core: Handling wgpu errors as fatal by default
thread 'main' panicked at \.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.20.1\src\backend\wgpu_core.rs:2996:5:
wgpu error: Validation Error
Caused by:
In Device::create_bind_group
note: label = `StandardMaterial`
Not enough memory left.
Minimal-ish 3d example:
use bevy::{diagnostic::*, prelude::*};
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
FrameTimeDiagnosticsPlugin,
LogDiagnosticsPlugin::default(),
))
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
let mesh = Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0)));
for i in 0..50000 {
commands.spawn((
mesh.clone(),
MeshMaterial3d(materials.add(Color::WHITE)),
Transform::from_xyz(4.0, 0.0, -i as f32 * 2.0),
));
}
commands.spawn(Camera3d::default());
}- In the 3d example 50k hangs for about 30s on 3060/Vulkan and crashes on DX12 with --release (worse without release)
Minimal-ish 2d example:
use bevy::{diagnostic::*, prelude::*};
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
FrameTimeDiagnosticsPlugin,
LogDiagnosticsPlugin::default(),
))
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
let mesh = Mesh2d(meshes.add(Rectangle::default()));
for i in 0..200000 {
commands.spawn((
mesh.clone(),
MeshMaterial2d(materials.add(Color::WHITE)),
Transform::from_xyz(i as f32, 0.0, 0.0),
));
}
commands.spawn(Camera2d);
}- 200k on Apple M1 hangs for about 70s
- 200k on 3060/Vulkan hangs for about 20s and crashes on Dx12
- Dx12 crash seems to happen with only 3k, but works with 2k (Note Dx12 also crashes in 0.14)
- (all with --release, worse without release)
Here's vtune filtered in on just the portion of time where it's hanging on the minimal 3d example:

https://github.com/gfx-rs/wgpu/blob/c746c90ac0f34e19d975668e022b5e8c367201c3/wgpu-core/src/device/resource.rs#L2299

vtune tested using release with debug symbols: --profile release-with-debug
[profile.release-with-debug]
inherits = "release"
debug = true