Commit Graph

86 Commits

Author SHA1 Message Date
Patrick Walton 21a82ae049 Update the OpenGL backend 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 520817e909 Add OpenGL 4.3 support to the GL backend, enabling compute shader on
non-Metal platforms
2020-05-07 16:33:03 -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 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 32a56eab85 Stop leaking textures and framebuffers in the OpenGL backend.
Closes #264.

Possibly addresses #286.
2020-03-31 17:14:28 -07:00
Patrick Walton 0c93045f50 Replace the individual tile shaders with an ubershader 2020-03-25 21:59:51 -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
Patrick Walton 740597d886
Merge pull request #254 from arturoc/remove-log-restriction
Remove log restriction
2020-02-06 08:38:08 -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
Arturo Castro 3be6d70577 remove log restrictions from renderer, demo/common and gl crates 2020-01-28 15:24:21 +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 5d5d30346b Remove unnecessary dependencies from `pathfinder_gl` 2019-10-19 15:37:17 -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 412d35ae57
Merge pull request #182 from toolness/cfg-debug-assertions
Define ck() based on cfg(debug_assertions)
2019-06-05 18:32:51 -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
Atul Varma 7563e95d96 Add a more helpful panic message when GL errors occur. 2019-06-05 08:15:21 -04:00
Atul Varma 5ce4e2e128 Define ck() based on cfg(debug_assertions). 2019-06-05 07:45:52 -04: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
Luis de Bethencourt 0231542141 Fix unused variable warning
Fixing the following warning
warning: unused variable: `resources`
2019-05-27 15:22:27 -04:00
Atul Varma ea3cdbb2a9 Merge remote-tracking branch 'origin/master' into pathfinder-unity-fun 2019-05-27 13:41:19 -04:00
Atul Varma a51501791d Add GLDevice::set_default_framebuffer(). 2019-05-27 07:56:36 -04: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 e04cc273ee Add enough C bindings to recreate `canvas_minimal` in C.
Closes #12.
2019-05-25 20:21:38 -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 8606cd013e Replace commented out printlns with proper debug statements 2019-04-29 16:43:24 -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 62a3fefca4 Reenable the tile and fill counts in the debug display 2019-04-18 15:09:37 -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 29cedb96ef
Merge pull request #113 from asajeffrey/gl-nonzero-default-framebuffer
Allow a non-zero default framebuffer
2019-03-25 15:13:46 -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
Alan Jeffrey ab3b28f82b Allow a non-zero default framebuffer 2019-03-21 13:34:59 -05: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 e09b447d0d Move the contents of `gl::device` into `gl` 2019-03-05 14:51:29 -08:00
Patrick Walton f7a8b573ce Move the GPU rendering code out of `pathfinder_gl`, since it's now no longer
OpenGL-specific
2019-03-05 14:46:18 -08: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 8b4c06fe2a Do GL error checks 2019-03-04 19:43:13 -08:00
Patrick Walton ae450b063e WIP: Factor out GL code 2019-03-04 14:55:32 -08:00
Patrick Walton dc69d1197e Tweak debug UI 2019-02-26 15:24:39 -08:00
Patrick Walton 92777c6346 Make rects rounded and optimize PNGs 2019-02-26 13:48:35 -08:00
Patrick Walton 5c7423d59c Add more statistics to the performance debug window 2019-02-25 16:12:47 -08:00
Patrick Walton fc62e9bc71 Subdivide offset curves to an error bound. 2019-02-20 18:27:27 -08:00
Patrick Walton c7a1d9e960 Use stencil to integrate the vector scene into the 3D environment 2019-02-19 12:03:02 -08:00
Patrick Walton 3b8ecfd74c WIP before removing barycentric coordinates 2019-02-18 18:13:10 -08:00
Patrick Walton 9af3bac11f Implement depth interpolation, not working yet 2019-02-18 13:42:30 -08:00
Patrick Walton 661a865508 Fill depth when drawing the ground plane 2019-02-15 19:07:42 -08:00
Patrick Walton d30743a69c Begin refactoring the demo into a shared library and a platform-specific
entry point.

This will help the upcoming wasm port.
2019-02-15 18:21:46 -08:00
Patrick Walton e4803cfddf Add some ground to the 3D scene, no depth buffer yet 2019-02-14 18:53:02 -08:00
Patrick Walton 22fe63503f Implement 2D rotation 2019-02-12 12:40:24 -08:00
Patrick Walton dbf880d011 Rename `demo3` to `demo` 2019-02-08 14:53:20 -08:00
Patrick Walton 2a118c3af0 Get all postprocessing filters working 2019-02-08 14:37:30 -08:00
Patrick Walton ba5a0f987c Add basic postprocessing support 2019-02-08 13:55:31 -08:00
Patrick Walton 7429821867 Move demo UI to the demo 2019-02-07 15:35:21 -08:00
Patrick Walton c9a80304dc Add some more (non-functional) UI widgets to the demo 2019-02-07 14:07:05 -08:00
Patrick Walton 0b662b0660 Draw a settings button, not functional yet 2019-02-06 20:59:29 -08:00
Patrick Walton a81850a899 Add window resizing support to the demo 2019-02-06 18:09:37 -08:00
Patrick Walton 8771dd6789 wip: dilation not working yet 2019-02-05 20:10:20 -08:00
Patrick Walton 3d0463999c Add a SIMD integer rect type 2019-02-05 10:55:01 -08:00
Patrick Walton f25682f0f1 Add a defringing shader for subpixel antialiasing, untested as of yet 2019-02-04 16:04:13 -08:00
Patrick Walton b0e91369e5 Do scene building just-in-time on a per-outline basis as part of tiling 2019-02-02 11:36:42 -08:00
Patrick Walton eb9b4a2a06 Work around macOS Radeon driver bug 2019-01-31 19:10:59 -08:00
Patrick Walton dd480feb52 Factor out the GL rendering code into a separate crate 2019-01-30 19:31:29 -08:00