Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMove more to the GPU in Pathfinder 3 when available #119
Comments
In case it helps with inspiration, fastuidraw renders strokes in a uber shader. The CPU side mostly sends information about where the joins are and their drawing parameters, while the vertex shader extrudes a conservative bounding geometry along the path and the fragment shader does the job of rendering the joins with the right shapes. Here's an example of some join-type-specific logic in the vertex shader: https://github.com/intel/fastuidraw/blob/f57d39936eb7c584432091863de4edd5b62c66ab/src/fastuidraw/glsl/shaders/painter/fastuidraw_painter_stroke_compute_offset.vert.glsl.resource_string#L146 |
|
We have a D3D11 backend now that moves most things to GPU. Let's close this in favor of more specific items. |
This is just a sketch of various ideas for moving CPU passes to the GPU. On certain devices such as Magic Leap 1 we're CPU bottlenecked.
Stroke
Required features: None.
Just replace stroke algorithm with a shader.
Not clear yet how to do miter joins.
Transform
Required features: Transform feedback. GL 3.0; GLES 3.0.
This one is pretty obvious. Obvious hazard is readback from GPU.
Clipping
Required features: Transform feedback, geometry or compute shader. GL 3.2; GLES 3.1.
Will require some experimentation to find best clipbuffer representation.
Tiling
Required features: Compute shader, indirect draw. GL 4.3; GLES 3.1.
Break curves into lines on GPU, assign to tiles via compute (or geometry) shader. During fill stage, accumulate outgoing fill in SSBO or writable image using atomics. Then propagate fills between tiles using a binary flood algorithm in compute shader.
Not clear how to do occlusion culling. Possibly detect solid tiles during outgoing fill tile propagation.
Intra-tile curve-to-line conversion
Required features: Geometry or tessellation shader. GL 3.2; GLES 3.2.
Not sure if this is worth it due to needing to solve cubic equations. Probably not needed if GPU tiling works out.