Commit graph

602 commits

Author SHA1 Message Date
Chad Brokaw 3ff87c88a7 Make return value mutable
Changes the return mutability for pgpu_glyph_provider_get()
2022-05-10 03:59:31 -04:00
Chad Brokaw 532b6ee808 Add C api for glyph rendering
First cut at a public C api that supports glyph rendering on Metal targets.
2022-05-10 03:56:06 -04:00
Chad Brokaw b178741c19 Merge branch 'fragments' of https://github.com/dfrg/piet-gpu into fragments 2022-05-10 00:53:58 -04:00
Chad Brokaw e12b063cd3 Add Renderer::upload_scene()
This allows rendering from raw stream data and may be temporary depending on the crate structure after the traditional piet api is removed.
2022-05-10 00:53:48 -04:00
Chad Brokaw 7f3639b15a
Merge branch 'linebender:master' into fragments 2022-05-09 22:40:48 -04:00
Chad Brokaw c749addf6c rebase on timer query patch 2022-05-09 22:39:59 -04:00
Chad Brokaw 05624de19d
Merge pull request #164 from linebender/metal_timer
Timer queries on more platforms, particularly Metal
2022-05-05 13:56:18 -04:00
Chad Brokaw f2e8c32876 Erase remaining commented write_timestamp() 2022-05-04 02:03:25 -04:00
Chad Brokaw 60bca997e5 Remove deprecated functions
* remove CmdBuff::dispatch() which was moved to ComputePass

* remove CmdBuff::write_timestamp() which is replaced by timestamp index pair in ComputePassDescriptor
2022-05-04 01:59:49 -04:00
Chad Brokaw 41316ccd4b Add debug label functions to ComputePass 2022-05-04 01:56:16 -04:00
Chad Brokaw ba7f85731c add glyph provider API
This exposes a new uniform API for generating scene fragments for glyph outlines.
2022-05-02 04:15:48 -04:00
chad 867b97f41d Detect metal counter sampling style
Use MTLDevice::supports_counter_sampling() to select the appropriate counter style.
2022-04-25 02:34:19 -04:00
chad 02cc867950 command style metal timer queries + compute pass
This commit adds timestamps to compute pass boundaries for command style timer queries on metal.

It also updates the code in piet-gpu/stages, piet-gpu/lib.rs and tests/ to use the new ComputePass type.
2022-04-21 04:20:54 -04:00
Raph Levien ea0fbab8aa Add memory barrier to ComputePass
We need to be able to call memory_barrier() on ComputePass, to avoid the borrow checker complaining if we tried to call it on the underlying command buffer.
2022-04-20 15:13:54 -07:00
Raph Levien 5a9b8d9243 Start applying compute pass to tests
Use compute pass for tests in tests subdir. This is also shaking out some issues that weren't apparent from just collatz.

In particular, we need more autorelease pools to prevent things from leaking. As of this commit, the "clear" test runs correctly but the others haven't yet been converted to the compute_pass format.
2022-04-20 13:45:42 -07:00
Raph Levien 58836244a4 Change signature of ComputePass::end() to self
As per review comment.
2022-04-20 09:19:22 -07:00
Raph Levien 8cf09f4db3
Merge pull request #160 from linebender/radial-commit
Radial gradients
2022-04-18 09:16:18 -07:00
Chad Brokaw d243d38b04 render using the new scene API
This commit implements actual rendering for the new piet-scene crate.

In particular, it adds a new EncodedSceneRef type in piet_gpu::encoder to store references to the raw stream data. This is used as a proxy for both PietGpuRenderContext and piet_scene::scene::Scene to feed data into the renderer.

Much of this is still hacky for expedience and because the intention is to be a transitional state that maintains both interfaces until we can move to the new scene API and add a wrapper for the traditional piet API.

The general structure and relationships between these crates need further discussion.
2022-04-18 03:48:10 -04:00
Raph Levien 9980c858b6 Fix timer queries in Vulkan and DX12 backends
Current status: the piet-gpu-hal module (including the collatz example)
have the new API (with queries set on compute pass) implemented. The
other uses have not yet been updated.

On Metal, only M1 is tested. The "command" counter style is partly
implemented, but not fully wired up.
2022-04-14 17:17:33 -07:00
Raph Levien ba2b27cc3c Rework of compute encoder abstraction
The current plan is to more or less follow the wgpu/wgpu-hal approach. In the mux/backend layer (which corresponds fairly strongly to wgpu-hal), there isn't explicit construction of a compute encoder, but there are new methods for beginning and ending a compute pass. At the hub layer (which corresponds to wgpu) there will be a ComputeEncoder object.

That said, there will be some differences. The WebGPU "end" method on a compute encoder is implemented in wgpu as Drop, and that is not ideal. Also, the wgpu-hal approach to timer queries (still based on write_timestamp) is not up to the task of Metal timer queries, where the query offsets have to be specified at compute encoder creation. That's why there are different projects :)

WIP: current state is that stage-style queries work on Apple Silicon, but non-Metal backends are broken, and piet-gpu is not yet updated to use new API.
2022-04-14 10:19:28 -07:00
Raph Levien 290d5d2e13 More progress
This puts most of the infrastructure in place but I'm hitting an error
that "sampleCountersInBuffer is not supported on this device".

The issue is that M1 supports stage boundaries and not command boundaries.
We'll have to rework the logic a bit. (And, in the most general case, support
both)

Start implementing stage boundaries, but it will probably require an API
change.
2022-04-11 13:07:46 -07:00
Chad Brokaw db2c4d21c9 Remove unused path representation 2022-04-11 06:14:58 -04:00
Chad Brokaw f8f91e4207 Add layer encoding 2022-04-11 06:05:40 -04:00
Chad Brokaw 753b97c342 Rebase on radial branch 2022-04-11 05:30:08 -04:00
Raph Levien 4458e36efa Start implementing timer queries in Metal 2022-04-08 16:10:53 -07:00
Raph Levien 38b44b13c4
Merge pull request #162 from simbleau/issue-161
Factored out file loading on render tick for winit bin
2022-04-05 07:45:05 -07:00
Spencer Imbleau 18d6c39f14 Factored out file loading on render tick for winit bin 2022-04-04 16:09:24 -04:00
Raph Levien 0f91149b49 Radial gradients
This patch adds radial gradients, including both the piet API and some
new methods specifically to support COLRv1, including the ability to
transform the gradient separately from the path.
2022-03-30 20:32:13 -07:00
Raph Levien 7a8d41455a
Merge pull request #159 from linebender/varenc
Variable size encoding of draw objects
2022-03-30 20:27:56 -07:00
Raph Levien 05dc88b70f Fix is_clip nit
Not necessary to test is_clip when is_blend is set.

Also recompiles shaders on Windows machine.
2022-03-30 07:27:29 -07:00
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