diff src/vulkan_helpers.nim @ 12:9e5fe647ff91

did: cleanup up a bit
author Sam <sam@basx.dev>
date Tue, 27 Dec 2022 20:47:48 +0700
parents 0660ba9d1930
children b40466fa446a
line wrap: on
line diff
--- a/src/vulkan_helpers.nim	Sat Dec 24 22:38:09 2022 +0700
+++ b/src/vulkan_helpers.nim	Tue Dec 27 20:47:48 2022 +0700
@@ -129,32 +129,23 @@
 
 proc createVulkanInstance*(vulkanVersion: uint32): VkInstance =
 
+  var requiredExtensions = @["VK_KHR_surface".cstring]
   when defined(linux):
-    var requiredExtensions = [
-      # "VK_EXT_acquire_xlib_display".cstring,
-      # "VK_EXT_direct_mode_display".cstring,
-      # "VK_KHR_display".cstring,
-      "VK_KHR_surface".cstring,
-      "VK_KHR_xlib_surface".cstring,
-      "VK_EXT_debug_utils".cstring,
-    ]
+    requiredExtensions.add("VK_KHR_xlib_surface".cstring)
   when defined(windows):
-    var requiredExtensions = [
-      "VK_KHR_win32_surface".cstring,
-      #"VK_KHR_display".cstring,
-      "VK_KHR_surface".cstring,
-      "VK_EXT_debug_utils".cstring,
-    ]
+    requiredExtensions.add("VK_KHR_win32_surface".cstring)
+  when ENABLEVULKANVALIDATIONLAYERS:
+    requiredExtensions.add("VK_EXT_debug_utils".cstring)
   
   let availableExtensions = getInstanceExtensions()
   for extension in requiredExtensions:
     assert $extension in availableExtensions, $extension
 
-  let desiredLayers = ["VK_LAYER_KHRONOS_validation".cstring, "VK_LAYER_MESA_overlay".cstring]
   let availableLayers = getValidationLayers()
   var usableLayers = newSeq[cstring]()
 
   when ENABLEVULKANVALIDATIONLAYERS:
+    const desiredLayers = ["VK_LAYER_KHRONOS_validation".cstring, "VK_LAYER_MESA_overlay".cstring]
     for layer in desiredLayers:
       if $layer in availableLayers:
         usableLayers.add(layer)
@@ -176,7 +167,7 @@
     enabledLayerCount: usableLayers.len.uint32,
     ppEnabledLayerNames: cast[ptr UncheckedArray[cstring]](addrOrNil(usableLayers)),
     enabledExtensionCount: requiredExtensions.len.uint32,
-    ppEnabledExtensionNames: cast[ptr UncheckedArray[cstring]](addr(requiredExtensions))
+    ppEnabledExtensionNames: cast[ptr UncheckedArray[cstring]](addr(requiredExtensions[0]))
   )
   checkVkResult vkCreateInstance(addr(createinfo), nil, addr(result))