Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 std::unique_ptr<Surface> AcquireNextSurface();
76
77 /// @brief Mark the current swapchain configuration as dirty, forcing it to be
78 /// recreated on the next frame.
79 void UpdateSurfaceSize(const ISize& size) const;
80
81 void InitializeCommonlyUsedShadersIfNeeded() const override;
82
83#ifdef FML_OS_ANDROID
84 vk::UniqueSurfaceKHR CreateAndroidSurface(ANativeWindow* window) const;
85#endif // FML_OS_ANDROID
86
87 const vk::Device& GetDevice() const;
88
89 const ContextVK& GetParent() const;
90
91 private:
92 std::shared_ptr<ContextVK> parent_;
93 std::shared_ptr<SwapchainVK> swapchain_;
94};
95
96} // namespace impeller
97
98#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SURFACE_CONTEXT_VK_H_
To do anything rendering related with Impeller, you need a context.
Definition context.h:46
bool SetWindowSurface(vk::UniqueSurfaceKHR surface, const ISize &size)
std::shared_ptr< PipelineLibrary > GetPipelineLibrary() const override
Returns the library of pipelines used by render or compute commands.
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,...
const ContextVK & GetParent() const
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.
GLFWwindow * window
Definition main.cc:45
VkSurfaceKHR surface
Definition main.cc:49
struct ANativeWindow ANativeWindow