Flutter Engine
The Flutter Engine
surface_context_vk.cc
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
6
7#include "flutter/fml/trace_event.h"
12
13namespace impeller {
14
15SurfaceContextVK::SurfaceContextVK(const std::shared_ptr<ContextVK>& parent)
16 : parent_(parent) {}
17
19
21 return parent_->GetBackendType();
22}
23
25 return parent_->DescribeGpuModel();
26}
27
29 return parent_->IsValid();
30}
31
32std::shared_ptr<Allocator> SurfaceContextVK::GetResourceAllocator() const {
33 return parent_->GetResourceAllocator();
34}
35
36std::shared_ptr<ShaderLibrary> SurfaceContextVK::GetShaderLibrary() const {
37 return parent_->GetShaderLibrary();
38}
39
40std::shared_ptr<SamplerLibrary> SurfaceContextVK::GetSamplerLibrary() const {
41 return parent_->GetSamplerLibrary();
42}
43
44std::shared_ptr<PipelineLibrary> SurfaceContextVK::GetPipelineLibrary() const {
45 return parent_->GetPipelineLibrary();
46}
47
48std::shared_ptr<CommandBuffer> SurfaceContextVK::CreateCommandBuffer() const {
49 return parent_->CreateCommandBuffer();
50}
51
52std::shared_ptr<CommandQueue> SurfaceContextVK::GetCommandQueue() const {
53 return parent_->GetCommandQueue();
54}
55
56const std::shared_ptr<const Capabilities>& SurfaceContextVK::GetCapabilities()
57 const {
58 return parent_->GetCapabilities();
59}
60
62 parent_->Shutdown();
63}
64
66 const ISize& size) {
67 return SetSwapchain(SwapchainVK::Create(parent_, std::move(surface), size));
68}
69
70bool SurfaceContextVK::SetSwapchain(std::shared_ptr<SwapchainVK> swapchain) {
71 if (!swapchain || !swapchain->IsValid()) {
72 VALIDATION_LOG << "Invalid swapchain.";
73 return false;
74 }
75 swapchain_ = std::move(swapchain);
76 return true;
77}
78
79std::unique_ptr<Surface> SurfaceContextVK::AcquireNextSurface() {
80 TRACE_EVENT0("impeller", __FUNCTION__);
81 auto surface = swapchain_ ? swapchain_->AcquireNextDrawable() : nullptr;
82 if (!surface) {
83 return nullptr;
84 }
85 if (auto pipeline_library = parent_->GetPipelineLibrary()) {
86 impeller::PipelineLibraryVK::Cast(*pipeline_library)
88 }
89 parent_->GetCommandPoolRecycler()->Dispose();
90 parent_->GetResourceAllocator()->DebugTraceMemoryStatistics();
91 return surface;
92}
93
95 swapchain_->UpdateSurfaceSize(size);
96}
97
98const vk::Device& SurfaceContextVK::GetDevice() const {
99 return parent_->GetDevice();
100}
101
103 parent_->InitializeCommonlyUsedShadersIfNeeded();
104}
105
106const std::shared_ptr<ContextVK>& SurfaceContextVK::GetParent() const {
107 return parent_;
108}
109
110} // namespace impeller
static PipelineLibraryVK & Cast(PipelineLibrary &base)
Definition: backend_cast.h:13
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.
static std::shared_ptr< SwapchainVK > Create(const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true)
Definition: swapchain_vk.cc:18
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
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131
#define VALIDATION_LOG
Definition: validation.h:73