Commit graph

552 commits

Author SHA1 Message Date
Raph Levien bfa4abf642
Merge pull request #181 from linebender/mem2
Implement robust dynamic memory
2022-07-14 07:27:38 -07:00
Raph Levien 78bdd08f01 Add ref_name to commit message 2022-07-14 07:25:18 -07:00
Commit by GitHub Action cac14a0aa7 merge from dev branch 2022-07-14 04:33:57 +00:00
Raph Levien d5b04a69dd
Merge pull request #183 from linebender/winit_0_26
Update winit to 0.26.1
2022-07-13 21:33:11 -07:00
Raph Levien 1a20fe78f6 Portability fixes
Makes the changes work on Windows and Android.
2022-07-13 17:43:28 -07:00
Raph Levien 61598d2da0 Gather timing statistics from RenderDriver
Also change command line binaries to use new abstraction.
2022-07-13 17:01:48 -07:00
Raph Levien 169f053003 Update winit to 0.26.1
This is mostly to silence security warnings about a nix vulnerability.
2022-07-13 12:45:17 -07:00
Raph Levien 9930c9d1de rustfmt 2022-07-13 12:35:21 -07:00
Raph Levien 240f44a228 Implement robust dynamic memory
This is the core logic for robust dynamic memory. There are changes to both shaders and the driver logic.

On the shader side, failure information is more useful and fine grained. In particular, it now reports which stage failed and how much memory would have been required to make that stage succeed.

On the driver side, there is a new RenderDriver abstraction which owns command buffers (and associated query pools) and runs the logic to retry and reallocate buffers when necessary. There's also a fairly significant rework of the logic to produce the config block, as that overlaps the robust memory.

The RenderDriver abstraction may not stay. It was done this way to minimize code disruption, but arguably it should just be combined with Renderer.

Another change: the GLSL length() method on a buffer requires additional infrastructure (at least on Metal, where it needs a binding of its own), so we now pass that in as a field in the config.

This also moves blend memory to its own buffer. This worked out well because coarse rasterization can simply report the size of the blend buffer and it can be reallocated without needing to rerun the pipeline. In the previous state, blend allocations and ptcl writes were interleaved in coarse rasterization, so a failure of the former would require rerunning coarse. This should fix #83 (finally!)

There are a few loose ends. The binaries haven't (yet) been updated (I've been testing using a hand-written test program). Gradients weren't touched so still have a fixed size allocation. And the logic to calculate the new buffer size on allocation failure could be smarter.

Closes #175
2022-07-13 12:34:51 -07:00
Commit by GitHub Action f6ea9308ba commit compiled shaders 2022-07-13 19:27:07 +00:00
Raph Levien 64e6268059 Remove generated shaders from dev branch 2022-07-13 12:22:11 -07:00
Raph Levien b77df99159
Merge pull request #178 from linebender/ci2
Shader compilation in GitHub Actions
2022-07-13 12:21:37 -07:00
Raph Levien 57b94a3bed
Merge pull request #180 from DJMcNab/pgpu_render_not_apple
Make `pgpu-render`  compile on non apple platforms
2022-07-13 12:10:47 -07:00
Raph Levien db49bed50c Doc improvements
Explain the shader compilation approach. Also add links while I'm at it.
2022-07-13 12:07:55 -07:00
Raph Levien a2f9e106cc Cover all generated shader directories
Also remove 'shader/gen' gitignore line in main (it's present in dev).
2022-07-13 11:22:04 -07:00
Raph Levien 52f1ab228b Merge branch 'main' into ci2 2022-07-13 10:40:46 -07:00
Raph Levien b8b4aad9c4
Merge pull request #179 from linebender/desc_update
Add HAL methods to update descriptor set
2022-07-11 08:25:38 -07:00
Daniel McNab 35fe9b4d1f Disable the android example when not compiling for android 2022-06-25 14:16:20 +01:00
Daniel McNab 28cbc8f199 Make pgpu-render compile on non apple platforms
Also add `resolver="2"` to the entire workspace, in case we gain a wgpu
dependency
2022-06-25 14:11:13 +01:00
Raph Levien b5b75cc42d Add Vulkan and DX12 backends to descriptor update 2022-06-23 15:44:42 -07:00
Raph Levien 95081971fe Add HAL method to update buffer descriptor
This is WIP because only the Metal implementation is added.

Part of the work for #175
2022-06-23 12:05:09 -07:00
Raph Levien 682e4b769f Shader compilation in GitHub Actions
This patch sets up very basic CI (right now just cargo fmt) but more importantly compiles shaders in a GitHub Action.

Any PR to branches other than main will run shader compilation. Any push to the dev branch will run shader compilation and then merge to main.

Closes #177
2022-06-16 21:19:39 -07:00
Raph Levien 60d197bb4e
Merge pull request #173 from linebender/blend_mem
Blend mem
2022-05-20 14:27:58 -07:00
Raph Levien 9df486ef35 Fix blend memory issues 2022-05-20 14:02:24 -07:00
Raph Levien 368954a643 Merge branch 'master' into blend_mem
This does the merge and also rebuilds the generated shaders.
2022-05-19 15:42:45 -07:00
Raph Levien a4299c1f02
Merge pull request #172 from linebender/query_pool_size
Fix query pool size
2022-05-19 15:39:31 -07:00
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