Commit graph

61 commits

Author SHA1 Message Date
Chad Brokaw 4b1f9d1921 remove timer 2022-12-08 12:45:45 -05:00
Chad Brokaw 4ea379aaa7 address feedback 2022-12-08 12:43:09 -05:00
Chad Brokaw e5081b51e4 remove unnecessary deps 2022-12-08 12:12:35 -05:00
Chad Brokaw c6b319aca0 fmt 2022-12-08 11:58:09 -05:00
Chad Brokaw 6bd644f7cc
Merge branch 'main' into raph-browser 2022-12-08 11:56:58 -05:00
Chad Brokaw 942817755c replace let with const on web 2022-12-08 11:53:35 -05:00
Raph Levien e2469fbcaa Increase sizes of binning buffers
Increase the size of the bin header and path buffers to accommodate the actual extents accessed by the shaders.

Also add a missing workgroup barrier, not essential to fixing this bug but found while auditing the code.

Fixes #222
2022-12-05 13:26:16 -08:00
Raph Levien 375f71b46d cargo fmt 2022-11-29 19:51:43 -08:00
Raph Levien 28816a027e Disable timing debug out
Time is not supported in the browser
2022-11-29 19:49:21 -08:00
Raph Levien c4274c7153 Tweak canvas aspect ratio 2022-11-29 19:42:52 -08:00
Raph Levien 340ac1d69c Hacky attempt to get running in browser 2022-11-29 19:36:05 -08:00
Raph Levien 876a3ad581 Combine info and bin_data buffers
We need to reduce the number of buffer bindings to 8 so it can run on
all WebGPU devices. The best candidate was to combine info and bin_data,
which are written by two different stages (draw_leaf and binning,
respectively), both read by coarse, and are unstructured, so the only
real shader change needed is to add the offset for the binning data.

I thought I was going to have to do a blit to make it fit, but
fortunately that wasn't needed.

Progress to #202
2022-11-29 17:39:22 -08:00
Raph Levien e8f8ebbd14 Squeeze pipeline to fit
This commit reduces the workgroup shared memory of binning to fit in
16k (by packing two u16's in a u32), and moves the config binding to
uniform, from readonly storage.

Progress toward #202
2022-11-29 17:23:12 -08:00
Chad Brokaw d13ec497e2 Address review feedback.
* add comment for ClipInp::path_ix
* update comment for SceneBuilder drawtags
* remove copy of blend data through info buffer. Instead, update EndClip's DrawMonoid::scene_offset to point to the same scene data of the associated EndClip.
2022-11-29 14:52:03 -05:00
Chad Brokaw 28082af9ec clip changes/blend group alpha
Adds blend group alpha. Also changes the clip logic to sync blend mode and alpha from BeginClip to EndClip in clip_leaf.
2022-11-29 13:28:25 -05:00
Chad Brokaw 6d8428e377 fix and offset bug and remove comment 2022-11-28 18:29:57 -05:00
Chad Brokaw c8ed14ae67 read gradient data from info buf 2022-11-28 18:20:29 -05:00
Chad Brokaw 923765aff9 Address review feedback
* Add comment about avoiding NaNs to inverse alpha divisions
* Change inverse alpha computations to use max(a, epsilon) rather than +
* Emit alpha component in blit fragment shader (enables support for partially transparent windows)
2022-11-28 14:07:26 -05:00
Chad Brokaw 4fea305883 Hodgepodge of small fixes
This just a collection of minor fixes to various things I noticed while looking over the code.

Adds a `Device::poll` call to the winit example.
Removes some lingering unnecessary `<f32>`s in the blit shaders.
Removes a duplicated bbox entry in the shared shader inclusion code and collapses nested `concat!`s.

Finally, it reintroduces the computation of separated alpha in the output of fine which I removed in a previous PR. This allows the `render_to_texture` mode to be useful for generating images that can be properly blended over other content. The blit shader has been changed to accommodate this.
2022-11-28 00:03:02 -05:00
Daniel McNab c689767782
Remove the old pipeline (#209)
Remove the old hal and pipeline. 

Update the README to reflect this
2022-11-27 16:02:16 +00:00
Raph Levien 2338e3bedd Fix style nit 2022-11-26 17:07:23 -08:00
Raph Levien 3c0752f6ae Fix rendering artifacts with strokes
A number of things weren't being computed correctly for strokes,
including bounding boxes and also incorrectly applying y_edge logic
(which is only correct for fills).
2022-11-26 16:51:22 -08:00
Chad Brokaw 9ad7f7270e revert rename of SceneBuilder ctors 2022-11-26 16:00:34 -05:00
Chad Brokaw 36fa836735 include shaders in source 2022-11-26 15:51:07 -05:00
Chad Brokaw a4441007c4 make use of Result type in RenderContext 2022-11-26 14:56:43 -05:00
Chad Brokaw 3174e284f2 remove double && 2022-11-26 14:53:51 -05:00
Chad Brokaw 37a9763748 fix longstanding annoying in SceneBuilder ctor
SceneBuilder::new() now takes &mut Scene or &mut SceneFragment
2022-11-26 14:38:26 -05:00
Chad Brokaw 016f9de05f Libify piet-wgsl
This creates a new Renderer type that offers fairly simple render_to_texture and render_to_surface methods, the latter of which handles the final blit internally. Also adds a util module with some helpers for device and surface creation.

There is a new winit example in piet-wgsl/examples/winit that shows how to make use of it all. This should be fairly trivial to adapt to glazier/xilem.
2022-11-26 14:27:19 -05:00
Chad Brokaw ff4f71ef3c wgsl port in realtime
* add writeable image support to engine
* add external resources to engine
* update fine to output to a texture
* copy over original piet-gpu test scenes
* put it all in a pretty (resizable!) window
2022-11-25 17:16:56 -05:00
Raph Levien 09aa38799d More cleanup
Missed a few cases (and I'm still not 100% sure I've got them all).
2022-11-25 09:51:11 -08:00
Raph Levien 94a310a245 Clean up unneded type annotations in vec
Now that wgsl-analyzer 0.6 is released, most explicit type annotations on vec can be dropped (the exception being when it is a type conversion).

Also changes mix to select when the selector is actually boolean.
2022-11-25 09:37:11 -08:00
Daniel McNab 7d5063b187
Remove all wgsl-analyzer errors (#210)
* Fix missing import

* Format
2022-11-25 16:43:21 +00:00
Chad Brokaw 5dbeb992e9
Merge pull request #208 from dfrg/peniko
Update piet-scene to depend on peniko
2022-11-23 17:06:26 -05:00
Daniel McNab 0755e8bfaa Allow arbitrary output sizes (#206)
* Support basic resizing

* Fix resizing
2022-11-23 19:32:30 +00:00
Chad Brokaw fc1a6e9e4e update for improved kurbo/peniko ergonomics
also removes some annoying lingering tabs from blend.wgsl
2022-11-23 12:50:28 -05:00
Chad Brokaw c1e91cb233 prevent encoding empty paths for layers too 2022-11-22 15:17:50 -05:00
Chad Brokaw f19dbdb1b5 Update piet-scene to depend on peniko
This adds a new dependency on peniko, reintroduces kurbo for geometry (!), removes the now defunct types from piet-scene and updates all the test scenes to use the new types.
2022-11-22 14:49:51 -05:00
Elias Naur 18c0da02e5
Clarify licensing for WGSL shaders (#205)
As stated by the README, the intention is for the shaders to be
provided under the terms of the Unlicense in addition to the MIT
and Apache-2.0 licenses.

While here, add a self-contained UNLICENSE file to replace the
external reference to unlicense.org.
2022-11-19 16:45:42 +00:00
Chad Brokaw adc9811776 add clips and blends 2022-11-18 17:26:26 -05:00
Chad Brokaw 9adeaf3e82 format 2022-11-16 12:02:11 -05:00
Chad Brokaw 20f7b68514 finish gradient support 2022-11-16 10:49:38 -05:00
Raph Levien ef3ed3c9d7 Checkpoint of clip and gradient work
This is a checkpoint of partly completed work. Much of the GPU side is done, very little of the CPU side.

For clips, the clip_els bindings (binding 6 of draw_leaf) are not added. Clip logic is missing from coarse. The overflow buffer is missing from fine, as is its size calculation in coarse (but it should work as long as the max depth fits within BLEND_STACK_SPLIT).

For gradients, the texture binding is missing (binding 6) is missing from fine, as is the infrastructure in engine to deal with texture resources, and of course porting over the logic to fill it.

The code is not tested, bugs may lurk.
2022-11-10 19:48:36 -08:00
Raph Levien 5bd3a3639f Fix precedence issue
Note that this is evidence in favor of https://github.com/gfx-rs/naga/issues/2098 - my code is actually wrong, and it was caught by trying to port it to run in Chrome Canary.
2022-11-08 19:30:47 -08:00
Raph Levien 494f523c41 Tiger!
Still one flaw, fat lines aren't expanded with strokes in path coarse rasterization. But that's a small visual ding, and can be fixed

That said, there is some really strange stuff going on in tile_alloc. It's using storage to do a uniform broadcast (the result of bump allocation for the workgroup), which is not great at all. It should be using workgroup storage, but on my mac it behaves as if the workgroup barrier is not in place. Investigating.
2022-11-04 21:41:37 -07:00
Raph Levien 17a74fb370 Almost rendering tiger
We cut'n'pasted the picosvg stuff, kinda ugly.

It renders a number of paths of the tiger. I think the gap might be in prefix sums.
2022-11-04 13:15:05 -07:00
Raph Levien 7ae5aa7491 Mostly working strokes
The fat line in coarse path rendering is not done, but when lines are thin that mostly looks ok. Onward to tiger!
2022-11-04 12:40:54 -07:00
Raph Levien 92d6b1188f Fix color
Get rgba order right in rendering, plus generate separated alpha for png. The latter is just for debugging, we won't generally use separated alpha.
2022-11-04 09:25:06 -07:00
Raph Levien c3d81e0985 Mostly working path rendering
It draws multiple paths and applies affine transformations.

One problem: RGBA writing is byte-reversed and premultiplied.
2022-11-04 08:59:23 -07:00
Raph Levien 06fa3cb9ab Checkpoint
Felt like checkpointing what I have before trying to run the pipeline. Theoretically everything should work.
2022-11-03 19:37:38 -07:00
Raph Levien 5851ef1417 Shaders loaded
This checkpoint loads the shaders for full rendering, but there's a bunch of stuff still needing to be done.
2022-11-03 16:53:34 -07:00