9#include "flutter/flutter_vma/flutter_skia_vma.h"
10#include "flutter/fml/logging.h"
11#include "flutter/shell/common/context_options.h"
12#include "flutter/testing/test_vulkan_context.h"
13#include "flutter/vulkan/vulkan_skia_proc_table.h"
15#include "flutter/fml/memory/ref_ptr.h"
16#include "flutter/fml/native_library.h"
17#include "flutter/vulkan/swiftshader_path.h"
37 FML_LOG(
ERROR) <<
"Couldn't find Vulkan ICD \"" << vulkan_icd
38 <<
"\", trying \"libvulkan.so\" instead.";
39 vulkan_icd =
"libvulkan.so";
42 FML_LOG(INFO) <<
"Using Vulkan ICD: " << vulkan_icd;
44 vk_ = fml::MakeRefCounted<vulkan::VulkanProcTable>(vulkan_icd);
46 FML_LOG(
ERROR) <<
"Proc table has not acquired mandatory proc addresses.";
50 application_ = std::make_unique<vulkan::VulkanApplication>(
51 *vk_,
"Flutter Unittests", std::vector<std::string>{},
53 if (!application_->IsValid()) {
54 FML_LOG(
ERROR) <<
"Failed to initialize basic Vulkan state.";
62 device_ = application_->AcquireFirstCompatibleLogicalDevice();
63 if (!device_ || !device_->IsValid()) {
64 FML_LOG(
ERROR) <<
"Failed to create compatible logical device.";
74 if (!device_->GetPhysicalDeviceFeatures(&features)) {
75 FML_LOG(
ERROR) <<
"Failed to get physical device features.";
81 if (get_proc ==
nullptr) {
82 FML_LOG(
ERROR) <<
"Failed to create Vulkan getProc for Skia.";
89 device_->GetPhysicalDeviceHandle(), device_->GetHandle(), vk_,
true);
94 backend_context.
fInstance = application_->GetInstance();
96 backend_context.
fDevice = device_->GetHandle();
97 backend_context.
fQueue = device_->GetQueueHandle();
102 backend_context.
fGetProc = get_proc;
128 static_cast<uint32_t
>(
size.height()), 1},
137 .queueFamilyIndexCount = 0,
138 .pQueueFamilyIndices =
nullptr,
144 vk_->CreateImage(device_->GetHandle(), &
info,
nullptr, &
image)))) {
154 vk_->GetImageMemoryRequirements(device_->GetHandle(),
image, &mem_req);
157 alloc_info.allocationSize = mem_req.size;
158 alloc_info.memoryTypeIndex =
static_cast<uint32_t
>(__builtin_ctz(
161 VkDeviceMemory memory;
168 memory, [&
vk = vk_, &
device = device_](VkDeviceMemory memory) {
169 vk->FreeMemory(
device->GetHandle(), memory,
nullptr);
173 device_->GetHandle(),
result.image_,
result.memory_, 0)))) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
void releaseResourcesAndAbandonContext()
static sk_sp< VulkanMemoryAllocator > Make(uint32_t vulkan_api_version, VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, const fml::RefPtr< vulkan::VulkanProcTable > &vk, bool mustUseCoherentHostVisibleMemory)
sk_sp< GrDirectContext > GetGrDirectContext() const
std::optional< TestVulkanImage > CreateImage(const SkISize &size) const
Captures the lifetime of a test VkImage along with its bound memory.
static fml::RefPtr< NativeLibrary > Create(const char *path)
bool HasAcquiredMandatoryProcAddresses() const
bool AreInstanceProcsSetup() const
#define FML_LOG(severity)
SK_API sk_sp< GrDirectContext > MakeVulkan(const skgpu::VulkanBackendContext &, const GrContextOptions &)
sk_sp< const SkImage > image
GrContextOptions MakeDefaultContextOptions(ContextType type, std::optional< GrBackendApi > api)
Initializes GrContextOptions with values suitable for Flutter. The options can be further tweaked bef...
@ kRender
The context is used to render to a texture or renderbuffer.
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
GrVkGetProc CreateSkiaGetProc(const fml::RefPtr< vulkan::VulkanProcTable > &vk)
sk_sp< VulkanMemoryAllocator > fMemoryAllocator
const VkPhysicalDeviceFeatures * fDeviceFeatures
uint32_t fGraphicsQueueIndex
skgpu::VulkanGetProc fGetProc
VkPhysicalDevice fPhysicalDevice
const skgpu::VulkanExtensions * fVkExtensions
@ VK_IMAGE_LAYOUT_UNDEFINED
@ VK_SHARING_MODE_EXCLUSIVE
@ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
@ VK_IMAGE_TILING_OPTIMAL
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
@ VK_IMAGE_USAGE_SAMPLED_BIT
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
#define VK_MAKE_VERSION(major, minor, patch)
@ VK_FORMAT_R8G8B8A8_UNORM
@ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
@ VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO
#define VK_CALL_LOG_ERROR(expression)