# Request fixed-rate compression

## 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/)

Compression is specified at image creation time. To request fixed-rate compression, provide a `VkImageCompressionControlEXT` structure to the `pNext` chain of `VkImageCreateInfo`:

```c
VkImageCompressionControlEXT compression_control = {
    VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_CONTROL_EXT
};
compression_control.flags = VK_IMAGE_COMPRESSION_FIXED_RATE_DEFAULT_EXT;

image_create_info.pNext = &compression_control;
```

Note that these are the same `VkImageCompressionControlEXT` and `VkImageCreateInfo` structures used in the previous step.

You can then create the image:

```c
VkImage image_handle;

vkCreateImage(get_device().get_handle(), &image_create_info, nullptr, &image_handle);
```

This requests default fixed-rate compression (which depends on the device). On Arm GPUs, it’s the highest supported bitrate that is the highest possible quality.

To request a specific bitrate (after confirming that it’s supported, as shown in the previous step), you can instead use `VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT` like this:

```c
VkImageCompressionFixedRateFlagsEXT fixed_rate_flags_array[1] = { VK_IMAGE_COMPRESSION_FIXED_RATE_2BPC_BIT_EXT };

VkImageCompressionControlEXT compression_control = {
    VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_CONTROL_EXT
};
compression_control.flags = VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT;
compression_control.compressionControlPlaneCount = 1;
compression_control.pFixedRateFlags = &fixed_rate_flags_array[0];

image_format_info.pNext = &compression_control;
```

This example requests a fixed rate of 2 bits per component.
