# Vulkan Extensions

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/afrc/)
- [What is fixed-rate compression?](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/afrc/p1-intro/)
- [How to run the code examples](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/afrc/p2-setup/)
- [Vulkan Extensions](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/afrc/p3-enable-extensions/)
- [Query for compression support](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/afrc/p4-query-afrc-support/)
- [Request fixed-rate compression](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/afrc/p5-request-afrc/)
- [Verify that compression is applied](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/afrc/p6-verify-afrc/)
- [Next Steps](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/afrc/_next-steps/)

The Vulkan extension [VK_EXT_image_compression_control](https://docs.vulkan.org/spec/latest/appendices/extensions.html#VK_EXT_image_compression_control) can be used to verify if default compression (such as AFBC) was applied, and to request fixed-rate compression.

Swapchain images are a special case, and additionally require the [VK_EXT_image_compression_control_swapchain](https://docs.vulkan.org/spec/latest/appendices/extensions.html#VK_EXT_image_compression_control_swapchain) extension.

## Enable VK_EXT_image_compression_control

In your application, you can use [vkEnumerateDeviceExtensionProperties](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkEnumerateDeviceExtensionProperties.html) to check if the device supports the extension, and, if so, include it in [VkDeviceCreateInfo](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkDeviceCreateInfo.html)’s `ppEnabledExtensionNames` before calling [vkCreateDevice](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateDevice.html). In the Vulkan Samples framework, this can be handled in the sample’s constructor with this helper function:

```cpp
afrc::afrc()
{
	add_device_extension(VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME);
}
```

If a device supports the extension, it doesn’t mean that it also supports fixed-rate compression of images. The extension can still be used to verify if the images use default (lossless) compression.

Before compressing a `VkImage`, you need to use the extension to query if any given image, with its particular format and usage properties, supports fixed-rate compression, as shown in the next step.
