557
|
1 import std/tables
|
|
2 import std/options
|
|
3
|
554
|
4 import semicongine/vulkan
|
555
|
5 import semicongine/platform/window
|
554
|
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
|
557
|
18 var thewindow = createWindow("Test")
|
|
19 var instance = thewindow.createInstance(
|
554
|
20 vulkanVersion=VK_MAKE_API_VERSION(0, 1, 3, 0),
|
555
|
21 instanceExtensions= @["VK_EXT_debug_utils"],
|
|
22 layers= @["VK_LAYER_KHRONOS_validation"]
|
554
|
23 )
|
|
24 var debugger = instance.createDebugMessenger()
|
555
|
25
|
|
26 # diagnostic output
|
554
|
27 echo "Devices"
|
|
28 for device in instance.getPhysicalDevices():
|
|
29 echo " " & $device
|
557
|
30 echo " Rating: " & $device.rateGraphics()
|
554
|
31 echo " Extensions"
|
|
32 for extension in device.getExtensions():
|
|
33 echo " " & $extension
|
557
|
34 echo " Properties"
|
|
35 echo " " & $device.getProperties()
|
|
36 echo " Features"
|
|
37 echo " " & $device.getFeatures()
|
554
|
38 echo " Queue families"
|
|
39 for queueFamily in device.getQueueFamilies():
|
|
40 echo " " & $queueFamily
|
555
|
41 echo " Surface present modes"
|
557
|
42 for mode in device.getSurfacePresentModes():
|
555
|
43 echo " " & $mode
|
|
44 echo " Surface formats"
|
557
|
45 for format in device.getSurfaceFormats():
|
555
|
46 echo " " & $format
|
554
|
47
|
|
48 # create devices
|
557
|
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"
|
554
|
64
|
|
65 # cleanup
|
557
|
66 swapchain.destroy()
|
|
67 device.destroy()
|
554
|
68
|
|
69 debugger.destroy()
|
|
70 instance.destroy()
|