Commit graph

24 commits

Author SHA1 Message Date
Bruce Mitchener fba1b46971 Update to wgpu 0.17. 2023-08-05 07:25:14 +07:00
Bruce Mitchener 6a82732435 Add license to vello-encoding, vello-shaders. 2023-08-01 21:39:17 +07:00
Bruce Mitchener 75b27d65f5 vello_shaders: Use naga 0.12, not git rev.
The git revision being used was from `0.11` while the current
release is `0.12`. `0.12` is used in `wgpu`, so this lets us
have a single `naga` crate being built.
2023-07-05 10:18:50 +07:00
Raph Levien 3774928b24 Enforce clippy lints
This turns on clippy checking and also fixes all lints in the code.

Many lints are obvious improvements. Only a small number are slightly annoying, so I think overall worth having a vanilla default config.
2023-05-18 16:13:32 -07:00
Arman Uguray ef2630ad9c
Merge pull request #323 from armansito/shaders-fixes-for-bazel
[shaders] Shader path look up fixes for hermetic builds
2023-05-16 15:38:00 -07:00
Arman Uguray d82bd409ff [shaders] Shader path look up fixes for hermetic builds
* Bazel builds seem to fail to open relative paths to parent directories
  due to hermetic sandboxing of third-party repositories. This adds a
  WORKSPACE_MANIFEST_FILE environment variable that allows the caller to
  optionally provide an absolute path to the workspace root manifest
  file.
* The existing code processed a shader file only if
  `FileType::is_file` returns true for it. This is not the case when
  sources are accessed via symbolic links, which is possible in a Bazel
  sandbox. The code now filters for the ".wgsl" file extension instead
  of the file type which should generally be safe.
2023-05-16 15:08:54 -07:00
Chad Brokaw 14eef3fafb
Merge pull request #316 from linebender/gradient-fixes
General gradient improvements
2023-05-16 02:36:42 -04:00
Arman Uguray b4ffb88494 [shaders] Revise access to backend-agnostic metadata
Previously the generated shader data structures were rooted in
backend-specific top-level mods (`mod wgsl`, `mod msl`, etc). This made
access to per-shader information that is common to all backends (e.g.
workgroup sizes, shader name etc) awkward to access from backend
agnostic code, especially when feature-gated conditional compilation is
used on the client side.

The data structures have been rearranged such that there is a top-level
`ComputeShader` declaration for each stage under a `gen` mod. The
`ComputeShader` struct declares feature-gated fields for backend shader
sources, such that backend specific data is now a leaf node in the
structure rather than the root. This has some additional benefits:

1. Common data doesn't have to be redeclared, saving on code size when
   multiple backends are enabled.

2. The backend specific source code was previously encoded as a `[u8]`.
   We can now use types that more closely match the expected format, for
   example `&str` for WGSL and MSL, `[u32]` for SPIR-V, etc.

3. If we ever need to expose additional backend-specific metadata in the
   future, we can bundle them alongside the source code in a
   backend-specific data structure at this level of the tree.
2023-05-10 14:12:13 -07: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 e9c2ce1623 resolve merge conflicts 2023-05-03 14:53:36 -04:00
Chad Brokaw 4f9ae4c937 Merge branch 'main' into gradient-fixes 2023-05-03 14:49:57 -04:00
Chad Brokaw c68d011c7c feature gate full pipeline encoding support
Adds a new feature called "full" (on by default) that enables encoding support for the full pipeline.
2023-05-03 12:22:51 -04:00
Chad Brokaw 46328c7a2c cleanup for review
* rename resolve_simple to resolve_solid_paths_only to better capture the semantics of the function
* move duplicated buffer size computation code to separate function
* change Resolver::resolve to call resolve_solid_paths_only when encoding.patches.is_empty() is true. This is likely to be slightly faster and will ensure that the "simple" code path is actually used.
2023-05-02 16:42:50 -04:00
Chad Brokaw c3ca624c1e Add resolve function for path only pipeline
Adds a new `resolve_simple` function that doesn't handle late bound resources (gradients, images and glyph runs).
2023-05-02 14:07:25 -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
Arman Uguray 2b0eab2bbc fix some clippy errors/warnings 2023-04-18 15:15:01 -07:00
Arman Uguray e9278a9253 [vello_encoding] Declare bump buffer sizes in terms of element count 2023-04-18 15:02:31 -07:00
Arman Uguray 4ae4177510 [vello_encoding] Fixup copyright headers 2023-04-18 14:46:16 -07:00
Arman Uguray fe29125a84 Remove unused WG size declarations 2023-04-18 14:46:16 -07:00
Arman Uguray 0256d8a92f [vello_encoding] Minor clean ups and correctness fixes
- Use the buffer sizes in src/render.rs as the current 128K is not
  sufficient for even the test scenes
- Add BumpAllocators type and bump buffer size
- Support the `base_color` render option
- Use immutable type construction where possible
- Fix the path tag stream length calculation to use the offsets stored
  in Layout. This both matches the current behavior in src/render.rs and
  makes it so that CpuConfig's construction no longer needs the Encoding
  type as an input
- Renamed CpuConfig & GpuConfig types to 'RenderConfig' and
  'ConfigUniform'
2023-04-18 14:46:16 -07:00
Arman Uguray 3ff490fc13 [vello_encoding] Declare padding in binding types to match WGSL layout 2023-04-18 14:46:16 -07:00
Chad Brokaw 9f27fae64e capture computation of workgroup and buffer sizes 2023-04-18 14:46:16 -07:00
Arman Uguray db2fefdc8f [vello_encoding] Move the encoding module into its own crate
This change moves the vello encoding logic to a new crate under
crates/encoding. Combined with the `vello_shaders` crate, this enables
lightweight integration of the Vello pipelines into renderers that don't
depend on wgpu (or perhaps written in languages other than Rust).

The Scene/Fragment API currently remain the vello crate.
2023-04-18 14:46:14 -07:00
Arman Uguray 0a6a6e2c21 [vello_shaders] Move vello_shaders to crates/shaders 2023-03-29 12:24:28 -07:00