When we want to not only read data from a buffer inside shaders, but we would also like to store data in it, we need to use storage buffers. These are created with a VK_BUFFER_USAGE_STORAGE_BUFFER_BIT usage.
Creating a storage buffer
How to do it...
- Take the handle of a logical device and store it in a variable of type VkPhysicalDevice named physical_device.
- Create a variable of type VkBuffer named storage_buffer in which a handle of a created buffer will be stored.
- Create a buffer of a desired size and usage using the logical_device variable. Specified usage must contain at least a VK_BUFFER_USAGE_STORAGE_BUFFER_BIT flag. Store the created handle in the storage_buffer variable (refer to the Creating a buffer recipe from Chapter 4, Resources and Memory).
- Allocate...