Add very preliminary architecture documentation

This commit is contained in:
Patrick Walton 2019-01-03 10:35:19 -08:00
parent ad8814fcea
commit f4ed611e56
3 changed files with 203 additions and 0 deletions

18
doc/architecture.dot Normal file
View File

@ -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;
}

74
doc/architecture.md Normal file
View File

@ -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 (<span class="todo">TODO</span>: 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.
<style>
.todo {
text-transform: lowercase;
font-variant: small-caps;
}
</style>

111
doc/architecture.svg Normal file
View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.40.1 (20161225.0304)
-->
<!-- Title: G Pages: 1 -->
<svg width="702pt" height="102pt"
viewBox="0.00 0.00 701.94 102.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 98)">
<title>G</title>
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-98 697.936,-98 697.936,4 -4,4"/>
<g id="clust1" class="cluster">
<title>cluster_CPU</title>
<polygon fill="none" stroke="#000000" points="82,-8 82,-86 431.936,-86 431.936,-8 82,-8"/>
<text text-anchor="middle" x="256.968" y="-70.8" font-family="Source Sans Pro" font-size="14.00" fill="#000000">CPU</text>
</g>
<g id="clust2" class="cluster">
<title>clusterGPU</title>
<polygon fill="none" stroke="#000000" points="451.936,-8 451.936,-86 611.936,-86 611.936,-8 451.936,-8"/>
<text text-anchor="middle" x="531.936" y="-70.8" font-family="Source Sans Pro" font-size="14.00" fill="#000000">GPU</text>
</g>
<!-- Simplify -->
<g id="node1" class="node">
<title>Simplify</title>
<polygon fill="none" stroke="#000000" points="153.904,-52 90.032,-52 90.032,-16 153.904,-16 153.904,-52"/>
<text text-anchor="middle" x="121.968" y="-31.599" font-family="Source Sans Pro" font-size="14.00" fill="#000000">Simplify</text>
</g>
<!-- Tile -->
<g id="node2" class="node">
<title>Tile</title>
<polygon fill="none" stroke="#000000" points="243.936,-52 189.936,-52 189.936,-16 243.936,-16 243.936,-52"/>
<text text-anchor="middle" x="216.936" y="-31.599" font-family="Source Sans Pro" font-size="14.00" fill="#000000">Tile</text>
</g>
<!-- Simplify&#45;&gt;Tile -->
<g id="edge1" class="edge">
<title>Simplify&#45;&gt;Tile</title>
<path fill="none" stroke="#000000" d="M154.1198,-34C162.3831,-34 171.3403,-34 179.8319,-34"/>
<polygon fill="#000000" stroke="#000000" points="189.8808,-34 179.8809,-38.5001 184.8808,-34 179.8808,-34.0001 179.8808,-34.0001 179.8808,-34.0001 184.8808,-34 179.8808,-29.5001 189.8808,-34 189.8808,-34"/>
</g>
<!-- Cull -->
<g id="node3" class="node">
<title>Cull</title>
<polygon fill="none" stroke="#000000" points="333.936,-52 279.936,-52 279.936,-16 333.936,-16 333.936,-52"/>
<text text-anchor="middle" x="306.936" y="-31.599" font-family="Source Sans Pro" font-size="14.00" fill="#000000">Cull</text>
</g>
<!-- Tile&#45;&gt;Cull -->
<g id="edge2" class="edge">
<title>Tile&#45;&gt;Cull</title>
<path fill="none" stroke="#000000" d="M243.939,-34C251.9637,-34 260.9025,-34 269.4669,-34"/>
<polygon fill="#000000" stroke="#000000" points="279.641,-34 269.6411,-38.5001 274.641,-34 269.641,-34.0001 269.641,-34.0001 269.641,-34.0001 274.641,-34 269.641,-29.5001 279.641,-34 279.641,-34"/>
</g>
<!-- Pack -->
<g id="node4" class="node">
<title>Pack</title>
<polygon fill="none" stroke="#000000" points="423.936,-52 369.936,-52 369.936,-16 423.936,-16 423.936,-52"/>
<text text-anchor="middle" x="396.936" y="-31.599" font-family="Source Sans Pro" font-size="14.00" fill="#000000">Pack</text>
</g>
<!-- Cull&#45;&gt;Pack -->
<g id="edge3" class="edge">
<title>Cull&#45;&gt;Pack</title>
<path fill="none" stroke="#000000" d="M333.939,-34C341.9637,-34 350.9025,-34 359.4669,-34"/>
<polygon fill="#000000" stroke="#000000" points="369.641,-34 359.6411,-38.5001 364.641,-34 359.641,-34.0001 359.641,-34.0001 359.641,-34.0001 364.641,-34 359.641,-29.5001 369.641,-34 369.641,-34"/>
</g>
<!-- Fill -->
<g id="node5" class="node">
<title>Fill</title>
<polygon fill="none" stroke="#000000" points="513.936,-52 459.936,-52 459.936,-16 513.936,-16 513.936,-52"/>
<text text-anchor="middle" x="486.936" y="-31.599" font-family="Source Sans Pro" font-size="14.00" fill="#000000">Fill</text>
</g>
<!-- Pack&#45;&gt;Fill -->
<g id="edge5" class="edge">
<title>Pack&#45;&gt;Fill</title>
<path fill="none" stroke="#000000" d="M423.939,-34C431.9637,-34 440.9025,-34 449.4669,-34"/>
<polygon fill="#000000" stroke="#000000" points="459.641,-34 449.6411,-38.5001 454.641,-34 449.641,-34.0001 449.641,-34.0001 449.641,-34.0001 454.641,-34 449.641,-29.5001 459.641,-34 459.641,-34"/>
</g>
<!-- Shade -->
<g id="node6" class="node">
<title>Shade</title>
<polygon fill="none" stroke="#000000" points="603.936,-52 549.936,-52 549.936,-16 603.936,-16 603.936,-52"/>
<text text-anchor="middle" x="576.936" y="-31.599" font-family="Source Sans Pro" font-size="14.00" fill="#000000">Shade</text>
</g>
<!-- Fill&#45;&gt;Shade -->
<g id="edge4" class="edge">
<title>Fill&#45;&gt;Shade</title>
<path fill="none" stroke="#000000" d="M513.939,-34C521.9637,-34 530.9025,-34 539.4669,-34"/>
<polygon fill="#000000" stroke="#000000" points="549.641,-34 539.6411,-38.5001 544.641,-34 539.641,-34.0001 539.641,-34.0001 539.641,-34.0001 544.641,-34 539.641,-29.5001 549.641,-34 549.641,-34"/>
</g>
<!-- Image -->
<g id="node8" class="node">
<title>Image</title>
<text text-anchor="middle" x="666.936" y="-31.599" font-family="Source Sans Pro" font-size="14.00" fill="#000000">Image</text>
</g>
<!-- Shade&#45;&gt;Image -->
<g id="edge7" class="edge">
<title>Shade&#45;&gt;Image</title>
<path fill="none" stroke="#000000" d="M603.939,-34C611.9637,-34 620.9025,-34 629.4669,-34"/>
<polygon fill="#000000" stroke="#000000" points="639.641,-34 629.6411,-38.5001 634.641,-34 629.641,-34.0001 629.641,-34.0001 629.641,-34.0001 634.641,-34 629.641,-29.5001 639.641,-34 639.641,-34"/>
</g>
<!-- Paths -->
<g id="node7" class="node">
<title>Paths</title>
<text text-anchor="middle" x="27" y="-31.599" font-family="Source Sans Pro" font-size="14.00" fill="#000000">Paths</text>
</g>
<!-- Paths&#45;&gt;Simplify -->
<g id="edge6" class="edge">
<title>Paths&#45;&gt;Simplify</title>
<path fill="none" stroke="#000000" d="M54.214,-34C62.0853,-34 70.8714,-34 79.4399,-34"/>
<polygon fill="#000000" stroke="#000000" points="89.7075,-34 79.7075,-38.5001 84.7075,-34 79.7075,-34.0001 79.7075,-34.0001 79.7075,-34.0001 84.7075,-34 79.7074,-29.5001 89.7075,-34 89.7075,-34"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.0 KiB