Skip to content

Implement generic pipeline caching in WgpuExecutor#4210

Open
timon-schelling wants to merge 14 commits into
masterfrom
gp-wgpu-pipeline-cache
Open

Implement generic pipeline caching in WgpuExecutor#4210
timon-schelling wants to merge 14 commits into
masterfrom
gp-wgpu-pipeline-cache

Conversation

@timon-schelling

Copy link
Copy Markdown
Member

changing shader nodes to work with this will be done in a followup PR, for now they keep the separate ShaderRuntime.

@timon-schelling timon-schelling marked this pull request as ready for review June 7, 2026 23:33

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the WGPU pipeline execution model by introducing a dynamic, generic Pipeline trait system. Hardcoded compositor and resampler fields in WgpuExecutor are replaced with a thread-safe pipelines map that caches and runs pipelines dynamically. Additionally, the render_background and pixel_preview (renamed to render_pixel_preview) nodes have been refactored to use this new system. Feedback on these changes suggests adding an early return in render_background when viewport_zoom <= 0.0 to prevent uninitialized texture returns, simplifying the Pipeline trait using impl Future to avoid boxed future allocations, releasing the RwLockReadGuard earlier during pipeline retrieval, and cleaning up a verbose type signature in BackgroundCompositor::run.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread node-graph/nodes/gstd/src/render_background.rs Outdated
Comment on lines +8 to +37
pub trait Pipeline: std::any::Any + Send + Sync + Sized {
type Args<'a>;
type Out: Send;

fn create(context: &WgpuContext) -> Self;

fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> PipelineFuture<'a, Self::Out>;
}

pub trait AsyncPipeline: std::any::Any + Send + Sync + Sized {
type Args<'a>;
type Out: Send;

fn create(context: &WgpuContext) -> Self;

fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> impl Future<Output = Self::Out> + Send + 'a;
}

impl<P: AsyncPipeline> Pipeline for P {
type Args<'a> = <P as AsyncPipeline>::Args<'a>;
type Out = <P as AsyncPipeline>::Out;

fn create(context: &WgpuContext) -> Self {
<P as AsyncPipeline>::create(context)
}

fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> PipelineFuture<'a, Self::Out> {
Box::pin(<P as AsyncPipeline>::run(self, executor, args))
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since WgpuExecutor::run_pipeline always downcasts to the concrete pipeline type P, there is no need for a trait object or boxed futures. We can leverage Rust's support for impl Future in traits to define a single Pipeline trait without any boxing, eliminating the Box::pin allocation on every pipeline execution.

Suggested change
pub trait Pipeline: std::any::Any + Send + Sync + Sized {
type Args<'a>;
type Out: Send;
fn create(context: &WgpuContext) -> Self;
fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> PipelineFuture<'a, Self::Out>;
}
pub trait AsyncPipeline: std::any::Any + Send + Sync + Sized {
type Args<'a>;
type Out: Send;
fn create(context: &WgpuContext) -> Self;
fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> impl Future<Output = Self::Out> + Send + 'a;
}
impl<P: AsyncPipeline> Pipeline for P {
type Args<'a> = <P as AsyncPipeline>::Args<'a>;
type Out = <P as AsyncPipeline>::Out;
fn create(context: &WgpuContext) -> Self {
<P as AsyncPipeline>::create(context)
}
fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> PipelineFuture<'a, Self::Out> {
Box::pin(<P as AsyncPipeline>::run(self, executor, args))
}
}
pub trait Pipeline: std::any::Any + Send + Sync + Sized {
type Args<'a>;
type Out: Send;
fn create(context: &WgpuContext) -> Self;
fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> impl Future<Output = Self::Out> + Send + 'a;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

error: lifetime bound not satisfied
  --> node-graph/nodes/gstd/src/render_background.rs:17:1
   |
17 | #[node_macro::node(category(""))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)
   = note: this error originates in the attribute macro `node_macro::node` (in Nightly builds, run with -Z macro-backtrace for more info)

error: lifetime bound not satisfied
  --> node-graph/nodes/gstd/src/render_pixel_preview.rs:13:1
   |
13 | #[node_macro::node(category(""))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)
   = note: this error originates in the attribute macro `node_macro::node` (in Nightly builds, run with -Z macro-backtrace for more info)

Comment thread node-graph/libraries/wgpu-executor/src/lib.rs Outdated
Comment thread node-graph/nodes/gstd/src/render_background.rs Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 issues found across 15 files

Confidence score: 2/5

  • There is a concrete user-facing regression risk in node-graph/nodes/gstd/src/render_background.rs: the zoom <= 0 early return can skip compositing/copying and produce a blank render output.
  • Several high-confidence panic paths were introduced (unwrap/expect and unwrapped application_io) across node-graph/nodes/gstd/src/render_background.rs and node-graph/libraries/wgpu-executor/src/lib.rs, which can crash runtime/executor flows instead of failing gracefully.
  • Additional executor-path concerns in node-graph/libraries/wgpu-executor/src/pipeline.rs and node-graph/libraries/wgpu-executor/src/lib.rs (per-call boxing in a hot path, eager duplicate pipeline creation, and longer-than-needed lock scope) increase performance/concurrency risk but are secondary to correctness issues.
  • Pay close attention to node-graph/nodes/gstd/src/render_background.rs, node-graph/libraries/wgpu-executor/src/lib.rs, node-graph/libraries/wgpu-executor/src/pipeline.rs - potential blank output, panic-on-error behavior, and executor hot-path regressions.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread node-graph/nodes/gstd/src/render_background.rs
Comment thread node-graph/libraries/wgpu-executor/src/lib.rs Outdated
Comment thread node-graph/libraries/wgpu-executor/src/lib.rs Outdated
Comment thread node-graph/libraries/wgpu-executor/src/pipeline.rs
Comment thread node-graph/nodes/gstd/src/render_background.rs Outdated
Comment thread node-graph/nodes/gstd/src/render_background.rs
Comment thread node-graph/libraries/wgpu-executor/src/lib.rs Outdated
@timon-schelling timon-schelling changed the title Implement generic pipeline caching for WgpuExecutor Implement generic pipeline caching in WgpuExecutor Jun 8, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread node-graph/libraries/wgpu-executor/src/lib.rs Outdated
YohYamasaki and others added 14 commits June 11, 2026 19:50
…ributes with graphic List<T> types (#4111)

* Add conversion from Fill to Table<Graphic>

* Refactor Vector vello renderer for Gradient / Color

# Conflicts:
#	node-graph/libraries/rendering/src/renderer.rs

* Refactor Vector SVG renderer for Gradient / Color

* Fix conflicts

* Add basic clipping-based fill for SVG rendering

* Use Cow to avoid cloning graphic list for fill

* Cleanup for Cow usage

* format code

* Use `<pattern>` instead of `<clipPath>` for clip

This simplifies the future implementation of clipping-based rendering
for strokes, as the stroke does not support the use of a clip path but
rather paint sources from a paint server.

* Move svg pattern rendering function to RenderExt

* Fix comment

* Fix empty fill list rendering as default black

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* Move opaque check function to Graphic impl

* Add color converter and debug node to use graphic

* WIP: Use List<Graphic> to render Color & Gradient

* Use `Arc<List<Vector>>` for vector_data metadata

This exposes List's attributes to message handlers, enabling them to
access the necessary attribute data such as ATTR_STROKE_PAINT_GRAPHIC
as `Fill` and `Stroke` will not have paint information in the future.

* Recurse opacity checks on nested `Graphic`

Also extracts `fill_graphic_list_at` /
`stroke_paint_graphic_list_at` to share the row-attribute
lookup across the existing call sites.

* Fix fill and stroke visibility check degradation

* Fix clipping based stroke paint positioning

* Refactor vello renderer for stroke to use graphic

* Reduce `Fill` / `Stroke.color` to `List<Graphic>` allocations

* Revert "Use `Arc<List<Vector>>` for vector_data metadata"

This reverts commit 4285243

* Expose paint row attributes as dedicated metadata for vectors

Add `fill_attributes` / `stroke_paint_attributes` to `DocumentMetadata`
so the `ExpandFillStrokeOnSelectedLayers` handler can read row paint
visibility without exposing entire `List<Vector>`.

* Fix transparency check to consider fill opacity

* Fix consistency of gradient placement for SVG stroke

* Rename `stroke_paint_..` to `stroke_..`

* Remove debug nodes

* Allow to use any graphic type without casting

* Rename `fill_graphic` / `stroke_graphic` to `fill` / `stroke`

* Fix SVG pattern placement when stroke transform differs from item transform

* Fix click target fill check for empty list in graphic

* Fix blank fill/stroke attribute masking legacy style

* Fix SVG's paint order trick for vector/raster fills

* Add zero-division guard for pattern wraparound prevention

* Code review

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
@timon-schelling timon-schelling force-pushed the gp-wgpu-pipeline-cache branch from a3efae0 to 181408e Compare June 13, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants