comparison tests/test_vulkan_wrapper.nim @ 98:335a65d3f892

add: more vulkan objects
author Sam <sam@basx.dev>
date Mon, 06 Mar 2023 23:50:21 +0700
parents 110ed3ee5df8
children 4deffc94484a
comparison
equal deleted inserted replaced
97:110ed3ee5df8 98:335a65d3f892
1 import std/options 1 import std/options
2 2
3 import semicongine/vulkan 3 import semicongine/vulkan
4 import semicongine/platform/window 4 import semicongine/platform/window
5 import semicongine/math
5 6
6 7
7 when isMainModule: 8 when isMainModule:
8 # print basic driver infos 9 # print basic driver infos
9 echo "Layers" 10 echo "Layers"
51 @[], 52 @[],
52 @[], 53 @[],
53 selectedPhysicalDevice.filterForGraphicsPresentationQueues() 54 selectedPhysicalDevice.filterForGraphicsPresentationQueues()
54 ) 55 )
55 56
56 echo "Created device ", device.physicalDevice.name 57 # setup render pipeline
57 var (swapchain, res) = device.createSwapchain(device.physicalDevice.getSurfaceFormats().filterSurfaceFormat()) 58 var (swapchain, res) = device.createSwapchain(device.physicalDevice.getSurfaceFormats().filterSurfaceFormat())
58 if res != VK_SUCCESS: 59 if res != VK_SUCCESS:
59 raise newException(Exception, "Unable to create swapchain") 60 raise newException(Exception, "Unable to create swapchain")
61 var renderpass = device.simpleForwardRenderPass(swapchain.format)
62 var framebuffers: seq[Framebuffer]
63 for imageview in swapchain.imageviews:
64 framebuffers.add device.createFramebuffer(renderpass, [imageview], swapchain.dimension)
65
66 # todo: could be create inside "device", but it would be nice to have nim v2 with support for circular dependencies first
67 var commandPool = device.createCommandPool(family=device.firstGraphicsQueue().get().family, nBuffers=1)
60 68
61 echo "All successfull" 69 echo "All successfull"
62 echo "Start cleanup" 70 echo "Start cleanup"
63 71
72 commandPool.destroy()
64 # cleanup 73 # cleanup
74 for fb in framebuffers.mitems:
75 fb.destroy()
76 renderpass.destroy()
65 swapchain.destroy() 77 swapchain.destroy()
66 device.destroy() 78 device.destroy()
67 79
68 debugger.destroy() 80 debugger.destroy()
69 instance.destroy() 81 instance.destroy()