Commit graph

275 commits

Author SHA1 Message Date
Chad Brokaw 2c258363ad restore tile.h to maintain sync with tile.rs 2022-07-16 16:48:04 -04:00
Chad Brokaw 8943fa7ea6 encode absolute transforms
This removes the GPU transform stage, changes shaders to reference transforms directly from the scene, and modifies the render context to maintain a transform stack.
2022-07-15 14:36:20 -04:00
Chad Brokaw d6ffe970f9 Make graphics support non-optional for Vulkan
This also removes the new present flag, deletes some commented code and explains the lack of surface validation in device selection.
2022-07-15 13:14:12 -04:00
Chad Brokaw fb952de1f3
Update piet-gpu/bin/android.rs
Co-authored-by: Raph Levien <raph.levien@gmail.com>
2022-07-15 12:49:40 -04:00
Chad Brokaw 58721dc5c2 fix new API use for android example 2022-07-14 15:03:27 -04:00
Chad Brokaw 8de34f8728 remove shader gen directories 2022-07-14 14:57:17 -04:00
Chad Brokaw 9626eaa19b separate instance and surface creation
This separates creation of Instance and Surfaces, allowing for rendering to multiple windows.
2022-07-14 14:46:46 -04:00
Commit by GitHub Action bbdd4432f5 commit compiled shaders 2022-07-14 14:28:45 +00:00
Commit by GitHub Action d529d3b0e8 merge from dev branch - dev 2022-07-14 14:28:25 +00:00
Raph Levien bfa4abf642
Merge pull request #181 from linebender/mem2
Implement robust dynamic memory
2022-07-14 07:27:38 -07:00
Commit by GitHub Action cac14a0aa7 merge from dev branch 2022-07-14 04:33:57 +00: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 db49bed50c Doc improvements
Explain the shader compilation approach. Also add links while I'm at it.
2022-07-13 12:07:55 -07:00
Daniel McNab 35fe9b4d1f Disable the android example when not compiling for android 2022-06-25 14:16:20 +01: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
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
Raph Levien aac6513409 Compile shaders on Windows
Updates DXIL on generated shaders.
2022-05-18 15:41:00 -07: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 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 c749addf6c rebase on timer query patch 2022-05-09 22:39:59 -04: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
Chad Brokaw 753b97c342 Rebase on radial branch 2022-04-11 05:30:08 -04:00
Spencer Imbleau 18d6c39f14 Factored out file loading on render tick for winit bin 2022-04-04 16:09:24 -04: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
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 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 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 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