Commit Graph

54 Commits

Author SHA1 Message Date
Michael Pfaff 5e41738e4c Improve C API
I ran `cargo fmt` on the project, which in hindsight was a poor choice.
I'm not correcting it right now.
2024-08-09 03:17:33 -04:00
Andrea Frigido d0f8005169
Update license field following SPDX 2.1 license expression standard (#540) 2024-02-06 16:59:01 +00:00
Kamil Becmer 0403bc3736 Replace use of deprecated methods from image 2022-08-26 15:37:42 +02:00
Patrick Walton 5f8fcbeac2 Fix WebGL, and add a simple example of WebGL usage 2020-07-02 19:49:09 -07:00
Patrick Walton 7771fd877d Add a unified GPU allocator 2020-06-23 13:10:06 -07:00
Patrick Walton ef0c0e0679 Associate texture parameters in shaders with specific texture units, to work
around a macOS Radeon driver bug.

Also, ensure there is always a dummy texture bound to every parameter in the
OpenGL backend.

These together stop the macOS Radeon drivers from recompiling the shader on
every drawcall.

Possibly addresses #300.
2020-05-12 21:40:38 -07:00
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 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 adf87d7636 Bump the `pathfinder_color` version to 0.5 to match other crates 2020-04-17 13:00:43 -07:00
Patrick Walton a91da6fdb4 Publish `pathfinder_resources` to crates.io 2020-04-17 12:33:22 -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 9723fa441b Update `image`, `glutin`, and `jni` crates.
From #277.
2020-03-27 15:49:26 -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 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 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 677c607a8c Get clips working for canvas 2020-02-16 13:45:15 -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 2db43797c3 Split colors out into their own crate.
A lot of downstream consumers of `pathfinder_gpu` want to use colors without
the path stuff.
2020-01-31 09:17:04 +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 8dabd0a7ea Add RGBA32F support 2019-12-14 13: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 bcac119324 Rename `Transform2DF` to `Transform2F` and `Transform3DF` to `Transform4F` 2019-07-11 14:59:10 -07: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 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
Patrick Walton dbf02fb742 Make `get_vertex_attr()` fallible 2019-06-12 10:50:24 -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
Patrick Walton a1b0df0a42 Rename `Point2DF` to `Vector2F`, `Point3DF` to `Vector4F`, and `LineSegmentF`
to `LineSegment2F`.

Straw poll on Twitter suggested that these names were preferred.
2019-06-03 12:39:29 -07:00
Patrick Walton e1bcc11ace Change the `F32` and `I32` suffixes to `F` and `I` to match the C API.
They're shorter and less noisy.
2019-05-29 19:17:16 -07:00
Patrick Walton acf666b701 Stop using triangle fans for DX12/Vulkan compatibility.
Closes #165.
2019-05-29 16:04:33 -07:00
Patrick Walton bc713a5181 Remove the rustache dependency.
1/3 reduction in binary size for `canvas_minimal`.

Closes #158.
2019-05-26 13:02:52 -07:00
Patrick Walton 7a02b78b3d Explicitly specify color texture coordinates for alpha and solid tiles.
This is groundwork for gradients and images.

This commit also refactors the interface for vertex attributes to use named
parameters (via structs), for clarity.
2019-05-14 15:11:04 -07:00
Patrick Walton f129f09bd8 Rust `rustfmt` on the GPU crate 2019-04-29 16:57:56 -07:00
Patrick Walton 6c31e1bc01 In VR mode, render one eye and then reproject to both eyes instead of rendering
twice.

This reduces both CPU and GPU time a lot in exchange for a small loss in
quality.
2019-04-26 17:22:54 -07:00
Patrick Walton c688d04412 Remove the scene assembly thread, and pipeline only fills instead of alpha
tiles.

Removing a thread should make it easier to manually assign threads to CPUs, as
is necessary on devices with poor schedulers like Magic Leap 1.
2019-04-18 13:50:26 -07:00
Patrick Walton db3851d754 Get subpixel AA and gamma correction working in 2D 2019-03-25 16:20:34 -07:00
Patrick Walton 224c8e85b9 Create separate shaders for monochrome and multicolor tiles.
This is preparation for fixing subpixel AA.
2019-03-22 14:28:31 -07:00
Patrick Walton 0458d9a7f2 Factor out bits of the postprocessing shader into includes 2019-03-18 21:40:10 -07:00
Patrick Walton bb32777101 Initial work toward VR support 2019-03-14 14:42:22 -07:00
Patrick Walton 9c404dfdc1 Add an Android port 2019-03-12 13:55:26 -07:00
Patrick Walton bc80490158 Remove raw GL code from the demo 2019-03-05 13:57:28 -08:00
Patrick Walton 6b9adcb6fc Fix GPU abstraction 2019-03-05 13:22:11 -08:00
Patrick Walton ae450b063e WIP: Factor out GL code 2019-03-04 14:55:32 -08:00