Skip to content

feat: Vello PTCL per-draw blend modes (CmdSetBlend) #440

Description

@kolkov

Vello Compute Pipeline: Per-Draw Blend Modes (CmdSetBlend)

Depends on: #439 (per-operation blend in SoftwareRenderer)

Currently, the Vello 9-stage compute pipeline (internal/gpu/tilecompute/) only supports blend modes at layer boundaries (BeginClip/EndClip). Individual fill/stroke commands are hardcoded to SrcOver. After #439 enables per-operation blend in the CPU rasterizer, the Vello compute path becomes the remaining gap.

Architecture

A new PTCL command CmdSetBlend (tag=14) will set the blend mode for subsequent color/gradient/image application commands:

CmdFill(...)        → coverage (unchanged)
CmdSetBlend(blend)  → set blend mode for next apply
CmdColor(rgba)      → apply with current blend

Zero overhead for SrcOverCmdSetBlend is not emitted for default SrcOver draws.

Pipeline Changes (4 stages)

Stage Change
Scene encoding New DrawTagColorBlend (scene_size=2: color + blend)
Stage 4 (draw_leaf) Handle new tag
Stage 7 (coarse) Read blend, emit CmdSetBlend
Stage 9 (fine) currentBlend state + blendMixCompose() dispatch

Research

Deep analysis of Rust Vello architecture complete. Key findings:

Conflation Artifacts (Known Trade-off)

Per-draw blend without layer isolation produces incorrect results for overlapping geometry with non-SrcOver modes (blend applied twice to overlap). Same limitation as Skia Graphite. For correct results: use PushLayer/PopLayer. Documented trade-off.

Phases

  1. CPU path (fine.go + coarse.go + ptcl.go) — after fix: SetBlendMode() is a no-op — per-operation blend modes not wired #439
  2. GPU shaders (coarse.wgsl + fine.wgsl)
  3. Context integration (auto-dispatch)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions