Commit graph

912 commits

Author SHA1 Message Date
Arman Uguray 5543ad01fe [examples] Use instant crate's time::Instant
crates.io/crates/instant provides a std::time::Instant implementation
that works on both WASM and non-wasm builds.
2023-04-23 12:02:39 -07:00
Arman Uguray 8a35c51289 Roll wgpu to 0.16 2023-04-23 12:02:39 -07:00
Arman Uguray fa027978ed
Merge pull request #310 from armansito/svg-timing
[svg] Log parse and render times separately
2023-04-23 11:31:19 -07:00
Arman Uguray 97250fb2dc
Merge pull request #311 from armansito/clip-leaf-bounds-check
[shaders] Explicitly guard writes to clip_bboxes
2023-04-23 11:27:27 -07:00
Arman Uguray ceeb0b33b6 [shaders] Explicitly guard writes to clip_bboxes
The very last statement of the `clip_leaf` shader is the assignment to
the `clip_bboxes` buffer. The buffer write is indexed on the global
invocation ID. It is possible for this index to be larger than the total
number of clips in at least one workgroup since the clip count isn't
strictly a multiple of workgroup size.

Currently the size of the clip_bboxes buffer matches the number of
clips. This means the buffer index is likely to run past the buffer.
This is not an issue when running on wgpu as it internally enables
bounds checking when compiling WGSL (so all buffer accesses are
implicitly conditional). When compiling the shaders to native backends
the vello_shaders crate currently does not enable implicit bounds
checking, so a buffer overrun is possible.

There are a few potential solutions:

1. Have an explicit bounds check in the shader. This is straightforward
   and consistent with the existing code that reads from clip_inp. The
   downside is that with bounds checking enabled, this extra check is
   redundant in the generated code. This is the solution included in
   this PR.

2. Make sure that the clip_bboxes buffer has a size that is a multiple
   of clip_leaf's workgroup size. This was the approach taken by
   piet-gpu on its native HALs. This effectively wastes up to 4080 bytes
   (255 * 16) to store unused bbox values.

3. Enable Naga's implicit bounds checks when compiling to native. This
   would make the behavior consistent with the wgpu backend, however it
   comes at the cost of increased renderer complexity as the native
   implementation must supply the sizes of each buffer in an implicitly
   generated buffer binding to every shader stage.
2023-04-21 18:43:51 -07:00
Arman Uguray 23f26ef2a1 [svg] Log parse and render times separately
The examples logged the total processing time for an SVG including both
parse and GPU buffer encoding times. Times for these two operations are
now logged separately.
2023-04-21 18:31:20 -07:00
Arman Uguray 3d83bd7fa0
Merge pull request #307 from linebender/vello_encoding
vello_encoding crate
2023-04-19 12:25:42 -07: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 ad82519444 [vello_encoding] Use the vello_encoding crate in the vello renderer
Removed the workgroup count and buffer size calculations from
src/render.rs. This code now uses the types returned by the
vello_encoding crate for this purpose.
2023-04-18 14:46:16 -07:00
Arman Uguray 899ecaa430 Remove the reduced render method
This method was intended for the coverage mask variant of the pipelines
that was present in piet-gpu. This code has regressed since the wgpu
rewrite and the mask rendering variant of the pipelines will be
redesigned. Remove this for now instead of having to maintain it until
the rewrite.
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 6d2b98cade [vello_encoding] Re-export vello_encoding::Glyph from vello
This makes it so that users of the vello crate that use the Glyph type
don't need to directly depend on the vello_encoding crate.
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
Chad Brokaw b8e1bcfac3
Merge pull request #309 from linebender/fello-deps
Fix fello deps
2023-04-14 09:15:54 -04:00
Chad Brokaw 315ce5a372 pin tested revs 2023-04-14 09:00:06 -04:00
Chad Brokaw 9934adf94c
Fix fello deps
I let a transitive dependency get away from me. This should hopefully fix #308
2023-04-14 07:11:01 -04:00
Chad Brokaw 0e71aa1d0f
Merge pull request #265 from linebender/vello_shaders
`vello_shaders` crate for AOT compilation and lightweight integration with external renderer projects
2023-03-29 16:13:15 -04:00
Arman Uguray 0a6a6e2c21 [vello_shaders] Move vello_shaders to crates/shaders 2023-03-29 12:24:28 -07:00
Arman Uguray 64020a3f77 [vello_shaders] Fix typo in README 2023-03-29 11:23:06 -07:00
Arman Uguray d2b41d628b [vello_shaders] Add a README 2023-03-29 11:20:56 -07:00
Arman Uguray 7a99ae5a9e [vello_shaders] Add copyright headers 2023-03-29 11:20:38 -07:00
Arman Uguray eb1d4be36a [vello_shaders] Pin naga dependency 2023-03-29 11:20:15 -07:00
Arman Uguray 4f445c2e0a [vello_shaders] Provide workgroup shared memory allocation sizes
Naga traslates workgroup variable declarations to threadgroup
address-space entry-point parameters when generating MSL. Metal API
validation requires that the memory sizes for these parameters be set
explicitly by calling setThreadgroupMemoryLength:index on the
MTLComputeCommandEncoder.

The crate now calculates the required memory size for global workgroup
variables that are accessed by the entry point and provides them
alongside the binding list. This is abstracted separately from the
binding list.

While the current usage that we're aware of is limited to Metal, this
information is being provided as part of the generic ComputeShader type
instead of a MSL-specific type, as the information itself is computed
from the parsed WGSL IR and not specific to Metal.
2023-03-29 10:38:10 -07:00
Arman Uguray b52ef32c90 [vello_shaders] Use thiserror::Error for the library Error type 2023-03-29 10:38:10 -07:00
Arman Uguray 14ab8d90ae [vello_shaders] Use the per_entry_point_map option for MSL 2023-03-29 10:38:10 -07:00
Chad Brokaw 87803cc8a6 fmt 2023-03-29 10:38:10 -07:00
Chad Brokaw a532eacf7b Replace HashMap with sorted Vec so builds are deterministic 2023-03-29 10:38:10 -07:00
Chad Brokaw a5434569b6 fix build rerun path 2023-03-29 10:38:10 -07:00
Chad Brokaw 0db71153ad Playing with shader permutations and AOT compilation 2023-03-29 10:38:10 -07:00
Raph Levien 1a6add81b1
Merge pull request #298 from linebender/flower
Change image to flower
2023-03-22 18:13:31 -07:00
Raph Levien 8cfe903f7e Change image to flower
Using vector graphics for the image doesn't make a huge amount of sense. The flower photo is by Raph and happily licensed to anyone who wants to use it.
2023-03-22 15:53:44 -07:00
Chad Brokaw 4c5ff6b5bf
Merge pull request #297 from linebender/vello-fello
Replace font backend
2023-03-21 22:07:36 -04:00
Chad Brokaw eb8cc5275f Replace font backend
This replaces the old moscato font backend with one that has proper support for variable fonts.
2023-03-21 19:27:21 -04:00
Arman Uguray a1f319d090
Merge pull request #288 from armansito/frame-stats
Add frame statistics UI to with_winit example
2023-03-21 15:37:43 -07:00
Arman Uguray 703d22f4b7 [frame_stats] Use match statement for color coding graph 2023-03-21 15:29:16 -07:00
Arman Uguray 6f3051837f [frame_stats] Adapt the graph scale based on the current mean frame time
This allows the graph to display at a reasonable scale in the face of
fluctuations and a max recorded sample that is much larger than the
current average.
2023-03-21 15:16:45 -07:00
Arman Uguray e6f4f6de57 [frame_stats] Draw thresholds for 16.66ms, 33.33ms, and 8.33 timings
Also added color coding for the bar graph based on these thresholds.
2023-03-21 11:38:38 -07:00
Arman Uguray 5ba2826460 [frame_stats] Scale the frame time graph linearly
The sqrt scale doesn't add much value any more since the max frame time
can be reset with a keypress.
2023-03-21 11:34:33 -07:00
Arman Uguray 8bd1bdfaa8 [frame_stats] Use wgpu::PresentMode::AutoVsync/AutoNoVsync for VSync mode
The Auto* modes should have wider compatibility as they implement
fallback behavior based on what the platform supports. This also means
that on web "vsync off" will likely be incorrect.
2023-03-21 11:34:26 -07:00
Arman Uguray 02a222f435 [frame_stats] Reduce stats time delta between elapsed() and next frame start time
This does not account for the time spent in processing
`Stats::add_sample` but it should be very close.
2023-03-21 11:34:20 -07:00
Arman Uguray a1c0df1058 [frame_stats] Track frame time more tightly
We now track the frame time from snapshot to snapshot corresponding to
the exact presentation time.
2023-03-21 11:34:14 -07:00
Arman Uguray 1250cdcf86 [frame_stats] Add a VSync toggle key; show the current VSync state in stats UI 2023-03-21 11:34:08 -07:00
Arman Uguray 306aeab6df [frame_stats] Key binding to clear min/max frame time; address review comments 2023-03-21 11:34:01 -07:00
Arman Uguray 1ac4a4f1a8 [frame_stats] Draw a live plot of frame time samples
Also abandoned the FrameScope idea and revised the `Stats::add_sample`
to accept a struct to accept a variety of future measurements.
2023-03-21 11:33:50 -07:00
Arman Uguray bacaeebcb6 [frame_stats] Show viewport resolution on the stats layer
Also set the stats layer toggle to be on by default until we add some UI
to toggle it on mobile.
2023-03-21 11:33:43 -07:00