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
..