96
|
1 import std/tables
|
|
2 import std/options
|
|
3
|
93
|
4 import semicongine/vulkan
|
94
|
5 import semicongine/platform/window
|
93
|
6
|
|
7
|
|
8 when isMainModule:
|
|
9 # print basic driver infos
|
|
10 echo "Layers"
|
|
11 for layer in getLayers():
|
|
12 echo " " & layer
|
|
13 echo "Instance extensions"
|
|
14 for extension in getInstanceExtensions():
|
|
15 echo " " & extension
|
|
16
|
|
17 # create instance
|
96
|
18 var thewindow = createWindow("Test")
|
|
19 var instance = thewindow.createInstance(
|
93
|
20 vulkanVersion=VK_MAKE_API_VERSION(0, 1, 3, 0),
|
94
|
21 instanceExtensions= @["VK_EXT_debug_utils"],
|
|
22 layers= @["VK_LAYER_KHRONOS_validation"]
|
93
|
23 )
|
|
24 var debugger = instance.createDebugMessenger()
|
94
|
25
|
|
26 # diagnostic output
|
93
|
27 echo "Devices"
|
|
28 for device in instance.getPhysicalDevices():
|
|
29 echo " " & $device
|
96
|
30 echo " Rating: " & $device.rateGraphics()
|
93
|
31 echo " Extensions"
|
|
32 for extension in device.getExtensions():
|
|
33 echo " " & $extension
|
96
|
34 echo " Properties"
|
|
35 echo " " & $device.getProperties()
|
|
36 echo " Features"
|
|
37 echo " " & $device.getFeatures()
|
93
|
38 echo " Queue families"
|
|
39 for queueFamily in device.getQueueFamilies():
|
|
40 echo " " & $queueFamily
|
94
|
41 echo " Surface present modes"
|
96
|
42 for mode in device.getSurfacePresentModes():
|
94
|
43 echo " " & $mode
|
|
44 echo " Surface formats"
|
96
|
45 for format in device.getSurfaceFormats():
|
94
|
46 echo " " & $format
|
93
|
47
|
|
48 # create devices
|
96
|
49 let selectedPhysicalDevice = instance.getPhysicalDevices().filterBestGraphics()
|
|
50 var device = instance.createDevice(
|
|
51 selectedPhysicalDevice,
|
|
52 @[],
|
|
53 @[],
|
|
54 selectedPhysicalDevice.filterForGraphicsPresentationQueues()
|
|
55 )
|
|
56
|
|
57 echo "Created device ", device.physicalDevice.name
|
|
58 var (swapchain, res) = device.createSwapchain(device.physicalDevice.getSurfaceFormats().filterSurfaceFormat())
|
|
59 if res != VK_SUCCESS:
|
|
60 raise newException(Exception, "Unable to create swapchain")
|
|
61
|
|
62 echo "All successfull"
|
|
63 echo "Start cleanup"
|
93
|
64
|
|
65 # cleanup
|
96
|
66 swapchain.destroy()
|
|
67 device.destroy()
|
93
|
68
|
|
69 debugger.destroy()
|
|
70 instance.destroy()
|