Commit graph

676 commits

Author SHA1 Message Date
Raph Levien d62a40ea34
Update piet-gpu/bin/cli.rs
Co-authored-by: Chad Brokaw <cbrokaw@gmail.com>
2022-05-19 15:35:15 -07:00
Raph Levien 693ecd69e1 Make query pool size an associated constant 2022-05-19 15:28:46 -07:00
Chad Brokaw 663607dd12
Merge pull request #171 from dfrg/kurbo_conv
Add kurbo conversions to scene API
2022-05-19 18:18:47 -04:00
Chad Brokaw 5252a33c5d Oops. Delete one remaining lossy conversion 2022-05-19 18:16:30 -04:00
Chad Brokaw d30750e8a7 Remove poorly named functions
Moves the more descriptive comments to the free functions.
2022-05-19 18:07:07 -04:00
Chad Brokaw 39b773c611 Replace lossy conversions with methods 2022-05-19 18:04:00 -04:00
Raph Levien ccac8f1ddd
Merge pull request #169 from linebender/fix_blends
Fix blending math
2022-05-19 14:35:00 -07:00
Raph Levien ee6694729b Fix query pool size
This was causing harmless warnings on mac but causing rendering to fail
on Pixel 6.
2022-05-19 14:31:00 -07:00
Chad Brokaw 938d6fc052 Add clip mode for blends
This matches the changes in the fix_blends PR.
2022-05-19 16:59:14 -04:00
Chad Brokaw 7f37355ba0
Merge branch 'linebender:master' into kurbo_conv 2022-05-18 19:05:04 -04:00
Raph Levien 708cb3d0b8
Merge pull request #170 from armansito/fix-links
Fix some broken links in vision document
2022-05-18 15:42:01 -07:00
Raph Levien aac6513409 Compile shaders on Windows
Updates DXIL on generated shaders.
2022-05-18 15:41:00 -07:00
Chad Brokaw a20dd43b39 Updates to scene/fragment builder
* Add impl Into<Affine> for pushing transforms.
* Small QOL API changes to Scene and Fragment.
* Add some missing docs.
2022-05-18 16:26:31 -04:00
Chad Brokaw e600bdbbe4 Remove PlusDarker composition mode
Reassigns value 13 to PlusLighter to match the upcoming blend fixes
2022-05-18 16:23:17 -04:00
Chad Brokaw 94f7b51bc5 Add kurbo conversions
Adds kurbo as an optional dependency and implements conversions to/from the common types.

This also removes the direct pinot dependency and changes moscato (temporarily) to a git based dep to allow iteration on the underlying glyph loading code without PR churn here.
2022-05-18 16:22:27 -04:00
Arman Uguray 0699c6b5af Fix some broken links in vision document 2022-05-18 15:03:18 -04:00
Raph Levien 307bf8d227 More blend mode fixes
Adds a test to visualize the blend modes. Fixes a dumb bug in blend.h and also a more subtle issue where default blending is not the same as clipping, as the former needs to always push a blend group (to cause isolation) and the latter does not. This might be something we need to get back to.

This should fix the rendering, so it fairly closely resembles the Mozilla reference image. There's also a compile-time switch to disable sRGB conversion, which is (sadly) needed for compatible rendering.
2022-05-17 16:12:05 -07:00
Raph Levien e73049fe98 First cut at split blend stack
Split the blend stack into register and memory segments. Do blending in registers up to that size, then spill to memory if needed.

This version may regress performance on Pixel 4, as it uses common memory for the blend stack, rather than keeping that memory read-only in fine rasterization, and using a separate buffer for blend stack. This needs investigation. It's possible we'll want to have single common memory as a config option, as it pools allocations and decreases the probability of failure.

Also a flaw in this version: there is no checking of memory overflow.

For understanding code history: this commit largely reverts #77, but there were some intervening changes to blending, and this commit also implements the split so some of the stack is in registers.

Closes #156
2022-05-16 11:12:33 -07:00
Raph Levien 18563101b2 Fix blending math
The blending math had two errors: first, colors were not separated for the purpose of blending (blending was wrongly applied to premultiplied values), and second, alpha was applied over-aggressively to the alpha channel.

This PR does *not* address the issue of gamma correctness. That is a complex issue and should probably be handled in the short term by disabling sRGB conversions and doing the internal math in sRGB color space rather than linear. This will degrade the quality of antialiasing but on the other hand give spec-compliant results for compositing.

We remove the plus-darker mode as its specification does not appear to be valid. The plus-lighter mode remains as it is quite useful for cross-fading effects.

Also the generated shaders were compiled on mac so the DXIL is unsigned. Those should be compiled on Windows before this PR is merged. (and we should figure out a better strategy for all that)
2022-05-13 10:18:29 -07:00
Chad Brokaw f5a721d92b
Merge pull request #168 from dfrg/fragments
New scene/resource API
2022-05-11 15:45:12 -04:00
Chad Brokaw 3afe2eaac2 Fix transform stack bugs in color glyph loader 2022-05-11 14:39:09 -04:00
Chad Brokaw 6f9e53459a Address review feedback
* Change pgpu-render header file generator to add a comment noting that the file is auto-generated
* Remove bin target and associated dependencies from piet-scene crate
* Remove FP constructors from the Color type
* Better codegen and rounding in Color::to_premul_u32()
* Add kurbo attribution for piet_scene::geometry module
2022-05-10 20:07:41 -04:00
Chad Brokaw a9356cc50b Change color packing to match target format 2022-05-10 04:19:36 -04:00
Chad Brokaw c95887b4df Change metal format to BGRA8Unorm
This should fix channel swizzling on M1 and restore functionality on Intel
2022-05-10 04:09:02 -04:00
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