Creating descriptors with a texture and a uniform buffer
In this sample recipe, we will see how to create the most commonly used resources: a combined image sampler and a uniform buffer. We will prepare a descriptor set layout for them, create a descriptor pool, and allocate a descriptor set from it. Then we will update the allocated set with the created resources. This way, we can later bind the descriptor set to a command buffer and access resources in shaders.
How to do it...
- Create a combined image sampler (an image, image view, and a sampler) with the selected parameters--the most commonly used are
VK_IMAGE_TYPE_2D
image type,VK_FORMAT_R8G8B8A8_UNORM
format,VK_IMAGE_VIEW_TYPE_2D
view type,VK_IMAGE_ASPECT_COLOR_BIT
aspect,VK_FILTER_LINEAR
filter mode, andVK_SAMPLER_ADDRESS_MODE_REPEAT
addressing mode for all texture coordinates. Store the created handles in a variable of typeVkSampler
namedsampler
, of typeVkImage
namedsampled_image
, and another one of typeVkImageView
namedsampled_image_view...