Dealing with buffers in Vulkan
Buffers in Vulkan are regions of memory that store data that can be rendered on the GPU. To render a 3D scene using the Vulkan API, we must transform the scene data into a format that's suitable for the GPU. In this recipe, we will describe how to create a GPU buffer and upload vertex data into it.
Getting ready
Uploading data into GPU buffers is an operation that is executed, just like any other Vulkan operation, using command buffers. This means we need to have a command queue that's capable of performing transfer operations. We learned how to create and use command buffers earlier in this chapter, in the Using Vulkan command buffers recipe.
How to do it...
Let's create some helper functions for dealing with different buffers:
- First, we need the
findMemoryType()
function, which selects an appropriate heap type on the GPU, based on the required properties and a filter:uint32_t findMemoryType( VkPhysicalDevice...