Mercurial > games > semicongine
diff src/semicongine/vulkan/buffer.nim @ 94:f036546f5ea2
add: device, surface and refactoring
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 28 Feb 2023 23:51:07 +0700 |
parents | e872cf354110 |
children | 110ed3ee5df8 |
line wrap: on
line diff
--- a/src/semicongine/vulkan/buffer.nim Tue Feb 28 00:08:52 2023 +0700 +++ b/src/semicongine/vulkan/buffer.nim Tue Feb 28 23:51:07 2023 +0700 @@ -1,14 +1,15 @@ import ./api +import ./device type Buffer = object - device: VkDevice + device: Device vk: VkBuffer size: uint64 # currently no support for extended structure and concurrent/shared use # (shardingMode = VK_SHARING_MODE_CONCURRENT not supported) -proc createBuffer(device: VkDevice, size: uint64, flags: openArray[VkBufferCreateFlagBits], usage: openArray[VkBufferUsageFlagBits]): Buffer = +proc createBuffer(device: Device, size: uint64, flags: openArray[VkBufferCreateFlagBits], usage: openArray[VkBufferUsageFlagBits]): Buffer = result.device = device result.size = size var createInfo = VkBufferCreateInfo( @@ -20,12 +21,13 @@ ) checkVkResult vkCreateBuffer( - device=device, + device=device.vk, pCreateInfo=addr createInfo, pAllocator=nil, pBuffer=addr result.vk ) proc destroy(buffer: Buffer) = - if uint(buffer.vk) != 0: - vkDestroyBuffer(buffer.device, buffer.vk, nil) + assert buffer.device.vk.valid + assert buffer.vk.valid + buffer.device.vk.vkDestroyBuffer(buffer.vk, nil)