Add Layer Compositing Cache architecture for improved performance#581
Add Layer Compositing Cache architecture for improved performance#581softmarshmallow merged 28 commits intomainfrom
Conversation
- Introduced a new section on Layer Compositing Cache, replacing the global tile-based raster caching strategy. - Detailed the advantages of layer-based compositing over tile-based caching, addressing issues like pixel bleeding and animation inefficiencies. - Provided a comprehensive architecture overview, including promotion heuristics and effect cacheability classification to optimize rendering performance. - Enhanced documentation with flowcharts and tables to clarify the caching process and decision-making for node promotion. These changes significantly improve the optimization techniques for high-performance rendering in design tools.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis PR replaces tile-based raster caching with a layer-based GPU compositing pipeline: it renames the runtime API from Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant Renderer as Renderer
participant SceneCache as SceneCache
participant Compositor as Compositor (LayerImageCache)
participant Atlas as AtlasSet
participant GPU as GPU Surface
App->>Renderer: frame(bounds, zoom, stable)
Renderer->>SceneCache: build/get EffectTree
SceneCache-->>Renderer: EffectNode list
Renderer->>Renderer: compute camera_change
alt zoom changed
Renderer->>Compositor: invalidate_all()
end
alt stable frame
Renderer->>Compositor: request promoted nodes
Compositor-->>Renderer: Vec<NodeId>
Renderer->>Renderer: build FramePlan(promoted)
else unstable frame
Renderer->>Renderer: FramePlan(empty promoted)
end
Renderer->>Renderer: draw(canvas, plan)
Renderer->>Compositor: update_compositor(parent_surface)
loop each promoted node
Compositor->>Atlas: get_image_and_src_rect(node_id)
alt atlas-backed
Atlas-->>Compositor: (image, src_rect)
Compositor->>GPU: blit image(src_rect)
else individual
Compositor-->>Compositor: use individual image
Compositor->>GPU: blit image
end
end
loop live (non-promoted) nodes
Renderer->>Renderer: process PainterRenderCommand
alt RenderSurface needed
Renderer->>GPU: draw offscreen surface and apply effects
else direct draw
Renderer->>GPU: draw commands
end
end
Renderer-->>App: return DrawResult (cache metrics, timings)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests (beta)
|
…nd related concepts - Introduced multiple new documents detailing the Chromium compositor architecture, including the roles of main, compositor, and worker threads. - Added a glossary of key terms and concepts related to the compositor and display compositor. - Documented the interaction and quality management strategies during user interactions, including tree priority and checkerboarding. - Provided insights into memory management and tile priority systems, emphasizing the soft/hard memory limits and eviction policies. - Explained the render surfaces mechanism for handling complex effects and compositing. - Detailed the tiling and rasterization processes, including tile sizes, rasterization modes, and the invalidation mechanism. These additions enhance the understanding of Chromium's rendering architecture, serving as a valuable reference for developers and researchers in the field.
…ives benchmark - Updated the rendering optimization strategies document to clarify performance targets and added new techniques for caching and rendering. - Introduced a new document detailing the Skia GPU primitives benchmark, including raw operation costs and key findings on texture handling and performance implications. - Provided insights into caching strategies for effect-heavy nodes and the impact of texture switching on performance. These updates improve the clarity and comprehensiveness of rendering optimization strategies, serving as a valuable resource for developers working on high-performance rendering.
- Introduced a new example for benchmarking Skia GPU primitives, measuring the performance of various rendering operations. - Added a benchmark fixture generator tool to create large scene files for stress-testing rendering and layout performance. - Implemented an extreme benchmark fixture generator for generating very large files (100K–1M+ nodes) to evaluate rendering and cache performance at scale. - Enhanced existing headless GPU example to include detailed benchmarking scenarios and improved output formatting. These additions provide valuable tools for developers to assess and optimize rendering performance in the Grida framework.
…solution scaling, and tiling - Introduced new documents covering Chromium's strategies for optimizing visual effects, including render surface avoidance, filter classification, and batching techniques. - Added a comprehensive analysis of resolution scaling during user interactions, detailing how Chromium manages rendering quality during pinch-zoom and scroll gestures. - Included an in-depth exploration of the tiling implementation, covering tile sizing, grid layout, rasterization, and memory management. These additions enhance the understanding of Chromium's rendering optimizations, serving as valuable resources for developers and researchers in the field.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/grida-canvas/Cargo.toml (1)
4-4:⚠️ Potential issue | 🟡 MinorUpdate edition to "2024" per coding guidelines.
The crate uses edition "2021", but the coding guidelines require Rust 2024 edition for crates in
crates/**/Cargo.toml.Proposed fix
-edition = "2021" +edition = "2024"As per coding guidelines: "Use Rust 2024 edition for crates".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/grida-canvas/Cargo.toml` at line 4, Update the crate's Cargo.toml edition setting from edition = "2021" to edition = "2024": locate the edition field (edition = "2021") in the Cargo.toml for the grida-canvas crate and change its value to "2024" so the crate uses the Rust 2024 edition per guidelines; ensure no other Cargo.toml files are inadvertently altered and run a quick build to verify compatibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@crates/grida-canvas/Cargo.toml`:
- Line 4: Update the crate's Cargo.toml edition setting from edition = "2021" to
edition = "2024": locate the edition field (edition = "2021") in the Cargo.toml
for the grida-canvas crate and change its value to "2024" so the crate uses the
Rust 2024 edition per guidelines; ensure no other Cargo.toml files are
inadvertently altered and run a quick build to verify compatibility.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0d5f9722-a3fe-40e8-94ff-3029f0231a06
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
crates/OPTIMIZATION_SIZE.mdcrates/grida-canvas/CHANGELOG.mdcrates/grida-canvas/Cargo.tomlcrates/grida-canvas/README.mdcrates/grida-canvas/src/io/io_figma.rscrates/grida-canvas/src/io/mod.rs
💤 Files with no reviewable changes (5)
- crates/grida-canvas/src/io/mod.rs
- crates/grida-canvas/CHANGELOG.md
- crates/grida-canvas/README.md
- crates/grida-canvas/src/io/io_figma.rs
- crates/OPTIMIZATION_SIZE.md
…mark - Removed the `bench_pan` benchmark to streamline performance testing. - Introduced a new comprehensive `bench_camera` benchmark that evaluates various camera operations including pan, zoom, and pinch-zoom. - Updated `Cargo.toml` to reflect the removal of the obsolete benchmark.
…s to .grida archives - Introduced a new `fig2grida` command-line interface for converting Figma `.fig` files into Grida `.grida` archives. - Added a programmatic API in `fig2grida-core.ts` for direct usage in TypeScript. - Updated README with usage instructions and examples for both CLI and API. - Implemented tests to ensure conversion functionality and validate output structure. - Enhanced package.json with a script to run the CLI tool.
…upport - Added an interactive window that opens by default, allowing users to drop various file types (.grida, .grida1, .svg, .png, .jpg, .jpeg, .webp) for scene loading. - Updated the `master` command to function as an alias for the interactive window. - Refactored scene loading to support multiple scenes from dropped files, improving the user experience. - Enhanced documentation to reflect new command usage and file drop capabilities.
… operations - Replaced `ZoomOnly` with distinct `ZoomIn` and `ZoomOut` variants in `CameraChangeKind` to better represent zoom actions. - Enhanced `LayerImage` struct to include `stale` entries, allowing for better cache management during zoom changes. - Updated cache invalidation logic to mark images as stale instead of invalidating all on zoom changes, improving performance. - Adjusted rendering logic to handle stale entries appropriately, ensuring they remain valid for GPU-stretched blitting until re-rasterized. - Modified tests to reflect changes in zoom handling and cache behavior, ensuring correctness in the new implementation.
- Introduced a new README.md to outline the purpose and structure of skills for AI coding agents. - Added a detailed SKILL.md for the `cg-perf` skill, providing guidelines for performance optimization on the Grida Canvas Rust engine. - Included instructions on when to use the skill, how to orient oneself, and the verification workflow for performance changes. - Documented the two benchmark systems and their usage to ensure effective performance measurement and optimization strategies.
These changes significantly improve the optimization techniques for high-performance rendering in design tools.
Summary by CodeRabbit
New Features
Chores
Breaking / Removals