Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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)
 
MockVulkanContextBuilderSetDeviceExtensions (const std::vector< std::string > &device_extensions)
 
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)
 
MockVulkanContextBuilder SetAcquireNextImageCallback (std::function< std::remove_pointer_t< PFN_vkAcquireNextImageKHR > > acquire_next_image_callback)
 
MockVulkanContextBuilder SetWaitForFencesCallback (std::function< std::remove_pointer_t< PFN_vkWaitForFences > > wait_for_fences_callback)
 

Detailed Description

Definition at line 59 of file mock_vulkan.h.

Constructor & Destructor Documentation

◆ MockVulkanContextBuilder()

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

Definition at line 1058 of file mock_vulkan.cc.

1059 : instance_extensions_({"VK_KHR_surface", "VK_MVK_macos_surface"}),
1060 device_extensions_({"VK_KHR_swapchain"}),
1061 format_properties_callback_([](VkPhysicalDevice physicalDevice,
1062 VkFormat format,
1063 VkFormatProperties* pFormatProperties) {
1064 if (format == VK_FORMAT_R8G8B8A8_UNORM) {
1065 pFormatProperties->optimalTilingFeatures =
1066 static_cast<VkFormatFeatureFlags>(
1067 vk::FormatFeatureFlagBits::eColorAttachment);
1068 } else if (format == VK_FORMAT_D32_SFLOAT_S8_UINT) {
1069 pFormatProperties->optimalTilingFeatures =
1070 static_cast<VkFormatFeatureFlags>(
1071 vk::FormatFeatureFlagBits::eDepthStencilAttachment);
1072 } else if (format == VK_FORMAT_S8_UINT) {
1073 pFormatProperties->optimalTilingFeatures =
1074 static_cast<VkFormatFeatureFlags>(
1075 vk::FormatFeatureFlagBits::eDepthStencilAttachment);
1076 }
1077 }) {}

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 1079 of file mock_vulkan.cc.

1079 {
1080 auto message_loop = fml::ConcurrentMessageLoop::Create();
1081 ContextVK::Settings settings;
1082 settings.proc_address_callback = GetMockVulkanProcAddress;
1083 if (settings_callback_) {
1084 settings_callback_(settings);
1085 }
1086 g_mock_vulkan_state.reset(new MockVulkanState());
1087 g_mock_vulkan_state->instance_extensions = instance_extensions_;
1088 g_mock_vulkan_state->instance_layers = instance_layers_;
1089 g_mock_vulkan_state->device_extensions = device_extensions_;
1090 g_mock_vulkan_state->format_properties_callback = format_properties_callback_;
1091 g_mock_vulkan_state->physical_device_properties_callback =
1092 physical_properties_callback_;
1093 g_mock_vulkan_state->acquire_next_image_callback =
1094 acquire_next_image_callback_;
1095 g_mock_vulkan_state->wait_for_fences_callback = wait_for_fences_callback_;
1096 settings.embedder_data = embedder_data_;
1097 std::shared_ptr<ContextVK> result = ContextVK::Create(std::move(settings));
1098 return result;
1099}
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(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ SetAcquireNextImageCallback()

MockVulkanContextBuilder impeller::testing::MockVulkanContextBuilder::SetAcquireNextImageCallback ( std::function< std::remove_pointer_t< PFN_vkAcquireNextImageKHR > >  acquire_next_image_callback)
inline

Definition at line 123 of file mock_vulkan.h.

125 {
126 acquire_next_image_callback_ = std::move(acquire_next_image_callback);
127 return *this;
128 }
std::function< std::remove_pointer_t< PFN_vkAcquireNextImageKHR > > acquire_next_image_callback

References acquire_next_image_callback.

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

◆ SetDeviceExtensions()

MockVulkanContextBuilder & impeller::testing::MockVulkanContextBuilder::SetDeviceExtensions ( const std::vector< std::string > &  device_extensions)
inline

Definition at line 92 of file mock_vulkan.h.

93 {
94 device_extensions_ = device_extensions;
95 return *this;
96 }
std::vector< std::string > device_extensions

References device_extensions.

Referenced by impeller::android::testing::TEST().

◆ SetEmbedderData()

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

Definition at line 117 of file mock_vulkan.h.

118 {
119 embedder_data_ = embedder_data;
120 return *this;
121 }

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 }
std::vector< std::string > instance_extensions

References instance_extensions.

◆ 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 }
std::vector< std::string > instance_layers

References instance_layers.

◆ 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 100 of file mock_vulkan.h.

104 {
105 format_properties_callback_ = std::move(format_properties_callback);
106 return *this;
107 }
std::function< void(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties)> format_properties_callback

References format_properties_callback.

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().

◆ SetWaitForFencesCallback()

MockVulkanContextBuilder impeller::testing::MockVulkanContextBuilder::SetWaitForFencesCallback ( std::function< std::remove_pointer_t< PFN_vkWaitForFences > >  wait_for_fences_callback)
inline

Definition at line 130 of file mock_vulkan.h.

132 {
133 wait_for_fences_callback_ = std::move(wait_for_fences_callback);
134 return *this;
135 }
std::function< std::remove_pointer_t< PFN_vkWaitForFences > > wait_for_fences_callback

References wait_for_fences_callback.


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