Flutter Engine
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

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)
 
std::string VulkanResultToString (VkResult result)
 
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 int kGrCacheMaxCount = 8192
 
static const size_t kGrCacheMaxByteSize = 512 * (1 << 20)
 
static const VkDebugReportFlagsEXT kVulkanErrorFlags FML_ALLOW_UNUSED_TYPE
 
constexpr auto kVulkanInvalidGraphicsQueueIndex
 

Function Documentation

◆ DesiredFormatInfos()

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

Definition at line 26 of file vulkan_swapchain.cc.

Referenced by vulkan::VulkanSwapchain::VulkanSwapchain().

26  {
27  return {{VK_FORMAT_R8G8B8A8_SRGB, kRGBA_8888_SkColorType,
28  SkColorSpace::MakeSRGB()},
29  {VK_FORMAT_B8G8R8A8_SRGB, kRGBA_8888_SkColorType,
30  SkColorSpace::MakeSRGB()},
31  {VK_FORMAT_R16G16B16A16_SFLOAT, kRGBA_F16_SkColorType,
32  SkColorSpace::MakeSRGBLinear()},
33  {VK_FORMAT_R8G8B8A8_UNORM, kRGBA_8888_SkColorType,
34  SkColorSpace::MakeSRGB()},
35  {VK_FORMAT_B8G8R8A8_UNORM, kRGBA_8888_SkColorType,
36  SkColorSpace::MakeSRGB()}};
37 }

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

References InstanceOrDeviceLayersToEnable().

Referenced by vulkan::VulkanDevice::VulkanDevice().

106  {
107  if (!physical_device) {
108  return {};
109  }
110 
111  return InstanceOrDeviceLayersToEnable(vk, physical_device,
112  enable_validation_layers);
113 }
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.

References kVulkanInvalidGraphicsQueueIndex.

Referenced by vulkan::VulkanDevice::VulkanDevice().

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 }
constexpr auto kVulkanInvalidGraphicsQueueIndex

◆ InstanceLayersToEnable()

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

Definition at line 97 of file vulkan_utilities.cc.

References InstanceOrDeviceLayersToEnable().

Referenced by vulkan::VulkanApplication::VulkanApplication().

98  {
99  return InstanceOrDeviceLayersToEnable(vk, VK_NULL_HANDLE,
100  enable_validation_layers);
101 }
static std::vector< std::string > InstanceOrDeviceLayersToEnable(const VulkanProcTable &vk, VkPhysicalDevice physical_device, bool enable_validation_layers)

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

References VK_CALL_LOG_ERROR.

Referenced by DeviceLayersToEnable(), and InstanceLayersToEnable().

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 
52  if (physical_device == VK_NULL_HANDLE) {
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 
67  if (physical_device == VK_NULL_HANDLE) {
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 }
#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 110 of file vulkan_debug_report.cc.

References FML_DCHECK, FML_LOG, ValidationErrorsFatal(), VkDebugReportFlagsEXTToString(), and VkDebugReportObjectTypeEXTToString().

Referenced by vulkan::VulkanDebugReport::VulkanDebugReport().

117  {
118  std::vector<std::pair<std::string, std::string>> items;
119 
120  items.emplace_back("Severity", VkDebugReportFlagsEXTToString(flags));
121 
122  items.emplace_back("Object Type",
124 
125  items.emplace_back("Object Handle", std::to_string(object));
126 
127  if (location != 0) {
128  items.emplace_back("Location", std::to_string(location));
129  }
130 
131  if (message_code != 0) {
132  items.emplace_back("Message Code", std::to_string(message_code));
133  }
134 
135  if (layer_prefix != nullptr) {
136  items.emplace_back("Layer", layer_prefix);
137  }
138 
139  if (message != nullptr) {
140  items.emplace_back("Message", message);
141  }
142 
143  size_t padding = 0;
144 
145  for (const auto& item : items) {
146  padding = std::max(padding, item.first.size());
147  }
148 
149  padding += 1;
150 
151  std::stringstream stream;
152 
153  stream << std::endl;
154 
155  stream << "--- Vulkan Debug Report ----------------------------------------";
156 
157  stream << std::endl;
158 
159  for (const auto& item : items) {
160  stream << "| " << std::setw(static_cast<int>(padding)) << item.first
161  << std::setw(0) << ": " << item.second << std::endl;
162  }
163 
164  stream << "-----------------------------------------------------------------";
165 
166  if (flags & kVulkanErrorFlags) {
167  if (ValidationErrorsFatal()) {
168  FML_DCHECK(false) << stream.str();
169  } else {
170  FML_LOG(ERROR) << stream.str();
171  }
172  } else {
173  FML_LOG(INFO) << stream.str();
174  }
175 
176  // Returning false tells the layer not to stop when the event occurs, so
177  // they see the same behavior with and without validation layers enabled.
178  return VK_FALSE;
179 }
#define FML_DCHECK(condition)
Definition: logging.h:86
static const char * VkDebugReportFlagsEXTToString(VkDebugReportFlagsEXT flags)
#define FML_LOG(severity)
Definition: logging.h:65
static const char * VkDebugReportObjectTypeEXTToString(VkDebugReportObjectTypeEXT type)
bool ValidationErrorsFatal()
DEF_SWITCHES_START snapshot asset Path to the directory containing the four files specified by VmSnapshotInstructions and IsolateSnapshotInstructions vm snapshot The VM instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present isolate snapshot The isolate instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present icu symbol Prefix for the symbols representing ICU data linked into the Flutter library dart flags
Definition: switches.h:66

◆ ValidationErrorsFatal()

bool vulkan::ValidationErrorsFatal ( )

Definition at line 20 of file vulkan_utilities.cc.

Referenced by OnVulkanDebugReportCallback().

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.

Referenced by vulkan::VulkanDebugReport::VulkanDebugReport().

16  {
17  return false;
18 }

◆ VkDebugReportFlagsEXTToString()

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

Definition at line 26 of file vulkan_debug_report.cc.

Referenced by OnVulkanDebugReportCallback().

26  {
27  if (flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) {
28  return "Information";
29  } else if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
30  return "Warning";
31  } else if (flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) {
32  return "Performance Warning";
33  } else if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
34  return "Error";
35  } else if (flags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
36  return "Debug";
37  }
38  return "UNKNOWN";
39 }
DEF_SWITCHES_START snapshot asset Path to the directory containing the four files specified by VmSnapshotInstructions and IsolateSnapshotInstructions vm snapshot The VM instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present isolate snapshot The isolate instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present icu symbol Prefix for the symbols representing ICU data linked into the Flutter library dart flags
Definition: switches.h:66

◆ VkDebugReportObjectTypeEXTToString()

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

Definition at line 41 of file vulkan_debug_report.cc.

Referenced by OnVulkanDebugReportCallback().

42  {
43  switch (type) {
44  case VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT:
45  return "Unknown";
46  case VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT:
47  return "Instance";
48  case VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT:
49  return "Physical Device";
50  case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT:
51  return "Device";
52  case VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT:
53  return "Queue";
54  case VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT:
55  return "Semaphore";
56  case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT:
57  return "Command Buffer";
58  case VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT:
59  return "Fence";
60  case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT:
61  return "Device Memory";
62  case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT:
63  return "Buffer";
64  case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT:
65  return "Image";
66  case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT:
67  return "Event";
68  case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT:
69  return "Query Pool";
70  case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT:
71  return "Buffer View";
72  case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT:
73  return "Image_view";
74  case VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT:
75  return "Shader Module";
76  case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT:
77  return "Pipeline Cache";
78  case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT:
79  return "Pipeline Layout";
80  case VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT:
81  return "Render Pass";
82  case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT:
83  return "Pipeline";
84  case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT:
85  return "Descriptor Set Layout";
86  case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT:
87  return "Sampler";
88  case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT:
89  return "Descriptor Pool";
90  case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT:
91  return "Descriptor Set";
92  case VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT:
93  return "Framebuffer";
94  case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT:
95  return "Command Pool";
96  case VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT:
97  return "Surface";
98  case VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT:
99  return "Swapchain";
100  case VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT:
101  return "Debug";
102  default:
103  break;
104  }
105 
106  return "Unknown";
107 }

◆ 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";
23  case VK_ERROR_OUT_OF_HOST_MEMORY:
24  return "VK_ERROR_OUT_OF_HOST_MEMORY";
25  case VK_ERROR_OUT_OF_DEVICE_MEMORY:
26  return "VK_ERROR_OUT_OF_DEVICE_MEMORY";
27  case VK_ERROR_INITIALIZATION_FAILED:
28  return "VK_ERROR_INITIALIZATION_FAILED";
29  case VK_ERROR_DEVICE_LOST:
30  return "VK_ERROR_DEVICE_LOST";
31  case VK_ERROR_MEMORY_MAP_FAILED:
32  return "VK_ERROR_MEMORY_MAP_FAILED";
33  case VK_ERROR_LAYER_NOT_PRESENT:
34  return "VK_ERROR_LAYER_NOT_PRESENT";
35  case VK_ERROR_EXTENSION_NOT_PRESENT:
36  return "VK_ERROR_EXTENSION_NOT_PRESENT";
37  case VK_ERROR_FEATURE_NOT_PRESENT:
38  return "VK_ERROR_FEATURE_NOT_PRESENT";
39  case VK_ERROR_INCOMPATIBLE_DRIVER:
40  return "VK_ERROR_INCOMPATIBLE_DRIVER";
41  case VK_ERROR_TOO_MANY_OBJECTS:
42  return "VK_ERROR_TOO_MANY_OBJECTS";
43  case VK_ERROR_FORMAT_NOT_SUPPORTED:
44  return "VK_ERROR_FORMAT_NOT_SUPPORTED";
45  case VK_ERROR_FRAGMENTED_POOL:
46  return "VK_ERROR_FRAGMENTED_POOL";
47  case VK_ERROR_SURFACE_LOST_KHR:
48  return "VK_ERROR_SURFACE_LOST_KHR";
49  case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
50  return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR";
51  case VK_SUBOPTIMAL_KHR:
52  return "VK_SUBOPTIMAL_KHR";
53  case VK_ERROR_OUT_OF_DATE_KHR:
54  return "VK_ERROR_OUT_OF_DATE_KHR";
55  case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
56  return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
57  case VK_ERROR_VALIDATION_FAILED_EXT:
58  return "VK_ERROR_VALIDATION_FAILED_EXT";
59  case VK_ERROR_INVALID_SHADER_NV:
60  return "VK_ERROR_INVALID_SHADER_NV";
61  case VK_RESULT_RANGE_SIZE:
62  return "VK_RESULT_RANGE_SIZE";
63  case VK_RESULT_MAX_ENUM:
64  return "VK_RESULT_MAX_ENUM";
65  case VK_ERROR_INVALID_EXTERNAL_HANDLE:
66  return "VK_ERROR_INVALID_EXTERNAL_HANDLE";
67  case VK_ERROR_OUT_OF_POOL_MEMORY:
68  return "VK_ERROR_OUT_OF_POOL_MEMORY";
69  default:
70  return "Unknown Error";
71  }
72  return "";
73 }

Variable Documentation

◆ FML_ALLOW_UNUSED_TYPE

static const VkDebugReportFlagsEXT kVulkanInfoFlags vulkan::FML_ALLOW_UNUSED_TYPE
static
Initial value:
=
VK_DEBUG_REPORT_WARNING_BIT_EXT |
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT

Definition at line 15 of file vulkan_debug_report.cc.

◆ kGrCacheMaxByteSize

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

◆ kGrCacheMaxCount

const int vulkan::kGrCacheMaxCount = 8192
static

◆ kVulkanInvalidGraphicsQueueIndex

constexpr auto vulkan::kVulkanInvalidGraphicsQueueIndex
Initial value:
=
std::numeric_limits<uint32_t>::max()

Definition at line 18 of file vulkan_device.cc.

Referenced by FindGraphicsQueueIndex().