Commit Graph

32 Commits

Author SHA1 Message Date
Patrick Walton 2421de6616 Enable compute shader by default if the OpenGL version is high enough. 2020-05-08 12:16:31 -07:00
Patrick Walton 0545d840db Reduce timing jitter in the Metal backend 2020-05-04 19:11:50 -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 ccf9822e11 Fix `pathfinder_metal` crate description 2020-04-17 13:05:45 -07:00
Patrick Walton adf87d7636 Bump the `pathfinder_color` version to 0.5 to match other crates 2020-04-17 13:00:43 -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 93f5fbc6d2 Add convenience constructors: `vec2f`, `vec2i`, `Vector2F::zero()`,
`Vector2I::zero()`
2020-03-31 11:29:21 -07:00
Patrick Walton 0f35d9c817 Add an embedded resource loader that places resources directly in the binary.
This is useful for WebGL and for downstream crates.io use.
2020-02-28 17:10:53 -08:00
Patrick Walton 060241e4d0 Fix Metal backend 2020-02-27 04:07:09 -08:00
Patrick Walton 3a014d78eb Implement a blur filter for canvas shadows 2020-02-26 18:43:41 -08:00
Patrick Walton d1c7da8bd2 Implement pattern repeating and image smoothing control 2020-02-26 14:56:05 -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 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 3245796445 Add support for multiple paint texture pages.
This avoids arbitrary limits on the number of images, gradients, etc. you can
have.
2020-02-21 14:46:10 -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 4933efb513 Add Lighten and Darken composite ops 2020-02-20 20:38:43 -08:00
Patrick Walton 0c3dad974f Expose individual blend factors in `pathfinder_gpu` 2020-02-20 15:28:37 -08:00
Patrick Walton d9e994e46d Transition the existing postprocessing system to a layers system.
This is preparatory work for composite ops and blurs.

Closes #261.
2020-02-20 11:21:45 -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 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
Emmanuel Gil Peyrot 6ce416e77c Bump all outdated dependencies
I’m pleasantly surprised that none of these required any (visible) code
change, but tests pass so let’s go with that. :)
2020-02-06 09:39:50 +01:00
Patrick Walton ce3b40cd5c Make timer queries and framebuffer readback async 2020-01-07 13:03:15 -08:00
Patrick Walton 0662f6433f Allow any texture format to be uploaded; fix Metal compilation on newer rustcs 2019-12-20 11:48:51 -08:00
Patrick Walton 7c655246ae Add some more features to blending, and expand texture upload features 2019-12-19 08:58:02 -08:00
Patrick Walton fa54868eb1 Add support for single float uniforms to `pathfinder_gpu` 2019-11-15 21:17:50 -08:00
Patrick Walton ff212dce36 Add 2D matrix uniform types and a couple more useful geometry methods 2019-11-10 10:28:20 -08:00
Patrick Walton b886c157c1 Use 2-lane instead of 4-lane SIMD types for 2D vectors.
Also, this commit rewrites the `add_fill()` method to stop using shuffle
instructions, which can be slow and make the code overly complicated. The
shuffle instructions have been removed from the various SIMD backends.
2019-06-26 16:38:37 -07:00
Patrick Walton e727fd9018 Try to work around #199 2019-06-24 11:45:44 -07:00
Patrick Walton dfdfebfdd2 Fix use-after-free in Metal argument encoding 2019-06-22 14:39:29 -07:00
Patrick Walton 431dcf3d2e Rename `pathfinder_geometry::basic` to simply `pathfinder_geometry`, and move
the remaining code in that crate to a new crate, `pathfinder_content`

The old hierarchy was confusing.
2019-06-21 10:06:19 -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