changeset 576:677e4f7fb567

add: comments for further refactoring
author Sam <sam@basx.dev>
date Mon, 03 Apr 2023 00:10:08 +0700
parents eaedc0369c38
children 070a58822f09
files tests/test_vulkan_wrapper.nim
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_vulkan_wrapper.nim	Mon Apr 03 00:06:24 2023 +0700
+++ b/tests/test_vulkan_wrapper.nim	Mon Apr 03 00:10:08 2023 +0700
@@ -10,6 +10,14 @@
 
 proc diagnostics(instance: Instance) =
   # diagnostic output
+  # print basic driver infos
+  echo "Layers"
+  for layer in getLayers():
+    echo "  " & layer
+  echo "Instance extensions"
+  for extension in getInstanceExtensions():
+    echo "  " & extension
+
   echo "Devices"
   for device in instance.getPhysicalDevices():
     echo "  " & $device
@@ -32,14 +40,8 @@
       echo "    " & $format
 
 when isMainModule:
-  # print basic driver infos
-  echo "Layers"
-  for layer in getLayers():
-    echo "  " & layer
-  echo "Instance extensions"
-  for extension in getInstanceExtensions():
-    echo "  " & extension
 
+  # INIT ENGINE:
   # create instance
   var thewindow = createWindow("Test")
   var instance = thewindow.createInstance(
@@ -48,7 +50,6 @@
     layers= @["VK_LAYER_KHRONOS_validation", "VK_LAYER_MESA_overlay"]
   )
   var debugger = instance.createDebugMessenger()
-
   # create devices
   let selectedPhysicalDevice = instance.getPhysicalDevices().filterBestGraphics()
   var device = instance.createDevice(
@@ -58,6 +59,7 @@
     selectedPhysicalDevice.filterForGraphicsPresentationQueues()
   )
 
+  # INIT RENDERER:
   const
     vertexInput = initAttributeGroup(
       asAttribute(default(Vec3f), "position"),
@@ -86,6 +88,7 @@
   if res != VK_SUCCESS:
     raise newException(Exception, "Unable to create swapchain")
 
+  # INIT SCENE
   var thescene = Scene(
     name: "main",
     root: newEntity("root",
@@ -97,6 +100,7 @@
   )
   thescene.setupDrawables(renderPass)
 
+  # MAINLOOP
   echo "Setup successfull, start rendering"
   for i in 0 ..< 1000:
     discard swapchain.drawScene(thescene)
@@ -106,16 +110,16 @@
   # cleanup
   echo "Start cleanup"
 
-  # logical
+  # destroy scene
   thescene.destroy()
 
-  # rendering objects
+  # destroy renderer
   vertexshader.destroy()
   fragmentshader.destroy()
   renderPass.destroy()
   swapchain.destroy()
 
-  # global objects
+  # destroy engine
   device.destroy()
   debugger.destroy()
   instance.destroy()