annotate tests/test_vulkan_wrapper.nim @ 93:cb773e81032f

add: testing for vulkan API wrapper
author Sam <sam@basx.dev>
date Tue, 28 Feb 2023 00:08:52 +0700
parents
children f036546f5ea2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
1 import semicongine/vulkan
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
2
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
3
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
4 when isMainModule:
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
5 # print basic driver infos
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
6 echo "Layers"
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
7 for layer in getLayers():
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
8 echo " " & layer
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
9 echo "Instance extensions"
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
10 for extension in getInstanceExtensions():
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
11 echo " " & extension
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
12
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
13 # create instance
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
14 var instance = createInstance(
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
15 vulkanVersion=VK_MAKE_API_VERSION(0, 1, 3, 0),
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
16 instanceExtensions=["VK_EXT_debug_utils"],
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
17 layers=["VK_LAYER_KHRONOS_validation"]
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
18 )
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
19 var debugger = instance.createDebugMessenger()
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
20 echo "Devices"
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
21 for device in instance.getPhysicalDevices():
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
22 echo " " & $device
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
23 echo " Extensions"
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
24 for extension in device.getExtensions():
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
25 echo " " & $extension
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
26 echo " Queue families"
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
27 for queueFamily in device.getQueueFamilies():
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
28 echo " " & $queueFamily
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
29
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
30 # create devices
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
31 var devices: seq[Device]
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
32 for physicalDevice in instance.getPhysicalDevices():
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
33 devices.add physicalDevice.createDevice([], [], [])
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
34
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
35 # cleanup
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
36 for device in devices.mitems:
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
37 device.destroy()
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
38
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
39 debugger.destroy()
cb773e81032f add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
40 instance.destroy()