diff --git a/doc/architecture.dot b/doc/architecture.dot new file mode 100644 index 00000000..3b542995 --- /dev/null +++ b/doc/architecture.dot @@ -0,0 +1,18 @@ +digraph G { + graph[rankdir=LR,fontname="Source Sans Pro"]; + node[shape=box,fontname="Source Sans Pro"]; + edge[arrowhead=vee]; + subgraph cluster_CPU { + Simplify -> Tile -> Cull -> Pack; + label="CPU"; + } + subgraph clusterGPU { + Fill -> Shade; + label="GPU"; + } + Pack -> Fill; + Paths[shape=none]; + Image[shape=none]; + Paths -> Simplify; + Shade -> Image; +} diff --git a/doc/architecture.md b/doc/architecture.md new file mode 100644 index 00000000..e47ea99b --- /dev/null +++ b/doc/architecture.md @@ -0,0 +1,74 @@ +# Pathfinder 3 Architecture + +## Rendering pipeline + +![](architecture.svg) + +Quoted timings are for the Ghostscript tiger at 1600×1600 pixels, 8-bit RGBA destination, 2017 +MacBook Pro, Intel Core i7-7920HQ CPU @ 3.10GHz, (quad-core with hyperthreading), Intel HD Graphics +630 1536 MB. + +### CPU + +#### Simplify + +Across all paths in parallel: + +* Apply transforms. + +* Convert strokes to fills. + +* Make curves monotonic. + +#### Tile + +Across all paths in parallel: + +* Cut paths into 16×16 tiles. + +* Approximate curves with lines. + +* Flag tiles that consist entirely of a solid color. + +#### Cull + +Sequentially (TODO: in parallel): + +* Cull tiles occluded by solid-color tiles. + +#### Pack + +Sequentially: + +* Gather up and compress per-instance data produced by the tile pass into batches. + +* Upload to GPU. + +Approximate CPU time for the tile, cull, and pack passes: 2.2 ms. + +### GPU + +#### Fill + +In parallel: + +* Rasterize all edges to an alpha coverage framebuffer (16-bit single-channel floating point). + +Approximate GPU time: 2.6 ms. + +#### Shade + +In parallel: + +* Draw solid-color tiles. (Z-buffer is not needed because we did occlusion culling in software.) + +* Shade tiles back-to-front using the alpha mask generated during the fill step. + +Approximate GPU time: 2.3 ms. + + diff --git a/doc/architecture.svg b/doc/architecture.svg new file mode 100644 index 00000000..6e685ab8 --- /dev/null +++ b/doc/architecture.svg @@ -0,0 +1,111 @@ + + + + + + +G + + +cluster_CPU + +CPU + + +clusterGPU + +GPU + + + +Simplify + +Simplify + + + +Tile + +Tile + + + +Simplify->Tile + + + + + +Cull + +Cull + + + +Tile->Cull + + + + + +Pack + +Pack + + + +Cull->Pack + + + + + +Fill + +Fill + + + +Pack->Fill + + + + + +Shade + +Shade + + + +Fill->Shade + + + + + +Image +Image + + + +Shade->Image + + + + + +Paths +Paths + + + +Paths->Simplify + + + + +