Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
gpu_surface_vulkan_impeller_unittests.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
5#include <vulkan/vulkan.h>
6
11#include "gtest/gtest.h"
12#include "impeller/entity/vk/entity_shaders_vk.h"
13#include "impeller/entity/vk/framebuffer_blend_shaders_vk.h"
14#include "impeller/entity/vk/modern_shaders_vk.h"
16
17namespace flutter {
18namespace testing {
19
20std::vector<std::shared_ptr<fml::Mapping>> ShaderLibraryMappings() {
21 return {
22 std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_vk_data,
23 impeller_entity_shaders_vk_length),
24 std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_vk_data,
25 impeller_modern_shaders_vk_length),
26 std::make_shared<fml::NonOwnedMapping>(
27 impeller_framebuffer_blend_shaders_vk_data,
28 impeller_framebuffer_blend_shaders_vk_length),
29 };
30}
31
33 public:
35 : vk_(fml::MakeRefCounted<vulkan::VulkanProcTable>(
36 vkGetInstanceProcAddr)),
37 test_context_(fml::MakeRefCounted<TestVulkanContext>()),
38 test_surface_(TestVulkanSurface::Create(*test_context_, {100, 100})) {}
39
40 const vulkan::VulkanProcTable& vk() override { return *vk_; }
41
43 return {
45 .image = reinterpret_cast<uint64_t>(test_surface_->GetImage()),
46 .format = VK_FORMAT_R8G8B8A8_UNORM,
47 };
48 }
49
50 bool PresentImage(VkImage image, VkFormat format) override { return true; }
51
52 private:
55 std::unique_ptr<TestVulkanSurface> test_surface_;
56};
57
58TEST(GPUSurfaceVulkanImpeller, DisposesThreadLocalResources) {
59 impeller::ContextVK::Settings context_settings;
60 context_settings.proc_address_callback = vkGetInstanceProcAddr;
62 auto context = impeller::ContextVK::Create(std::move(context_settings));
63
65
66 std::unique_ptr<Surface> surface =
67 std::make_unique<GPUSurfaceVulkanImpeller>(&delegate, context);
68
69 // Add a command pool to the global map.
70 auto pool = context->GetCommandPoolRecycler()->Get();
72
73 // Check that AcquireFrame disposes thread local resources and removes
74 // the pool from the global map.
75 auto frame = surface->AcquireFrame(DlISize(100, 100));
77}
78
79} // namespace testing
80} // namespace flutter
Interface implemented by all platform surfaces that can present a Vulkan backing store to the "screen...
const vulkan::VulkanProcTable & vk() override
Obtain a reference to the Vulkan implementation's proc table.
FlutterVulkanImage AcquireImage(const DlISize &size) override
Called by the engine to fetch a VkImage for writing the next frame.
bool PresentImage(VkImage image, VkFormat format) override
Called by the engine once a frame has been rendered to the image and it's ready to be bound for furth...
static int GetGlobalPoolCount(const ContextVK &context)
static std::shared_ptr< ContextVK > Create(Settings settings)
FlutterVulkanImage * image
VkSurfaceKHR surface
Definition main.cc:65
uint32_t uint32_t * format
static std::vector< std::shared_ptr< fml::Mapping > > ShaderLibraryMappings()
TEST(NativeAssetsManagerTest, NoAvailableAssets)
impeller::ISize32 DlISize
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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
size_t struct_size
The size of this struct. Must be sizeof(FlutterVulkanImage).
Definition embedder.h:935
std::vector< std::shared_ptr< fml::Mapping > > shader_libraries_data
Definition context_vk.h:81
PFN_vkGetInstanceProcAddr proc_address_callback
Definition context_vk.h:80