mbrea-c / bevy_firework

🎆 CPU-driven, batch-rendered particle system for the Bevy game engine.
Apache License 2.0
38 stars 6 forks source link

Fix crash when Msaa is off #13

Closed mbrea-c closed 8 months ago

mbrea-c commented 8 months ago

The current rendering code was assuming that Msaa was always on due to an oversight. This PR will determines whether to bind a texture with multisampling enabled based on the actual msaa configuration.

Fixes the second crash mentioned in #11, and works around the first in the example code.

rparrett commented 8 months ago

Seems to fix the issue on my end.

I would probably do something like

diff --git a/examples/pbr.rs b/examples/pbr.rs
index 159e631..91d3353 100644
--- a/examples/pbr.rs
+++ b/examples/pbr.rs
@@ -11,8 +11,13 @@ use bevy_utilitarian::prelude::*;

 fn main() {
     let mut app = App::new();
-    app.add_plugins(DefaultPlugins)
-        .add_plugins(ParticleSystemPlugin)
+    app.add_plugins(DefaultPlugins);
+
+    // Msaa must be disabled on the web. See issue#whatever
+    #[cfg(target_arch = "wasm32")]
+    app.insert_resource(Msaa::Off);
+
+    app.add_plugins(ParticleSystemPlugin)
         .add_systems(Startup, setup)
         .add_systems(Update, adjust_time_scale);

rather than duplicate the pbr example, personally, especially as this workaround is currently needed in the non-pbr examples too.

mbrea-c commented 8 months ago

rather than duplicate the pbr example, personally, especially as this workaround is currently needed in the non-pbr examples too.

Yeah, good point. I wanted to test that the plugin does not crash with either Msaa setting, but I should just do it the proper way and set up some integration tests