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