Commit Graph

52 Commits

Author SHA1 Message Date
Patrick Walton 0e82acda2b Allow radial gradients to be evaluated with any nonzero discriminant, not just
ones with magnitude above `EPSILON`.

Closes #399.
2020-07-23 13:45:20 -07:00
Sebastian K dd0ac124d8 Add ColorMatrix filter 2020-07-23 12:46:59 -07:00
Patrick Walton 6a32f8c055 Stop clamping radial gradient t values to [0.0, 1.0].
Closes #393.
2020-07-16 10:30:39 -07:00
Patrick Walton 79326025af Rework the blit shader 2020-06-23 13:15:59 -07:00
Patrick Walton 61833168e5 Update the debug UI 2020-06-23 13:15:59 -07:00
Patrick Walton 754a44ae22 Rename the existing renderer to `d3d9` in preparation for the D3D11 branch 2020-06-23 13:10:05 -07:00
Patrick Walton 2ad02b0b78 Only define `precision highp sampler2D` in OpenGL ES.
Closes #309.
2020-05-08 16:59:40 -07:00
Patrick Walton 6299d2c36b Clear the canvas to the background color if no drawing command did so.
Closes #318.
2020-05-07 21:36:13 -07:00
Patrick Walton 478008dcf0 Use all four channels in the mask texture.
Each bundle of four pixels on a scanline is packed into the RGBA channels of
the mask texture. The area LUT is also expanded to be RGBA so that four pixels'
worth of areas can be looked up at once.

Nice improvement on `paris-30k` from MPVG.

Closes #262.
2020-05-05 13:11:37 -07:00
Patrick Walton ac83f79d94 Add a compute shader path, optimize GPU memory management, and switch from SDL
to `surfman`.

This is a large commit; explanations of each change follow.

This adds an optional compute shader path, off by default, for rendering fills
to alpha masks. It usually does not improve performance at present, but it
provides a good baseline for further optimizations. Later improvements will
likely aim to avoid writes to the mask texture entirely. Supporting
infrastructure for compute shader has been added to `pathfinder_gpu` for the
OpenGL and Metal backends.

The Metal backend has been optimized to avoid unneccessary buffer allocations
and reflection. As part of this, argument buffers have been removed, as the
current SPIRV-Cross compiler no longer requires them.

The GPU renderer has been improved to avoid stalls. Now, separate buffers are
allocated for each fill batch and for each frame. This can be extended in the
future to allow for separate buffers for tile draw operations as well.

SDL usage has been removed in favor of the native Rust `surfman` and `winit`.
Because `surfman` allows for selection of the integrated GPU on multi-GPU
system, it is chosen by default. The demo supports a new
`--high-performance-gpu` option to opt into the discrete GPU.
2020-04-30 13:33:29 -07:00
Patrick Walton 104869a6e9 Move the mask enable flag to the tile to reduce drawcall count 2020-04-22 11:04:16 -07:00
Patrick Walton a9003fe69b Add missing `tile_clip` shader to `resources`.
Closes #301.
2020-04-22 09:13:42 -07:00
Patrick Walton cd09177ead Implement the infrastructure needed to support multiple clip paths.
This also lays the groundwork needed to reduce batch breaks between solid and
alpha tiles.
2020-04-21 18:25:20 -07:00
Patrick Walton 6c996981a3 Fix some transform issues and implement transformed radial gradients in SVG.
In particular, this fixes the usvg-to-Pathfinder transform conversion and the
definition of `Transform2F::row_major()`.

Makes `drops.svg` from the MPVG samples work.
2020-04-20 16:40:02 -07:00
Sebastian K 582f025c91 Update WebGL backend for recent changes 2020-04-16 12:02:42 -07:00
Patrick Walton 0fec0061e6 Clamp radial gradient t values to [0.0, 1.0] instead of rendering transparent
black
2020-04-14 16:13:32 -07:00
Patrick Walton cdbe2fbb6b Introduce the concept of a base color in order to handle canvas shadow alpha
correctly
2020-04-13 18:31:25 -07:00
Patrick Walton 895f73096e Switch back to instanced drawing for tiles.
Improves tile build time by something around 2x in the NanoVG demo.
2020-04-08 17:16:54 -07:00
Patrick Walton 6eb0232aad Add `precision highp sampler2D` everywhere so our winding numbers don't get clipped
Closes #280.
2020-03-27 14:53:00 -07:00
Patrick Walton 55df287fec Move radial gradients from the CPU to the GPU 2020-03-26 21:24:20 -07:00
Patrick Walton 0c93045f50 Replace the individual tile shaders with an ubershader 2020-03-25 21:59:51 -07:00
Patrick Walton 2548ab853a Unify solid tiles and render target tiles.
This commit also removes old shaders from the manifest.
2020-03-05 12:22:01 -08:00
Patrick Walton f607b607b0 Composite render targets using tiles, taking the Z-buffer into account.
We can do more tile-based optimization, but this should be enough to ensure a
correct rendering.

This temporarily breaks subpixel AA, but it should be fixable by modifying
`blur.fs.glsl`.

Closes #271.
2020-03-02 20:10:10 -08:00
Patrick Walton ee6c7e0797 Explicitly cast `aTessCoord` to `vec2` for WebGL compatibility 2020-02-28 12:49:21 -08:00
Patrick Walton b998449885 Remove unused #define 2020-02-26 18:46:48 -08:00
Patrick Walton 3a014d78eb Implement a blur filter for canvas shadows 2020-02-26 18:43:41 -08:00
Patrick Walton 77b3555828 Separate opacity out from paint.
This allows `globalAlpha` to work on render targets.
2020-02-26 12:43:07 -08:00
Patrick Walton 1deb53fa9c Implement the remaining Porter-Duff compositing operators 2020-02-25 18:37:23 -08:00
Patrick Walton 0a3f64eb44 Implement the difference and exclusion blend modes 2020-02-25 14:55:58 -08:00
Patrick Walton a8e33d3d3d Add the soft light blend mode 2020-02-25 14:39:06 -08:00
Patrick Walton 9b4217300f Implement the source-in, destination-in, source-out, and destination-atop blend
modes to round out the assortment of Porter-Duff blend modes
2020-02-25 12:52:11 -08:00
Patrick Walton 02012431ca Implement color dodge and color burn blend modes 2020-02-25 11:37:42 -08:00
Patrick Walton 5b228ed825 Implement multiply, screen, hard light, and overlay blend modes. 2020-02-24 21:23:17 -08:00
Patrick Walton 00b7a2ee5a Factor out 3-element selection into a `select3()` function 2020-02-24 21:21:30 -08:00
Patrick Walton c96cb62f47 Factor out common functions used in tile alpha shaders 2020-02-24 19:42:32 -08:00
Patrick Walton 5421525eaa Implement the HSL filters (called "non-separable blend modes" in the spec).
These cannot be implemented with the standard OpenGL blending functions, so we
have to do them manually in a shader, which requires a good deal of machinery
to create intermediate framebuffers and so forth.
2020-02-24 15:37:44 -08:00
Patrick Walton 36538d5748 Implement a few more blend modes and switch to premultiplied alpha for layer
compositing
2020-02-20 22:22:15 -08:00
Patrick Walton 16a2de88df Rename "postprocessing" to "effects" and start initial work on composite ops 2020-02-20 14:22:07 -08:00
Patrick Walton 3ad1c25796 Implement the even-odd fill rule 2020-02-17 14:44:48 -08:00
Patrick Walton 677c607a8c Get clips working for canvas 2020-02-16 13:45:15 -08:00
Patrick Walton a8019a1a1a Fix mask positioning on OpenGL 2020-02-15 18:00:25 -08:00
Patrick Walton 631e16ce9b Fix flipped Y axis in mask texture positioning 2020-02-15 14:08:22 -08:00
Patrick Walton 6e28552a44 Add missing shaders 2020-02-14 22:10:04 -08:00
Patrick Walton 0883f54e2d Add a separate mask blit step, in preparation for supporting clips.
We can elide this in the future if there are no clips, but it isn't a huge
performance regression right now, so let's just unconditionally do it.
2020-02-14 21:56:43 -08:00
Patrick Walton 5a21557a6d Implement basic linear gradients.
This is not a very efficient implementation yet, but it seems to work.
2020-02-10 16:01:05 -08:00
Patrick Walton a66ed4c073 Specify tile texture coordinates as an affine transform.
Part of the groundwork for gradients.
2020-02-05 13:59:32 -08:00
Patrick Walton b269723254 Switch to per-pixel texture lookup for paints.
This is a prerequisite for supporting gradients and images.
2020-02-04 21:50:13 -08:00
Patrick Walton 222fa89b23 Use a 3D transform in the tile vertex shaders.
This opens the door to caching tiles at different zoom levels (issue #191).
2019-06-25 11:32:39 -07:00
Patrick Walton d86ff9011a Update the postprocessing shader and vertex array for the Metal changes.
Closes #201.
2019-06-21 18:04:18 -07:00
Patrick Walton de0662e08e Update `spirv-cross` to upstream master.
A fix has been merged for the issue that was breaking Pathfinder, so we can now
use the master branch.
2019-06-21 07:24:24 -07:00
Patrick Walton 487577a11b Add Metal support.
This commit substantially reworks the `pathfinder_gpu` API to better support
modern APIs like Metal. It should open the door to `gfx-rs`, `wgpu`, Vulkan,
and D3D12 backends relatively straightforwardly.

A new example, `canvas_metal_minimal`, has been added.

Note that the new Metal shaders require a patched version of `spirv-cross` to
build properly. An upstream patch is forthcoming.
2019-06-20 11:47:22 -07:00
Patrick Walton 9f9233c153 Add Metal shaders, cross-compiled from the GLSL via SPIR-V.
The Metal shaders are checked into the repository for convenience, but they
should not be directly edited. Instead, edit the corresponding GLSL shader in
the top-level `shaders/` directory, and rerun `make` in there.
2019-06-05 18:29:25 -07:00