annotate tests/test_vulkan_wrapper.nim @ 554:f9a5ada2df1e

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
554
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
1 import semicongine/vulkan
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
2
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
3
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
4 when isMainModule:
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
5 # print basic driver infos
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
6 echo "Layers"
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
7 for layer in getLayers():
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
8 echo " " & layer
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
9 echo "Instance extensions"
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
10 for extension in getInstanceExtensions():
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
11 echo " " & extension
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
12
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
13 # create instance
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
14 var instance = createInstance(
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
15 vulkanVersion=VK_MAKE_API_VERSION(0, 1, 3, 0),
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
16 instanceExtensions=["VK_EXT_debug_utils"],
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
17 layers=["VK_LAYER_KHRONOS_validation"]
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
18 )
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
19 var debugger = instance.createDebugMessenger()
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
20 echo "Devices"
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
21 for device in instance.getPhysicalDevices():
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
22 echo " " & $device
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
23 echo " Extensions"
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
24 for extension in device.getExtensions():
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
25 echo " " & $extension
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
26 echo " Queue families"
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
27 for queueFamily in device.getQueueFamilies():
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
28 echo " " & $queueFamily
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
29
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
30 # create devices
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
31 var devices: seq[Device]
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
32 for physicalDevice in instance.getPhysicalDevices():
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
33 devices.add physicalDevice.createDevice([], [], [])
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
34
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
35 # cleanup
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
36 for device in devices.mitems:
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
37 device.destroy()
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
38
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
39 debugger.destroy()
f9a5ada2df1e add: testing for vulkan API wrapper
Sam <sam@basx.dev>
parents:
diff changeset
40 instance.destroy()