Skip to content

tracking: AA rasterization improvements roadmap #126

@kolkov

Description

@kolkov

Summary

Tracking issue for AA (Anti-Aliasing) rasterization improvements in gg. Created after deep investigation of #95 and comprehensive AA architecture audit.

Current State (v0.31.0)

Production CPU path works correctly after two bug fixes (#95):

  • AdvanceX() drift removed — edges no longer expand toward bottom of shapes
  • coverageToRuns() maxValue bug fixed — vertex pixels get correct partial coverage
  • 4 regression tests added

Vello 9-stage GPU compute pipeline (v0.30.0–v0.31.0):

  • CPU reference implementation in internal/gpu/tilecompute/
  • 9 WGSL shaders written and dispatched via GPU compute
  • Fixed: fine.wgsl y_edge sign, coarse.wgsl Z-order
  • Full demo scene (6 paths, transparency, EvenOdd) — 0% pixel diff GPU=CPU
  • v0.31.0: Tier 5 scene accumulation wired into rendering cascade (GG-COMPUTE-008)
  • v0.31.0: PipelineMode wiring — Context.SetPipelineMode() propagates to GPU accelerator (GG-COMPUTE-006)
  • v0.31.0: Removed 2 naga WGSL workarounds from path_tiling.wgsl (see tracking: remaining naga SPIR-V workarounds in compute shaders #139 for remaining 3)

Remaining pixel-level differences vs fogleman/gg (max 7-8/255) are inherent algorithmic differences, not bugs — confirmed by mathematical proof (trapezoidal area vs 4x4 supersampling).

Architecture (5 rendering systems)

System Status Description
AnalyticFiller (Vello) + EdgeBuilder (tiny-skia) Production Scanline AA with trapezoidal coverage, FDot16 fixed-point
CPU SDF Production Smoothstep SDF for circles/rects/rrects
GPU 5-Tier Pipeline Production SDF + convex + stencil-then-cover + MSDF text + Vello compute
TileRasterizer (Vello 16×16) Validation CPU reference for GPU compute golden tests
GPU Compute Pipeline (9-stage) Production (v0.31.0) 9 WGSL shaders, VelloAccelerator dispatches via hal.Queue

Current rendering cascade (automatic per-draw fallback via ErrFallbackToCPU):

GPU 5-Tier → CPU SDF → AnalyticFiller

Improvement Tasks

Quality (v0.32.0+):

  • GG-AA-018: Native curve evaluation — eliminate Bezier flattening for CPU path (P1)
  • GG-AA-020: Float32 pipeline — remove FDot16 quantization noise (P2)
  • GG-AA-019: Configurable AA quality — hint-based API (P3)

Integration (completed):

  • GG-AA-016: TileRasterizer validation — CPU reference + golden test suite for GPU compute ✅ v0.30.0
  • GG-AA-017: GPU Compute Pipeline — 9 WGSL shaders written, CPU reference complete ✅ v0.30.0
  • GG-COMPUTE-008: Tier 5 scene accumulation — VelloAccelerator accumulates paths during FillPath/StrokePath, dispatches via compute on Flush ✅ v0.31.0
  • GG-COMPUTE-006: PipelineMode wiring — Context.SetPipelineMode() propagates to GPU accelerator, SDFAccelerator routes to compute when active ✅ v0.31.0

Shader cleanup:

Testing:

  • GG-AA-015: Visual AA comparison test suite — automated quality metrics (P2)

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions