changeset 93:cb773e81032f

add: testing for vulkan API wrapper
author Sam <sam@basx.dev>
date Tue, 28 Feb 2023 00:08:52 +0700
parents e872cf354110
children f036546f5ea2
files tests/test_vulkan_wrapper.nim
diffstat 1 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_vulkan_wrapper.nim	Tue Feb 28 00:08:52 2023 +0700
@@ -0,0 +1,40 @@
+import semicongine/vulkan
+
+
+when isMainModule:
+  # print basic driver infos
+  echo "Layers"
+  for layer in getLayers():
+    echo "  " & layer
+  echo "Instance extensions"
+  for extension in getInstanceExtensions():
+    echo "  " & extension
+
+  # create instance
+  var instance = createInstance(
+    vulkanVersion=VK_MAKE_API_VERSION(0, 1, 3, 0),
+    instanceExtensions=["VK_EXT_debug_utils"],
+    layers=["VK_LAYER_KHRONOS_validation"]
+  )
+  var debugger = instance.createDebugMessenger()
+  echo "Devices"
+  for device in instance.getPhysicalDevices():
+    echo "  " & $device
+    echo "  Extensions"
+    for extension in device.getExtensions():
+      echo "    " & $extension
+    echo "  Queue families"
+    for queueFamily in device.getQueueFamilies():
+      echo "    " & $queueFamily
+
+  # create devices
+  var devices: seq[Device]
+  for physicalDevice in instance.getPhysicalDevices():
+    devices.add physicalDevice.createDevice([], [], [])
+
+  # cleanup
+  for device in devices.mitems:
+    device.destroy()
+
+  debugger.destroy()
+  instance.destroy()