Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
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. More...
 
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)
 

Detailed Description

Definition at line 59 of file mock_vulkan.h.

Constructor & Destructor Documentation

◆ MockVulkanContextBuilder()

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

Definition at line 892 of file mock_vulkan.cc.

893 : instance_extensions_({"VK_KHR_surface", "VK_MVK_macos_surface"}),
894 format_properties_callback_([](VkPhysicalDevice physicalDevice,
896 VkFormatProperties* pFormatProperties) {
898 pFormatProperties->optimalTilingFeatures =
899 static_cast<VkFormatFeatureFlags>(
900 vk::FormatFeatureFlagBits::eColorAttachment);
901 } else if (format == VK_FORMAT_D32_SFLOAT_S8_UINT) {
902 pFormatProperties->optimalTilingFeatures =
903 static_cast<VkFormatFeatureFlags>(
904 vk::FormatFeatureFlagBits::eDepthStencilAttachment);
905 } else if (format == VK_FORMAT_S8_UINT) {
906 pFormatProperties->optimalTilingFeatures =
907 static_cast<VkFormatFeatureFlags>(
908 vk::FormatFeatureFlagBits::eDepthStencilAttachment);
909 }
910 }) {}
uint32_t uint32_t * format
VkFormatFeatureFlags optimalTilingFeatures
Definition: vulkan_core.h:3014
VkFlags VkFormatFeatureFlags
Definition: vulkan_core.h:2307
VkFormat
Definition: vulkan_core.h:1458
@ VK_FORMAT_S8_UINT
Definition: vulkan_core.h:1586
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan_core.h:1496
@ VK_FORMAT_D32_SFLOAT_S8_UINT
Definition: vulkan_core.h:1589

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

912 {
913 auto message_loop = fml::ConcurrentMessageLoop::Create();
914 ContextVK::Settings settings;
915 settings.proc_address_callback = GetMockVulkanProcAddress;
916 if (settings_callback_) {
917 settings_callback_(settings);
918 }
919 g_instance_extensions = instance_extensions_;
920 g_instance_layers = instance_layers_;
921 g_format_properties_callback = format_properties_callback_;
922 std::shared_ptr<ContextVK> result = ContextVK::Create(std::move(settings));
923 return result;
924}
static std::shared_ptr< ConcurrentMessageLoop > Create(size_t worker_count=std::thread::hardware_concurrency())
static std::shared_ptr< ContextVK > Create(Settings settings)
Definition: context_vk.cc:100
GAsyncResult * result

◆ 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 }

◆ 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 }

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