working on adding VK_KHR_surface support; breaks using with vulkaninfo
[kazan.git] / src / vulkan / api_objects.h
index ee05913c4c6502b4bcaf067798d50cff082ab84b..8cb1bcce8da762cbdebd56c9de4c12363d022a64 100644 (file)
@@ -42,9 +42,14 @@ namespace vulkan
 enum class Supported_extension
 {
     Not_supported,
+    KHR_surface,
+    KHR_xcb_surface,
 };
 
-kazan_util_generate_enum_traits(Supported_extension, Supported_extension::Not_supported);
+kazan_util_generate_enum_traits(Supported_extension,
+                                Supported_extension::Not_supported,
+                                Supported_extension::KHR_surface,
+                                Supported_extension::KHR_xcb_surface);
 
 typedef util::Enum_set<Supported_extension> Supported_extensions;
 
@@ -61,6 +66,14 @@ constexpr Extension_scope get_extension_scope(Supported_extension extension) noe
     {
     case Supported_extension::Not_supported:
         return Extension_scope::Not_supported;
+    case Supported_extension::KHR_surface:
+        return Extension_scope::Instance;
+    case Supported_extension::KHR_xcb_surface:
+#ifdef VK_USE_PLATFORM_XCB_KHR
+        return Extension_scope::Instance;
+#else
+        return Extension_scope::Not_supported;
+#endif
     }
     assert(!"unknown extension");
     return Extension_scope::Not_supported;
@@ -72,6 +85,20 @@ constexpr VkExtensionProperties get_extension_properties(Supported_extension ext
     {
     case Supported_extension::Not_supported:
         return {};
+    case Supported_extension::KHR_surface:
+        return {
+            .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
+            .specVersion = VK_KHR_SURFACE_SPEC_VERSION,
+        };
+    case Supported_extension::KHR_xcb_surface:
+#ifdef VK_USE_PLATFORM_XCB_KHR
+        return {
+            .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
+            .specVersion = VK_KHR_XCB_SURFACE_SPEC_VERSION,
+        };
+#else
+        return {};
+#endif
     }
     assert(!"unknown extension");
     return {};
@@ -105,6 +132,10 @@ constexpr Supported_extensions get_extension_dependencies(Supported_extension ex
     {
     case Supported_extension::Not_supported:
         return {};
+    case Supported_extension::KHR_surface:
+        return {};
+    case Supported_extension::KHR_xcb_surface:
+        return {Supported_extension::KHR_surface};
     }
     assert(!"unknown extension");
     return {};
@@ -1446,11 +1477,14 @@ struct Vulkan_device : public Vulkan_dispatchable_object<Vulkan_device, VkDevice
     VkPhysicalDeviceFeatures enabled_features;
     static constexpr std::size_t queue_count = 1;
     Queue queues[queue_count];
+    Supported_extensions extensions; // includes both device and instance extensions
     explicit Vulkan_device(Vulkan_physical_device &physical_device,
-                           const VkPhysicalDeviceFeatures &enabled_features) noexcept
+                           const VkPhysicalDeviceFeatures &enabled_features,
+                           const Supported_extensions &extensions) noexcept
         : instance(physical_device.instance),
           physical_device(physical_device),
-          enabled_features(enabled_features)
+          enabled_features(enabled_features),
+          extensions(extensions)
     {
     }
     void wait_idle()