243 Commits

Author SHA1 Message Date
Dan Field
ffa16ec08f [Impeller] Reland DlAiksCanvas (flutter/engine#45232)
Relands https://github.com/flutter/engine/pull/45131

Fixes https://github.com/flutter/flutter/issues/132416

Differences from last time:

- Some minor merge conflict fixes
- Use the RTree to get the bounds instead of recalculating the bounds
- Make the iOS platform view controller implementation use the impeller-aware slices instead of the display list ones. This has been fixed for Android and the desktop embedding, but I missed iOS. The unit tests weren't actually running before I branched for my PR, @zanderso fixed them up separately and this resulted in catching the failures on post submit last time.
2023-08-31 00:29:23 +00:00
Jonah Williams
a04635d9e6 Revert "[Impeller] DlAiksCanvas as a DlCanvas wrapper for impeller::Canvas" (flutter/engine#45149)
Reverts flutter/engine#45131

This is failing the Impeller variants of the unobstructed platform views tests:

https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20Production%20Engine%20Drone/132249/overview

```
Failing tests:
	-[UnobstructedPlatformViewTests testPlatformViewsMaxOverlays]
	-[UnobstructedPlatformViewTests testOneOverlay]
	-[UnobstructedPlatformViewTests testOneOverlayPartialIntersection]
	-[UnobstructedPlatformViewTests testTwoIntersectingOverlays]
	-[UnobstructedPlatformViewTests testOneOverlayAndTwoIntersectingOverlays]

** TEST FAILED **
```

We've retried it a few times so I suspect this isn't a flake.
2023-08-26 19:31:39 +00:00
Dan Field
e9b2008748 [Impeller] DlAiksCanvas as a DlCanvas wrapper for impeller::Canvas (flutter/engine#45131)
This is a reland of https://github.com/flutter/engine/pull/44248

Fixes https://github.com/flutter/flutter/issues/132416

Changes from last time:

- The `drawPoints` benchmark was failing to render anything meaningful because of an error in `AiksLayer` that resulted in an infinitely sized bounding rectangle poisoning the bounds with `NaN` (this happens, for example, with a `drawPaint` call, which that benchmark happens to use). Added a test covering this and filed https://github.com/flutter/flutter/issues/132770 to explore ways to avoid this in the future.
- There was a bug in `DlAiksCanvas::SaveLayer` where a `nullptr` `paint` but non-`nullptr` `backdrop` was failing to actually save the layer. This resulted in incorrect rendering.
- There was a bug in `impeller::Canvas::DrawPicture` that resulted in incorrect stencil depth counting. That was fixed separately by @bdero, but was the cause of incorrect rendering in some Wonderous screens.
- I've added a simple implementation for `AiksLayer::IsReplacing`. It does not currently compare as deeply as the `DisplayListLayer` version potentially does, but it is good enough to avoid the regression noted in https://github.com/flutter/flutter/issues/132071. That regression was on a benchmark that greatly benefits from partial repaint. With the new implementation, it still gains partial repaint where it previously did not. There is more work that can be done here, filed https://github.com/flutter/flutter/issues/133361 to track that work.

I merged but did not fully integrate the `DisplayListBuilder`/`CanvasToReceiver` work that @flar has done. I have a local experiment with that, but would prefer to see this land and run through the device lab so we get some better comparison numbers for which one performs better.
2023-08-26 05:37:28 +00:00
Brandon DeRosier
e5c4a38d8b [Impeller] Add STB text backend. (flutter/engine#44887)
Pull the STB text backend into the engine from impeller-cmake.
2023-08-23 13:06:50 -07:00
Brandon DeRosier
cdab07b84a [Impeller] Supply a text backend to the AiksContext at runtime. (flutter/engine#44884)
Resolves https://github.com/flutter/flutter/issues/130947.

- Allow for setting the text renderer (`TextRenderContext`) when the
`AiksContext` is built. Previously, the text renderer was selected at
build time through linking a `TextRenderContext::Create` symbol.
- Support using Impeller without a text backend. Throw a clear error
when trying to render text if no text backend is present.
- Don't track the Impeller context in `TextRenderContext`. Just let the
renderer supply its context when generating atlases.
- Allow for overriding the `TextRenderContext` for individual Aiks
playground tests/goldens.
2023-08-21 21:55:28 -07:00
Jason Simmons
2ae4942db0 Use the Clang unreachable code warning flag in the engine tree (flutter/engine#44458) 2023-08-08 17:40:03 +00:00
Jason Simmons
0413e2710d Revert "[Impeller] DlCanvas implementation wrapping Aiks canvas" (flutter/engine#44466)
This reverts commit 1785eb5cb8cba53da249614158065d1d53f8f863.

See https://github.com/flutter/flutter/issues/132071
2023-08-07 23:59:47 +00:00
Dan Field
1785eb5cb8 [Impeller] DlCanvas implementation wrapping Aiks canvas (flutter/engine#44248)
Fixes https://github.com/flutter/flutter/issues/130141

The primary goal of this patch is to move dispatching of `dart:ui` `Canvas` commands to the UI thread.

Before this patch, the architecture is something like:

## UI Thread
- `dart:ui` talks to `DisplayListBuilder`, a `DlCanvas` implementation.
- `DisplayListBuilder` does some clip/bounds tracking and creates a `DisplayList` object that is held by `dart:ui`'s `Picture` objects.
- `DisplayList`s are added to `DisplayListLayer`s in `flow`. 

## Raster Thread
- `flow` flattens the various operations into a single `DisplayList` via another `DisplayListBuilder`.
- A `DlOpReceiver`implementation converts that `DisplayList` into an `Aiks` `Canvas`/`Picture`.

After this patch, the architecture instead looks like:

## UI Thread

- No change for Skia.
- If Impeller, use a new `DlCanvasImplementation` that talks to `Aiks`'s `Canvas`.
- If Impeller, `dart:ui` Picture's now hold an `Aiks` `Picture`, which get shared into `AiksLayer`s in `flow`.

## Raster thread

- No change for Skia, but some light refactoring for places that assumed a `DisplayListBuilder` where they really just needed a `DlCanvas`.
- The `Aiks` `Picture`s are combined using new API on `DlCanvas` and still backed by `Aiks`.

These changes show significant improvement on raster times on Android and only very small regressions on UI times in local testing, see https://gist.github.com/dnfield/26528090194c9f5abdbac13cdcbf4f79 for old gallery transition perf numbers.

Many of the other changes in this patch are related to the following:

- Making `DlRTree` usable for Impeller.
  - It would be nice to have a version of DlRTree that speaks `impeller::Rect`.
- Creating the requisite classes to support `EmbeddedViews` so that Desktop works.

This patch does not remove the `impeller::DlDispatcher`, which now would only be used in tests.
2023-08-04 17:35:14 +00:00
Kevin Lubick
ecda6a659e Migrate GL calls of GrBackend* (flutter/engine#44334)
In https://skia-review.googlesource.com/c/skia/+/701398 Skia refactored
GrBackend* to not require #ifdefs. This changes
callsites in Flutter to use static functions instead of methods that
were conditionally compiled on those classes.

There should be no functional change with these. As I was updating these
callsites, I saw uses of the deprecated GrMipMapped enum and used the
updated skgpu::Mipmapped (the former is an alias to the latter).

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-08-03 15:46:14 -04:00
Jason Simmons
3bb1764557 [Impeller] Create a wrapper Impeller context for each Vulkan surface and its swapchain (flutter/engine#44171)
In https://github.com/flutter/engine/pull/41059 the Android context and surface were changed to share one impeller::ContextVK across all instances of AndroidSurfaceVulkanImpeller.  However, the ContextVK holds a reference to the current swapchain.  If an app uses multiple AndroidSurfaceVulkanImpeller instances (e.g. for platform views), then one surface may overwrite the ContextVK's swapchain while another surface is trying to render.

This patch allows each surface to get its own impeller::Context instance holding a swapchain tied to that surface.  The per-surface contexts will delegate most operations to the shared parent ContextVK.
2023-07-31 20:49:11 +00:00
Jonah Williams
79237f839b [Impeller] provide cull rect to Canvas in GL/Vulakn impeller backend. (flutter/engine#43961)
This was missing compared to the metal version. Doesn't matter on flutter/gallery but might matter elsewhere once platform views are working.
2023-07-24 18:15:52 +00:00
Jonah Williams
4698c6b307 [Impeller] Ensure that missing color attachment 0u does not cause crash in embedder API (flutter/engine#43705)
https://github.com/flutter/flutter/issues/130619
2023-07-14 22:17:56 +00:00
Kevin Lubick
bdc24b3d18 Remove calls to SkCanvas::flush() (flutter/engine#43684)
In https://skia-review.googlesource.com/c/skia/+/716476, Skia removed
calls to SkCanvas::flush(). This replaces those calls that Flutter was
making with what had been going on - calling GrDirectContext::flush() if
the canvas was backed by a Ganesh backend. Raster-backed canvases did
not need flushing.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-07-14 16:34:22 -04:00
Jonah Williams
24c6a07906 [Impeller] Add support to embedder for Impeller on GL (via Angle on Windows). (flutter/engine#43388)
Actually works now, though there is some issue with the default fbo stencil so I've filled https://github.com/flutter/flutter/issues/130048

Other issues:
* ~~Rendering looks wrong~~
* ~~Resizing window hangs~~
* ~~Reactor isn't set up correctly and all blit passes are currently failing.~~
* ~~Needs to handle falling back to sample count of 1 like we do on Android~~.
2023-07-13 00:34:34 +00:00
Brandon DeRosier
c85223dc95 [Impeller] Supply surface cull rect for Vulkan & GLES dispatchers (flutter/engine#43152)
Similar to Metal, have the DL cull entities early that lie entirely
outside the surface texture.
2023-06-24 15:46:14 -07:00
Dan Field
d33b2d4288 Delete WeakPtrFactory from GPUSurfaceVulkanImpeller (flutter/engine#42710)
Should fix https://github.com/flutter/flutter/issues/128618.

This is unused - if it were used we'd have to be careful about deleting the object on the same thread it's created on.
2023-06-09 22:27:46 +00:00
Brandon DeRosier
72a1fea6e2 [Impeller] Reland 2: Add Impeller Metal support in the embedder API (#42411) (flutter/engine#42597)
This reverts commit
8d6f091751
+ fixes bugs.

Reworked the surface wrapping to use a valid descriptor when wrapping
the drawable.
2023-06-06 23:02:02 -07:00
Zachary Anderson
8d6f091751 Revert "[Impeller] Reland: Add Impeller Metal support in the embedder API (#42411)" (flutter/engine#42593)
Reverts flutter/engine#42545

Not sure if this is needed, but getting a revert started for the
regression noted here:
https://github.com/flutter/engine/pull/42545#issuecomment-1579034704.
2023-06-06 10:57:57 -07:00
Brandon DeRosier
fba5e2b514 [Impeller] Reland: Add Impeller Metal support in the embedder API (#42411) (flutter/engine#42545)
This reverts commit
45dd178414.

Original PR: https://github.com/flutter/engine/pull/42411

Part of https://github.com/flutter/flutter/issues/112230.
2023-06-05 14:51:43 -07:00
Kevin Lubick
14d8bae027 Add missing includes of GrBackendSurface.h (flutter/engine#42563)
In https://skia-review.googlesource.com/c/skia/+/704942, Skia removed
some unnecessary #includes which parts of Flutter had been depending on
implicitly. This adds those includes in explicitly.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-06-05 10:32:41 -04:00
Brandon DeRosier
45dd178414 Revert "[Impeller] Add Impeller Metal support in the embedder API (#42411)" (flutter/engine#42532)
This reverts commit 666563a5544cf2a98a51c6b24e7bc03e265eedb0.

Expected to resolve https://github.com/flutter/flutter/issues/128145
2023-06-02 18:11:00 -07:00
Brandon DeRosier
666563a554 [Impeller] Add Impeller Metal support in the embedder API (flutter/engine#42411)
Part of https://github.com/flutter/flutter/issues/112230.

Now seemed like the right time to sneak this in:
* We have large desktop refactors on the horizon (multi-window).
* We're starting to land optimizations that complicate the surface behavior such as wide gamut and dirty regions.
* We have plans to migrate the iOS embedder to use the embedder API (https://github.com/flutter/flutter/issues/112232).

![Screenshot 2023-05-30 at 6 59 48 PM](https://github.com/flutter/engine/assets/919017/16616be8-f94e-42ba-8a97-4ce4aa29e662)
2023-06-01 20:10:58 +00:00
Kevin Lubick
7751d1c5eb Move SkSurface::MakeNull to SkSurfaces::Null (flutter/engine#42158)
In https://skia-review.googlesource.com/c/skia/+/696537 (and earlier in
https://skia-review.googlesource.com/c/skia/+/687639), Skia moved all
SkSurface factories. This changes the last calls of the old static
methods to the methods in the `SkSurfaces` namespace

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-20 10:11:44 -04:00
gaaclarke
47b14888c5 [Impeller] switches the wide gamut surface to f16 (flutter/engine#41994)
**requires https://github.com/flutter/flutter/pull/126712 to land
first**

fixes https://github.com/flutter/flutter/issues/126620
integration test at: https://github.com/flutter/flutter/pull/126715

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-15 10:25:43 -07:00
Kevin Lubick
0946d27add Migrate uses of SkSurface factories (flutter/engine#41978)
In http://review.skia.org/687639, many SkSurface static methods were moved and one was deleted (SkSurface::MakeRasterN32Premul). (SkSurface::MakeNull was omitted accidentally and http://review.skia.org/696537glesource.com/c/skia/+/696537 has not rolled into Flutter yet)

This changes the calls in Flutter to match those moved functions. There should be no functional difference and everything was done pretty mechanically (e.g. find and replace)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-15 16:41:10 +00:00
Jim Graham
6ad6014776 [Impeller] take advantage of DisplayList culling (flutter/engine#41606)
Switching the calls to dispatch into an Impeller Dispatcher to use a cull rect to enable pre-culling of the out-of-bounds ops.

This change showed an improvement of around 2x on the rendering performance of the non-intersecting platform view benchmark, but that was measured without the recent changes to the destructive blend modes in Impeller renderer.
2023-05-01 23:27:52 +00:00
Jonah Williams
8167e14475 [Impeller] partial repaint for Impeller/iOS. (flutter/engine#40959)
Implements partial repaint for Impeller.

Fixes https://github.com/flutter/flutter/issues/124526

The new code that manages the damage regions is more or less a copy paste from the existing Skia implementation. Compared to Skia, there are a few differences:

Normally Impeller wants to use the drawable as the resolve texture for the root MSAA pass. Unfortunately this will unconditonally clear that texture. Thus to do a partial repaint, we have to allocate a separate texture to resolve to and then blit into the drawable.

The blit seems to take about 500ns for a full screen on an iPhone 13. That implies that partial repaint is likely not worth doing if the screen is significantly changed. Thus I've added code in compositor_context.cc that computes the percentage of width or height that is part of the dirty rect. Above a threshold of (abitrarily chosen) 70%, we just render as normal. This should mean there is only a very minor hit from performing the diff on screens that are highly changed.

The other special case, is that sometimes we get damage rects that are empty - that is the drawable is already completely up to date with what we want to render. IN that case I shortcircuit all of the impeller code and just present immediately. I previously tried returning without a present but this resulted in Xcode reporting dropped frames. One caveat here is that if you use the XCode frame debugger and attempt to capture a frame where we early present, then it will claim it couldn't capture any command buffers (because we didn't create any).

To facilitate all of this, I added some additonal plumbing so that the impeller surface can get the clip rect from the submit info. Additionally, rather than using a clip rect impeller will translate and then shrink the root surface texture. This reduces memory usage compared to just clippling.
2023-04-26 21:13:03 +00:00
Chinmay Garde
4117cb927e [Impeller] Make //impeller/display_list TU naming consistent. (flutter/engine#41174)
No change in functionality. I've just renamed the TU's to replace `display_list_` to `dl_`. I am sure there are chances to make the naming better. For instance, the op receiver still being named a dispatcher.
2023-04-19 17:32:53 +00:00
Dan Field
b156f07ddc [Impeller] Allow image rasterization/decoding before/without surface acquisition (flutter/engine#41168)
[Impeller] Allow image rasterization/decoding before/without surface acquisition
2023-04-14 03:02:17 +00:00
Chinmay Garde
605e76a154 [Impeller] Patch up sundry issues in the Vulkan backend. (flutter/engine#39905)
Kaushik already did most of the great work. This patch gets us to a point where
all the playgrounds tests pass and the common performance optimizations are in
place. All known non-compute Impeller features should be implemented. There are
iOS only performance optimizations that haven’t been opted into because these
are behind define guards. These need to be generalized. Without that, the
performance of this backend will lag behind that of the Metal backend but only
because it is not an apples to apples comparison.

The general rubric was to keep the code and concepts as similar to the Metal
backend as possible.

The list of updates, all to the Vulkan Impeller backend:

* MSAA is wired up.
* Depth and stencil attachments and pipeline states are wired up.
* Got rid of Vulkan specific hacks in the inline pass context that were
  preventing clips from working.
* Storage modes for both device buffer and texture allocation are respected.
  This includes optimal usage of tile memory for device transient attachments.
* Host coherent memory for textures is no longer a requirement with explicit
  mapping management and write flushes.
* Texture uploads should be optimized for the UMA case without needing a staging
  buffer. That entire pipeline has been reworked.
* Textures track their current layout and ensure they get to the right layout
  based on usage without redundant transitions.
* Cube textures are now supported.
* Mipmapping has been reworked to correct image layout errors. With the new
  texture layout transition management, blit passes should be a whole lot easier
  to read and reason about.
* Allocator allocations are named using Vulkan debug utilities and the allocator
  (VMA). Comes in handy when chasing leaks. All of which are chased down.
* Left some handy utilities in there to debug resource leaks after context
  shutdown.  These are validation errors.
* Debug groups are pushed around render pass command encoding as well as the
  entire pass contents. This mimics the behavior of the Metal backend and it
  should be easy to map traces using both backends in Xcode and RenderDoc.
* Command buffer submission allows for tracking the life cycles of all resources
  referenced in the command stream and ensuring that the objects stay alive till
  past the submission of the command buffer. All use-after-free issues due to
  this class of issue have been chased down.
* Command pools are now context global instead of being created per pass.
* Descriptor pool are now context global instead of being created per pass.
  Individual descriptor types are now reference counted and returned to the pool
  when not needed. The pool is still fixed size though (and hence relatively
  large).
* All instances of global waitIdle on the device are removed during normal
  operation. The only times a waitIdle may happen is during swapchain recreation
  and context destruction.
* Swapchain adapt to them going out of date with the underlying surface and
  seamlessly resize as necessary on the next drawable acquisition.
* Playgrounds are resizable.
* Pipeline front face and cull modes are respected.
* Clears for all attachments are respected.
* Maximum textures sizes supported on the device are respected instead of
  hardcoding the minimum Vulkan requirement.

Fixes https://github.com/flutter/flutter/issues/112388
Fixes https://github.com/flutter/flutter/issues/112648
Fixes https://github.com/flutter/flutter/issues/112647 and a few other issues...
2023-02-27 21:14:06 -08:00
Jim Graham
0fa8cbec8a Create DlCanvas interface and implement with DisplayListBuilder and SkCanvasAdapter (flutter/engine#39762)
* Create DlCanvas interface and implement with DisplayListBuilder and SkCanvasAdapter
2023-02-23 22:09:35 -08:00
gaaclarke
f51ea3b01f [Impeller] Adds wide gamut support for iOS. (flutter/engine#39111)
* Implemented wide gamut images for iOS

Moved the surface to an extended range color format.

* wrong gamma but default pixel format set to bgra10_xr

* BGR10_XR add

* format

* updated todos

* updated todo with information about pixel formats

* switched logic for determining if we have a wide gamut image

* cleaned up gamut math to match style and linked source

* made the color attachment pixel format match the surface

* updated vulkan format switch

* removed comment

* added enable disable switch

* moved default to bgr10 for now since there is a bug where someone is still reading this, msaa?

* fixed the decoder settings to make sure we don't lose wide gamut colors

* fixed stored srgb gamut variable

* fixed false lint

* updated test

* added ability to grab the surface data for tests

* made the screenshot utility return the format

* added width and height to the platform channel payload

* fixed a couple of broken targets

* moved back the default pixel buffer format

* cleanup and add docstrings

* made the surfacedata feature only available in debug builds

* added decoding unit test

* fixed objc tests

* turned off by default

* bdero feedback1

* bdero2

* bdero3

* fixed merge issue

* removed using std::shared_ptr
2023-02-11 00:08:20 +00:00
Brandon DeRosier
841758cc6c Add SkSurface include to every file where it's used (flutter/engine#39304) 2023-02-01 00:50:58 +00:00
Jim Graham
eb615c6cc4 delete include of private GrMtlTypes header (flutter/engine#38783) 2023-01-11 19:57:47 +00:00
Chris Bracken
d260fc82cd [embedder] Ensure FlutterMetalTexture cleanup call (flutter/engine#38038)
This ensures FlutterMetalTexture.destruction_callback gets called.

FlutterRendererConfig.get_next_drawable_callback holds a callback used by the embedder API to request a drawable; in the case of Metal, this drawable is a FlutterMetalTexture.

FlutterMetalTexture.destruction_callback should be called when it's safe to release resources associated with the FlutterMetalTexture. This callback is not currently invoked for textures returned via FlutterRendererConfig.get_next_drawable_callback; instead we unpack the returned struct and pass it on.

In the compositor codepath, we do create an SkSurface that triggers the destruction callback, here:
bbdb5d6a3e/shell/platform/embedder/embedder.cc (L868-L881)

Issue: https://github.com/flutter/flutter/issues/116381
2022-12-03 01:30:23 -08:00
Brandon DeRosier
0a11bb12d7 Add more raster traces (flutter/engine#37510) 2022-11-11 17:05:25 -08:00
Kaushik Iska
b85721b43d [Impeller] Implement GPU Surface Vulkan for Impeller (flutter/engine#37215) 2022-11-01 21:48:17 +00:00
Kaushik Iska
1941c2ca48 [Impeller] Wire Flutter's own VulkanMemoryAllocator implementation (flutter/engine#37018) 2022-10-27 20:57:54 +00:00
gaaclarke
cb4c9f4727 Clang-tidy: made verbose print out commands and fixed quoting problem for warnings as errors (flutter/engine#37015) 2022-10-26 08:19:12 +00:00
gaaclarke
e41c775200 Removed instances of unnecessary values (flutter/engine#36221) 2022-09-26 21:28:04 +00:00
Dan Field
4f14c3d127 Use the frame size to cull (flutter/engine#35973) 2022-09-07 23:18:10 +00:00
ColdPaleLight
e9ad8e2454 [Impeller] Implement ui.Picture.toImage() (flutter/engine#35633) 2022-09-01 22:59:41 +00:00
Kaushik Iska
7cdcb0f837 Do not override partial repaint support globally (flutter/engine#35539) 2022-08-19 18:41:46 +00:00
Bernardo Eilert Trevisan
d9da8e0d2e Enable dirty region management within the Embedder API (flutter/engine#35022) 2022-08-12 10:52:54 -07:00
Kaushik Iska
fa17e34df7 Expose a iOS plist setting to disable partial repaint. (flutter/engine#34328)
If the following is added to Info.plist of the application,
it will disable partial repaint:

```
  <key>FLTDisablePartialRepaint</key>
  <true/>
```

The primary intended usecase for this is to enable applications to see if disabling partial repaint resolves:
https://github.com/flutter/flutter/issues/100522.
2022-06-27 16:47:17 -04:00
Dan Field
f7163f555c Roll SwiftShader, ANGLE, use SwANGLE in test harnesses (flutter/engine#33814)
Roll Swiftshader, ANGLE, and Vulkan deps.

Updates license bot for new locations of licenses and new files
in roll.

Converts unit test harnesses to use SwANGLE, which is the
supported way of using SwiftShader as a software backend for GLES.

Updates goldens due to swiftshader changes.

Fixes up include paths to avoid directly including third_party
code by that name, which is unlikely to work in other build
environments.

Includes upstream patches to ANGLE and SwiftShader to build in our
windows environments, as well as patches to Skia to support
defining the location of VulkanMemoryAllocator and a patch to ANGLE
to support opting into a newer version of VMA.
2022-06-23 16:43:39 -07:00
Chris Bracken
53a9648da9 [lint] Merge impeller .clang-tidy into main config (flutter/engine#33692)
Merges most (but not all) of the impeller .clang-tidy rules into the
main .clang-tidy config. Merges:

readability-identifier-naming.PrivateMemberSuffix (_)
readability-identifier-naming.EnumConstantPrefix (k)
modernize-use-default-member-init.UseAssignment
Does not merge:

readability-identifier-naming.PublicMethodCase (CamelCase)
readability-identifier-naming.PrivateMethodCase (CamelCase)
These last two are not merged due to the non-trivial number of existing
field accessors that use field_name() methods to directly return
field_name_. While these are permitted by the C++ style guide, we may
want to move to a single, simple rule and name everything in CamelCase.
These can be enabled in a followup patch.

No new tests added, since this change is style-only.
2022-06-21 11:52:42 -07:00
Chinmay Garde
16731be1a7 [Impeller] Allow for the specification of pipeline stage information at runtime. (flutter/engine#33882)
Towards implementing the FragmentProgram API in Impeller.

Specifies an Impeller specific format for data the renderer can use to create
pipelines with user supplied shader stages at runtime.

The data is in the form of a flatbuffer with a known schema.

This patch implements the wire format, creating and loading the program
payloads, and creating pipeline state objects using these payloads.

If the user supplied SPIRV intended for the older API, the loader will reject
this invalid payload. This is probably not going to be too much of an issue
because the FragmentProgram API will probably be modified to only allow buffers
loaded from asset managers. But still, in the meantime, I am using the old API
to pass these new buffers.

Fixes https://github.com/flutter/flutter/issues/104750
Fixes https://github.com/flutter/flutter/issues/105542
Towards resolving https://github.com/flutter/flutter/issues/102853
2022-06-13 18:33:00 -07:00
Kaushik Iska
7a71b8cbb3 [android] set presentation time via eglPresentationTimeANDROID (flutter/engine#33881)
Attempt to reland: https://github.com/flutter/engine/pull/29727/ with some fixes.
2022-06-08 12:49:58 -04:00
Kaushik Iska
af6bbe756d Move the args for GLContextPresent into a struct (flutter/engine#33758)
This refactor enables easier additions to the method
for fields that can be optionally consumed by various
platforms.
2022-06-01 23:11:37 -04:00