Implementing the image resource with optimal tiling
Optimal tiling is implemented through the staging buffer. First, a buffer resource object is created and stored with the raw image data contents. Next, the buffer resource data contents are copied to a newly created image object using the buffer-to-image copy command. The buffer-to-image copy command (vkCmdCopyBufferToImage
) copies the buffer memory contents to the image memory.
In this section, we will implement the image resources using optimal tiling. In order to create an image resource with optimal tiling our user defined function VulkanRenderer::createTextureOptimal()
can be used. This function takes parameters in the same way as the createTextureLinear()
function:
void VulkanRenderer::createTextureOptimal(const char* filename, TextureData *texture, VkImageUsageFlags imageUsageFlags, VkFormat format);
Let's understand and implement these functions step by step.
Loading the image file
Load the image file and retrieve its dimensions...