Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in write_indirect_parameters_buffer on start of application #13175

Open
arcashka opened this issue May 2, 2024 · 1 comment
Open

Crash in write_indirect_parameters_buffer on start of application #13175

arcashka opened this issue May 2, 2024 · 1 comment
Assignees
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@arcashka
Copy link
Contributor

arcashka commented May 2, 2024

Bevy version

16531fb
regression after #12889

AdapterInfo

`AdapterInfo { name: "Intel(R) Graphics (ADL GT2)", vendor: 32902, device: 17958, device_type: IntegratedGpu, driver: "Intel open-source Mesa driver", driver_info: "Mesa 23.2.1-1ubuntu3.1", backend: 
Vulkan }`

Minimal example

[package]
name = "issue2"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { path = "../bevy", default-features = false, features = [
    "bevy_core_pipeline",
    "x11",
] }
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());
}

What went wrong

❯ cargo run
   Compiling issue2 v0.1.0 (/home/arcashka/Documents/projects/other/issue2)
    Finished dev [unoptimized + debuginfo] target(s) in 5.83s
     Running `target/debug/issue2`
2024-05-02T09:16:43.445626Z  INFO bevy_winit::system: Creating new window "App" (Entity { index: 0, generation: 1 })
2024-05-02T09:16:43.446019Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1    
2024-05-02T09:16:43.519581Z  INFO bevy_render::renderer: AdapterInfo { name: "Intel(R) Graphics (ADL GT2)", vendor: 32902, device: 17958, device_type: IntegratedGpu, driver: "Intel open-source Mesa driver", driver_info: "Mesa 23.2.1-1ubuntu3.1", backend: 
Vulkan }
thread 'main' panicked at /home/arcashka/Documents/projects/other/bevy/crates/bevy_ecs/src/system/system_param.rs:576:17:
Resource requested by bevy_render::batching::gpu_preprocessing::write_indirect_parameters_buffer does not exist: bevy_render::batching::gpu_preprocessing::IndirectParametersBuffer
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::batching::gpu_preprocessing::write_indirect_parameters_buffer`!

Additional information

I can fix it locally with

diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs
index fa3cbdee0..5708cf829 100644
--- a/crates/bevy_pbr/src/render/mesh.rs
+++ b/crates/bevy_pbr/src/render/mesh.rs
@@ -217,8 +217,6 @@ impl Plugin for MeshRenderPlugin {
                     );
             };
 
-            let indirect_parameters_buffer = IndirectParametersBuffer::new();
-
             let render_device = render_app.world().resource::<RenderDevice>();
             if let Some(per_object_buffer_batch_size) =
                 GpuArrayBuffer::<MeshUniform>::batch_size(render_device)
@@ -230,7 +228,6 @@ impl Plugin for MeshRenderPlugin {
             }
 
             render_app
-                .insert_resource(indirect_parameters_buffer)
                 .init_resource::<MeshPipeline>();
         }
 

diff --git a/crates/bevy_render/src/batching/gpu_preprocessing.rs b/crates/bevy_render/src/batching/gpu_preprocessing.rs
index bcbcf8b97..c4b2edf29 100644
--- a/crates/bevy_render/src/batching/gpu_preprocessing.rs
+++ b/crates/bevy_render/src/batching/gpu_preprocessing.rs
@@ -48,7 +48,8 @@ impl Plugin for BatchingPlugin {
             return;
         };
 
-        render_app.init_resource::<GpuPreprocessingSupport>();
+        render_app.init_resource::<GpuPreprocessingSupport>()
+                  .init_resource::<IndirectParametersBuffer>();
     }
 }

But I'm not sure if that's correct and if it's not gonna break something else.

@arcashka arcashka added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels May 2, 2024
@pcwalton pcwalton self-assigned this May 3, 2024
@JMS55 JMS55 added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels May 3, 2024
@notmd
Copy link
Contributor

notmd commented May 13, 2024

I'm hitting this as well. This should be fixed before 0.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

4 participants