Creating a storage texel buffer
Storage texel buffers, like uniform texel buffers, are a way to provide large amount of image-like data to shaders. But they also allow us to store data in them and perform atomic operations on them. For this purpose, we need to create a buffer with a VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT
.
How to do it...
- Take the handle of a physical device. Store it in a variable of type
VkPhysicalDevice
namedphysical_device
. - Select a format for the texel buffer's data and use it to initialize a variable of type
VkFormat
namedformat
. - Create a variable of type
VkFormatProperties
namedformat_properties
. - Call
vkGetPhysicalDeviceFormatProperties( physical_device, format, &format_properties )
and provide the handle of the selected physical device, theformat
variable, and a pointer to theformat_properties
variable. - Make sure the selected format is suitable for a storage texel buffer by checking whether the
bufferFeatures
member of theformat_properties
variable has aVK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT...