Commit graph

885 commits

Author SHA1 Message Date
Bruce Mitchener 459bf0fc98
Merge pull request #338 from waywardmonkeys/remove-unused-deps
Remove direct dep on parking_lot, smallvec.
2023-07-06 23:09:30 +07:00
Bruce Mitchener ed8da9beec
Merge pull request #339 from waywardmonkeys/headless-can-use-workspace-pollster
headless: Use pollster from workspace.
2023-07-06 23:03:19 +07:00
Bruce Mitchener ccd745364a Remove direct dep on parking_lot, smallvec.
Both of these are used transitively, but not directly by `vello`,
so we don't need to list them here.
2023-07-03 16:42:14 +07:00
Bruce Mitchener c005e1b188 headless: Use pollster from workspace.
This prevents having 2 versions of `pollster` pulled into the workspace.
The workspace provided `pollster` `0.3`, while `headless` was still
using `0.2.5`.
2023-07-03 16:41:48 +07:00
Raph Levien 31f8d9ffa0
Merge pull request #336 from linebender/fix_json
Fix invalid settings JSON
2023-06-29 11:37:14 -07:00
Raph Levien a860979f28 Fix invalid settings JSON 2023-06-29 09:07:58 -07:00
Arman Uguray 443539891c
Merge pull request #335 from armansito/fix-clip-bug
Correctly handle disjoint bounding-box intersections in binning
2023-06-28 20:59:31 -07:00
Arman Uguray 2c46228d06 [binning] Correctly handle disjoint bounding-box intersections
When the bounding boxes of a path and its clip are disjoint (i.e. they
do not intersect) the result of their intersection is a negative
rectangle.

When calculating the intersection of the bboxes, the binning stage
ensures that the bbox is non-negative. It then normalizes the
coordinates to bin dimensions and rounds the top-left corner down
to the neareast integer and the bottom-right corner up.

However this rounding causes zero-area bounding boxes to have a non-zero
area and sends the bottom-right corner to the placed in the next bin.
This causes fully clipped out draw objects to be included in binning,
with an incorrect clip bounding box that causes them to be erroneously
drawn with partial clipping.

`binning` now takes care around this logic to make sure that a zero-area
intersected-bbox gets skipped and clipped out. `tile_alloc`, also takes
care in its logic.

Fixes #286 and #333
2023-06-28 20:42:52 -07:00
Arman Uguray cf25068795 [test_scenes] Add test scenes that demonstrate incorrect clipping
Added a test scene that demonstrates the clipping bugs reported in
vello#286 and vello#333.
2023-06-28 18:38:44 -07:00
Arman Uguray 12e764d58d
Merge pull request #329 from armansito/draw-monoid-overrun
[draw_leaf] Guard against invalid reads of drawtags and bad writes to draw monoids.
2023-06-28 13:22:47 -07:00
Arman Uguray 1dea6c0ef0 Fix invalid buffer access errors caught by shader validation
Fixed several other shader validation errors caught when running
vello_shaders natively on Metal.

These were primarily caused by reading an invalid drawtag while
accessing the scene buffer. Scene buffer access in the offending
pipelines now initialize the draw tag to DRAWTAG_NOP if an
invocation ID would land beyond the valid index range of encoded draw
objects.
2023-06-28 12:59:21 -07:00
Arman Uguray a016fc19de [draw_leaf] Don't write past the end of the draw_monoids buffer
The number of global invocations for draw_leaf can exceed the size of
the draw_monoids buffer which gets conservatively set to the number of
draw objects. Added an explicit bounds check to prevent the invalid
write.

This is not an issue when targeting wgpu as the WGSL compiler emits
implicit bounds checking. When targeting Metal, we disable implicit
bounds checks as that requires an extra buffer binding containing buffer
sizes.

This was caught by Xcode's Metal shader validation and resulted in
visual artifacts in native rendering.
2023-06-28 12:39:24 -07:00
Daniel McNab 8ded5ac7dc
Remove gitattributes - linguist supports WGSL (#332)
https://github.com/github-linguist/linguist/pull/6449
2023-06-22 16:05:23 +01:00
Daniel McNab 6d57093cc2
Add GPU profiling (#304)
* Add GPU profiling

* Fix conditional compilation for `headless`

* Add full profiling

* Productionise

* Fix MacOS trace file

* Try to make it easier to tell what's important

* Resolve CI issues
2023-06-01 16:10:27 +01:00
Raph Levien 03545e5d9a
Merge pull request #314 from linebender/failure
A bit of polishing on the demo
2023-06-01 07:25:04 -07:00
Raph Levien 4fcc348940 Change to caniuse for webgpu 2023-06-01 06:59:53 -07:00
Raph Levien 6ed6e4a940 Address review feedback 2023-05-31 17:44:57 -07:00
Raph Levien f60cb0c31b Merge branch 'main' into failure 2023-05-31 17:37:43 -07:00
Raph Levien ea224b459c
Merge pull request #325 from linebender/warnings
Quiet warnings
2023-05-21 09:19:19 -07:00
Raph Levien bfccd006e9
Tweak features for cargo check
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2023-05-20 12:35:55 -07:00
Raph Levien 6fb757266e Add dependencies
I wasn't sure the linux dependencies were needed just for a clippy check, but apparently so.
2023-05-18 16:18:42 -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
Raph Levien 8eb02ce330 Suppress one more warning in wasm case 2023-05-18 15:45:44 -07:00
Raph Levien 1f6b47bd78 Quiet warnings
Fixes the warnings remaining in the code, which should in turn let us check that in CI.

Also checks the optional features, which are easy enough to break.
2023-05-18 15:40:40 -07:00
Raph Levien 8158e77859 Rustfmt
I should set up git pre-push hooks. Also, I am surprised this needed a fmt, and would not add all the extra vertical space if it were up to me, but the reason we use default rustfmt is to avoid spending mental energy on such details.
2023-05-18 11:19:56 -07:00
Raph Levien 8f413c5b44 Fix headless example 2023-05-18 11:16:10 -07:00
Raph Levien f3587b1240 Merge branch 'main' into failure 2023-05-18 11:14:22 -07:00
Daniel McNab abfe9fbb56
Add a stats display for scene complexity (#322) 2023-05-18 18:50:57 +01:00
Daniel McNab 2c394aa265
Add a CI check that everything compiles (#321) 2023-05-18 16:14:46 +01: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
Chad Brokaw 780cff09db add examples from COLRv1 spec 2023-05-16 02:35:20 -04:00
Chad Brokaw 7b68630d6a refactor common scale ratio code 2023-05-15 14:54:44 -04:00
Chad Brokaw 58c7df469d Address review feedback
* replace one_minus_focal_x and abs_one_minus_focal_x variables with the actual expressions
* replace division by r^2-1 with multiplication by reciprocal
* revert chain selects to branchy code for clarity. Branching is dynamically uniform so shouldn't affect performance
* add suggested comment describing gradient kind/flags constants
2023-05-15 14:45:38 -04:00
Chad Brokaw 5e1188f968 replace branches with chained selects
This exchanges the per-pixel branching with additional ALU + selects. My expectation is that this will be faster, but that may be hardware/driver dependent and likely requires profiling and examination of generated code.

The original code is kept in a comment with notes to explain the more obfuscated select version.
2023-05-11 12:37:36 -04:00
Arman Uguray b0303ccf98
Merge pull request #320 from armansito/revise-backend-src-access
[shaders] Revise access to backend-agnostic metadata
2023-05-10 14:46:07 -07: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 006faab69f
Merge pull request #318 from linebender/export-font-api
Re-export font API
2023-05-10 13:59:29 -04:00
Chad Brokaw 570a0f3ce4 Re-export font API
Just exports fello from the glyph module so we can construct FontRefs in xilem.
2023-05-10 13:54:42 -04: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 ced6309a3b support two point radial with r0 > 0.0 2023-05-06 03:27:53 -04:00
Chad Brokaw 2db555145e clean up test scene code 2023-05-03 15:29:45 -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 6b69bff394
Merge pull request #317 from linebender/simple-resolve
[encoding] Add feature gate for full pipeline support
2023-05-03 14:46:12 -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