Commit graph

20 commits

Author SHA1 Message Date
Chad Brokaw 58c7df469d Address review feedback
* replace one_minus_focal_x and abs_one_minus_focal_x variables with the actual expressions
* replace division by r^2-1 with multiplication by reciprocal
* revert chain selects to branchy code for clarity. Branching is dynamically uniform so shouldn't affect performance
* add suggested comment describing gradient kind/flags constants
2023-05-15 14:45:38 -04:00
Chad Brokaw 5e1188f968 replace branches with chained selects
This exchanges the per-pixel branching with additional ALU + selects. My expectation is that this will be faster, but that may be hardware/driver dependent and likely requires profiling and examination of generated code.

The original code is kept in a comment with notes to explain the more obfuscated select version.
2023-05-11 12:37:36 -04:00
Chad Brokaw b103a55301 rework radial gradients
Adds full support for COLRv1 radial gradients based on the two-point conical gradient algorithm at https://skia.org/docs/dev/design/conical/

Also adds robustness to degenerate cases in gradient encoding:
* Radial where p0 == p1 && r0 == r1 renders transparent solid
* Empty stops render as transparent solid
* Single stop renders as solid
2023-05-09 18:09:53 -04:00
Chad Brokaw ced6309a3b support two point radial with r0 > 0.0 2023-05-06 03:27:53 -04:00
Chad Brokaw 15cd306af6 Extend modes for gradients
This patch implements the pad, repeat and reflect extend modes for gradient brushes. Adds a new example demonstrating the functionality.

Also fixes a few bugs:
* Clamps alpha in blend.wgsl for the `blend_compose` function. The `Plus` mode was generating `alpha > 1.0` leading to incorrect rendering.
* Small change to radial gradients in fine.wgsl to reject pixels outside the cone when the circles don't nest. This requires further work to properly extend the cone when one of the radii is not 0.
2023-04-30 23:11:57 -04:00
Chad Brokaw a6307a2520 predicate image loads on non-zero mask 2023-03-15 08:37:00 -04:00
Chad Brokaw d12b711fe1 premultiply alpha before filtering 2023-03-10 02:04:21 -05:00
Chad Brokaw a8585781cd move atlas rect to info
Atlas offset and image size were originally stored in the ptcl but are not tile dependent. Moving these to info saves 8 bytes per image tile.
2023-03-10 01:42:50 -05:00
Chad Brokaw 165b3a083b Let's add images 2023-03-09 17:18:03 -05:00
Arman Uguray 3bbf108df5 Renamed clear_color to base_color; addressed review comments 2023-03-02 14:29:44 -08:00
Arman Uguray 8eabc12a72 Add a clear_color uniform
Introduced an RGBA8 config parameter to apply as a base blend color in
the fine stage of the full pipeline.
2023-03-02 09:26:31 -08:00
Chad Brokaw 1f938e5f49 linear algebra refresher 2023-02-22 23:18:51 -05:00
Chad Brokaw 033870d91e Fix brush transforms
This fixes an incorrect application of the inverse transform for radial gradients in fine.

Also fixes an edge case in `SceneBuilder` where a brush transform is identical to the path transform leading to a corrupt encoding.
2023-02-22 20:10:00 -05:00
Chad Brokaw 1e8d194b6a initial GPU side work for robust memory
This should handle everything on the GPU side except for blend stack loading/storing in fine.
2023-01-17 14:08:20 -05:00
Raph Levien 5c469013c7 Fix even-odd rule
This works with winding numbers even larger than 2.
2023-01-12 21:08:51 -08:00
Chad Brokaw c6ac5bf590 Support even-odd fill rule
Add logic for handling the even-odd fill rule to `SceneBuilder` and the coarse and fine shaders.
2023-01-10 15:22:04 -05:00
Raph Levien 080277bcd9
Merge pull request #241 from linebender/fine_fixes
Fixes to fine rasterization
2023-01-08 13:50:51 -08:00
Duane Johnson 3e8a4813f0
Update references to piet-gpu where it makes sense (#240) 2023-01-08 16:15:51 +00:00
Raph Levien 29a16eb210 Fixes to fine rasterization
The area bug was found and fixed by @dfrg, and is adapted from #239. I wanted to move it to a separate PR so that one would be more focused on API.

The other bug is currently silent because the two quantities swapped are both 4, but it is triggered when experimenting with tuning for performance.
2023-01-08 07:41:01 -08:00
Daniel McNab ff59839737
Move the vello crate to the workspace root (#231)
* Move the vello crate to the root of the crate

* Add warning that README is work in progress

* Add newline in warning

* Move the unlicense into the shader folder

* Fixup wgsl-analyzer include paths
2023-01-05 09:32:09 +00:00
Renamed from vello/shader/fine.wgsl (Browse further)