93
|
1 import semicongine/vulkan
|
94
|
2 import semicongine/platform/window
|
93
|
3
|
|
4
|
|
5 when isMainModule:
|
|
6 # print basic driver infos
|
|
7 echo "Layers"
|
|
8 for layer in getLayers():
|
|
9 echo " " & layer
|
|
10 echo "Instance extensions"
|
|
11 for extension in getInstanceExtensions():
|
|
12 echo " " & extension
|
|
13
|
|
14 # create instance
|
|
15 var instance = createInstance(
|
|
16 vulkanVersion=VK_MAKE_API_VERSION(0, 1, 3, 0),
|
94
|
17 instanceExtensions= @["VK_EXT_debug_utils"],
|
|
18 layers= @["VK_LAYER_KHRONOS_validation"]
|
93
|
19 )
|
|
20 var debugger = instance.createDebugMessenger()
|
94
|
21
|
|
22 # create surface
|
|
23 var thewindow = createWindow("Test")
|
|
24 var surface = instance.createSurface(thewindow)
|
|
25
|
|
26 # diagnostic output
|
93
|
27 echo "Devices"
|
|
28 for device in instance.getPhysicalDevices():
|
|
29 echo " " & $device
|
|
30 echo " Extensions"
|
|
31 for extension in device.getExtensions():
|
|
32 echo " " & $extension
|
|
33 echo " Queue families"
|
|
34 for queueFamily in device.getQueueFamilies():
|
|
35 echo " " & $queueFamily
|
94
|
36 echo " Surface present modes"
|
|
37 for mode in device.getSurfacePresentModes(surface):
|
|
38 echo " " & $mode
|
|
39 echo " Surface formats"
|
|
40 for format in device.getSurfaceFormats(surface):
|
|
41 echo " " & $format
|
93
|
42
|
|
43 # create devices
|
|
44 var devices: seq[Device]
|
|
45 for physicalDevice in instance.getPhysicalDevices():
|
94
|
46 devices.add physicalDevice.createDevice([], [], physicalDevice.getQueueFamilies(surface).filterForGraphicsPresentationQueues())
|
93
|
47
|
|
48 # cleanup
|
94
|
49 surface.destroy()
|
93
|
50 for device in devices.mitems:
|
|
51 device.destroy()
|
|
52
|
|
53 debugger.destroy()
|
|
54 instance.destroy()
|