'How do I upload data into a compressed image?

I've recently tried using Block-Compressed image formats in Vulkan and found that when I switch up my code to use a compressed image format, I get a complete garbage image on render.

Using NVIDIA Nsight also shows the same image I see as well.

I uploading the data by copying the raw SRGB pixels to a staging buffer and initiate a vkCmdCopyBufferImage to the target image. I get this output if the VkImage and VkImageView are of the format: VK_FORMAT_R8G8B8A8_SRGB enter image description here

But when I changed the format to VK_FORMAT_BC7_SRGB_BLOCK. I get this image:enter image description here

I was wondering if I need to do any conversions before copying the data to the image or am I just handling compressed textures wrong

Pastebin for upload code: https://pastebin.com/yrmRrQGp



Solution 1:[1]

If you want to use a compressed image format, you must provide image data that has been compressed in accord with that format. You cannot just change the image format and expect everything to work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nicol Bolas