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.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
A GPU error is the render's error (#66): raea's engine answers Bevy's render errors itself (gpu_error), putting the first one, with what the GPU said, where a frame's other errors go, so raea render refuses with it. Bevy's own handler asks the app to quit, which an engine that steps its app never reads: the frame came back half drawn and was saved with APPLIED and exit 0 (on DX12 the blocks example drew its floor and one box; on an AMD iGPU's Vulkan, OutOfMemory left the background only). Drawing stops as before; it's said once, since Bevy asks again every update and a live game prints each one. A unit test gives it an FXC error twice
shinyobjectzaa0a416b7363
diff --git a/engine/render/src/engine/open.rs b/engine/render/src/engine/open.rsindex 0b2d52eb..f5548015 100644--- a/engine/render/src/engine/open.rs+++ b/engine/render/src/engine/open.rs@@ -71,7 +71,8 @@ impl Engine {.init_resource::<Error>().init_resource::<Gen>().init_resource::<PreStep>()- .init_resource::<Stages>();+ .init_resource::<Stages>()+ .insert_resource(bevy::render::error_handler::RenderErrorHandler(raea_sys_frame::gpu::gpu_error));// the frame in named sets (FrameSystems), in this order#[cfg(feature = "native")]{@@ -273,3 +274,4 @@ impl Engine {Ok(e)}}+diff --git a/systems/frame/src/gpu.rs b/systems/frame/src/gpu.rsnew file mode 100644index 00000000..4a96bef1--- /dev/null+++ b/systems/frame/src/gpu.rs@@ -0,0 +1,44 @@+//! A GPU error (a shader the driver's compiler refuses, memory it hasn't got) is the frame's error, said with what the+//! GPU said: Bevy's own handler asks the app to quit, which no one reads in an engine that steps its app itself, so the+//! frame was read back half drawn and saved as if all was well (#66: DX12's FXC refusing a shader). The engine installs+//! this as Bevy's RenderErrorHandler. Drawing stops either way. Bevy asks again every update while drawing is stopped:+//! only the first is said (a live game's caller prints each one it takes).++use bevy::prelude::*;+use bevy::render::error_handler::{RenderError, RenderErrorPolicy};++use crate::Error;++pub fn gpu_error(e: &RenderError, main: &mut World, _: &mut World) -> RenderErrorPolicy {+ if main.get_resource::<GpuStopped>().is_none() {+ main.insert_resource(GpuStopped);+ let said: Vec<&str> = e.description.lines().map(str::trim).filter(|l| !l.is_empty()).take(4).collect();+ if let Some(mut error) = main.get_resource_mut::<Error>() {+ error.0 = Some(format!("the GPU stopped the render ({:?} error): {}", e.ty, said.join(" ")));+ }+ }+ RenderErrorPolicy::StopRendering+}++/// The GPU stopped drawing: said once+#[derive(Resource)]+struct GpuStopped;++#[cfg(test)]+mod tests {+ use super::*;+ use bevy::render::error_handler::ErrorType;++ #[test]+ fn a_gpu_error_is_the_frames_error_said_once() {+ let (mut main, mut render) = (World::new(), World::new());+ main.init_resource::<Error>();+ let fxc = RenderError { ty: ErrorType::Validation, description: "Validation Error\n\nCaused by:\n In Device::create_render_pipeline, label = 'ink_outline'\n error X3511: unable to unroll loop\n more".into(), source: None };+ assert!(matches!(gpu_error(&fxc, &mut main, &mut render), RenderErrorPolicy::StopRendering));+ let said = main.resource_mut::<Error>().0.take().expect("the frame's error");+ assert_eq!(said, "the GPU stopped the render (Validation error): Validation Error Caused by: In Device::create_render_pipeline, label = 'ink_outline' error X3511: unable to unroll loop");+ // asked again on the next update: drawing stays stopped, nothing said again+ assert!(matches!(gpu_error(&fxc, &mut main, &mut render), RenderErrorPolicy::StopRendering));+ assert!(main.resource::<Error>().0.is_none());+ }+}diff --git a/systems/frame/src/lib.rs b/systems/frame/src/lib.rsindex 25a17a8b..10979e39 100644--- a/systems/frame/src/lib.rs+++ b/systems/frame/src/lib.rs@@ -12,6 +12,8 @@ use raea_core_program::ir::{Program, V};pub mod bevy_api;/// a camera row's order, clear and viewport among the cameras on its targetpub mod camera;+/// a GPU error as the frame's error (#66), Bevy's RenderErrorHandler in the engine+pub mod gpu;/// layer keys (docs/review.feature R2)pub mod layer;/// the part under a point of the frame (docs/preview.feature PV1a)