Commit graph

522 commits

Author SHA1 Message Date
Raph Levien 7134be2329 Fix missing blend/clip logic
We always do BeginClip/EndClip if it's a solid tile and the blend mode
is not default.

Also fix missing entry in pipeline layout (affects Vulkan but not Metal).
2022-03-16 14:40:58 -07:00
Raph Levien acb3933d94 Variable size encoding of draw objects
This patch switches to a variable size encoding of draw objects.

In addition to the CPU-side scene encoding, it changes the representation of intermediate per draw object state from the `Annotated` struct to a variable "info" encoding. In addition, the bounding boxes are moved to a separate array (for a more "structure of "arrays" approach). Data that's unchanged from the scene encoding is not copied. Rather, downstream stages can access the data from the scene buffer (reducing allocation and copying).

Prefix sums, computed in `DrawMonoid` track the offset of both scene and intermediate data. The tags for the CPU-side encoding have been split into their own stream (again a change from AoS to SoA style).

This is not necessarily the final form. There's some stuff (including at least one piet-gpu-derive type) that can be deleted. In addition, the linewidth field should probably move from the info to path-specific. Also, the 1:1 correspondence between draw object and path has not yet been broken.

Closes #152
2022-03-14 16:32:08 -07:00
Chad Brokaw 547672ab01
Merge pull request #157 from dfrg/master
Initial implementation of blend modes
2022-03-14 15:31:21 -04:00
Raph Levien 90774f1f46 Regenerate generated shaders
This just runs ninja on the piet-gpu/shaders on a Windows machine, so
translated shaders match the existing pipeline.

At some point, we'll rework this to reduce friction.
2022-03-07 12:49:59 -08:00
Chad Brokaw d3b08e4c52 Initial implementation of blend modes
* Add blend and composition mode enums to API
* Mirror these in the shaders
* Add new public blend function to PietGpuRenderContext that mirrors clip
* Plumb the modes through the pipeline from scene to kernel4
2022-02-28 12:38:14 -05:00
Raph Levien d81e5cb4ee
Merge pull request #150 from linebender/clip
New clip implementation
2022-02-21 13:23:31 -08:00
Raph Levien 3b67a4e7c1 New clip implementation
This PR reworks the clip implementation. The highlight is that clip bounding box accounting is now done on GPU rather than CPU. The clip mask is also rasterized on EndClip rather than BeginClip, which decreases memory traffic needed for the clip stack.

This is a pretty good working state, but not all cleanup has been applied. An important next step is to remove the CPU clip accounting (it is computed and encoded, but that result is not used). Another step is to remove the Annotated structure entirely.

Fixes #88. Also relevant to #119
2022-02-17 17:13:28 -08:00
Raph Levien a968f13382
Merge pull request #144 from linebender/mtl_guest
First cut at glyph rendering API
2022-02-14 16:12:00 -08:00
Raph Levien 43c5ed29b2 Fix generated shaders 2022-02-07 17:30:17 -08:00
Raph Levien 012d679e3d Merge branch 'master' into mtl_guest 2022-02-07 17:28:52 -08:00
Raph Levien b2e7c80d3b Fix non-mac builds
Also updates comment.

We know the implementation is incomplete and needs refinement, but it
seems useful to commit as a starting point for further work.
2022-02-07 13:54:24 -08:00
Tatsuyuki Ishi 8bee553e6e
Merge pull request #147 from ishitatsuyuki/clang-format 2022-02-01 10:13:30 +09:00
Tatsuyuki Ishi 53ec958137
Merge pull request #145 from ishitatsuyuki/ninja-targets 2022-02-01 10:13:11 +09:00
Tatsuyuki Ishi a7e926d67b shaders: Add .clang-format and reformat
Helps keeping the code tidy.

Style is chosen to minimize diff, but contains a slight bit of personal taste.
2022-01-30 16:33:14 +09:00
Tatsuyuki Ishi 1823ea6f2f
Merge pull request #146 from ishitatsuyuki/profiling 2022-01-22 10:53:15 +09:00
Tatsuyuki Ishi b5ffecba17 piet-gpu, hal: Add Vulkan debug markers
Other backends are left as stub for now.

Makes it easier to identify stages within Radeon GPU Profiler and others.
2022-01-21 11:34:34 +09:00
Tatsuyuki Ishi 2bdca399ab piet-gpu: Add phony targets for spv, dxil and msl
Makes building without dxc or spirv-cross easier.
2022-01-20 19:34:05 +09:00
Raph Levien 2613a7e500 Add generated kernel4_gray shaders 2022-01-19 12:18:39 -08:00
Raph Levien 0cf370f9c7 Mostly working rendering
This exposes interfaces to render glyphs into a texture atlas. The main changes are:

* Methods to plumb raw Metal GPU resources (device, texture, etc) into piet-gpu-hal objects.

* A new glyph_render API specialized to rendering glyphs. This is basically the same as just painting to a canvas, but will allow better caching (and has more direct access to fonts, bypassing the Piet font type which is underdeveloped).

* Ability to render to A8 target in addition to RGBA.

WIP, there are some rough edges, not least of which is that the image format changes are only on mac and cause compile errors elsewhere.
2022-01-19 12:10:51 -08:00
Raph Levien 833d993a4e More progress exposing interface
Much of the surface area exists for rendering now.

WIP of course still
2022-01-18 18:41:28 -08:00
Raph Levien 5e221d2e91 Add capability to function as a guest in Metal
WIP
2022-01-13 17:36:08 -08:00
Raph Levien 41c7118e91
Merge pull request #138 from linebender/new_element
Beginnings of new element pipeline
2021-12-15 09:03:29 -08:00
Raph Levien 9601989152 Tweak linguist settings
Mark shader/gen subdirectories as autogenerated to avoid cluttering diffs.
2021-12-08 12:49:40 -08:00
Raph Levien d948126c16 Adjust workgroup sizes
Make max workgroup size 256 and respect LG_WG_FACTOR.

Because the monoid scans only support a height of 2, this will reduce
the maximum scene complexity we can render. But it also increases
compatibility. Supporting larger scans is a TODO.
2021-12-08 11:48:38 -08:00
Raph Levien 75496f5e67 Fix draw test
We'll revert this later, but for now trying to keep tests green.
2021-12-08 10:38:46 -08:00
Raph Levien 49c3a3923b Restore gradients and clips
This changes gradients and clips to the new encoding. Lightly tested.
2021-12-07 18:39:33 -08:00
Raph Levien 5585b3563c Account path tags correctly 2021-12-06 15:59:32 -08:00
Raph Levien 55395fa533 Get text working
This wires up the text rendering. WIP though, as it tends to get stuck.
Not sure if that's text related or just being triggered by it.
2021-12-06 11:08:58 -08:00
Raph Levien 3ee81ad5a9 Fixes for mac
Fix incorrect workgroup sizes, and change strategy for assigning binding
numbers; ultimately we should get correct values for those from shader
compilation, but this works for now.
2021-12-03 20:40:15 -08:00
Raph Levien 395d400cd1 Remove debug printing 2021-12-03 16:35:57 -08:00
Raph Levien 7f3427420b Partial DX12 fixes
As of this patch, cli works in release mode, but hangs in debug. There
are some validation errors about incompatible resouce states.
2021-12-03 16:24:30 -08:00
Raph Levien c503ff28b0 Make shaders cross-platform
Translate all piet-gpu shaders into DXIL and MSL; move generated files
into the shader/gen directory.
2021-12-03 15:49:58 -08:00
Raph Levien 44327fe49f Beginnings of new element pipeline
This successfully renders the tiger; fills and strokes are supported.
Other parts of the imaging model, not yet.

Progress toward #119
2021-12-03 15:33:01 -08:00
Raph Levien 22b86072f2
Merge pull request #137 from linebender/draw_element
Add draw object stage
2021-12-03 15:32:51 -08:00
Raph Levien 875c8badf4 Add draw object stage
This is one of the stages in the new element pipeline. It's a simple
one, just a prefix sum of a couple counts, and some of it will probably
get merged with a downstream stage, but we'll do it separately for now
for convenience.

This patch also contains an update to Vulkan tools 1.2.198, which
accounts for the large diff of translated shaders.
2021-12-02 13:37:16 -08:00
Raph Levien 50153a7797
Merge pull request #136 from linebender/path_element
Path stream processing
2021-12-02 13:36:34 -08:00
Raph Levien 70723bf076 Very minor reorg
Move transform stage into its own file, cargo fmt.
2021-12-01 15:46:36 -08:00
Raph Levien 1d1801c1aa Cross-platform path stage shaders 2021-12-01 08:42:06 -08:00
Raph Levien 8af4707525 Fix uninitialized variable 2021-12-01 08:34:41 -08:00
Raph Levien 178761dcb3 Path stream processing
This patch contains the core of the path stream processing, though some
integration bits are missing. The core logic is tested, though
combinations of path types, transforms, and line widths are not (yet).

Progress towards #119
2021-12-01 07:33:24 -08:00
Raph Levien 5ea5c4bb9a
Merge pull request #135 from linebender/bufwrite
Access buffer data through mapping
2021-12-01 07:06:29 -08:00
Raph Levien a7a5b84c86 Clean up stray files 2021-11-30 10:34:42 -08:00
Raph Levien 3039a2ac39 Merge branch 'master' into bufwrite 2021-11-30 10:31:16 -08:00
Raph Levien 0880975c5b
Merge pull request #134 from linebender/new_element
Start work on new element pipeline
2021-11-30 10:20:56 -08:00
Raph Levien 97bc4c4471 Tweak BufWrite::push
Make it pass the value, not a reference, to more closely match Vec's
behavior.  It's not a big difference because the type is `Copy`, but
still better.
2021-11-26 07:50:45 -08:00
Raph Levien f1d7560b3c Tweak extend implementation
The one that takes T is more useful than the one that takes references
to T. When specialization lands, we will be able to have both under the
`extend` name.
2021-11-25 22:02:04 -08:00
Raph Levien ac0fb228c1 Fix Metal port 2021-11-25 21:34:06 -08:00
Raph Levien 9fb2ae91eb Access buffer data through mapping
This patch includes a number of changes to encourage reading and writing
buffers through mapping rather than copying data as before.

This includes a new `BufWrite` abstraction which is designed for filling
buffers. It behaves much like a Vec<u8>, but with fixed capacity.
2021-11-25 21:27:08 -08:00
Raph Levien 8f7ed161a6 Tune transform test parameters
Previous threshold was seeing occasional failures, and also fairly wide
variance in the error. This seems to be reliable, but hasn't been
validated extremely rigorously.
2021-11-24 09:40:52 -08:00
Raph Levien 5af8aa5e52
Merge pull request #133 from linebender/bytemuck
Use bytemuck
2021-11-24 08:02:22 -08:00