Lugdunum  0.1.0
Vulkan.cpp
Go to the documentation of this file.
2 #include <algorithm>
3 #include <cstring>
4 
5 inline namespace Vulkan {
6 
7 #define LUG_DEFINE_DEFINITION_VULKAN_FUNCTIONS(name) PFN_##name name = nullptr;
12 #undef LUG_DEFINE_DEFINITION_VULKAN_FUNCTIONS
13 
14 } // Vulkan
15 
16 namespace lug {
17 namespace Graphics {
18 namespace Vulkan {
19 
20 bool InstanceInfo::containsExtension(const char* extensionName) const {
21  auto compareExtensions = [&extensionName](const VkExtensionProperties& extension) {
22  return std::strcmp(extension.extensionName, extensionName) == 0;
23  };
24 
25  return std::find_if(extensions.cbegin(), extensions.cend(), compareExtensions) != extensions.cend();
26 }
27 
28 bool InstanceInfo::containsLayer(const char* layerName) const {
29  auto compareLayers = [&layerName](const VkLayerProperties& layer) {
30  return std::strcmp(layer.layerName, layerName) == 0;
31  };
32 
33  return std::find_if(layers.cbegin(), layers.cend(), compareLayers) != layers.cend();
34 }
35 
36 bool PhysicalDeviceInfo::containsExtension(const char* extensionName) const {
37  auto compareExtensions = [&extensionName](const VkExtensionProperties& extension) {
38  return std::strcmp(extension.extensionName, extensionName) == 0;
39  };
40 
41  return std::find_if(extensions.cbegin(), extensions.cend(), compareExtensions) != extensions.cend();
42 }
43 
44 bool PhysicalDeviceInfo::containsQueueFlags(VkQueueFlags queueFlags, int8_t& idx) const {
45  idx = -1;
46 
47  for (uint8_t i = 0; i < queueFamilies.size(); ++i) {
48  if (queueFamilies[i].queueCount && (queueFamilies[i].queueFlags & queueFlags) == queueFlags) {
49  if (idx == -1 || queueFamilies[i].queueFlags == queueFlags) {
50  idx = i;
51  }
52  }
53  }
54 
55  return idx != -1;
56 }
57 
58 } // Vulkan
59 } // Graphics
60 } // lug
#define LUG_DEFINE_DEFINITION_VULKAN_FUNCTIONS(name)
Definition: Vulkan.cpp:7
LUG_DEVICE_VULKAN_FUNCTIONS(LUG_DEFINE_DECLARATION_VULKAN_FUNCTIONS)
LUG_CORE_VULKAN_FUNCTIONS(LUG_DEFINE_DECLARATION_VULKAN_FUNCTIONS)
LUG_INSTANCE_VULKAN_FUNCTIONS(LUG_DEFINE_DECLARATION_VULKAN_FUNCTIONS)
LUG_EXPORTED_VULKAN_FUNCTIONS(LUG_DEFINE_DECLARATION_VULKAN_FUNCTIONS)