Flutter Engine
 
Loading...
Searching...
No Matches
impeller::testing::MockVulkanContextBuilder Class Reference

#include <mock_vulkan.h>

Public Member Functions

 MockVulkanContextBuilder ()
 
std::shared_ptr< ContextVKBuild ()
 Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the settings right before a context is created.
 
MockVulkanContextBuilderSetSettingsCallback (const std::function< void(ContextVK::Settings &)> &settings_callback)
 
MockVulkanContextBuilderSetInstanceExtensions (const std::vector< std::string > &instance_extensions)
 
MockVulkanContextBuilderSetInstanceLayers (const std::vector< std::string > &instance_layers)
 
MockVulkanContextBuilderSetPhysicalDeviceFormatPropertiesCallback (std::function< void(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties)> format_properties_callback)
 
MockVulkanContextBuilderSetPhysicalPropertiesCallback (std::function< void(VkPhysicalDevice device, VkPhysicalDeviceProperties *physicalProperties)> physical_properties_callback)
 
MockVulkanContextBuilder SetEmbedderData (const ContextVK::EmbedderData &embedder_data)
 

Detailed Description

Definition at line 59 of file mock_vulkan.h.

Constructor & Destructor Documentation

◆ MockVulkanContextBuilder()

impeller::testing::MockVulkanContextBuilder::MockVulkanContextBuilder ( )

Definition at line 969 of file mock_vulkan.cc.

970 : instance_extensions_({"VK_KHR_surface", "VK_MVK_macos_surface"}),
971 format_properties_callback_([](VkPhysicalDevice physicalDevice,
972 VkFormat format,
973 VkFormatProperties* pFormatProperties) {
974 if (format == VK_FORMAT_R8G8B8A8_UNORM) {
975 pFormatProperties->optimalTilingFeatures =
976 static_cast<VkFormatFeatureFlags>(
977 vk::FormatFeatureFlagBits::eColorAttachment);
978 } else if (format == VK_FORMAT_D32_SFLOAT_S8_UINT) {
979 pFormatProperties->optimalTilingFeatures =
980 static_cast<VkFormatFeatureFlags>(
981 vk::FormatFeatureFlagBits::eDepthStencilAttachment);
982 } else if (format == VK_FORMAT_S8_UINT) {
983 pFormatProperties->optimalTilingFeatures =
984 static_cast<VkFormatFeatureFlags>(
985 vk::FormatFeatureFlagBits::eDepthStencilAttachment);
986 }
987 }) {}

Member Function Documentation

◆ Build()

std::shared_ptr< ContextVK > impeller::testing::MockVulkanContextBuilder::Build ( )

Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the settings right before a context is created.

Returns
A context if one can be created.

Definition at line 989 of file mock_vulkan.cc.

989 {
990 auto message_loop = fml::ConcurrentMessageLoop::Create();
991 ContextVK::Settings settings;
992 settings.proc_address_callback = GetMockVulkanProcAddress;
993 if (settings_callback_) {
994 settings_callback_(settings);
995 }
996 g_instance_extensions = instance_extensions_;
997 g_instance_layers = instance_layers_;
998 g_format_properties_callback = format_properties_callback_;
999 g_physical_device_properties_callback = physical_properties_callback_;
1000 settings.embedder_data = embedder_data_;
1001 std::shared_ptr<ContextVK> result = ContextVK::Create(std::move(settings));
1002 return result;
1003}
static std::shared_ptr< ConcurrentMessageLoop > Create(size_t worker_count=std::thread::hardware_concurrency())
static std::shared_ptr< ContextVK > Create(Settings settings)

References impeller::ContextVK::Create(), fml::ConcurrentMessageLoop::Create(), impeller::ContextVK::Settings::embedder_data, and impeller::ContextVK::Settings::proc_address_callback.

Referenced by impeller::testing::TEST(), impeller::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ SetEmbedderData()

MockVulkanContextBuilder impeller::testing::MockVulkanContextBuilder::SetEmbedderData ( const ContextVK::EmbedderData embedder_data)
inline

Definition at line 111 of file mock_vulkan.h.

112 {
113 embedder_data_ = embedder_data;
114 return *this;
115 }

Referenced by impeller::testing::TEST(), and impeller::testing::TEST().

◆ SetInstanceExtensions()

MockVulkanContextBuilder & impeller::testing::MockVulkanContextBuilder::SetInstanceExtensions ( const std::vector< std::string > &  instance_extensions)
inline

Definition at line 80 of file mock_vulkan.h.

81 {
82 instance_extensions_ = instance_extensions;
83 return *this;
84 }

◆ SetInstanceLayers()

MockVulkanContextBuilder & impeller::testing::MockVulkanContextBuilder::SetInstanceLayers ( const std::vector< std::string > &  instance_layers)
inline

Definition at line 86 of file mock_vulkan.h.

87 {
88 instance_layers_ = instance_layers;
89 return *this;
90 }

◆ SetPhysicalDeviceFormatPropertiesCallback()

MockVulkanContextBuilder & impeller::testing::MockVulkanContextBuilder::SetPhysicalDeviceFormatPropertiesCallback ( std::function< void(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties)>  format_properties_callback)
inline

Set the behavior of vkGetPhysicalDeviceFormatProperties, which needs to respond differently for different formats.

Definition at line 94 of file mock_vulkan.h.

98 {
99 format_properties_callback_ = std::move(format_properties_callback);
100 return *this;
101 }

Referenced by impeller::testing::TEST(), and impeller::testing::TEST().

◆ SetPhysicalPropertiesCallback()

MockVulkanContextBuilder & impeller::testing::MockVulkanContextBuilder::SetPhysicalPropertiesCallback ( std::function< void(VkPhysicalDevice device, VkPhysicalDeviceProperties *physicalProperties)>  physical_properties_callback)
inline

◆ SetSettingsCallback()

MockVulkanContextBuilder & impeller::testing::MockVulkanContextBuilder::SetSettingsCallback ( const std::function< void(ContextVK::Settings &)> &  settings_callback)
inline

A callback that allows the modification of the ContextVK::Settings before the context is made.

Definition at line 74 of file mock_vulkan.h.

75 {
76 settings_callback_ = settings_callback;
77 return *this;
78 }

Referenced by impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().


The documentation for this class was generated from the following files: