diff tests/test_vulkan_wrapper.nim @ 555:7c44f714bd03

add: device, surface and refactoring
author Sam <sam@basx.dev>
date Tue, 28 Feb 2023 23:51:07 +0700
parents f9a5ada2df1e
children b9fc90de1450
line wrap: on
line diff
--- a/tests/test_vulkan_wrapper.nim	Tue Feb 28 00:08:52 2023 +0700
+++ b/tests/test_vulkan_wrapper.nim	Tue Feb 28 23:51:07 2023 +0700
@@ -1,4 +1,5 @@
 import semicongine/vulkan
+import semicongine/platform/window
 
 
 when isMainModule:
@@ -13,10 +14,16 @@
   # create instance
   var instance = createInstance(
     vulkanVersion=VK_MAKE_API_VERSION(0, 1, 3, 0),
-    instanceExtensions=["VK_EXT_debug_utils"],
-    layers=["VK_LAYER_KHRONOS_validation"]
+    instanceExtensions= @["VK_EXT_debug_utils"],
+    layers= @["VK_LAYER_KHRONOS_validation"]
   )
   var debugger = instance.createDebugMessenger()
+
+  # create surface
+  var thewindow = createWindow("Test")
+  var surface = instance.createSurface(thewindow)
+
+  # diagnostic output
   echo "Devices"
   for device in instance.getPhysicalDevices():
     echo "  " & $device
@@ -26,13 +33,20 @@
     echo "  Queue families"
     for queueFamily in device.getQueueFamilies():
       echo "    " & $queueFamily
+    echo "  Surface present modes"
+    for mode in device.getSurfacePresentModes(surface):
+      echo "    " & $mode
+    echo "  Surface formats"
+    for format in device.getSurfaceFormats(surface):
+      echo "    " & $format
 
   # create devices
   var devices: seq[Device]
   for physicalDevice in instance.getPhysicalDevices():
-    devices.add physicalDevice.createDevice([], [], [])
+    devices.add physicalDevice.createDevice([], [], physicalDevice.getQueueFamilies(surface).filterForGraphicsPresentationQueues())
 
   # cleanup
+  surface.destroy()
   for device in devices.mitems:
     device.destroy()