Mercurial > games > semicongine
annotate src/semicongine/vulkan/buffer.nim @ 105:4059aa0d689b
add: descriptors, better swapchain implementation
author | Sam <sam@basx.dev> |
---|---|
date | Fri, 24 Mar 2023 00:11:42 +0700 |
parents | 110ed3ee5df8 |
children | 0c5a74885796 |
rev | line source |
---|---|
89 | 1 import ./api |
94 | 2 import ./device |
89 | 3 |
4 type | |
105
4059aa0d689b
add: descriptors, better swapchain implementation
Sam <sam@basx.dev>
parents:
97
diff
changeset
|
5 Buffer* = object |
4059aa0d689b
add: descriptors, better swapchain implementation
Sam <sam@basx.dev>
parents:
97
diff
changeset
|
6 device*: Device |
4059aa0d689b
add: descriptors, better swapchain implementation
Sam <sam@basx.dev>
parents:
97
diff
changeset
|
7 vk*: VkBuffer |
4059aa0d689b
add: descriptors, better swapchain implementation
Sam <sam@basx.dev>
parents:
97
diff
changeset
|
8 size*: uint64 |
89 | 9 |
10 # currently no support for extended structure and concurrent/shared use | |
11 # (shardingMode = VK_SHARING_MODE_CONCURRENT not supported) | |
94 | 12 proc createBuffer(device: Device, size: uint64, flags: openArray[VkBufferCreateFlagBits], usage: openArray[VkBufferUsageFlagBits]): Buffer = |
89 | 13 result.device = device |
14 result.size = size | |
15 var createInfo = VkBufferCreateInfo( | |
16 sType: VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, | |
17 flags: toBits(flags), | |
18 size: size, | |
19 usage: toBits(usage), | |
20 sharingMode: VK_SHARING_MODE_EXCLUSIVE, | |
21 ) | |
22 | |
23 checkVkResult vkCreateBuffer( | |
94 | 24 device=device.vk, |
89 | 25 pCreateInfo=addr createInfo, |
26 pAllocator=nil, | |
27 pBuffer=addr result.vk | |
28 ) | |
29 | |
97
110ed3ee5df8
add: swapchain, images, fix some destroctors
Sam <sam@basx.dev>
parents:
94
diff
changeset
|
30 proc destroy(buffer: var Buffer) = |
94 | 31 assert buffer.device.vk.valid |
32 assert buffer.vk.valid | |
33 buffer.device.vk.vkDestroyBuffer(buffer.vk, nil) | |
97
110ed3ee5df8
add: swapchain, images, fix some destroctors
Sam <sam@basx.dev>
parents:
94
diff
changeset
|
34 buffer.vk.reset() |