Creating a sampled image
Sampled images are used to read data from images (textures) inside shaders. Usually, they are used together with samplers. And to be able to use an image as a sampled image, it must be created with a VK_IMAGE_USAGE_SAMPLED_BIT
usage.
How to do it...
- Take the handle of a physical device stored in a variable of type
VkPhysicalDevice
namedphysical_device
. - Select a format that will be used for an image. Initialize a variable of type
VkFormat
namedformat
with the selected image format.
- Create a variable of type
VkFormatProperties
namedformat_properties
. - Call
vkGetPhysicalDeviceFormatProperties( physical_device, format, &format_properties )
, for which to provide thephysical_device
variable, theformat
variable, and a pointer to theformat_properties
variable. - Make sure the selected image format is suitable for a sampled image. Do that by checking whether the
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
bit of anoptimalTilingFeatures
member of theformat_properties
variable...