ITADN

Jump flooding scales poorly with entity count

#54ClosedThe0x539 创建于 2025-04-22
T
The0x539commented
I'm working on a program that needs to apply outlines to sometimes-large clusters of entities. I tried to switch to jump flooding, hoping for a performance boost from doing less per-entity/per-mesh work. However, for relatively modest entity counts, I already noticed severe performance degradation, and past a couple hundred, my program just crashes immediately: ``` 2025-04-22T17:26:12.823170Z ERROR wgpu::backend::wgpu_core: Handling wgpu errors as fatal by default thread '<unnamed>' panicked at C:\Users\The0x539\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-23.0.1\src\backend\wgpu_core.rs:2075:22: wgpu error: Validation Error Caused by: In Queue::submit Not enough memory left. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Encountered a panic in system `bevy_render::renderer::render_system`! thread 'main' panicked at C:\Users\The0x539\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-hal-23.0.1\src\vulkan\instance.rs:173:58: Trying to destroy a SurfaceSemaphores that is still in use by a SurfaceTexture ``` I looked at the backtrace but I couldn't find anything I could make sense of, as the panic happens while Bevy is in control of execution, not in this crate. I believe this to be a bug because I don't see what aspect of jump flood would lead to this scaling behavior. MRE: ```rs use bevy::{ prelude::*, render::{ RenderPlugin, settings::{Backends, RenderCreation, WgpuSettings}, }, }; use bevy_mod_outline::{InheritOutline, OutlineMode, OutlineVolume}; fn main() { App::new() .add_plugins(DefaultPlugins.set(RenderPlugin { render_creation: RenderCreation::Automatic(WgpuSettings { backends: Some(Backends::VULKAN), ..default() }), ..default() })) .add_plugins(bevy_mod_outline::OutlinePlugin) .add_systems(Startup, setup) .run(); } fn setup( mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>, ) { commands.spawn(( Camera3d::default(), Transform::from_xyz(-1.0, 2.0, -5.0).looking_at(Vec3::ZERO, Vec3::Y), )); let root = ( Transform::IDENTITY, OutlineVolume { visible: true, width: 2.0, colour: Color::srgb(1.0, 0.0, 0.0), }, OutlineMode::FloodFlat, InheritedVisibility::VISIBLE, ); let cube = ( Mesh3d(meshes.add(Cuboid::from_length(1.0))), MeshMaterial3d(materials.add(Color::WHITE)), ); commands.spawn(root).with_children(|p| { let n = 21; for x in 0..n { for z in 0..n { let transform = Transform::from_xyz(2.0 * x as f32, 0.0, 2.0 * z as f32); p.spawn((cube.clone(), transform, InheritOutline)); } } }); } ```
关闭于 2025-05-06 9 条评论