Flutter Engine
The Flutter Engine
Classes | Functions | Variables
vulkan Namespace Reference

Classes

class  VulkanApplication
 
class  VulkanBackbuffer
 
class  VulkanCommandBuffer
 
class  VulkanDebugReport
 
class  VulkanDevice
 
class  VulkanHandle
 
class  VulkanImage
 
class  VulkanNativeSurface
 
class  VulkanNativeSurfaceAndroid
 
class  VulkanProcTable
 
class  VulkanProvider
 
class  VulkanSurface
 
class  VulkanSwapchain
 
class  VulkanWindow
 

Functions

std::string VulkanResultToString (VkResult result)
 
static const char * VkDebugReportFlagsEXTToString (VkDebugReportFlagsEXT flags)
 
static const char * VkDebugReportObjectTypeEXTToString (VkDebugReportObjectTypeEXT type)
 
static VKAPI_ATTR VkBool32 OnVulkanDebugReportCallback (VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT object_type, uint64_t object, size_t location, int32_t message_code, const char *layer_prefix, const char *message, void *user_data)
 
static uint32_t FindGraphicsQueueIndex (const std::vector< VkQueueFamilyProperties > &properties)
 
GrVkGetProc CreateSkiaGetProc (const fml::RefPtr< vulkan::VulkanProcTable > &vk)
 
static std::vector< FormatInfo > DesiredFormatInfos ()
 
bool ValidationLayerInfoMessagesEnabled ()
 
bool ValidationErrorsFatal ()
 
static std::vector< std::string > InstanceOrDeviceLayersToEnable (const VulkanProcTable &vk, VkPhysicalDevice physical_device, bool enable_validation_layers)
 
std::vector< std::string > InstanceLayersToEnable (const VulkanProcTable &vk, bool enable_validation_layers)
 
std::vector< std::string > DeviceLayersToEnable (const VulkanProcTable &vk, const VulkanHandle< VkPhysicalDevice > &physical_device, bool enable_validation_layers)
 

Variables

static const size_t kGrCacheMaxByteSize = 512 * (1 << 20)
 
static const VkDebugReportFlagsEXT kVulkanErrorFlags FML_ALLOW_UNUSED_TYPE
 
constexpr auto kVulkanInvalidGraphicsQueueIndex
 

Function Documentation

◆ CreateSkiaGetProc()

GrVkGetProc vulkan::CreateSkiaGetProc ( const fml::RefPtr< vulkan::VulkanProcTable > &  vk)

Definition at line 9 of file vulkan_skia_proc_table.cc.

9 {
10 if (!vk || !vk->IsValid()) {
11 return nullptr;
12 }
13
14 return [vk](const char* proc_name, VkInstance instance, VkDevice device) {
15 if (device != VK_NULL_HANDLE) {
16 auto result =
17 vk->AcquireProc(proc_name, VulkanHandle<VkDevice>{device, nullptr});
18 if (result != nullptr) {
19 return result;
20 }
21 }
22
23 return vk->AcquireProc(proc_name,
24 VulkanHandle<VkInstance>{instance, nullptr});
25 };
26}
VkDevice device
Definition: main.cc:53
VkInstance instance
Definition: main.cc:48
GAsyncResult * result
vk
Definition: malisc.py:42
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46

◆ DesiredFormatInfos()

static std::vector< FormatInfo > vulkan::DesiredFormatInfos ( )
static

Definition at line 32 of file vulkan_swapchain.cc.

32 {
43}
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkColorSpace > MakeSRGBLinear()
@ VK_FORMAT_R8G8B8A8_SRGB
Definition: vulkan_core.h:1502
@ VK_FORMAT_B8G8R8A8_UNORM
Definition: vulkan_core.h:1503
@ VK_FORMAT_B8G8R8A8_SRGB
Definition: vulkan_core.h:1509
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan_core.h:1496
@ VK_FORMAT_R16G16B16A16_SFLOAT
Definition: vulkan_core.h:1556

◆ DeviceLayersToEnable()

std::vector< std::string > vulkan::DeviceLayersToEnable ( const VulkanProcTable vk,
const VulkanHandle< VkPhysicalDevice > &  physical_device,
bool  enable_validation_layers 
)

Definition at line 103 of file vulkan_utilities.cc.

106 {
107 if (!physical_device) {
108 return {};
109 }
110
112 enable_validation_layers);
113}
VkPhysicalDevice physical_device
Definition: main.cc:51
static std::vector< std::string > InstanceOrDeviceLayersToEnable(const VulkanProcTable &vk, VkPhysicalDevice physical_device, bool enable_validation_layers)

◆ FindGraphicsQueueIndex()

static uint32_t vulkan::FindGraphicsQueueIndex ( const std::vector< VkQueueFamilyProperties > &  properties)
static

Definition at line 21 of file vulkan_device.cc.

22 {
23 for (uint32_t i = 0, count = static_cast<uint32_t>(properties.size());
24 i < count; i++) {
25 if (properties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
26 return i;
27 }
28 }
30}
int count
Definition: FontMgrTest.cpp:50
constexpr auto kVulkanInvalidGraphicsQueueIndex
@ VK_QUEUE_GRAPHICS_BIT
Definition: vulkan_core.h:2413

◆ InstanceLayersToEnable()

std::vector< std::string > vulkan::InstanceLayersToEnable ( const VulkanProcTable vk,
bool  enable_validation_layers 
)

Definition at line 97 of file vulkan_utilities.cc.

98 {
100 enable_validation_layers);
101}

◆ InstanceOrDeviceLayersToEnable()

static std::vector< std::string > vulkan::InstanceOrDeviceLayersToEnable ( const VulkanProcTable vk,
VkPhysicalDevice  physical_device,
bool  enable_validation_layers 
)
static

Definition at line 27 of file vulkan_utilities.cc.

30 {
31 if (!enable_validation_layers) {
32 return {};
33 }
34
35 // NOTE: The loader is sensitive to the ordering here. Please do not rearrange
36 // this list.
37#if OS_FUCHSIA
38 // The other layers in the Fuchsia SDK seem to have a bug right now causing
39 // crashes, so it is only recommended that we use VK_LAYER_KHRONOS_validation
40 // until we have a confirmation that they are fixed.
41 const std::vector<std::string> candidates = {"VK_LAYER_KHRONOS_validation"};
42#else
43 const std::vector<std::string> candidates = {
44 "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation",
45 "VK_LAYER_LUNARG_object_tracker", "VK_LAYER_LUNARG_core_validation",
46 "VK_LAYER_LUNARG_device_limits", "VK_LAYER_LUNARG_image",
47 "VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects"};
48#endif
49
50 uint32_t count = 0;
51
53 if (VK_CALL_LOG_ERROR(vk.EnumerateInstanceLayerProperties(
54 &count, nullptr)) != VK_SUCCESS) {
55 return {};
56 }
57 } else {
58 if (VK_CALL_LOG_ERROR(vk.EnumerateDeviceLayerProperties(
59 physical_device, &count, nullptr)) != VK_SUCCESS) {
60 return {};
61 }
62 }
63
64 std::vector<VkLayerProperties> properties;
65 properties.resize(count);
66
68 if (VK_CALL_LOG_ERROR(vk.EnumerateInstanceLayerProperties(
69 &count, properties.data())) != VK_SUCCESS) {
70 return {};
71 }
72 } else {
73 if (VK_CALL_LOG_ERROR(vk.EnumerateDeviceLayerProperties(
74 physical_device, &count, properties.data())) != VK_SUCCESS) {
75 return {};
76 }
77 }
78
79 std::unordered_set<std::string> available_extensions;
80
81 for (size_t i = 0; i < count; i++) {
82 available_extensions.emplace(properties[i].layerName);
83 }
84
85 std::vector<std::string> available_candidates;
86
87 for (const auto& candidate : candidates) {
88 auto found = available_extensions.find(candidate);
89 if (found != available_extensions.end()) {
90 available_candidates.emplace_back(candidate);
91 }
92 }
93
94 return available_candidates;
95}
@ VK_SUCCESS
Definition: vulkan_core.h:141
#define VK_CALL_LOG_ERROR(expression)

◆ OnVulkanDebugReportCallback()

static VKAPI_ATTR VkBool32 vulkan::OnVulkanDebugReportCallback ( VkDebugReportFlagsEXT  flags,
VkDebugReportObjectTypeEXT  object_type,
uint64_t  object,
size_t  location,
int32_t  message_code,
const char *  layer_prefix,
const char *  message,
void *  user_data 
)
static

Definition at line 114 of file vulkan_debug_report.cc.

121 {
122 std::vector<std::pair<std::string, std::string>> items;
123
124 items.emplace_back("Severity", VkDebugReportFlagsEXTToString(flags));
125
126 items.emplace_back("Object Type",
128
129 items.emplace_back("Object Handle", std::to_string(object));
130
131 if (location != 0) {
132 items.emplace_back("Location", std::to_string(location));
133 }
134
135 if (message_code != 0) {
136 items.emplace_back("Message Code", std::to_string(message_code));
137 }
138
139 if (layer_prefix != nullptr) {
140 items.emplace_back("Layer", layer_prefix);
141 }
142
143 if (message != nullptr) {
144 items.emplace_back("Message", message);
145 }
146
147 size_t padding = 0;
148
149 for (const auto& item : items) {
150 padding = std::max(padding, item.first.size());
151 }
152
153 padding += 1;
154
155 std::stringstream stream;
156
157 stream << std::endl;
158
159 stream << "--- Vulkan Debug Report ----------------------------------------";
160
161 stream << std::endl;
162
163 for (const auto& item : items) {
164 stream << "| " << std::setw(static_cast<int>(padding)) << item.first
165 << std::setw(0) << ": " << item.second << std::endl;
166 }
167
168 stream << "-----------------------------------------------------------------";
169
170 if (flags & kVulkanErrorFlags) {
171 if (ValidationErrorsFatal()) {
172 FML_DCHECK(false) << stream.str();
173 } else {
174 FML_LOG(ERROR) << stream.str();
175 }
176 } else {
177 FML_LOG(INFO) << stream.str();
178 }
179
180 // Returning false tells the layer not to stop when the event occurs, so
181 // they see the same behavior with and without validation layers enabled.
182 return VK_FALSE;
183}
FlutterSemanticsFlag flags
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_DCHECK(condition)
Definition: logging.h:103
static float max(float r, float g, float b)
Definition: hsl.cpp:49
Win32Message message
bool ValidationErrorsFatal()
static const char * VkDebugReportFlagsEXTToString(VkDebugReportFlagsEXT flags)
static const char * VkDebugReportObjectTypeEXTToString(VkDebugReportObjectTypeEXT type)
static SkString to_string(int n)
Definition: nanobench.cpp:119
#define ERROR(message)
Definition: elf_loader.cc:260
#define VK_FALSE
Definition: vulkan_core.h:125

◆ ValidationErrorsFatal()

bool vulkan::ValidationErrorsFatal ( )

Definition at line 20 of file vulkan_utilities.cc.

20 {
21#if OS_FUCHSIA
22 return false;
23#endif
24 return true;
25}

◆ ValidationLayerInfoMessagesEnabled()

bool vulkan::ValidationLayerInfoMessagesEnabled ( )

Definition at line 16 of file vulkan_utilities.cc.

16 {
17 return false;
18}

◆ VkDebugReportFlagsEXTToString()

static const char * vulkan::VkDebugReportFlagsEXTToString ( VkDebugReportFlagsEXT  flags)
static

Definition at line 27 of file vulkan_debug_report.cc.

27 {
29 return "Information";
31 return "Warning";
33 return "Performance Warning";
35 return "Error";
37 return "Debug";
38 }
39 return "UNKNOWN";
40}
@ VK_DEBUG_REPORT_INFORMATION_BIT_EXT
@ VK_DEBUG_REPORT_WARNING_BIT_EXT
@ VK_DEBUG_REPORT_DEBUG_BIT_EXT
@ VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT
@ VK_DEBUG_REPORT_ERROR_BIT_EXT

◆ VkDebugReportObjectTypeEXTToString()

static const char * vulkan::VkDebugReportObjectTypeEXTToString ( VkDebugReportObjectTypeEXT  type)
static

Definition at line 42 of file vulkan_debug_report.cc.

43 {
44 switch (type) {
46 return "Unknown";
48 return "Instance";
50 return "Physical Device";
52 return "Device";
54 return "Queue";
56 return "Semaphore";
58 return "Command Buffer";
60 return "Fence";
62 return "Device Memory";
64 return "Buffer";
66 return "Image";
68 return "Event";
70 return "Query Pool";
72 return "Buffer View";
74 return "Image_view";
76 return "Shader Module";
78 return "Pipeline Cache";
80 return "Pipeline Layout";
82 return "Render Pass";
84 return "Pipeline";
86 return "Descriptor Set Layout";
88 return "Sampler";
90 return "Descriptor Pool";
92 return "Descriptor Set";
94 return "Framebuffer";
96 return "Command Pool";
98 return "Surface";
100 return "Swapchain";
102 return "Debug";
103 default:
104 break;
105 }
106
107 return "Unknown";
108}
GLenum type
@ VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT
@ VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT

◆ VulkanResultToString()

std::string vulkan::VulkanResultToString ( VkResult  result)

Definition at line 9 of file vulkan_interface.cc.

9 {
10 switch (result) {
11 case VK_SUCCESS:
12 return "VK_SUCCESS";
13 case VK_NOT_READY:
14 return "VK_NOT_READY";
15 case VK_TIMEOUT:
16 return "VK_TIMEOUT";
17 case VK_EVENT_SET:
18 return "VK_EVENT_SET";
19 case VK_EVENT_RESET:
20 return "VK_EVENT_RESET";
21 case VK_INCOMPLETE:
22 return "VK_INCOMPLETE";
24 return "VK_ERROR_OUT_OF_HOST_MEMORY";
26 return "VK_ERROR_OUT_OF_DEVICE_MEMORY";
28 return "VK_ERROR_INITIALIZATION_FAILED";
30 return "VK_ERROR_DEVICE_LOST";
32 return "VK_ERROR_MEMORY_MAP_FAILED";
34 return "VK_ERROR_LAYER_NOT_PRESENT";
36 return "VK_ERROR_EXTENSION_NOT_PRESENT";
38 return "VK_ERROR_FEATURE_NOT_PRESENT";
40 return "VK_ERROR_INCOMPATIBLE_DRIVER";
42 return "VK_ERROR_TOO_MANY_OBJECTS";
44 return "VK_ERROR_FORMAT_NOT_SUPPORTED";
46 return "VK_ERROR_FRAGMENTED_POOL";
48 return "VK_ERROR_SURFACE_LOST_KHR";
50 return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR";
52 return "VK_SUBOPTIMAL_KHR";
54 return "VK_ERROR_OUT_OF_DATE_KHR";
56 return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
58 return "VK_ERROR_VALIDATION_FAILED_EXT";
60 return "VK_ERROR_INVALID_SHADER_NV";
61#if VK_HEADER_VERSION < 140
62 case VK_RESULT_RANGE_SIZE:
63 return "VK_RESULT_RANGE_SIZE";
64#endif
66 return "VK_RESULT_MAX_ENUM";
68 return "VK_ERROR_INVALID_EXTERNAL_HANDLE";
70 return "VK_ERROR_OUT_OF_POOL_MEMORY";
71 default:
72 return "Unknown Error";
73 }
74 return "";
75}
@ VK_ERROR_VALIDATION_FAILED_EXT
Definition: vulkan_core.h:170
@ VK_ERROR_INVALID_SHADER_NV
Definition: vulkan_core.h:171
@ VK_SUBOPTIMAL_KHR
Definition: vulkan_core.h:167
@ VK_ERROR_EXTENSION_NOT_PRESENT
Definition: vulkan_core.h:153
@ VK_INCOMPLETE
Definition: vulkan_core.h:146
@ VK_ERROR_INVALID_EXTERNAL_HANDLE
Definition: vulkan_core.h:161
@ VK_ERROR_DEVICE_LOST
Definition: vulkan_core.h:150
@ VK_EVENT_SET
Definition: vulkan_core.h:144
@ VK_EVENT_RESET
Definition: vulkan_core.h:145
@ VK_ERROR_OUT_OF_HOST_MEMORY
Definition: vulkan_core.h:147
@ VK_ERROR_INITIALIZATION_FAILED
Definition: vulkan_core.h:149
@ VK_ERROR_INCOMPATIBLE_DISPLAY_KHR
Definition: vulkan_core.h:169
@ VK_ERROR_OUT_OF_DEVICE_MEMORY
Definition: vulkan_core.h:148
@ VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
Definition: vulkan_core.h:166
@ VK_ERROR_OUT_OF_DATE_KHR
Definition: vulkan_core.h:168
@ VK_TIMEOUT
Definition: vulkan_core.h:143
@ VK_ERROR_FORMAT_NOT_SUPPORTED
Definition: vulkan_core.h:157
@ VK_ERROR_FRAGMENTED_POOL
Definition: vulkan_core.h:158
@ VK_ERROR_SURFACE_LOST_KHR
Definition: vulkan_core.h:165
@ VK_NOT_READY
Definition: vulkan_core.h:142
@ VK_ERROR_FEATURE_NOT_PRESENT
Definition: vulkan_core.h:154
@ VK_ERROR_TOO_MANY_OBJECTS
Definition: vulkan_core.h:156
@ VK_RESULT_MAX_ENUM
Definition: vulkan_core.h:198
@ VK_ERROR_MEMORY_MAP_FAILED
Definition: vulkan_core.h:151
@ VK_ERROR_LAYER_NOT_PRESENT
Definition: vulkan_core.h:152
@ VK_ERROR_INCOMPATIBLE_DRIVER
Definition: vulkan_core.h:155
@ VK_ERROR_OUT_OF_POOL_MEMORY
Definition: vulkan_core.h:160

Variable Documentation

◆ FML_ALLOW_UNUSED_TYPE

static const VkDebugReportFlagsEXT kVulkanInfoFlags vulkan::FML_ALLOW_UNUSED_TYPE
static

◆ kGrCacheMaxByteSize

const size_t vulkan::kGrCacheMaxByteSize = 512 * (1 << 20)
static

Definition at line 18 of file vulkan_application.h.

◆ kVulkanInvalidGraphicsQueueIndex

constexpr auto vulkan::kVulkanInvalidGraphicsQueueIndex
constexpr
Initial value:

Definition at line 18 of file vulkan_device.cc.