Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

A still no longer prints 54 CommandQueue warnings: the last frame's extract commands are applied before the engine goes (#89 item 7)

shinyobjectz76a4ef7885b8
diff --git a/engine/render/src/engine.rs b/engine/render/src/engine.rs
index c107bf50..8f7f6706 100644
--- a/engine/render/src/engine.rs
+++ b/engine/render/src/engine.rs
@@ -135,6 +135,12 @@ pub struct Engine {
kept: BTreeMap<(String, String), BTreeMap<String, V>>,
}
+/// The last frame's extract commands applied before the app goes: Bevy applies them in the next frame's render schedule, so
+/// on a still each extract system was dropped with its queue unapplied and warned (54 "CommandQueue" lines, #89 item 7)
+impl Drop for Engine {
+ fn drop(&mut self) { self.app.get_sub_app_mut(bevy::render::RenderApp).map(|sub| sub.world_mut().try_schedule_scope(bevy::render::ExtractSchedule, |w, s| s.apply_deferred(w))); }
+}
+
/// RAEA_MEM_MARKS: one line on stderr per start-up phase, "mem_mark <ms since the first mark> <phys_footprint MB>
/// <phase>", to line up with a memory timeline (the footprint is the process's, as the OS counts it).
pub fn mem_mark(what: &str) {
diff --git a/engine/render/src/engine/target.rs b/engine/render/src/engine/target.rs
index 07bc9b7e..f2b8313f 100644
--- a/engine/render/src/engine/target.rs
+++ b/engine/render/src/engine/target.rs
@@ -6,18 +6,11 @@ use super::*;
/// Bevy's render diagnostics (each pass's elapsed time, `render/...`), into the run's trace once a second.
#[cfg(feature = "native")]
pub(crate) fn forward_render_diagnostics(store: Res<bevy::diagnostic::DiagnosticsStore>, mut last: Local<Option<std::time::Instant>>) {
- if last.is_some_and(|t| t.elapsed().as_secs_f64() < 1.0) {
- return;
- }
+ if last.is_some_and(|t| t.elapsed().as_secs_f64() < 1.0) { return; }
*last = Some(std::time::Instant::now());
- let passes: serde_json::Map<String, serde_json::Value> = store
- .iter()
- .filter(|d| d.path().as_str().starts_with("render/"))
- .filter_map(|d| d.smoothed().map(|v| (d.path().as_str().trim_start_matches("render/").to_string(), serde_json::json!((v * 1000.0).round() / 1000.0))))
- .collect();
- if !passes.is_empty() {
- raea_io_trace::event("bevy_passes", serde_json::json!({"ms": passes}));
- }
+ let passes: serde_json::Map<String, serde_json::Value> = store.iter().filter(|d| d.path().as_str().starts_with("render/"))
+ .filter_map(|d| d.smoothed().map(|v| (d.path().as_str().trim_start_matches("render/").to_string(), serde_json::json!((v * 1000.0).round() / 1000.0)))).collect();
+ if !passes.is_empty() { raea_io_trace::event("bevy_passes", serde_json::json!({"ms": passes})); }
}
/// The Engine's target: the frame, and its tag row under it.