Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(rendering): keep the blur result cache to render hosts
Richie McIlroyc01767878dc9
diff --git a/crates/render-farm/src/main.rs b/crates/render-farm/src/main.rsindex aeb9effed..82ea72462 100644--- a/crates/render-farm/src/main.rs+++ b/crates/render-farm/src/main.rs@@ -124,6 +124,7 @@ async fn handle(op: Op) -> Result<Value> {}fn main() -> Result<()> {+ cap_rendering::enable_blur_result_cache();tracing_subscriber::fmt().with_writer(std::io::stderr).with_env_filter(diff --git a/crates/rendering/src/frame_pipeline.rs b/crates/rendering/src/frame_pipeline.rsindex 9785cf86c..b888ef8f0 100644--- a/crates/rendering/src/frame_pipeline.rs+++ b/crates/rendering/src/frame_pipeline.rs@@ -1836,6 +1836,19 @@ pub struct RenderSession {texture_height: u32,}+/// The blur result cache copies into session textures, so only render hosts+/// that enable it need them to be copy destinations.+fn session_texture_usage() -> wgpu::TextureUsages {+ let usage = wgpu::TextureUsages::TEXTURE_BINDING+ | wgpu::TextureUsages::RENDER_ATTACHMENT+ | wgpu::TextureUsages::COPY_SRC;+ if crate::blur_result_cache_enabled() {+ usage | wgpu::TextureUsages::COPY_DST+ } else {+ usage+ }+}+impl RenderSession {pub fn new(device: &wgpu::Device, width: u32, height: u32) -> Self {let phase = crate::readiness::Phase::start("frame.session");@@ -1850,10 +1863,7 @@ impl RenderSession {sample_count: 1,dimension: wgpu::TextureDimension::D2,format: wgpu::TextureFormat::Rgba8Unorm,- usage: wgpu::TextureUsages::TEXTURE_BINDING- | wgpu::TextureUsages::RENDER_ATTACHMENT- | wgpu::TextureUsages::COPY_SRC- | wgpu::TextureUsages::COPY_DST,+ usage: session_texture_usage(),label: Some("Intermediate Texture"),view_formats: &[],})@@ -1900,10 +1910,7 @@ impl RenderSession {sample_count: 1,dimension: wgpu::TextureDimension::D2,format: wgpu::TextureFormat::Rgba8Unorm,- usage: wgpu::TextureUsages::TEXTURE_BINDING- | wgpu::TextureUsages::RENDER_ATTACHMENT- | wgpu::TextureUsages::COPY_SRC- | wgpu::TextureUsages::COPY_DST,+ usage: session_texture_usage(),label: Some("Intermediate Texture"),view_formats: &[],})diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rsindex 0a47bb46a..7e7771af8 100644--- a/crates/rendering/src/lib.rs+++ b/crates/rendering/src/lib.rs@@ -1111,6 +1111,19 @@ pub mod loop_stats {}}+/// A blurred static background is identical on every frame. Render hosts+/// reuse the first frame's result; editor and desktop exports keep blurring+/// every frame until this has been verified there.+static BLUR_RESULT_CACHE: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);++pub fn enable_blur_result_cache() {+ BLUR_RESULT_CACHE.store(true, std::sync::atomic::Ordering::Relaxed);+}++fn blur_result_cache_enabled() -> bool {+ BLUR_RESULT_CACHE.load(std::sync::atomic::Ordering::Relaxed)+}+/// Layer pipelines take ~0.25-0.5 s to build per render. A process that/// renders many ranges of the same project (a render-farm engine) can set a/// key naming that project; successful renders then hand their layers to the@@ -7546,7 +7559,7 @@ impl RendererLayers {self.camera_only.copy_to_texture(encoder);self.background.render_surface(encoder);- let blur_key = (self.background_blur.blur_amount > 0.0)+ let blur_key = (blur_result_cache_enabled() && self.background_blur.blur_amount > 0.0).then(|| self.background.static_generation()).flatten().map(|background_generation| {