Updating the descriptor set
Once the texture is prepared by linear or optimal tiling, it is just a matter of updating the descriptor set with the created image resource object. This is done in the implemented VulkanDrawable::createDescriptorSet()
function. The input parameter useTexture
must be true
to support the texture. The following highlights a single-line change that is required in this function to support the texture.
When the useTexture
parameter is true
, the second VkWriteDescriptorSet
element (with index 1
) is populated with the texture information. Here are two things that are of utmost importance:
- Setting the texture object: The
pImageInfo
field ofVkWriteDescriptorSet
must be set with the texture object's (TextureData
)descsImgInfo
(of the typeVkDescriptorImageInfo
).
- Layout binding: This must be equal to the index number specified in the fragment shader. For instance, in the present example, the sampler is received at the layout binding
1
, therefore,writes[1].dstBinding...