Flutter Engine
The Flutter Engine
surface_context_vk.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SURFACE_CONTEXT_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SURFACE_CONTEXT_VK_H_
7
8#include <memory>
9
14
15namespace impeller {
16
17class ContextVK;
18class Surface;
19class SwapchainVK;
20
21/// For Vulkan, there is both a ContextVK that implements Context and a
22/// SurfaceContextVK that also implements Context and takes a ContextVK as its
23/// parent. There is a one to many relationship between ContextVK and
24/// SurfaceContextVK.
25///
26/// Most operations in this class are delegated to the parent ContextVK.
27/// This class specifically manages swapchains and creation of VkSurfaces on
28/// Android. By maintaining the swapchain this way, it is possible to have
29/// multiple surfaces sharing the same ContextVK without stepping on each
30/// other's swapchains.
32 public BackendCast<SurfaceContextVK, Context> {
33 public:
34 explicit SurfaceContextVK(const std::shared_ptr<ContextVK>& parent);
35
36 // |Context|
38
39 // |Context|
40 BackendType GetBackendType() const override;
41
42 // |Context|
43 std::string DescribeGpuModel() const override;
44
45 // |Context|
46 bool IsValid() const override;
47
48 // |Context|
49 std::shared_ptr<Allocator> GetResourceAllocator() const override;
50
51 // |Context|
52 std::shared_ptr<ShaderLibrary> GetShaderLibrary() const override;
53
54 // |Context|
55 std::shared_ptr<SamplerLibrary> GetSamplerLibrary() const override;
56
57 // |Context|
58 std::shared_ptr<PipelineLibrary> GetPipelineLibrary() const override;
59
60 // |Context|
61 std::shared_ptr<CommandBuffer> CreateCommandBuffer() const override;
62
63 // |Context|
64 const std::shared_ptr<const Capabilities>& GetCapabilities() const override;
65
66 // |Context|
67 std::shared_ptr<CommandQueue> GetCommandQueue() const override;
68
69 // |Context|
70 void Shutdown() override;
71
72 [[nodiscard]] bool SetWindowSurface(vk::UniqueSurfaceKHR surface,
73 const ISize& size);
74
75 [[nodiscard]] bool SetSwapchain(std::shared_ptr<SwapchainVK> swapchain);
76
77 std::unique_ptr<Surface> AcquireNextSurface();
78
79 /// @brief Mark the current swapchain configuration as dirty, forcing it to be
80 /// recreated on the next frame.
81 void UpdateSurfaceSize(const ISize& size) const;
82
83 void InitializeCommonlyUsedShadersIfNeeded() const override;
84
85 const vk::Device& GetDevice() const;
86
87 const std::shared_ptr<ContextVK>& GetParent() const;
88
89 private:
90 std::shared_ptr<ContextVK> parent_;
91 std::shared_ptr<SwapchainVK> swapchain_;
92};
93
94} // namespace impeller
95
96#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SURFACE_CONTEXT_VK_H_
To do anything rendering related with Impeller, you need a context.
Definition: context.h:45
bool SetWindowSurface(vk::UniqueSurfaceKHR surface, const ISize &size)
SurfaceContextVK(const std::shared_ptr< ContextVK > &parent)
std::shared_ptr< PipelineLibrary > GetPipelineLibrary() const override
Returns the library of pipelines used by render or compute commands.
const std::shared_ptr< ContextVK > & GetParent() const
bool SetSwapchain(std::shared_ptr< SwapchainVK > swapchain)
const std::shared_ptr< const Capabilities > & GetCapabilities() const override
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
BackendType GetBackendType() const override
Get the graphics backend of an Impeller context.
std::string DescribeGpuModel() const override
bool IsValid() const override
Determines if a context is valid. If the caller ever receives an invalid context, they must discard i...
void UpdateSurfaceSize(const ISize &size) const
Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame.
std::unique_ptr< Surface > AcquireNextSurface()
const vk::Device & GetDevice() const
std::shared_ptr< SamplerLibrary > GetSamplerLibrary() const override
Returns the library of combined image samplers used in shaders.
std::shared_ptr< CommandQueue > GetCommandQueue() const override
Return the graphics queue for submitting command buffers.
void Shutdown() override
Force all pending asynchronous work to finish. This is achieved by deleting all owned concurrent mess...
std::shared_ptr< CommandBuffer > CreateCommandBuffer() const override
Create a new command buffer. Command buffers can be used to encode graphics, blit,...
std::shared_ptr< ShaderLibrary > GetShaderLibrary() const override
Returns the library of shaders used to specify the programmable stages of a pipeline.
void InitializeCommonlyUsedShadersIfNeeded() const override
std::shared_ptr< Allocator > GetResourceAllocator() const override
Returns the allocator used to create textures and buffers on the device.
VkSwapchainKHR swapchain
Definition: main.cc:64
VkSurfaceKHR surface
Definition: main.cc:49
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259